GammaLib 2.2.0.dev
Loading...
Searching...
No Matches
GCOSEventAtom.cpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCOSEventAtom.cpp - COSI event atom class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2026 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 GCOSEventAtom.cpp
23 * @brief COSI 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 "GCOSEventAtom.hpp"
33
34/* __ Method name definitions ____________________________________________ */
35
36/* __ Macros _____________________________________________________________ */
37
38/* __ Coding definitions _________________________________________________ */
39
40/* __ Debug definitions __________________________________________________ */
41
42
43/*==========================================================================
44 = =
45 = Constructors/destructors =
46 = =
47 ==========================================================================*/
48
49/***********************************************************************//**
50 * @brief Void constructor
51 *
52 * Creates an empty COSI event atom.
53 ***************************************************************************/
55{
56 // Initialise class members for clean destruction
58
59 // Return
60 return;
61}
62
63
64/***********************************************************************//**
65 * @brief Copy constructor
66 *
67 * @param[in] atom COSI event atom.
68 ***************************************************************************/
70{
71 // Initialise class members for clean destruction
73
74 // Copy members
75 copy_members(atom);
76
77 // Return
78 return;
79}
80
81
82/***********************************************************************//**
83 * @brief Event constructor
84 *
85 * @param[in] dir COSI instrument direction.
86 * @param[in] energy Event energy.
87 * @param[in] time Event trigger time.
88 *
89 * Constructs a COSI event from the instrument direction, event energy and
90 * event trigger time.
91 ***************************************************************************/
93 const GEnergy& energy,
94 const GTime& time) : GEventAtom()
95{
96 // Initialise class members for clean destruction
98
99 // Set members
100 this->dir(dir);
101 this->energy(energy);
102 this->time(time);
103
104 // Return
105 return;
106}
107
108
109/***********************************************************************//**
110 * @brief Destructor
111 ***************************************************************************/
113{
114 // Free members
115 free_members();
116
117 // Return
118 return;
119}
120
121
122/*==========================================================================
123 = =
124 = Operators =
125 = =
126 ==========================================================================*/
127
128/***********************************************************************//**
129 * @brief Assignment operator
130 *
131 * @param[in] atom COSI event atom.
132 * @return COSI event atom.
133 ***************************************************************************/
135{
136 // Execute only if object is not identical
137 if (this != &atom) {
138
139 // Copy base class members
140 this->GEventAtom::operator=(atom);
141
142 // Free members
143 free_members();
144
145 // Initialise private members for clean destruction
146 init_members();
147
148 // Copy members
149 copy_members(atom);
150
151 } // endif: object was not identical
152
153 // Return this object
154 return *this;
155}
156
157
158/*==========================================================================
159 = =
160 = Public methods =
161 = =
162 ==========================================================================*/
163
164/***********************************************************************//**
165 * @brief Clear event atom
166 *
167 * Clears COSI event atom by resetting all class members to an
168 * initial state. Any information that was present before will be lost.
169 ***************************************************************************/
171{
172 // Free class members (base and derived classes, derived class first)
173 free_members();
175 this->GEvent::free_members();
176
177 // Initialise members
178 this->GEvent::init_members();
180 init_members();
181
182 // Return
183 return;
184}
185
186
187/***********************************************************************//**
188 * @brief Clone event atom
189 *
190 * @return Pointer to deep copy of COSI event atom.
191 ***************************************************************************/
193{
194 return new GCOSEventAtom(*this);
195}
196
197
198/***********************************************************************//**
199 * @brief Print event information
200 *
201 * @param[in] chatter Chattiness.
202 * @return String containing event information.
203 ***************************************************************************/
204std::string GCOSEventAtom::print(const GChatter& chatter) const
205{
206 // Initialise result string
207 std::string result;
208
209 // Continue only if chatter is not silent
210 if (chatter != SILENT) {
211
212 // Append event attributes
213 result.append("Dir="+m_dir.print(gammalib::reduce(chatter)));
214 result.append(" Energy="+m_energy.print(gammalib::reduce(chatter)));
215 result.append(" Time="+m_time.print(gammalib::reduce(chatter)));
216
217 } // endif: chatter was not silent
218
219 // Return result
220 return result;
221}
222
223
224/*==========================================================================
225 = =
226 = Private methods =
227 = =
228 ==========================================================================*/
229
230/***********************************************************************//**
231 * @brief Initialise class members
232 ***************************************************************************/
234{
235 // Initialise members
236 m_dir.clear();
237 m_time.clear();
238 m_energy.clear();
239
240 // Return
241 return;
242}
243
244
245/***********************************************************************//**
246 * @brief Copy class members
247 *
248 * @param[in] atom COSI event atom.
249 ***************************************************************************/
251{
252 // Copy members
253 m_dir = atom.m_dir;
254 m_time = atom.m_time;
255 m_energy = atom.m_energy;
256
257 // Return
258 return;
259}
260
261
262/***********************************************************************//**
263 * @brief Delete class members
264 ***************************************************************************/
266{
267 // Return
268 return;
269}
COSI event atom class definition.
GChatter
Definition GTypemaps.hpp:33
@ SILENT
Definition GTypemaps.hpp:34
COSI event atom class.
void free_members(void)
Delete class members.
void copy_members(const GCOSEventAtom &atom)
Copy class members.
GCOSEventAtom & operator=(const GCOSEventAtom &atom)
Assignment operator.
GCOSInstDir m_dir
Event direction.
void init_members(void)
Initialise class members.
const GEnergy & energy(void) const
Return event energy.
GCOSEventAtom(void)
Void constructor.
void clear(void)
Clear event atom.
const GTime & time(void) const
Return event time.
GTime m_time
Event time.
const GCOSInstDir & dir(void) const
Return event instrument direction.
GEnergy m_energy
Event energy.
virtual ~GCOSEventAtom(void)
Destructor.
GCOSEventAtom * clone(void) const
Clone event atom.
std::string print(const GChatter &chatter=NORMAL) const
Print event information.
COSI instrument direction class.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print COSI instrument direction information.
virtual void clear(void)
Clear COSI instrument direction.
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
Definition GEnergy.cpp:822
void clear(void)
Clear instance.
Definition GEnergy.cpp:267
Abstract interface for the event atom class.
virtual GEventAtom & operator=(const GEventAtom &atom)
Assignment operator.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
void free_members(void)
Delete class members.
Definition GEvent.cpp:163
void init_members(void)
Initialise class members.
Definition GEvent.cpp:141
Time class.
Definition GTime.hpp:55
void clear(void)
Clear time.
Definition GTime.cpp:252
std::string print(const GChatter &chatter=NORMAL) const
Print time.
Definition GTime.cpp:1212
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
Definition GTypemaps.hpp:65