GammaLib 2.0.0
Loading...
Searching...
No Matches
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 _______________________________________________ */
46class GFilename;
47
48/* __ Constants __________________________________________________________ */
49namespace 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 ***************************************************************************/
62class GCTAEventCube : public GEventCube {
63
64public:
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
106protected:
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 ***************************************************************************/
141inline
142std::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 ***************************************************************************/
153inline
154int 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 ***************************************************************************/
168inline
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 ***************************************************************************/
182inline
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 ***************************************************************************/
196inline
197void GCTAEventCube::weights(const GSkyMap& weights)
198{
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 ***************************************************************************/
209inline
210int 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 ***************************************************************************/
221inline
222int 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 ***************************************************************************/
233inline
234int 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 ***************************************************************************/
245inline
246int 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 ***************************************************************************/
257inline
258const GTime& GCTAEventCube::time(void) const
259{
260 return (m_time);
261}
262
263#endif /* GCTAEVENTCUBE_HPP */
CTA event bin class interface definition.
CTA instrument direction class interface definition.
CTA pointing class interface definition.
Energy boundaries class interface definition.
Energy value class definition.
Abstract event bin container class interface definition.
Abstract FITS image base class definition.
FITS table abstract base class interface definition.
Good time interval class interface definition.
Sky map class definition.
Time class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
GCTAEventBin class interface definition.
CTA event bin container class.
void init_bin(void)
Initialise event bin.
virtual void load(const GFilename &filename)
Load CTA event cube from FITS file.
const GEnergy & energy(const int &index) const
Return energy of cube layer.
const GSkyMap & counts(void) const
Return event cube counts as sky map.
GSkyMap m_weights
Cube weights stored as sky map.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print event cube information.
virtual void clear(void)
Clear CTA event cube.
void read_cntmap(const GFitsImage &hdu)
Read CTA counts map from HDU.
void copy_members(const GCTAEventCube &cube)
Copy class members.
GCTAEventBin m_bin
Actual event bin.
virtual int dim(void) const
Return dimension of event cube.
const GTime & time(void) const
Return event cube mean time.
virtual int size(void) const
Return number of bins in event cube.
void read_ebds(const GFitsTable &hdu)
Read energy boundaries from HDU.
int npix(void) const
Return number of pixels in one energy bins of the event cube.
int nx(void) const
Return number of bins in X direction.
void set_detxy(const GCTAPointing &pnt)
Set DETX and DETY coordinates.
virtual std::string classname(void) const
Return class name.
double m_ontime
Event cube ontime (sec)
void init_members(void)
Initialise class members.
GCTAEventCube(void)
Void constructor.
virtual int naxis(const int &axis) const
Return number of bins in axis.
virtual GCTAEventCube * clone(void) const
Clone CTA event cube.
std::vector< double > m_solidangle
Array of solid angles (sr)
std::vector< GCTAInstDir > m_dirs
Array of event directions.
GTime m_time
Event cube mean time.
std::vector< GEnergy > m_ewidth
Array of energy bin widths.
virtual void set_energies(void)
Set log mean energies and energy widths of event cube.
virtual GCTAEventCube & operator=(const GCTAEventCube &cube)
Assignment operator.
virtual GCTAEventBin * operator[](const int &index)
Event bin access operator.
virtual void read(const GFits &file)
Read CTA event cube from FITS file.
virtual void save(const GFilename &filename, const bool &clobber=false) const
Save CTA event cube into FITS file.
void free_members(void)
Delete class members.
bool m_has_pnt
Event cube has pointing.
const GSkyMap & weights(void) const
Return event cube weights as sky map.
virtual void write(GFits &file) const
Write CTA event cube into FITS file.
virtual ~GCTAEventCube(void)
Destructor.
virtual void set_times(void)
Set mean event time and ontime of event cube.
GSkyMap m_map
Counts cube stored as sky map.
void set_bin(const int &index)
Set event bin.
GCTAPointing m_pnt
Event cube pointing.
void read_gti(const GFitsTable &hdu)
Read GTIs from HDU.
std::vector< GEnergy > m_energies
Array of log mean energies.
void set_directions(void)
Set sky directions and solid angles of events cube.
int ebins(void) const
Return number of energy bins in the event cube.
virtual int number(void) const
Return number of events in cube.
int ny(void) const
Return number of bins in Y direction.
CTA pointing class.
Energy boundaries container class.
Definition GEbounds.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract event bin container class.
const GGti & gti(void) const
Return Good Time Intervals.
Definition GEvents.hpp:134
Filename class.
Definition GFilename.hpp:62
Abstract FITS image base class.
Abstract interface for FITS table.
FITS file class.
Definition GFits.hpp:63
Good Time Interval class.
Definition GGti.hpp:62
Sky map class.
Definition GSkyMap.hpp:89
const int & nmaps(void) const
Returns number of maps.
Definition GSkyMap.hpp:389
const int & nx(void) const
Returns number of pixels in x coordinate.
Definition GSkyMap.hpp:361
const int & npix(void) const
Returns number of pixels.
Definition GSkyMap.hpp:345
const int & ny(void) const
Returns number of pixels in y coordinate.
Definition GSkyMap.hpp:377
Time class.
Definition GTime.hpp:55
const std::string extname_cta_counts
const std::string extname_cta_weights