GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 _______________________________________________ */
35 class GTime;
36 class GEnergy;
37 class 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  ***************************************************************************/
62 class GSPIEventBin : public GEventBin {
63 
64  // Friend classes
65  friend class GSPIEventCube;
66 
67 public:
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 
98 protected:
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  ***************************************************************************/
127 inline
128 std::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  ***************************************************************************/
141 inline
142 const GSPIInstDir& GSPIEventBin::dir(void) const
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  ***************************************************************************/
155 inline
156 const GEnergy& GSPIEventBin::energy(void) const
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  ***************************************************************************/
169 inline
170 const 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  ***************************************************************************/
183 inline
184 double 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  ***************************************************************************/
197 inline
198 void 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  ***************************************************************************/
211 inline
212 double 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  ***************************************************************************/
225 inline
226 const 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  ***************************************************************************/
239 inline
240 const 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  ***************************************************************************/
253 inline
254 const 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  ***************************************************************************/
267 inline
268 const 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  ***************************************************************************/
281 inline
282 const 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  ***************************************************************************/
295 inline
296 const int& GSPIEventBin::iebin(void) const
297 {
298  return (m_iebin);
299 }
300 
301 #endif /* GSPIEVENTBIN_HPP */
GEnergy * m_energy
Pointer to energy of bin.
GSPIInstDir * m_dir
Pointer to direction of bin.
virtual double counts(void) const
Return number of counts.
virtual ~GSPIEventBin(void)
Destructor.
virtual const GEnergy & energy(void) const
Return energy.
double * m_livetime
Pointer to livetime of bin.
const int & idir(void) const
Return event bin direction index.
int m_ipt
Pointing index.
const double & livetime(void) const
Return livetime of event bin.
Abstract interface for the event bin class.
Definition: GEventBin.hpp:64
virtual double error(void) const
Return error in number of counts.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event information.
Abstract event bin base class definition.
int m_idir
Direction index.
Time class.
Definition: GTime.hpp:55
virtual void clear(void)
Clear INTEGRAL/SPI event bin.
const int & index(void) const
Return event bin index.
virtual const GSPIInstDir & dir(void) const
Return instrument direction.
int m_index
Dataspace index.
virtual GSPIEventBin & operator=(const GSPIEventBin &bin)
Assignment operator.
virtual const GTime & time(void) const
Return time.
INTEGRAL/SPI instrument direction class.
Definition: GSPIInstDir.hpp:52
virtual double size(void) const
Return size of event bin.
INTEGRAL/SPI event bin container class.
bool m_alloc
Signals proper memory allocation.
void free_members(void)
Delete class members.
double * m_ontime
Pointer to ontime of bin.
void init_members(void)
Initialise class members.
virtual GSPIEventBin * clone(void) const
Clone event bin.
const int & ipt(void) const
Return event bin pointing index.
GChatter
Definition: GTypemaps.hpp:33
double * m_size
Pointer to size of bin.
const int & iebin(void) const
Return event bin energy index.
double * m_models
Pointer to models of bin.
GTime * m_time
Pointer to time of bin.
double * m_counts
Pointer to number of counts.
int m_iebin
Energy bin index.
INTEGRAL/SPI event bin class.
virtual std::string classname(void) const
Return class name.
void copy_members(const GSPIEventBin &bin)
Copy class members.
const double & model(const int &index) const
Return model value.
const double & ontime(void) const
Return ontime of event bin.
INTEGRAL/SPI instrument direction class definition.
GSPIEventBin(void)
Void constructor.
int m_num_models
Number of models in bin.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48