GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTACubeEdisp.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTACubeEdisp.hpp - CTA cube analysis energy dispersion class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2016-2018 by Michael Mayer *
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 GCTACubeEdisp.hpp
23 * @brief CTA cube analysis energy disperson class definition
24 * @author Michael Mayer
25 */
26
27#ifndef GCTACUBEEDISP_HPP
28#define GCTACUBEEDISP_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <vector>
33#include "GBase.hpp"
34#include "GSkyMap.hpp"
35#include "GEbounds.hpp"
36#include "GEnergies.hpp"
37#include "GNodeArray.hpp"
38
39/* __ Forward declarations _______________________________________________ */
40class GFits;
41class GFilename;
42class GObservations;
43class GCTAEventCube;
44class GCTAObservation;
45
46/* __ Constants __________________________________________________________ */
47namespace gammalib {
48 const std::string extname_cta_migras = "MIGRAS";
49}
50
51
52/***********************************************************************//**
53 * @class GCTACubeEdisp
54 *
55 * @brief CTA energy dispersion for stacked analysis
56 *
57 * This class implements a mean CTA energy dispersion which provides the
58 * average energy dispersion probability density function for stacked
59 * analysis as function of sky position, energy migration, and true log10
60 * energy.
61 ***************************************************************************/
62class GCTACubeEdisp : public GBase {
63
64public:
65 // Constructors and destructors
66 GCTACubeEdisp(void);
68 explicit GCTACubeEdisp(const GFilename& filename);
70 const double& mmax,
71 const int& nmbins);
72 GCTACubeEdisp(const std::string& wcs,
73 const std::string& coords,
74 const double& x,
75 const double& y,
76 const double& dx,
77 const double& dy,
78 const int& nx,
79 const int& ny,
80 const GEnergies& energies,
81 const double& mmax,
82 const int& nmbins);
83 virtual ~GCTACubeEdisp(void);
84
85 // Operators
87 double operator()(const GEnergy& ereco,
88 const GEnergy& etrue,
89 const GSkyDir& dir) const;
90
91 // Methods
92 void clear(void);
93 GCTACubeEdisp* clone(void) const;
94 std::string classname(void) const;
95 void set(const GCTAObservation& obs);
96 void fill(const GObservations& obs, GLog* log = NULL);
97 const GSkyMap& cube(void) const;
98 const GEnergies& energies(void) const;
99 const GNodeArray& migras(void) const;
100 double migra_max(void) const;
101 int offset(const int& imigra, const int& iebin) const;
102 GEbounds ebounds(const GEnergy& obsEng) const;
103 void read(const GFits& fits);
104 void write(GFits& file) const;
105 void load(const GFilename& filename);
106 void save(const GFilename& filename,
107 const bool& clobber = false) const;
108 const GFilename& filename(void) const;
109 std::string print(const GChatter& chatter = NORMAL) const;
110
111protected:
112 // Methods
113 void init_members(void);
114 void copy_members(const GCTACubeEdisp& cube);
115 void free_members(void);
116 void clear_cube(void);
117 void fill_cube(const GCTAObservation& obs, GSkyMap* exposure = NULL,
118 GLog* log = NULL);
119 void update(const GEnergy& ereco, const GEnergy& etrue) const;
120 void set_eng_axis(void);
121 void set_migras(const double& mmax, const int& nmbins);
122 void compute_ebounds(void) const;
123
124 // Members
125 mutable GFilename m_filename; //!< Filename
126 GSkyMap m_cube; //!< Energy dispersion cube
127 GEnergies m_energies; //!< True energy values of cube
128 GNodeArray m_elogmeans; //!< Mean log10TeV energy for the Edisp cube
129 GNodeArray m_migras; //!< Migra bins for the Edisp cube
130
131private:
132 // Response table computation cache for 2D access
133 mutable int m_inx1; //!< Index of upper left node
134 mutable int m_inx2; //!< Index of lower left node
135 mutable int m_inx3; //!< Index of upper right node
136 mutable int m_inx4; //!< Index of lower right node
137 mutable double m_wgt1; //!< Weight of upper left node
138 mutable double m_wgt2; //!< Weight of lower left node
139 mutable double m_wgt3; //!< Weight of upper right node
140 mutable double m_wgt4; //!< Weight of lower right node
141 mutable std::vector<GEbounds> m_ebounds; //!< Energy boundaries
142};
143
144
145/***********************************************************************//**
146 * @brief Return class name
147 *
148 * @return String containing the class name ("GCTACubeEdisp").
149 ***************************************************************************/
150inline
151std::string GCTACubeEdisp::classname(void) const
152{
153 return ("GCTACubeEdisp");
154}
155
156
157/***********************************************************************//**
158 * @brief Return energy dispersion cube sky map
159 *
160 * @return Energy dispersion cube sky map.
161 *
162 * Returns the energy dispersion cube sky map.
163 ***************************************************************************/
164inline
165const GSkyMap& GCTACubeEdisp::cube(void) const
166{
167 return (m_cube);
168}
169
170
171/***********************************************************************//**
172 * @brief Return energies for energy dispersion cub
173 *
174 * @return Energies for energy dispersion cube
175 *
176 * Returns the true energies of the energy dispersion cube.
177 ***************************************************************************/
178inline
180{
181 return (m_energies);
182}
183
184
185/***********************************************************************//**
186 * @brief Return migra fractions of true and measured photon energy
187 *
188 * @return Offset migra between fractions of true and measured photon energy
189 ***************************************************************************/
190inline
192{
193 return (m_migras);
194}
195
196
197/***********************************************************************//**
198 * @brief Return maximum migra value
199 *
200 * @return Maximum migra value.
201 ***************************************************************************/
202inline
203double GCTACubeEdisp::migra_max(void) const
204{
205 // Get maximum delta value
206 double migra_max = (m_migras.size() > 0) ? m_migras[m_migras.size()-1] : 0.0;
207
208 // Return
209 return (migra_max);
210}
211
212
213/***********************************************************************//**
214 * @brief Return edisp cube filename
215 *
216 * @return Energy dispersion cube filename.
217 *
218 * Returns the filename from which the energy dispersion cube was loaded or into which
219 * the cube has been saved.
220 ***************************************************************************/
221inline
223{
224 return (m_filename);
225}
226
227
228/***********************************************************************//**
229 * @brief Return map offset
230 *
231 * @param[in] imigra Migration bin index.
232 * @param[in] iebin Energy bin index.
233 * @return Map offset.
234 *
235 * Returns the offset of the energy dispersion in the sky map for a given
236 * migration bin index and a given energy bin index.
237 ***************************************************************************/
238inline
239int GCTACubeEdisp::offset(const int& imigra, const int& iebin) const
240{
241 return (imigra + iebin*m_migras.size());
242}
243
244#endif /* GCTACUBEEDISP_HPP */
Definition of interface for all GammaLib classes.
Energy boundaries class interface definition.
Energy container class 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
Interface class for all GammaLib classes.
Definition GBase.hpp:52
CTA energy dispersion for stacked analysis.
void write(GFits &file) const
Write energy dispersion cube into FITS file.
void free_members(void)
Delete class members.
void clear_cube(void)
Clear all pixels in the energy dispersion cube.
const GNodeArray & migras(void) const
Return migra fractions of true and measured photon energy.
void init_members(void)
Initialise class members.
int m_inx3
Index of upper right node.
void update(const GEnergy &ereco, const GEnergy &etrue) const
Update energy dispersion cube indices and weights cache.
GCTACubeEdisp & operator=(const GCTACubeEdisp &cube)
Assignment operator.
double m_wgt3
Weight of upper right node.
virtual ~GCTACubeEdisp(void)
Destructor.
std::string print(const GChatter &chatter=NORMAL) const
Print energy dispersion cube information.
GNodeArray m_migras
Migra bins for the Edisp cube.
void set(const GCTAObservation &obs)
Set energy dispersion cube for one CTA observation.
void read(const GFits &fits)
Read energy dispersion cube from FITS file.
const GFilename & filename(void) const
Return edisp cube filename.
GCTACubeEdisp * clone(void) const
Clone energy dispersion cube.
void set_migras(const double &mmax, const int &nmbins)
Set nodes for interpolation in migration.
double m_wgt2
Weight of lower left node.
void set_eng_axis(void)
Set nodes for interpolation in true energy.
void fill(const GObservations &obs, GLog *log=NULL)
Fill energy dispersion cube from observation container.
void clear(void)
Clear energy dispersion cube.
std::vector< GEbounds > m_ebounds
Energy boundaries.
void copy_members(const GCTACubeEdisp &cube)
Copy class members.
GEbounds ebounds(const GEnergy &obsEng) const
Return boundaries in true energy.
int m_inx1
Index of upper left node.
void fill_cube(const GCTAObservation &obs, GSkyMap *exposure=NULL, GLog *log=NULL)
Fill energy dispersion cube from observation container.
double migra_max(void) const
Return maximum migra value.
int offset(const int &imigra, const int &iebin) const
Return map offset.
int m_inx4
Index of lower right node.
double m_wgt1
Weight of upper left node.
std::string classname(void) const
Return class name.
GNodeArray m_elogmeans
Mean log10TeV energy for the Edisp cube.
void compute_ebounds(void) const
Compute true energy boundary vector.
double m_wgt4
Weight of lower right node.
void save(const GFilename &filename, const bool &clobber=false) const
Save energy dispersion cube into FITS file.
double operator()(const GEnergy &ereco, const GEnergy &etrue, const GSkyDir &dir) const
Return energy dispersion in units of MeV .
GSkyMap m_cube
Energy dispersion cube.
void load(const GFilename &filename)
Load energy dispersion cube from FITS file.
int m_inx2
Index of lower left node.
const GSkyMap & cube(void) const
Return energy dispersion cube sky map.
GCTACubeEdisp(void)
Void constructor.
const GEnergies & energies(void) const
Return energies for energy dispersion cub.
GFilename m_filename
Filename.
GEnergies m_energies
True energy values of cube.
CTA event bin container class.
CTA observation class.
Energy boundaries container class.
Definition GEbounds.hpp:60
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
FITS file class.
Definition GFits.hpp:63
Information logger interface definition.
Definition GLog.hpp:62
Node array class.
int size(void) const
Return number of nodes in node array.
Observation container class.
Sky direction class.
Definition GSkyDir.hpp:62
Sky map class.
Definition GSkyMap.hpp:89
const std::string extname_cta_migras