GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 _______________________________________________ */
40 class GFits;
41 class GFitsHDU;
42 class GObservations;
43 class GCTAObservation;
44 class 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  ***************************************************************************/
55 class GCTACubeExposure : public GBase {
56 
57 public:
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 
99 protected:
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 
120 private:
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  ***************************************************************************/
134 inline
135 std::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  ***************************************************************************/
149 inline
150 const GSkyMap& GCTACubeExposure::cube(void) const
151 {
152  return (m_cube);
153 }
154 
155 
156 /***********************************************************************//**
157  * @brief Return energies
158  *
159  * @return Energies
160  ***************************************************************************/
161 inline
163 {
164  return (m_energies);
165 }
166 
167 
168 /***********************************************************************//**
169  * @brief Return Good Time Intervals
170  *
171  * @return Good Time Intervals.
172  ***************************************************************************/
173 inline
174 const GGti& GCTACubeExposure::gti(void) const
175 {
176  return (m_gti);
177 }
178 
179 
180 /***********************************************************************//**
181  * @brief Return livetime
182  *
183  * @return Livetime (seconds).
184  ***************************************************************************/
185 inline
186 const double& GCTACubeExposure::livetime(void) const
187 {
188  return (m_livetime);
189 }
190 
191 
192 /***********************************************************************//**
193  * @brief Return ontime
194  *
195  * @return Ontime (seconds).
196  ***************************************************************************/
197 inline
198 const 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  ***************************************************************************/
209 inline
210 double 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  ***************************************************************************/
224 inline
226 {
227  return (m_filename);
228 }
229 
230 #endif /* GCTACUBEEXPOSURE_HPP */
CTA exposure cube class.
Sky map class.
Definition: GSkyMap.hpp:89
double operator()(const GSkyDir &dir, const GEnergy &energy) const
Return exposure (in units of cm**2 s)
double m_livetime
Livetime (sec)
Node array class.
Definition: GNodeArray.hpp:60
void fill(const GObservations &obs, GLog *log=NULL)
Fill exposure cube from observation container.
void write(GFits &file) const
Write CTA exposure cube into FITS file.
std::string classname(void) const
Return class name.
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
void clear(void)
Clear instance.
void read(const GFits &fits)
Read exposure cube from FITS object.
Definition of interface for all GammaLib classes.
void write_attributes(GFitsHDU &hdu) const
Write attributes to exposure extension.
GCTACubeExposure & operator=(const GCTACubeExposure &exp)
Assignment operator.
FITS file class.
Definition: GFits.hpp:63
void init_members(void)
Initialise class members.
Sky map class definition.
GCTACubeExposure * clone(void) const
Clone exposure cube.
Good time interval class interface definition.
void update(const double &logE) const
Update 1D cache.
Energy container class.
Definition: GEnergies.hpp:60
std::string print(const GChatter &chatter=NORMAL) const
Print exposure cube information.
void fill_cube(const GCTAObservation &obs, GLog *log=NULL)
Fill exposure cube for one observation.
void load(const GFilename &filename)
Load exposure cube from FITS file.
Information logger interface definition.
Definition: GLog.hpp:62
Node array class interface definition.
const GGti & gti(void) const
Return Good Time Intervals.
CTA event bin container class.
GCTACubeExposure(void)
Void constructor.
Filename class.
Definition: GFilename.hpp:62
Energy container class definition.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
const GEnergies & energies(void) const
Return energies.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
Definition: GVector.cpp:1274
const GFilename & filename(void) const
Return exposure cube filename.
GSkyMap m_cube
Average Exposure cube.
double m_wgt_right
Weight of right node.
GFilename m_filename
Filename.
void read_attributes(const GFitsHDU &hdu)
Read exposure attributes.
GChatter
Definition: GTypemaps.hpp:33
double deadc(void) const
Return deadtime correction.
Good Time Interval class.
Definition: GGti.hpp:62
Observation container class.
void copy_members(const GCTACubeExposure &exp)
Copy class members.
void free_members(void)
Delete class members.
void save(const GFilename &filename, const bool &clobber=false) const
Save exposure cube into FITS file.
void set(const GCTAObservation &obs)
Set exposure cube for one CTA observation.
const double & ontime(void) const
Return ontime.
int m_inx_right
Index of right node.
const GSkyMap & cube(void) const
Return exposure cube.
const double & livetime(void) const
Return livetime.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
int m_inx_left
Index of left node.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
Definition: GVector.cpp:1232
virtual ~GCTACubeExposure(void)
Destructor.
GNodeArray m_elogmeans
Mean energy for the Exposure cube.
CTA observation class.
Sky direction class.
Definition: GSkyDir.hpp:62
const double & ontime(void) const
Returns ontime.
Definition: GGti.hpp:240
GEnergies m_energies
Energy values for the Exposure cube.
Filename class interface definition.
GGti m_gti
Good time interval for the Exposure cube.
double m_wgt_left
Weight of left node.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48