GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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  ***************************************************************************/
52 class GCTAEventBin : public GEventBin {
53 
54  // Friend classes
55  friend class GCTAEventCube;
56 
57 public:
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 
98 protected:
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  ***************************************************************************/
124 inline
125 std::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  ***************************************************************************/
139 inline
140 const 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  ***************************************************************************/
153 inline
154 void 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  ***************************************************************************/
169 inline
170 const 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  ***************************************************************************/
183 inline
184 void 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  ***************************************************************************/
198 inline
200 {
201  return (emin() + ewidth());
202 }
203 
204 #endif /* GCTAEVENTBIN_HPP */
const int & ieng(void) const
Return the energy layer index.
GEnergy emin(void) const
Return minimum energy of event bin.
double * m_ontime
Pointer to ontime of bin (seconds)
virtual ~GCTAEventBin(void)
Destructor.
double * m_counts
Pointer to number of counts.
Energy value class definition.
virtual const GCTAInstDir & dir(void) const
Return instrument direction of event bin.
const double & weight(void) const
Return weight of event bin.
GCTAEventBin class interface definition.
Abstract interface for the event bin class.
Definition: GEventBin.hpp:64
int m_ipix
Index in spatial map.
Abstract event bin base class definition.
GCTAEventBin(void)
Void constructor.
Time class.
Definition: GTime.hpp:55
virtual const GEnergy & energy(void) const
Return energy of event bin.
int m_ieng
Index of energy layer.
GCTAInstDir * m_dir
Pointer to bin direction.
GEnergy emax(void) const
Return maximum energy of event bin.
virtual double size(void) const
Return size of event bin.
virtual GCTAEventBin * clone(void) const
Clone event bin.
GTime * m_time
Pointer to bin time.
CTA event bin container class.
const GEnergy & ewidth(void) const
Return energy width of event bin.
const double & ontime(void) const
Return ontime of event bin.
virtual const GTime & time(void) const
Return time of event bin.
CTA instrument direction class interface definition.
GChatter
Definition: GTypemaps.hpp:33
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
bool m_alloc
Signals proper memory allocation.
virtual void clear(void)
Clear eventbin.
double * m_weight
Pointer to weight of bin.
virtual GCTAEventBin & operator=(const GCTAEventBin &bin)
Assignment operator.
virtual std::string classname(void) const
Return class name.
double * m_solidangle
Pointer to solid angle of pixel (sr)
GEnergy * m_ewidth
Pointer to energy width of bin.
CTA instrument direction class.
Definition: GCTAInstDir.hpp:63
GEnergy * m_energy
Pointer to bin energy.
const double & solidangle(void) const
Return solid angle of event bin.
void copy_members(const GCTAEventBin &bin)
Copy class members.
const int & ipix(void) const
Return the spatial pixel index.
virtual double counts(void) const
Return number of counts in event bin.
Time class interface definition.
virtual double error(void) const
Return error in number of counts.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event information.