GammaLib  1.7.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-2019 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 "GCOMEventAtom.hpp"
33 #include "GCOMSupport.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  *
53  * Creates an empty COMPTEL event atom.
54  ***************************************************************************/
56 {
57  // Initialise class members for clean destruction
58  init_members();
59 
60  // Return
61  return;
62 }
63 
64 
65 /***********************************************************************//**
66  * @brief Copy constructor
67  *
68  * @param[in] atom COMPTEL event atom.
69  ***************************************************************************/
71 {
72  // Initialise class members for clean destruction
73  init_members();
74 
75  // Copy members
76  copy_members(atom);
77 
78  // Return
79  return;
80 }
81 
82 
83 /***********************************************************************//**
84  * @brief Destructor
85  ***************************************************************************/
87 {
88  // Free members
89  free_members();
90 
91  // Return
92  return;
93 }
94 
95 
96 /*==========================================================================
97  = =
98  = Operators =
99  = =
100  ==========================================================================*/
101 
102 /***********************************************************************//**
103  * @brief Assignment operator
104  *
105  * @param[in] atom COMPTEL event atom.
106  * @return COMPTEL event atom.
107  ***************************************************************************/
109 {
110  // Execute only if object is not identical
111  if (this != &atom) {
112 
113  // Copy base class members
114  this->GEventAtom::operator=(atom);
115 
116  // Free members
117  free_members();
118 
119  // Initialise private members for clean destruction
120  init_members();
121 
122  // Copy members
123  copy_members(atom);
124 
125  } // endif: object was not identical
126 
127  // Return this object
128  return *this;
129 }
130 
131 
132 /*==========================================================================
133  = =
134  = Public methods =
135  = =
136  ==========================================================================*/
137 
138 /***********************************************************************//**
139  * @brief Clear event atom
140  *
141  * Clears COMPTEL event atom by resetting all class members to an
142  * initial state. Any information that was present before will be lost.
143  ***************************************************************************/
145 {
146  // Free class members (base and derived classes, derived class first)
147  free_members();
148  this->GEventAtom::free_members();
149  this->GEvent::free_members();
150 
151  // Initialise members
152  this->GEvent::init_members();
153  this->GEventAtom::init_members();
154  init_members();
155 
156  // Return
157  return;
158 }
159 
160 
161 /***********************************************************************//**
162  * @brief Clone event atom
163  *
164  * @return Pointer to deep copy of COMPTEL event atom.
165  ***************************************************************************/
167 {
168  return new GCOMEventAtom(*this);
169 }
170 
171 
172 /***********************************************************************//**
173  * @brief Set event time
174  *
175  * @param[in] tjd Truncated Julian Days (days).
176  * @param[in] tics COMPTEL ticks (1/8 ms).
177  *
178  * Sets the event time from the native COMPTEL time format.
179  ***************************************************************************/
180 void GCOMEventAtom::time(const int& tjd, const int& tics)
181 {
182  // Set event time by converting from the native COMPTEL time format
183  m_time = gammalib::com_time(tjd, tics);
184 
185  // Return
186  return;
187 }
188 
189 
190 /***********************************************************************//**
191  * @brief Print event information
192  *
193  * @param[in] chatter Chattiness.
194  * @return String containing event information.
195  ***************************************************************************/
196 std::string GCOMEventAtom::print(const GChatter& chatter) const
197 {
198  // Initialise result string
199  std::string result;
200 
201  // Continue only if chatter is not silent
202  if (chatter != SILENT) {
203 
204  // Append event attributes
205  result.append("Chi="+gammalib::str(m_dir.dir().l_deg()));
206  result.append(" Psi="+gammalib::str(m_dir.dir().b_deg()));
207  result.append(" Phibar="+gammalib::str(m_dir.phibar()));
208  result.append(" Energy="+m_energy.print(chatter));
209  result.append(" Time="+m_time.print(chatter));
210 
211  } // endif: chatter was not silent
212 
213  // Return result
214  return result;
215 }
216 
217 
218 /*==========================================================================
219  = =
220  = Private methods =
221  = =
222  ==========================================================================*/
223 
224 /***********************************************************************//**
225  * @brief Initialise class members
226  ***************************************************************************/
228 {
229  // Initialise members
230  m_dir.clear();
231  m_energy.clear();
232  m_time.clear();
233  m_e1 = 0.0;
234  m_e2 = 0.0;
235  m_phibar = 0.0;
236  m_theta = 0.0;
237  m_phi = 0.0;
238  m_eha = 0.0;
239  m_psd = 0;
240  m_tof = 0;
241  m_modcom = 0;
242  m_reflag = 0;
243  m_veto = 0;
244 
245  // Return
246  return;
247 }
248 
249 
250 /***********************************************************************//**
251  * @brief Copy class members
252  *
253  * @param[in] atom COMPTEL event atom.
254  ***************************************************************************/
256 {
257  // Copy members
258  m_dir = atom.m_dir;
259  m_energy = atom.m_energy;
260  m_time = atom.m_time;
261  m_e1 = atom.m_e1;
262  m_e2 = atom.m_e2;
263  m_phibar = atom.m_phibar;
264  m_theta = atom.m_theta;
265  m_phi = atom.m_phi;
266  m_eha = atom.m_eha;
267  m_psd = atom.m_psd;
268  m_tof = atom.m_tof;
269  m_modcom = atom.m_modcom;
270  m_reflag = atom.m_reflag;
271  m_veto = atom.m_veto;
272 
273  // Return
274  return;
275 }
276 
277 
278 /***********************************************************************//**
279  * @brief Delete class members
280  ***************************************************************************/
282 {
283  // Return
284  return;
285 }
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.
COMPTEL event atom class definition.
void clear(void)
Clear time.
Definition: GTime.cpp:251
GCOMEventAtom(void)
Void constructor.
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 ticks in GTime object.
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:1161
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_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:413