GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTACubeExposure.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTACubeExposure.hpp - CTA cube analysis exposure class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2014-2016 by Chia-Chun Lu *
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 GCTACubeExposure.hpp
23 * @brief CTA cube analysis exposure class definition
24 * @author Chia-Chun Lu
25 */
26
27#ifndef GCTACUBEEXPOSURE_HPP
28#define GCTACUBEEXPOSURE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GBase.hpp"
33#include "GFilename.hpp"
34#include "GSkyMap.hpp"
35#include "GEnergies.hpp"
36#include "GNodeArray.hpp"
37#include "GGti.hpp"
38
39/* __ Forward declarations _______________________________________________ */
40class GFits;
41class GFitsHDU;
42class GObservations;
43class GCTAObservation;
44class GCTAEventCube;
45
46
47/***********************************************************************//**
48 * @class GCTACubeExposure
49 *
50 * @brief CTA exposure cube class
51 *
52 * This class implements a CTA exposure cube which provides the average
53 * exposure for binned analysis as function of sky position and energy.
54 ***************************************************************************/
55class GCTACubeExposure : public GBase {
56
57public:
58
59 // Constructors and destructors
60 GCTACubeExposure(void);
62 explicit GCTACubeExposure(const GFilename& filename);
63 explicit GCTACubeExposure(const GCTAEventCube& cube);
64 GCTACubeExposure(const std::string& wcs,
65 const std::string& coords,
66 const double& x,
67 const double& y,
68 const double& dx,
69 const double& dy,
70 const int& nx,
71 const int& ny,
72 const GEnergies& energies);
73 virtual ~GCTACubeExposure(void);
74
75 // Operators
77 double operator()(const GSkyDir& dir, const GEnergy& energy) const;
78
79 // Methods
80 void clear(void);
81 GCTACubeExposure* clone(void) const;
82 std::string classname(void) const;
83 void set(const GCTAObservation& obs);
84 void fill(const GObservations& obs, GLog* log = NULL);
85 const GSkyMap& cube(void) const;
86 const GEnergies& energies(void) const;
87 const GGti& gti(void) const;
88 const double& livetime(void) const;
89 const double& ontime(void) const;
90 double deadc(void) const;
91 void read(const GFits& fits);
92 void write(GFits& file) const;
93 void load(const GFilename& filename);
94 void save(const GFilename& filename,
95 const bool& clobber = false) const;
96 const GFilename& filename(void) const;
97 std::string print(const GChatter& chatter = NORMAL) const;
98
99protected:
100 // Methods
101 void init_members(void);
102 void copy_members(const GCTACubeExposure& exp);
103 void free_members(void);
104 void fill_cube(const GCTAObservation& obs, GLog* log = NULL);
105 void update(const double& logE) const;
106 void set_eng_axis(void);
107 void read_attributes(const GFitsHDU& hdu);
108 void write_attributes(GFitsHDU& hdu) const;
109
110 // Members
111 mutable GFilename m_filename; //!< Filename
112 GSkyMap m_cube; //!< Average Exposure cube
113 GEnergies m_energies; //!< Energy values for the Exposure cube
114 GNodeArray m_elogmeans; //!< Mean energy for the Exposure cube
115 GGti m_gti; //!< Good time interval for the Exposure cube
116
117 // Exposure attributes
118 double m_livetime; //!< Livetime (sec)
119
120private:
121 // Response table computation cache for 1D access
122 mutable int m_inx_left; //!< Index of left node
123 mutable int m_inx_right; //!< Index of right node
124 mutable double m_wgt_left; //!< Weight of left node
125 mutable double m_wgt_right; //!< Weight of right node
126};
127
128
129/***********************************************************************//**
130 * @brief Return class name
131 *
132 * @return String containing the class name ("GCTACubeExposure").
133 ***************************************************************************/
134inline
135std::string GCTACubeExposure::classname(void) const
136{
137 return ("GCTACubeExposure");
138}
139
140
141/***********************************************************************//**
142 * @brief Return exposure cube
143 *
144 * @return Exposure cube.
145 *
146 * Returns the GSkyMap object that is used to store the exposure cube
147 * information.
148 ***************************************************************************/
149inline
151{
152 return (m_cube);
153}
154
155
156/***********************************************************************//**
157 * @brief Return energies
158 *
159 * @return Energies
160 ***************************************************************************/
161inline
163{
164 return (m_energies);
165}
166
167
168/***********************************************************************//**
169 * @brief Return Good Time Intervals
170 *
171 * @return Good Time Intervals.
172 ***************************************************************************/
173inline
174const GGti& GCTACubeExposure::gti(void) const
175{
176 return (m_gti);
177}
178
179
180/***********************************************************************//**
181 * @brief Return livetime
182 *
183 * @return Livetime (seconds).
184 ***************************************************************************/
185inline
186const double& GCTACubeExposure::livetime(void) const
187{
188 return (m_livetime);
189}
190
191
192/***********************************************************************//**
193 * @brief Return ontime
194 *
195 * @return Ontime (seconds).
196 ***************************************************************************/
197inline
198const double& GCTACubeExposure::ontime(void) const
199{
200 return (m_gti.ontime());
201}
202
203
204/***********************************************************************//**
205 * @brief Return deadtime correction
206 *
207 * @return Deadtime correction factor.
208 ***************************************************************************/
209inline
210double GCTACubeExposure::deadc(void) const
211{
212 return ((m_gti.ontime() > 0.0) ? m_livetime/m_gti.ontime() : 1.0);
213}
214
215
216/***********************************************************************//**
217 * @brief Return exposure cube filename
218 *
219 * @return Exposure cube filename.
220 *
221 * Returns the filename from which the exposure cube was loaded or into which
222 * the exposure cube has been saved.
223 ***************************************************************************/
224inline
226{
227 return (m_filename);
228}
229
230#endif /* GCTACUBEEXPOSURE_HPP */
Definition of interface for all GammaLib classes.
Energy container class definition.
Filename class interface definition.
Good time interval class interface definition.
Node array class interface definition.
Sky map class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition GVector.cpp:1274
GVector exp(const GVector &vector)
Computes exponential of vector elements.
Definition GVector.cpp:1232
Interface class for all GammaLib classes.
Definition GBase.hpp:52
CTA exposure cube class.
void set(const GCTAObservation &obs)
Set exposure cube for one CTA observation.
void read(const GFits &fits)
Read exposure cube from FITS object.
const GEnergies & energies(void) const
Return energies.
void free_members(void)
Delete class members.
GNodeArray m_elogmeans
Mean energy for the Exposure cube.
GSkyMap m_cube
Average Exposure cube.
virtual ~GCTACubeExposure(void)
Destructor.
int m_inx_right
Index of right node.
GCTACubeExposure * clone(void) const
Clone exposure cube.
std::string classname(void) const
Return class name.
GCTACubeExposure(void)
Void constructor.
GCTACubeExposure & operator=(const GCTACubeExposure &exp)
Assignment operator.
GGti m_gti
Good time interval for the Exposure cube.
int m_inx_left
Index of left node.
const double & ontime(void) const
Return ontime.
const GGti & gti(void) const
Return Good Time Intervals.
double m_wgt_right
Weight of right node.
GEnergies m_energies
Energy values for the Exposure cube.
void copy_members(const GCTACubeExposure &exp)
Copy class members.
void fill_cube(const GCTAObservation &obs, GLog *log=NULL)
Fill exposure cube for one observation.
void init_members(void)
Initialise class members.
std::string print(const GChatter &chatter=NORMAL) const
Print exposure cube information.
void write(GFits &file) const
Write CTA exposure cube into FITS file.
void save(const GFilename &filename, const bool &clobber=false) const
Save exposure cube into FITS file.
void update(const double &logE) const
Update 1D cache.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
GFilename m_filename
Filename.
const GSkyMap & cube(void) const
Return exposure cube.
void clear(void)
Clear instance.
void fill(const GObservations &obs, GLog *log=NULL)
Fill exposure cube from observation container.
void load(const GFilename &filename)
Load exposure cube from FITS file.
const GFilename & filename(void) const
Return exposure cube filename.
void read_attributes(const GFitsHDU &hdu)
Read exposure attributes.
double m_wgt_left
Weight of left node.
double deadc(void) const
Return deadtime correction.
const double & livetime(void) const
Return livetime.
double operator()(const GSkyDir &dir, const GEnergy &energy) const
Return exposure (in units of cm**2 s)
double m_livetime
Livetime (sec)
void write_attributes(GFitsHDU &hdu) const
Write attributes to exposure extension.
CTA event bin container class.
CTA observation class.
Energy container class.
Definition GEnergies.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Filename class.
Definition GFilename.hpp:62
Abstract FITS extension base class.
Definition GFitsHDU.hpp:51
FITS file class.
Definition GFits.hpp:63
Good Time Interval class.
Definition GGti.hpp:62
const double & ontime(void) const
Returns ontime.
Definition GGti.hpp:240
Information logger interface definition.
Definition GLog.hpp:62
Node array class.
Observation container class.
Sky direction class.
Definition GSkyDir.hpp:62
Sky map class.
Definition GSkyMap.hpp:89