GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAEventCube.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAEventCube.hpp - CTA event bin container class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2018 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 GCTAEventCube.hpp
23  * @brief CTA event bin container class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAEVENTCUBE_HPP
28 #define GCTAEVENTCUBE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GEventCube.hpp"
34 #include "GCTAEventBin.hpp"
35 #include "GSkyMap.hpp"
36 #include "GEbounds.hpp"
37 #include "GGti.hpp"
38 #include "GEnergy.hpp"
39 #include "GTime.hpp"
40 #include "GCTAPointing.hpp"
41 #include "GCTAInstDir.hpp"
42 #include "GFitsTable.hpp"
43 #include "GFitsImage.hpp"
44 
45 /* __ Forward declarations _______________________________________________ */
46 class GFilename;
47 
48 /* __ Constants __________________________________________________________ */
49 namespace gammalib {
50  const std::string extname_cta_counts = "COUNTS";
51  const std::string extname_cta_weights = "WEIGHTS";
52 }
53 
54 
55 /***********************************************************************//**
56  * @class GCTAEventCube
57  *
58  * @brief CTA event bin container class
59  *
60  * This class is a container class for CTA event bins.
61  ***************************************************************************/
62 class GCTAEventCube : public GEventCube {
63 
64 public:
65  // Constructors and destructors
66  GCTAEventCube(void);
67  explicit GCTAEventCube(const GFilename& filename);
68  GCTAEventCube(const GSkyMap& map, const GEbounds& ebds, const GGti& gti);
69  GCTAEventCube(const GSkyMap& map, const GSkyMap& weights,
70  const GEbounds& ebds, const GGti& gti);
71  GCTAEventCube(const GCTAEventCube& cube);
72  virtual ~GCTAEventCube(void);
73 
74  // Operators
75  virtual GCTAEventCube& operator=(const GCTAEventCube& cube);
76  virtual GCTAEventBin* operator[](const int& index);
77  virtual const GCTAEventBin* operator[](const int& index) const;
78 
79  // Implemented pure virtual base class methods
80  virtual void clear(void);
81  virtual GCTAEventCube* clone(void) const;
82  virtual std::string classname(void) const;
83  virtual int size(void) const;
84  virtual int dim(void) const;
85  virtual int naxis(const int& axis) const;
86  virtual void load(const GFilename& filename);
87  virtual void save(const GFilename& filename,
88  const bool& clobber = false) const;
89  virtual void read(const GFits& file);
90  virtual void write(GFits& file) const;
91  virtual int number(void) const;
92  virtual std::string print(const GChatter& chatter = NORMAL) const;
93 
94  // Other methods
95  const GTime& time(void) const;
96  const GEnergy& energy(const int& index) const;
97  void counts(const GSkyMap& counts);
98  const GSkyMap& counts(void) const;
99  void weights(const GSkyMap& weights);
100  const GSkyMap& weights(void) const;
101  int nx(void) const;
102  int ny(void) const;
103  int npix(void) const;
104  int ebins(void) const;
105 
106 protected:
107  // Protected methods
108  void init_members(void);
109  void copy_members(const GCTAEventCube& cube);
110  void free_members(void);
111  void read_cntmap(const GFitsImage& hdu);
112  void read_ebds(const GFitsTable& hdu);
113  void read_gti(const GFitsTable& hdu);
114  void set_directions(void);
115  void set_detxy(const GCTAPointing& pnt);
116  virtual void set_energies(void);
117  virtual void set_times(void);
118  void init_bin(void);
119  void set_bin(const int& index);
120 
121  // Protected members
122  GSkyMap m_map; //!< Counts cube stored as sky map
123  GSkyMap m_weights; //!< Cube weights stored as sky map
124  GCTAEventBin m_bin; //!< Actual event bin
125  GTime m_time; //!< Event cube mean time
126  GCTAPointing m_pnt; //!< Event cube pointing
127  bool m_has_pnt; //!< Event cube has pointing
128  std::vector<GCTAInstDir> m_dirs; //!< Array of event directions
129  std::vector<double> m_solidangle; //!< Array of solid angles (sr)
130  std::vector<GEnergy> m_energies; //!< Array of log mean energies
131  std::vector<GEnergy> m_ewidth; //!< Array of energy bin widths
132  double m_ontime; //!< Event cube ontime (sec)
133 };
134 
135 
136 /***********************************************************************//**
137  * @brief Return class name
138  *
139  * @return String containing the class name ("GCTAEventCube").
140  ***************************************************************************/
141 inline
142 std::string GCTAEventCube::classname(void) const
143 {
144  return ("GCTAEventCube");
145 }
146 
147 
148 /***********************************************************************//**
149  * @brief Return dimension of event cube
150  *
151  * @return Dimension of event cube.
152  ***************************************************************************/
153 inline
154 int GCTAEventCube::dim(void) const
155 {
156  // Return dimension
157  return ((m_map.nmaps() > 0) ? 3 : 0);
158 }
159 
160 
161 /***********************************************************************//**
162  * @brief Return event cube counts as sky map
163  *
164  * @return Event cube counts.
165  *
166  * Returns the event cube counts as sky map.
167  ***************************************************************************/
168 inline
169 const GSkyMap& GCTAEventCube::counts(void) const
170 {
171  return (m_map);
172 }
173 
174 
175 /***********************************************************************//**
176  * @brief Return event cube weights as sky map
177  *
178  * @return Event cube weights.
179  *
180  * Returns the event cube weights as sky map.
181  ***************************************************************************/
182 inline
183 const GSkyMap& GCTAEventCube::weights(void) const
184 {
185  return (m_weights);
186 }
187 
188 
189 /***********************************************************************//**
190  * @brief Set event cube weights from sky map
191  *
192  * @param[in] weights Event cube weights sky map.
193  *
194  * Sets the event cube weights from sky map.
195  ***************************************************************************/
196 inline
197 void GCTAEventCube::weights(const GSkyMap& weights)
198 {
199  m_weights = weights;
200  return;
201 }
202 
203 
204 /***********************************************************************//**
205  * @brief Return number of bins in X direction
206  *
207  * @return Number of bins in X direction.
208  ***************************************************************************/
209 inline
210 int GCTAEventCube::nx(void) const
211 {
212  return (m_map.nx());
213 }
214 
215 
216 /***********************************************************************//**
217  * @brief Return number of bins in Y direction
218  *
219  * @return Number of bins in Y direction.
220  ***************************************************************************/
221 inline
222 int GCTAEventCube::ny(void) const
223 {
224  return (m_map.ny());
225 }
226 
227 
228 /***********************************************************************//**
229  * @brief Return number of pixels in one energy bins of the event cube
230  *
231  * @return Number of pixels in one energy bins of the event cube.
232  ***************************************************************************/
233 inline
234 int GCTAEventCube::npix(void) const
235 {
236  return (m_map.npix());
237 }
238 
239 
240 /***********************************************************************//**
241  * @brief Return number of energy bins in the event cube
242  *
243  * @return Number of energy bins in the event cube.
244  ***************************************************************************/
245 inline
246 int GCTAEventCube::ebins(void) const
247 {
248  return (m_map.nmaps());
249 }
250 
251 
252 /***********************************************************************//**
253  * @brief Return event cube mean time
254  *
255  * @return Event cube mean time.
256  ***************************************************************************/
257 inline
258 const GTime& GCTAEventCube::time(void) const
259 {
260  return (m_time);
261 }
262 
263 #endif /* GCTAEVENTCUBE_HPP */
void read_ebds(const GFitsTable &hdu)
Read energy boundaries from HDU.
const GGti & gti(void) const
Return Good Time Intervals.
Definition: GEvents.hpp:134
Sky map class.
Definition: GSkyMap.hpp:89
Abstract FITS image base class.
Definition: GFitsImage.hpp:43
const int & ny(void) const
Returns number of pixels in y coordinate.
Definition: GSkyMap.hpp:377
Energy value class definition.
virtual GCTAEventBin * operator[](const int &index)
Event bin access operator.
GCTAPointing m_pnt
Event cube pointing.
const GTime & time(void) const
Return event cube mean time.
GCTAEventBin class interface definition.
const GSkyMap & weights(void) const
Return event cube weights as sky map.
virtual GCTAEventCube * clone(void) const
Clone CTA event cube.
virtual void clear(void)
Clear CTA event cube.
CTA event bin class interface definition.
GCTAEventCube(void)
Void constructor.
void free_members(void)
Delete class members.
Abstract event bin container class interface definition.
CTA pointing class interface definition.
virtual void set_energies(void)
Set log mean energies and energy widths of event cube.
virtual int number(void) const
Return number of events in cube.
Time class.
Definition: GTime.hpp:55
FITS file class.
Definition: GFits.hpp:63
virtual GCTAEventCube & operator=(const GCTAEventCube &cube)
Assignment operator.
Sky map class definition.
Good time interval class interface definition.
void set_directions(void)
Set sky directions and solid angles of events cube.
Abstract FITS image base class definition.
int ny(void) const
Return number of bins in Y direction.
GTime m_time
Event cube mean time.
virtual void set_times(void)
Set mean event time and ontime of event cube.
std::vector< GEnergy > m_ewidth
Array of energy bin widths.
const std::string extname_cta_weights
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event cube information.
CTA event bin container class.
std::vector< GCTAInstDir > m_dirs
Array of event directions.
int npix(void) const
Return number of pixels in one energy bins of the event cube.
Energy boundaries container class.
Definition: GEbounds.hpp:60
double m_ontime
Event cube ontime (sec)
const int & nmaps(void) const
Returns number of maps.
Definition: GSkyMap.hpp:389
Filename class.
Definition: GFilename.hpp:62
int nx(void) const
Return number of bins in X direction.
virtual void load(const GFilename &filename)
Load CTA event cube from FITS file.
GCTAEventBin m_bin
Actual event bin.
void init_bin(void)
Initialise event bin.
void set_detxy(const GCTAPointing &pnt)
Set DETX and DETY coordinates.
const std::string extname_cta_counts
CTA pointing class.
CTA instrument direction class interface definition.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
const GEnergy & energy(const int &index) const
Return energy of cube layer.
GSkyMap m_weights
Cube weights stored as sky map.
Good Time Interval class.
Definition: GGti.hpp:62
std::vector< GEnergy > m_energies
Array of log mean energies.
void copy_members(const GCTAEventCube &cube)
Copy class members.
void init_members(void)
Initialise class members.
void read_gti(const GFitsTable &hdu)
Read GTIs from HDU.
virtual ~GCTAEventCube(void)
Destructor.
virtual int dim(void) const
Return dimension of event cube.
Energy boundaries class interface definition.
const int & nx(void) const
Returns number of pixels in x coordinate.
Definition: GSkyMap.hpp:361
GSkyMap m_map
Counts cube stored as sky map.
virtual std::string classname(void) const
Return class name.
void set_bin(const int &index)
Set event bin.
virtual void write(GFits &file) const
Write CTA event cube into FITS file.
const int & npix(void) const
Returns number of pixels.
Definition: GSkyMap.hpp:345
int ebins(void) const
Return number of energy bins in the event cube.
Abstract event bin container class.
Definition: GEventCube.hpp:46
Time class interface definition.
virtual void read(const GFits &file)
Read CTA event cube from FITS file.
void read_cntmap(const GFitsImage &hdu)
Read CTA counts map from HDU.
std::vector< double > m_solidangle
Array of solid angles (sr)
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
const GSkyMap & counts(void) const
Return event cube counts as sky map.
bool m_has_pnt
Event cube has pointing.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save CTA event cube into FITS file.
virtual int naxis(const int &axis) const
Return number of bins in axis.
virtual int size(void) const
Return number of bins in event cube.
FITS table abstract base class interface definition.