GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATEventAtom.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATEventAtom.cpp - LAT event atom class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2009-2021 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GLATEventAtom.cpp
23  * @brief GLATEventAtom class implementation.
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include <string>
32 #include "GTools.hpp"
33 #include "GLATEventAtom.hpp"
34 
35 /* __ Method name definitions ____________________________________________ */
36 
37 /* __ Macros _____________________________________________________________ */
38 
39 /* __ Coding definitions _________________________________________________ */
40 
41 /* __ Debug definitions __________________________________________________ */
42 
43 
44 /*==========================================================================
45  = =
46  = Constructors/destructors =
47  = =
48  ==========================================================================*/
49 
50 /***********************************************************************//**
51  * @brief Void constructor
52  ***************************************************************************/
54 {
55  // Initialise class members for clean destruction
56  init_members();
57 
58  // Return
59  return;
60 }
61 
62 
63 /***********************************************************************//**
64  * @brief Copy constructor
65  *
66  * @param[in] atom Event atom.
67  ***************************************************************************/
69 {
70  // Initialise class members for clean destruction
71  init_members();
72 
73  // Copy members
74  copy_members(atom);
75 
76  // Return
77  return;
78 }
79 
80 
81 /***********************************************************************//**
82  * @brief Destructor
83  ***************************************************************************/
85 {
86  // Free members
87  free_members();
88 
89  // Return
90  return;
91 }
92 
93 
94 /*==========================================================================
95  = =
96  = Operators =
97  = =
98  ==========================================================================*/
99 
100 /***********************************************************************//**
101  * @brief Assignment operator
102  *
103  * @param[in] atom Event atom.
104  * @return Event atom.
105  ***************************************************************************/
107 {
108  // Execute only if object is not identical
109  if (this != &atom) {
110 
111  // Copy base class members
112  this->GEventAtom::operator=(atom);
113 
114  // Free members
115  free_members();
116 
117  // Initialise private members for clean destruction
118  init_members();
119 
120  // Copy members
121  copy_members(atom);
122 
123  } // endif: object was not identical
124 
125  // Return this object
126  return *this;
127 }
128 
129 
130 /*==========================================================================
131  = =
132  = Public methods =
133  = =
134  ==========================================================================*/
135 
136 /***********************************************************************//**
137  * @brief Clear event atom
138  ***************************************************************************/
140 {
141  // Free class members (base and derived classes, derived class first)
142  free_members();
143  this->GEventAtom::free_members();
144  this->GEvent::free_members();
145 
146  // Initialise members
147  this->GEvent::init_members();
148  this->GEventAtom::init_members();
149  init_members();
150 
151  // Return
152  return;
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief Clone event atom
158  *
159  * @return Pointer to deep copy of event atom
160  ***************************************************************************/
162 {
163  return new GLATEventAtom(*this);
164 }
165 
166 
167 /***********************************************************************//**
168  * @brief Print event information
169  *
170  * @param[in] chatter Chattiness (defaults to NORMAL).
171  * @return String containing event information.
172  ***************************************************************************/
173 std::string GLATEventAtom::print(const GChatter& chatter) const
174 {
175  // Initialise result string
176  std::string result;
177 
178  // Continue only if chatter is not silent
179  if (chatter != SILENT) {
180 
181  // Append event attributes
182  result.append("Dir="+m_dir.print(chatter));
183  result.append(" Energy="+m_energy.print(chatter));
184  result.append(" Time="+m_time.print(chatter));
185 
186  } // endif: chatter was not silent
187 
188  // Return result
189  return result;
190 }
191 
192 
193 /*==========================================================================
194  = =
195  = Private methods =
196  = =
197  ==========================================================================*/
198 
199 /***********************************************************************//**
200  * @brief Initialise class members
201  ***************************************************************************/
203 {
204  // Initialise members
205  m_dir.clear();
206  m_time.clear();
207  m_energy.clear();
208  m_theta = 0.0;
209  m_phi = 0.0;
210  m_zenith_angle = 0.0;
211  m_earth_azimuth_angle = 0.0;
212  m_event_id = 0;
213  m_run_id = 0;
214  m_recon_version = 0;
215  m_calib_version[0] = 0;
216  m_calib_version[1] = 0;
217  m_calib_version[2] = 0;
218  m_event_class = 0;
219  m_conversion_type = 0;
220  m_livetime = 0.0;
221  m_difrsp = NULL;
222  m_num_difrsp = 0;
223 
224  // Return
225  return;
226 }
227 
228 
229 /***********************************************************************//**
230  * @brief Copy class members
231  *
232  * @param[in] atom Event atom.
233  ***************************************************************************/
235 {
236  // Copy members
237  m_dir = atom.m_dir;
238  m_time = atom.m_time;
239  m_energy = atom.m_energy;
240  m_theta = atom.m_theta;
241  m_phi = atom.m_phi;
244  m_event_id = atom.m_event_id;
245  m_run_id = atom.m_run_id;
247  m_calib_version[0] = atom.m_calib_version[0];
248  m_calib_version[1] = atom.m_calib_version[1];
249  m_calib_version[2] = atom.m_calib_version[2];
252  m_livetime = atom.m_livetime;
253 
254  // Copy other attributes
255  m_num_difrsp = atom.m_num_difrsp;
256 
257  // If there are diffuse response components then copy them
258  if (m_num_difrsp > 0 && atom.m_difrsp != NULL) {
259 
260  // Allocate memory for diffuse response components
261  m_difrsp = new double[m_num_difrsp];
262 
263  // Copy diffuse response components
264  for (int i = 0; i < m_num_difrsp; ++i) {
265  m_difrsp[i] = atom.m_difrsp[i];
266  }
267 
268  } // endif: there were diffuse response components to copy
269 
270  // Return
271  return;
272 }
273 
274 
275 /***********************************************************************//**
276  * @brief Delete class members
277  ***************************************************************************/
279 {
280  // Free memory
281  if (m_difrsp != NULL) delete [] m_difrsp;
282 
283  // Signal free pointers
284  m_difrsp = NULL;
285 
286  // Return
287  return;
288 }
short m_conversion_type
Type of conversion: 0=Front, 1=Back.
GLATInstDir m_dir
Event direction.
short m_calib_version[3]
Version of calibration tables for ACD, CAL.
void copy_members(const GLATEventAtom &atom)
Copy class members.
float m_theta
Zenith angle in instrument system.
std::string print(const GChatter &chatter=NORMAL) const
Print event information.
long m_run_id
Run number of original event.
void clear(void)
Clear time.
Definition: GTime.cpp:252
double * m_difrsp
Diffuse response components.
virtual ~GLATEventAtom(void)
Destructor.
void free_members(void)
Delete class members.
Gammalib tools definition.
void init_members(void)
Initialise class members.
Definition: GEventAtom.cpp:143
GLATEventAtom * clone(void) const
Clone event atom.
long m_event_id
ID number of original event.
virtual GEventAtom & operator=(const GEventAtom &atom)
Assignment operator.
Definition: GEventAtom.cpp:104
float m_zenith_angle
Zenith angle in Earth system.
virtual void clear(void)
Clear Fermi/LAT instrument direction.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
Definition: GEnergy.cpp:748
short m_event_class
Event class: 0, 1, 2, ...
GLATEventAtom(void)
Void constructor.
int m_num_difrsp
Number of diffuse model components.
GTime m_time
Event time.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print instrument direction information.
GChatter
Definition: GTypemaps.hpp:33
void init_members(void)
Initialise class members.
std::string print(const GChatter &chatter=NORMAL) const
Print time.
Definition: GTime.cpp:1188
void clear(void)
Clear event atom.
void init_members(void)
Initialise class members.
Definition: GEvent.cpp:141
GEnergy m_energy
Event energy.
Fermi/LAT event atom class definition.
short m_recon_version
Version of event reconstruction software.
void free_members(void)
Delete class members.
Definition: GEvent.cpp:163
void free_members(void)
Delete class members.
Definition: GEventAtom.cpp:165
double m_livetime
Accumulated livetime since mission start.
float m_phi
Azimuth angle in instrument system.
float m_earth_azimuth_angle
Azimuth angle in Earth system.
GLATEventAtom & operator=(const GLATEventAtom &atom)
Assignment operator.
void clear(void)
Clear instance.
Definition: GEnergy.cpp:261
Fermi/LAT event atom class.
Abstract interface for the event atom class.
Definition: GEventAtom.hpp:62