GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMEventAtom.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMEventAtom.cpp - COMPTEL event atom class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-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 GCOMEventAtom.cpp
23  * @brief COMPTEL event atom 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 "GCOMTools.hpp"
34 #include "GCOMSupport.hpp"
35 #include "GCOMEventAtom.hpp"
36 
37 /* __ Method name definitions ____________________________________________ */
38 
39 /* __ Macros _____________________________________________________________ */
40 
41 /* __ Coding definitions _________________________________________________ */
42 
43 /* __ Debug definitions __________________________________________________ */
44 
45 
46 /*==========================================================================
47  = =
48  = Constructors/destructors =
49  = =
50  ==========================================================================*/
51 
52 /***********************************************************************//**
53  * @brief Void constructor
54  *
55  * Creates an empty COMPTEL event atom.
56  ***************************************************************************/
58 {
59  // Initialise class members for clean destruction
60  init_members();
61 
62  // Return
63  return;
64 }
65 
66 
67 /***********************************************************************//**
68  * @brief Copy constructor
69  *
70  * @param[in] atom COMPTEL event atom.
71  ***************************************************************************/
73 {
74  // Initialise class members for clean destruction
75  init_members();
76 
77  // Copy members
78  copy_members(atom);
79 
80  // Return
81  return;
82 }
83 
84 
85 /***********************************************************************//**
86  * @brief Destructor
87  ***************************************************************************/
89 {
90  // Free members
91  free_members();
92 
93  // Return
94  return;
95 }
96 
97 
98 /*==========================================================================
99  = =
100  = Operators =
101  = =
102  ==========================================================================*/
103 
104 /***********************************************************************//**
105  * @brief Assignment operator
106  *
107  * @param[in] atom COMPTEL event atom.
108  * @return COMPTEL event atom.
109  ***************************************************************************/
111 {
112  // Execute only if object is not identical
113  if (this != &atom) {
114 
115  // Copy base class members
116  this->GEventAtom::operator=(atom);
117 
118  // Free members
119  free_members();
120 
121  // Initialise private members for clean destruction
122  init_members();
123 
124  // Copy members
125  copy_members(atom);
126 
127  } // endif: object was not identical
128 
129  // Return this object
130  return *this;
131 }
132 
133 
134 /*==========================================================================
135  = =
136  = Public methods =
137  = =
138  ==========================================================================*/
139 
140 /***********************************************************************//**
141  * @brief Clear event atom
142  *
143  * Clears COMPTEL event atom by resetting all class members to an
144  * initial state. Any information that was present before will be lost.
145  ***************************************************************************/
147 {
148  // Free class members (base and derived classes, derived class first)
149  free_members();
150  this->GEventAtom::free_members();
151  this->GEvent::free_members();
152 
153  // Initialise members
154  this->GEvent::init_members();
155  this->GEventAtom::init_members();
156  init_members();
157 
158  // Return
159  return;
160 }
161 
162 
163 /***********************************************************************//**
164  * @brief Clone event atom
165  *
166  * @return Pointer to deep copy of COMPTEL event atom.
167  ***************************************************************************/
169 {
170  return new GCOMEventAtom(*this);
171 }
172 
173 
174 /***********************************************************************//**
175  * @brief Set event time
176  *
177  * @param[in] tjd Truncated Julian Days (days).
178  * @param[in] tics COMPTEL ticks (1/8 ms).
179  *
180  * Sets the event time from the native COMPTEL time format.
181  ***************************************************************************/
182 void GCOMEventAtom::time(const int& tjd, const int& tics)
183 {
184  // Set event time by converting from the native COMPTEL time format
185  m_time = gammalib::com_time(tjd, tics);
186 
187  // Return
188  return;
189 }
190 
191 
192 /***********************************************************************//**
193  * @brief Print event information
194  *
195  * @param[in] chatter Chattiness.
196  * @return String containing event information.
197  ***************************************************************************/
198 std::string GCOMEventAtom::print(const GChatter& chatter) const
199 {
200  // Initialise result string
201  std::string result;
202 
203  // Continue only if chatter is not silent
204  if (chatter != SILENT) {
205 
206  // Append event attributes
207  result.append("Chi="+gammalib::str(m_dir.dir().l_deg()));
208  result.append(" Psi="+gammalib::str(m_dir.dir().b_deg()));
209  result.append(" Phibar="+gammalib::str(m_dir.phibar()));
210  result.append(" Energy="+m_energy.print(chatter));
211  result.append(" Time="+m_time.print(chatter));
212 
213  } // endif: chatter was not silent
214 
215  // Return result
216  return result;
217 }
218 
219 
220 /*==========================================================================
221  = =
222  = Private methods =
223  = =
224  ==========================================================================*/
225 
226 /***********************************************************************//**
227  * @brief Initialise class members
228  ***************************************************************************/
230 {
231  // Initialise members
232  m_dir.clear();
233  m_energy.clear();
234  m_time.clear();
235  m_e1 = 0.0;
236  m_e2 = 0.0;
237  m_phibar = 0.0;
238  m_theta = 0.0;
239  m_phi = 0.0;
240  m_eha = 0.0;
241  m_psd = 0.0;
242  m_tof = 0.0;
243  m_x_d2 = 0.0;
244  m_y_d2 = 0.0;
245  m_modcom = 0;
246  m_reflag = 0;
247  m_veto = 0;
248 
249  // Return
250  return;
251 }
252 
253 
254 /***********************************************************************//**
255  * @brief Copy class members
256  *
257  * @param[in] atom COMPTEL event atom.
258  ***************************************************************************/
260 {
261  // Copy members
262  m_dir = atom.m_dir;
263  m_energy = atom.m_energy;
264  m_time = atom.m_time;
265  m_e1 = atom.m_e1;
266  m_e2 = atom.m_e2;
267  m_phibar = atom.m_phibar;
268  m_theta = atom.m_theta;
269  m_phi = atom.m_phi;
270  m_eha = atom.m_eha;
271  m_psd = atom.m_psd;
272  m_tof = atom.m_tof;
273  m_x_d2 = atom.m_x_d2;
274  m_y_d2 = atom.m_y_d2;
275  m_modcom = atom.m_modcom;
276  m_reflag = atom.m_reflag;
277  m_veto = atom.m_veto;
278 
279  // Return
280  return;
281 }
282 
283 
284 /***********************************************************************//**
285  * @brief Delete class members
286  ***************************************************************************/
288 {
289  // Return
290  return;
291 }
GCOMEventAtom & operator=(const GCOMEventAtom &atom)
Assignment operator.
void phibar(const double &phibar)
Set event Compton scatter angle.
GCOMInstDir m_dir
Event direction.
void init_members(void)
Initialise class members.
GEnergy m_energy
Event energy.
void free_members(void)
Delete class members.
float m_x_d2
D2 model X position (mm)
Definition of COMPTEL tools.
COMPTEL event atom class definition.
void clear(void)
Clear time.
Definition: GTime.cpp:252
GCOMEventAtom(void)
Void constructor.
Gammalib tools definition.
float m_phi
Azimuth angle of scatter direction (deg)
void init_members(void)
Initialise class members.
Definition: GEventAtom.cpp:143
float m_tof
Time of flight value (channel)
GTime com_time(const int &tjd, const int &tics)
Convert TJD and COMPTEL tics in GTime object.
Definition: GCOMTools.cpp:55
virtual ~GCOMEventAtom(void)
Destructor.
float m_e1
D1 energy deposit (MeV)
float m_e2
D2 energy deposit (MeV)
Implementation of support function used by COMPTEL classes.
float m_eha
Earth horizon angle (deg)
virtual GEventAtom & operator=(const GEventAtom &atom)
Assignment operator.
Definition: GEventAtom.cpp:104
float m_psd
PSD value (channel)
int m_veto
Veto flag.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
Definition: GEnergy.cpp:748
void dir(const GSkyDir &dir)
Set event scatter direction.
GChatter
Definition: GTypemaps.hpp:33
std::string print(const GChatter &chatter=NORMAL) const
Print time.
Definition: GTime.cpp:1188
float m_theta
Zenith angle of scatter direction (deg)
void init_members(void)
Initialise class members.
Definition: GEvent.cpp:141
void clear(void)
Clear event atom.
const GTime & time(void) const
Return event time.
int m_modcom
Mini telescope number.
virtual void clear(void)
Clear instance.
GCOMEventAtom * clone(void) const
Clone event atom.
void free_members(void)
Delete class members.
Definition: GEvent.cpp:163
void free_members(void)
Delete class members.
Definition: GEventAtom.cpp:165
std::string print(const GChatter &chatter=NORMAL) const
Print event information.
float m_y_d2
D2 model X position (mm)
float m_phibar
Compton scatter angle (deg)
int m_reflag
Rejection flag.
void copy_members(const GCOMEventAtom &atom)
Copy class members.
void clear(void)
Clear instance.
Definition: GEnergy.cpp:261
GTime m_time
Event time.
Abstract interface for the event atom class.
Definition: GEventAtom.hpp:62
COMPTEL event atom class.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:489