GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAEventBin.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAEventBin.hpp - CTA event bin class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-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 GCTAEventBin.hpp
23 * @brief CTA event bin class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCTAEVENTBIN_HPP
28#define GCTAEVENTBIN_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GEventBin.hpp"
33#include "GEnergy.hpp"
34#include "GTime.hpp"
35#include "GCTAInstDir.hpp"
36
37
38/***********************************************************************//**
39 * @class GCTAEventBin
40 *
41 * @brief GCTAEventBin class interface definition
42 *
43 * This class implements a CTA event bin. The event bin is a collection of
44 * pointers that points to the relevant information in memory. The class
45 * itself does not allocate any memory, it just is a vector to collect
46 * all relevant event information in a single place. This avoids duplication
47 * of information.
48 *
49 * Setting up the pointers is done by the corresponding event bin container
50 * class (GCTAEventCube).
51 ***************************************************************************/
52class GCTAEventBin : public GEventBin {
53
54 // Friend classes
55 friend class GCTAEventCube;
56
57public:
58 // Constructors and destructors
59 GCTAEventBin(void);
60 GCTAEventBin(const GCTAEventBin& bin);
61 virtual ~GCTAEventBin(void);
62
63 // Operators
64 virtual GCTAEventBin& operator=(const GCTAEventBin& bin);
65
66 // Implemented pure virtual base class methods
67 virtual void clear(void);
68 virtual GCTAEventBin* clone(void) const;
69 virtual std::string classname(void) const;
70 virtual double size(void) const;
71 virtual const GCTAInstDir& dir(void) const;
72 virtual const GEnergy& energy(void) const;
73 virtual const GTime& time(void) const;
74 virtual double counts(void) const;
75 virtual double error(void) const;
76 virtual void counts(const double& counts);
77 virtual std::string print(const GChatter& chatter = NORMAL) const;
78
79 // Other methods
80 const int& ipix(void) const;
81 const int& ieng(void) const;
82 const double& solidangle(void) const;
83 GEnergy emin(void) const;
84 GEnergy emax(void) const;
85 const GEnergy& ewidth(void) const;
86 const double& ontime(void) const;
87 const double& weight(void) const;
88 void dir(const GCTAInstDir& dir);
89 void energy(const GEnergy& energy);
90 void time(const GTime& time);
91 void ipix(const int& ipix);
92 void ieng(const int& ieng);
93 void solidangle(const double& solidangle);
94 void ewidth(const GEnergy& ewidth);
95 void ontime(const double& ontime);
96 void weight(const double& weight);
97
98protected:
99 // Protected methods
100 void init_members(void);
101 void copy_members(const GCTAEventBin& bin);
102 void free_members(void);
103
104 // Protected members
105 bool m_alloc; //!< Signals proper memory allocation
106 int m_ipix; //!< Index in spatial map
107 int m_ieng; //!< Index of energy layer
108 GCTAInstDir* m_dir; //!< Pointer to bin direction
109 GTime* m_time; //!< Pointer to bin time
110 GEnergy* m_energy; //!< Pointer to bin energy
111 GEnergy* m_ewidth; //!< Pointer to energy width of bin
112 double* m_counts; //!< Pointer to number of counts
113 double* m_solidangle; //!< Pointer to solid angle of pixel (sr)
114 double* m_ontime; //!< Pointer to ontime of bin (seconds)
115 double* m_weight; //!< Pointer to weight of bin
116};
117
118
119/***********************************************************************//**
120 * @brief Return class name
121 *
122 * @return String containing the class name ("GCTAEventBin").
123 ***************************************************************************/
124inline
125std::string GCTAEventBin::classname(void) const
126{
127 return ("GCTAEventBin");
128}
129
130
131/***********************************************************************//**
132 * @brief Return the spatial pixel index
133 *
134 * @return Spatial pixel index.
135 *
136 * Returns the spatial index of the event bin in the event cube. If the event
137 * is not part of an event cube, -1 is returned.
138 ***************************************************************************/
139inline
140const int& GCTAEventBin::ipix(void) const
141{
142 return (m_ipix);
143}
144
145
146/***********************************************************************//**
147 * @brief Set the spatial pixel index
148 *
149 * @param[in] ipix Spatial pixel index.
150 *
151 * Sets the spatial index of the event bin in the event cube.
152 ***************************************************************************/
153inline
154void GCTAEventBin::ipix(const int& ipix)
155{
156 m_ipix = ipix;
157 return;
158}
159
160
161/***********************************************************************//**
162 * @brief Return the energy layer index
163 *
164 * @return Energy layer index.
165 *
166 * Returns the energy layer of the event bin in the event cube. If the event
167 * is not part of an event cube, -1 is returned.
168 ***************************************************************************/
169inline
170const int& GCTAEventBin::ieng(void) const
171{
172 return (m_ieng);
173}
174
175
176/***********************************************************************//**
177 * @brief Set the energy layer index
178 *
179 * @param[in] ieng Energy layer index.
180 *
181 * Sets the energy layer of the event bin in the event cube.
182 ***************************************************************************/
183inline
184void GCTAEventBin::ieng(const int& ieng)
185{
186 m_ieng = ieng;
187 return;
188}
189
190
191/***********************************************************************//**
192 * @brief Return maximum energy of event bin
193 *
194 * @return Maximum energy of event bin.
195 *
196 * Returns the maximum energy of event bin.
197 ***************************************************************************/
198inline
200{
201 return (emin() + ewidth());
202}
203
204#endif /* GCTAEVENTBIN_HPP */
CTA instrument direction class interface 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
GCTAEventBin class interface definition.
int m_ieng
Index of energy layer.
double * m_weight
Pointer to weight of bin.
double * m_solidangle
Pointer to solid angle of pixel (sr)
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event information.
virtual double counts(void) const
Return number of counts in event bin.
virtual GCTAEventBin * clone(void) const
Clone event bin.
virtual double size(void) const
Return size of event bin.
const int & ipix(void) const
Return the spatial pixel index.
const int & ieng(void) const
Return the energy layer index.
GEnergy * m_energy
Pointer to bin energy.
double * m_counts
Pointer to number of counts.
const double & weight(void) const
Return weight of event bin.
const GEnergy & ewidth(void) const
Return energy width of event bin.
virtual GCTAEventBin & operator=(const GCTAEventBin &bin)
Assignment operator.
GEnergy * m_ewidth
Pointer to energy width of bin.
void copy_members(const GCTAEventBin &bin)
Copy class members.
GEnergy emax(void) const
Return maximum energy of event bin.
virtual ~GCTAEventBin(void)
Destructor.
GTime * m_time
Pointer to bin time.
virtual const GTime & time(void) const
Return time of event bin.
GCTAEventBin(void)
Void constructor.
virtual const GCTAInstDir & dir(void) const
Return instrument direction of event bin.
void free_members(void)
Delete class members.
virtual std::string classname(void) const
Return class name.
virtual double error(void) const
Return error in number of counts.
const double & ontime(void) const
Return ontime of event bin.
virtual const GEnergy & energy(void) const
Return energy of event bin.
int m_ipix
Index in spatial map.
void init_members(void)
Initialise class members.
GCTAInstDir * m_dir
Pointer to bin direction.
double * m_ontime
Pointer to ontime of bin (seconds)
const double & solidangle(void) const
Return solid angle of event bin.
virtual void clear(void)
Clear eventbin.
GEnergy emin(void) const
Return minimum energy of event bin.
bool m_alloc
Signals proper memory allocation.
CTA event bin container class.
CTA 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