GammaLib  1.7.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-2013 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 "GLATEventAtom.hpp"
33 #include "GLATException.hpp"
34 #include "GTools.hpp"
35 
36 /* __ Method name definitions ____________________________________________ */
37 
38 /* __ Macros _____________________________________________________________ */
39 
40 /* __ Coding definitions _________________________________________________ */
41 
42 /* __ Debug definitions __________________________________________________ */
43 
44 
45 /*==========================================================================
46  = =
47  = Constructors/destructors =
48  = =
49  ==========================================================================*/
50 
51 /***********************************************************************//**
52  * @brief Void constructor
53  ***************************************************************************/
55 {
56  // Initialise class members for clean destruction
57  init_members();
58 
59  // Return
60  return;
61 }
62 
63 
64 /***********************************************************************//**
65  * @brief Copy constructor
66  *
67  * @param[in] atom Event atom.
68  ***************************************************************************/
70 {
71  // Initialise class members for clean destruction
72  init_members();
73 
74  // Copy members
75  copy_members(atom);
76 
77  // Return
78  return;
79 }
80 
81 
82 /***********************************************************************//**
83  * @brief Destructor
84  ***************************************************************************/
86 {
87  // Free members
88  free_members();
89 
90  // Return
91  return;
92 }
93 
94 
95 /*==========================================================================
96  = =
97  = Operators =
98  = =
99  ==========================================================================*/
100 
101 /***********************************************************************//**
102  * @brief Assignment operator
103  *
104  * @param[in] atom Event atom.
105  * @return Event atom.
106  ***************************************************************************/
108 {
109  // Execute only if object is not identical
110  if (this != &atom) {
111 
112  // Copy base class members
113  this->GEventAtom::operator=(atom);
114 
115  // Free members
116  free_members();
117 
118  // Initialise private members for clean destruction
119  init_members();
120 
121  // Copy members
122  copy_members(atom);
123 
124  } // endif: object was not identical
125 
126  // Return this object
127  return *this;
128 }
129 
130 
131 /*==========================================================================
132  = =
133  = Public methods =
134  = =
135  ==========================================================================*/
136 
137 /***********************************************************************//**
138  * @brief Clear event atom
139  ***************************************************************************/
141 {
142  // Free class members (base and derived classes, derived class first)
143  free_members();
144  this->GEventAtom::free_members();
145  this->GEvent::free_members();
146 
147  // Initialise members
148  this->GEvent::init_members();
149  this->GEventAtom::init_members();
150  init_members();
151 
152  // Return
153  return;
154 }
155 
156 
157 /***********************************************************************//**
158  * @brief Clone event atom
159  *
160  * @return Pointer to deep copy of event atom
161  ***************************************************************************/
163 {
164  return new GLATEventAtom(*this);
165 }
166 
167 
168 /***********************************************************************//**
169  * @brief Print event information
170  *
171  * @param[in] chatter Chattiness (defaults to NORMAL).
172  * @return String containing event information.
173  ***************************************************************************/
174 std::string GLATEventAtom::print(const GChatter& chatter) const
175 {
176  // Initialise result string
177  std::string result;
178 
179  // Continue only if chatter is not silent
180  if (chatter != SILENT) {
181 
182  // Append event attributes
183  result.append("Dir="+m_dir.print(chatter));
184  result.append(" Energy="+m_energy.print(chatter));
185  result.append(" Time="+m_time.print(chatter));
186 
187  } // endif: chatter was not silent
188 
189  // Return result
190  return result;
191 }
192 
193 
194 /*==========================================================================
195  = =
196  = Private methods =
197  = =
198  ==========================================================================*/
199 
200 /***********************************************************************//**
201  * @brief Initialise class members
202  ***************************************************************************/
204 {
205  // Initialise members
206  m_dir.clear();
207  m_time.clear();
208  m_energy.clear();
209  m_theta = 0.0;
210  m_phi = 0.0;
211  m_zenith_angle = 0.0;
212  m_earth_azimuth_angle = 0.0;
213  m_event_id = 0;
214  m_run_id = 0;
215  m_recon_version = 0;
216  m_calib_version[0] = 0;
217  m_calib_version[1] = 0;
218  m_calib_version[2] = 0;
219  m_event_class = 0;
220  m_conversion_type = 0;
221  m_livetime = 0.0;
222  m_difrsp = NULL;
223  m_num_difrsp = 0;
224 
225  // Return
226  return;
227 }
228 
229 
230 /***********************************************************************//**
231  * @brief Copy class members
232  *
233  * @param[in] atom Event atom.
234  ***************************************************************************/
236 {
237  // Copy members
238  m_dir = atom.m_dir;
239  m_time = atom.m_time;
240  m_energy = atom.m_energy;
241  m_theta = atom.m_theta;
242  m_phi = atom.m_phi;
245  m_event_id = atom.m_event_id;
246  m_run_id = atom.m_run_id;
248  m_calib_version[0] = atom.m_calib_version[0];
249  m_calib_version[1] = atom.m_calib_version[1];
250  m_calib_version[2] = atom.m_calib_version[2];
253  m_livetime = atom.m_livetime;
254 
255  // Copy other attributes
256  m_num_difrsp = atom.m_num_difrsp;
257 
258  // If there are diffuse response components then copy them
259  if (m_num_difrsp > 0 && atom.m_difrsp != NULL) {
260 
261  // Allocate memory for diffuse response components
262  m_difrsp = new double[m_num_difrsp];
263 
264  // Copy diffuse response components
265  for (int i = 0; i < m_num_difrsp; ++i) {
266  m_difrsp[i] = atom.m_difrsp[i];
267  }
268 
269  } // endif: there were diffuse response components to copy
270 
271  // Return
272  return;
273 }
274 
275 
276 /***********************************************************************//**
277  * @brief Delete class members
278  ***************************************************************************/
280 {
281  // Free memory
282  if (m_difrsp != NULL) delete [] m_difrsp;
283 
284  // Signal free pointers
285  m_difrsp = NULL;
286 
287  // Return
288  return;
289 }
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:251
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.
LAT exception handler interface definition.
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:1161
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