GammaLib 2.0.0
Loading...
Searching...
No Matches
GSPIEventBin.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GSPIEventBin.hpp - INTEGRAL/SPI event bin class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2020 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 GSPIEventBin.hpp
23 * @brief INTEGRAL/SPI event bin class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GSPIEVENTBIN_HPP
28#define GSPIEVENTBIN_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include "GEventBin.hpp"
32#include "GSPIInstDir.hpp"
33
34/* __ Forward declarations _______________________________________________ */
35class GTime;
36class GEnergy;
37class GSPIEventCube;
38
39/* __ Constants __________________________________________________________ */
40
41
42/***********************************************************************//**
43 * @class GSPIEventBin
44 *
45 * @brief INTEGRAL/SPI event bin class
46 *
47 * This class defines an event bin of the INTEGRAL/SPI event cube.
48 *
49 * Since many event bins share the same attributes (for example many bins
50 * will actually have the same energy), it would be a waste of memory to
51 * store all bin attributes together with the bin. Therefore, the
52 * GSPIEventBin class implement it's own memory management. Either the
53 * class allocates memory for all attributes, or it takes pointers to
54 * GSPIEventCube class member that store the information in an efficient
55 * way.
56 *
57 * The data member m_alloc signals in which mode the bin operates. I true,
58 * GSPIEventBin has allocated itself the memory for all attributes, and
59 * hence has to take care about the memory allocation upon destruction.
60 * Otherwise the pointers are just released.
61 ***************************************************************************/
62class GSPIEventBin : public GEventBin {
63
64 // Friend classes
65 friend class GSPIEventCube;
66
67public:
68 // Constructors and destructors
69 GSPIEventBin(void);
70 GSPIEventBin(const GSPIEventBin& bin);
71 virtual ~GSPIEventBin(void);
72
73 // Operators
74 virtual GSPIEventBin& operator=(const GSPIEventBin& bin);
75
76 // Implemented pure virtual base class methods
77 virtual void clear(void);
78 virtual GSPIEventBin* clone(void) const;
79 virtual std::string classname(void) const;
80 virtual double size(void) const;
81 virtual const GSPIInstDir& dir(void) const;
82 virtual const GEnergy& energy(void) const;
83 virtual const GTime& time(void) const;
84 virtual double counts(void) const;
85 virtual double error(void) const;
86 virtual void counts(const double& counts);
87 virtual std::string print(const GChatter& chatter = NORMAL) const;
88
89 // Other methods
90 const double& model(const int& index) const;
91 const double& ontime(void) const;
92 const double& livetime(void) const;
93 const int& index(void) const;
94 const int& ipt(void) const;
95 const int& idir(void) const;
96 const int& iebin(void) const;
97
98protected:
99 // Protected methods
100 void init_members(void);
101 void copy_members(const GSPIEventBin& bin);
102 void free_members(void);
103
104 // Protected members
105 bool m_alloc; //!< Signals proper memory allocation
106 int m_index; //!< Dataspace index
107 int m_ipt; //!< Pointing index
108 int m_idir; //!< Direction index
109 int m_iebin; //!< Energy bin index
110 int m_num_models; //!< Number of models in bin
111 GSPIInstDir* m_dir; //!< Pointer to direction of bin
112 GTime* m_time; //!< Pointer to time of bin
113 GEnergy* m_energy; //!< Pointer to energy of bin
114 double* m_counts; //!< Pointer to number of counts
115 double* m_ontime; //!< Pointer to ontime of bin
116 double* m_livetime; //!< Pointer to livetime of bin
117 double* m_size; //!< Pointer to size of bin
118 double* m_models; //!< Pointer to models of bin
119};
120
121
122/***********************************************************************//**
123 * @brief Return class name
124 *
125 * @return String containing the class name ("GSPIEventBin").
126 ***************************************************************************/
127inline
128std::string GSPIEventBin::classname(void) const
129{
130 return ("GSPIEventBin");
131}
132
133
134/***********************************************************************//**
135 * @brief Return instrument direction
136 *
137 * @return Instrument direction.
138 *
139 * Returns the instrument direction of the event bin.
140 ***************************************************************************/
141inline
143{
144 return (*m_dir);
145}
146
147
148/***********************************************************************//**
149 * @brief Return energy
150 *
151 * @return Energy.
152 *
153 * Returns the energy of the event bin.
154 ***************************************************************************/
155inline
157{
158 return (*m_energy);
159}
160
161
162/***********************************************************************//**
163 * @brief Return time
164 *
165 * @return Time.
166 *
167 * Returns the time of the event bin.
168 ***************************************************************************/
169inline
170const GTime& GSPIEventBin::time(void) const
171{
172 return (*m_time);
173}
174
175
176/***********************************************************************//**
177 * @brief Return number of counts
178 *
179 * @return Number of counts.
180 *
181 * Returns the number of counts in the event bin.
182 ***************************************************************************/
183inline
184double GSPIEventBin::counts(void) const
185{
186 return (*m_counts);
187}
188
189
190/***********************************************************************//**
191 * @brief Set number of counts
192 *
193 * @param[in] counts Number of counts.
194 *
195 * Set the number of counts in the event bin.
196 ***************************************************************************/
197inline
198void GSPIEventBin::counts(const double& counts)
199{
200 *m_counts = counts;
201 return;
202}
203
204/***********************************************************************//**
205 * @brief Return size of event bin
206 *
207 * @return Size of event bin (MeV s)
208 *
209 * Returns the size of the event bin.
210 ***************************************************************************/
211inline
212double GSPIEventBin::size(void) const
213{
214 return (*m_size);
215}
216
217
218/***********************************************************************//**
219 * @brief Return ontime of event bin
220 *
221 * @return Size of ontime of bin (s)
222 *
223 * Returns the ontime of the event bin.
224 ***************************************************************************/
225inline
226const double& GSPIEventBin::ontime(void) const
227{
228 return (*m_ontime);
229}
230
231
232/***********************************************************************//**
233 * @brief Return livetime of event bin
234 *
235 * @return Size of livetime of bin (s)
236 *
237 * Returns the livetime of the event bin.
238 ***************************************************************************/
239inline
240const double& GSPIEventBin::livetime(void) const
241{
242 return (*m_livetime);
243}
244
245
246/***********************************************************************//**
247 * @brief Return event bin index
248 *
249 * @return Event bin index
250 *
251 * Returns the event bin index in the event cube.
252 ***************************************************************************/
253inline
254const int& GSPIEventBin::index(void) const
255{
256 return (m_index);
257}
258
259
260/***********************************************************************//**
261 * @brief Return event bin pointing index
262 *
263 * @return Event bin pointing index
264 *
265 * Returns the event bin pointing index in the event cube.
266 ***************************************************************************/
267inline
268const int& GSPIEventBin::ipt(void) const
269{
270 return (m_ipt);
271}
272
273
274/***********************************************************************//**
275 * @brief Return event bin direction index
276 *
277 * @return Event bin direction index
278 *
279 * Returns the event bin instrument direction index in the event cube.
280 ***************************************************************************/
281inline
282const int& GSPIEventBin::idir(void) const
283{
284 return (m_idir);
285}
286
287
288/***********************************************************************//**
289 * @brief Return event bin energy index
290 *
291 * @return Event bin energy index
292 *
293 * Returns the event bin energy index in the event cube.
294 ***************************************************************************/
295inline
296const int& GSPIEventBin::iebin(void) const
297{
298 return (m_iebin);
299}
300
301#endif /* GSPIEVENTBIN_HPP */
Abstract event bin base class definition.
INTEGRAL/SPI instrument direction class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract interface for the event bin class.
Definition GEventBin.hpp:64
INTEGRAL/SPI event bin class.
virtual GSPIEventBin * clone(void) const
Clone event bin.
const double & ontime(void) const
Return ontime of event bin.
virtual void clear(void)
Clear INTEGRAL/SPI event bin.
virtual double counts(void) const
Return number of counts.
bool m_alloc
Signals proper memory allocation.
const int & ipt(void) const
Return event bin pointing index.
void copy_members(const GSPIEventBin &bin)
Copy class members.
int m_index
Dataspace index.
void init_members(void)
Initialise class members.
GSPIInstDir * m_dir
Pointer to direction of bin.
GTime * m_time
Pointer to time of bin.
virtual GSPIEventBin & operator=(const GSPIEventBin &bin)
Assignment operator.
GEnergy * m_energy
Pointer to energy of bin.
double * m_counts
Pointer to number of counts.
int m_num_models
Number of models in bin.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event information.
int m_iebin
Energy bin index.
const int & iebin(void) const
Return event bin energy index.
void free_members(void)
Delete class members.
const double & model(const int &index) const
Return model value.
virtual double error(void) const
Return error in number of counts.
virtual const GEnergy & energy(void) const
Return energy.
virtual double size(void) const
Return size of event bin.
double * m_ontime
Pointer to ontime of bin.
int m_idir
Direction index.
double * m_livetime
Pointer to livetime of bin.
GSPIEventBin(void)
Void constructor.
const int & idir(void) const
Return event bin direction index.
virtual const GTime & time(void) const
Return time.
virtual ~GSPIEventBin(void)
Destructor.
virtual const GSPIInstDir & dir(void) const
Return instrument direction.
double * m_size
Pointer to size of bin.
virtual std::string classname(void) const
Return class name.
const double & livetime(void) const
Return livetime of event bin.
int m_ipt
Pointing index.
double * m_models
Pointer to models of bin.
const int & index(void) const
Return event bin index.
INTEGRAL/SPI event bin container class.
INTEGRAL/SPI instrument direction class.
Time class.
Definition GTime.hpp:55