GammaLib 2.2.0.dev
Loading...
Searching...
No Matches
GCOSEventBin.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCOSEventBin.hpp - COSI event bin 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 GCOSEventBin.hpp
23 * @brief COSI event bin class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCOSEVENTBIN_HPP
28#define GCOSEVENTBIN_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include "GEventBin.hpp"
32#include "GEnergy.hpp"
33#include "GTime.hpp"
34#include "GCOSInstDir.hpp"
35
36/* __ Forward declarations _______________________________________________ */
37
38/* __ Constants __________________________________________________________ */
39
40
41/***********************************************************************//**
42 * @class GCOSEventBin
43 *
44 * @brief COSI event bin class
45 *
46 * This class defines an event bin of the COSI event cube.
47 *
48 * Since many event bins share the same attributes (for example many bins
49 * will actually have the same energy), it would be a waste of memory to
50 * store all bin attributes together with the bin. Therefore, the
51 * GCOSEventBin class implements it's own memory management. Either the
52 * class allocates memory for all attributes, or it takes pointers to
53 * GCOSEventCube class members that store the information in an efficient
54 * way.
55 *
56 * The data member m_alloc signals in which mode the bin operates. If true,
57 * GCOSEventBin has allocated itself the memory for all attributes, and
58 * hence has to take care about the memory allocation upon destruction.
59 * Otherwise the pointers are just released.
60 ***************************************************************************/
61class GCOSEventBin : public GEventBin {
62
63 // Friend classes
64 friend class GCOSEventCube;
65
66public:
67 // Constructors and destructors
68 GCOSEventBin(void);
69 GCOSEventBin(const GCOSEventBin& bin);
70 virtual ~GCOSEventBin(void);
71
72 // Operators
73 virtual GCOSEventBin& operator=(const GCOSEventBin& bin);
74
75 // Implemented pure virtual base class methods
76 virtual void clear(void);
77 virtual GCOSEventBin* clone(void) const;
78 virtual std::string classname(void) const;
79 virtual double size(void) const;
80 virtual const GCOSInstDir& dir(void) const;
81 virtual const GEnergy& energy(void) const;
82 virtual const GTime& time(void) const;
83 virtual double counts(void) const;
84 virtual double error(void) const;
85 virtual void counts(const double& counts);
86 virtual std::string print(const GChatter& chatter = NORMAL) const;
87
88 // Other methods
89 const int& index(void) const;
90 double chi(void) const;
91 double psi(void) const;
92 const double& phi(void) const;
93 const double& solidangle(void) const;
94 const double& phiwidth(void) const;
95 const GEnergy& ewidth(void) const;
96 const double& ontime(void) const;
97 void index(const int& index);
98 void dir(const GCOSInstDir& dir);
99 void dir(const double& chi, const double& psi, const double& phi);
100 void energy(const GEnergy& energy);
101 void time(const GTime& time);
102 void solidangle(const double& solidangle);
103 void phiwidth(const double& phiwidth);
104 void ewidth(const GEnergy& ewidth);
105 void ontime(const double& ontime);
106
107protected:
108 // Protected methods
109 void init_members(void);
110 void copy_members(const GCOSEventBin& bin);
111 void free_members(void);
112
113 // Protected members
114 bool m_alloc; //!< Signals proper memory allocation
115 int m_index; //!< Dataspace index
116 double* m_counts; //!< Pointer to number of counts
117 GCOSInstDir* m_dir; //!< Pointer to bin direction
118 double* m_solidangle; //!< Pointer to solid angle of pixel (sr)
119 GTime* m_time; //!< Pointer to bin time
120 double* m_ontime; //!< Pointer to ontime of bin (seconds)
121 double* m_phiwidth; //!< Pointer to Phi width
122 GEnergy* m_energy; //!< Pointer to bin energy
123 GEnergy* m_ewidth; //!< Pointer to energy width of bin
124};
125
126
127/***********************************************************************//**
128 * @brief Return class name
129 *
130 * @return String containing the class name ("GCOSEventBin").
131 ***************************************************************************/
132inline
133std::string GCOSEventBin::classname(void) const
134{
135 return ("GCOSEventBin");
136}
137
138
139/***********************************************************************//**
140 * @brief Return bin index
141 *
142 * @return Bin index.
143 *
144 * Returns the index of the event bin if the bin is part of an event cube. If
145 * the event is not part of an event cube, -1 is returned.
146 ***************************************************************************/
147inline
148const int& GCOSEventBin::index(void) const
149{
150 return (m_index);
151}
152
153
154/***********************************************************************//**
155 * @brief Set bin index
156 *
157 * @param[in] index Bin index.
158 *
159 * Set the index of the event bin if the bin is part of an event cube. If
160 * the event is not part of an event cube the index should be set to -1.
161 ***************************************************************************/
162inline
163void GCOSEventBin::index(const int& index)
164{
165 m_index = index;
166 return;
167}
168
169#endif /* GCOSEVENTBIN_HPP */
COSI instrument direction class definition.
Energy value class definition.
Abstract event bin base class definition.
Time class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
COSI event bin class.
virtual std::string classname(void) const
Return class name.
double chi(void) const
Return Galactic longitude of event bin scatter direction Chi.
double * m_ontime
Pointer to ontime of bin (seconds)
double * m_phiwidth
Pointer to Phi width.
const double & phi(void) const
Return event bin scatter angle Phi.
virtual double counts(void) const
Return number of counts in event bin.
virtual double error(void) const
Return error in number of counts.
virtual void clear(void)
Clear COSI event bin.
double psi(void) const
Return Galactic longitude of event bin scatter direction Psi.
virtual const GTime & time(void) const
Return time of event bin.
virtual GCOSEventBin * clone(void) const
Clone event bin.
GEnergy * m_energy
Pointer to bin energy.
void init_members(void)
Initialise class members.
const GEnergy & ewidth(void) const
Return energy width of event bin.
virtual ~GCOSEventBin(void)
Destructor.
virtual GCOSEventBin & operator=(const GCOSEventBin &bin)
Assignment operator.
bool m_alloc
Signals proper memory allocation.
GTime * m_time
Pointer to bin time.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event information.
const double & ontime(void) const
Return ontime of event bin.
virtual const GCOSInstDir & dir(void) const
Return instrument direction of event bin.
const double & phiwidth(void) const
Return Phi width of event bin.
GEnergy * m_ewidth
Pointer to energy width of bin.
int m_index
Dataspace index.
GCOSInstDir * m_dir
Pointer to bin direction.
void copy_members(const GCOSEventBin &bin)
Copy class members.
double * m_solidangle
Pointer to solid angle of pixel (sr)
virtual double size(void) const
Return size of event bin.
const double & solidangle(void) const
Return solid angle of event bin.
double * m_counts
Pointer to number of counts.
GCOSEventBin(void)
Void constructor.
virtual const GEnergy & energy(void) const
Return energy of event bin.
void free_members(void)
Delete class members.
const int & index(void) const
Return bin index.
COSI event bin container class.
COSI instrument direction class.
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract interface for the event bin class.
Definition GEventBin.hpp:64
Time class.
Definition GTime.hpp:55