GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAEdispRmf.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAEdispRmf.hpp - CTA RMF energy dispersion class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2014-2018 by Christoph Deil & Ellis Owen *
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 GCTAEdispRmf.hpp
23 * @brief CTA RMF energy dispersion class definition
24 * @author Christoph Deil & Ellis Owen
25 */
26
27#ifndef GCTAEDISPRMF_HPP
28#define GCTAEDISPRMF_HPP
29
30/* __ Includes (members required) ________________________________________ */
31#include <string>
32#include "GFilename.hpp"
33#include "GRmf.hpp"
34#include "GMatrixSparse.hpp"
35#include "GNodeArray.hpp"
36#include "GCTAEdisp.hpp"
37
38/* __ Forward declarations _______________________________________________ */
39class GFunction;
40class GRan;
41class GEnergy;
42class GEbounds;
43
44
45/***********************************************************************//**
46 * @class GCTAEdispRmf
47 *
48 * @brief CTA Redistribution Matrix File (RMF) energy dispersion class
49 *
50 * The energy dispersion is defined as
51 *
52 * \f[
53 * E_{\rm disp}(E_{\rm reco} | E_{\rm true})
54 * \f]
55 *
56 * in units of MeV\f$^{-1}\f$ where
57 * \f$E_{\rm reco}\f$ is the reconstructed energy, and
58 * \f$E_{\rm true}\f$ is the true energy.
59 ***************************************************************************/
60class GCTAEdispRmf : public GCTAEdisp {
61
62public:
63 // Constructors and destructors
64 GCTAEdispRmf(void);
65 explicit GCTAEdispRmf(const GFilename& filename);
66 GCTAEdispRmf(const GCTAEdispRmf& edisp);
67 virtual ~GCTAEdispRmf(void);
68
69 // Operators
70 GCTAEdispRmf& operator=(const GCTAEdispRmf& edisp);
71 double operator()(const GEnergy& ereco,
72 const GEnergy& etrue,
73 const double& theta = 0.0,
74 const double& phi = 0.0,
75 const double& zenith = 0.0,
76 const double& azimuth = 0.0) const;
77
78 // Implemented pure virtual methods
79 void clear(void);
80 GCTAEdispRmf* clone(void) const;
81 std::string classname(void) const;
82 void load(const GFilename& filename);
83 GFilename filename(void) const;
84 GEnergy mc(GRan& ran,
85 const GEnergy& etrue,
86 const double& theta = 0.0,
87 const double& phi = 0.0,
88 const double& zenith = 0.0,
89 const double& azimuth = 0.0) const;
90 GEbounds ereco_bounds(const GEnergy& etrue,
91 const double& theta = 0.0,
92 const double& phi = 0.0,
93 const double& zenith = 0.0,
94 const double& azimuth = 0.0) const;
95 GEbounds etrue_bounds(const GEnergy& ereco,
96 const double& theta = 0.0,
97 const double& phi = 0.0,
98 const double& zenith = 0.0,
99 const double& azimuth = 0.0) const;
100 double prob_erecobin(const GEnergy& ereco_min,
101 const GEnergy& ereco_max,
102 const GEnergy& etrue,
103 const double& theta) const;
104 std::string print(const GChatter& chatter = NORMAL) const;
105
106 // Other methods
107 const GRmf& rmf(void) const;
108
109private:
110 // Methods
111 void init_members(void);
112 void copy_members(const GCTAEdispRmf& psf);
113 void free_members(void);
114 void set_matrix(void);
115 void set_max_edisp(void);
116 void set_cache(void) const;
117 void update(const GEnergy& ereco, const GEnergy& etrue) const;
118 void compute_ereco_bounds(void) const;
119 void compute_etrue_bounds(void) const;
120
121 // Members
122 GFilename m_filename; //!< Name of response file
123 GRmf m_rmf; //!< Redistribution matrix file
124 GMatrixSparse m_matrix; //!< Normalised redistribution matrix
125 double m_max_edisp; //!< Maximum energy dispersion value for MC
126
127 // Interpolation cache
128 mutable GNodeArray m_etrue; //!< Array of log10(Etrue)
129 mutable GNodeArray m_ereco; //!< Array of log10(Ereco)
130 mutable GEnergy m_last_etrue; //!< Last true energy
131 mutable GEnergy m_last_ereco; //!< Last reconstructed energy
132 mutable int m_itrue1; //!< Index of left Etrue
133 mutable int m_itrue2; //!< Index of right Etrue
134 mutable int m_ireco1; //!< Index of left Ereco
135 mutable int m_ireco2; //!< Index of right Ereco
136 mutable double m_wgt1; //!< Weight of lower left node
137 mutable double m_wgt2; //!< Weight of upper left node
138 mutable double m_wgt3; //!< Weight of lower right node
139 mutable double m_wgt4; //!< Weight of upper right node
140
141 // Computation cache
146 mutable int m_index_ereco;
147 mutable int m_index_etrue;
148 mutable std::vector<GEbounds> m_ereco_bounds;
149 mutable std::vector<GEbounds> m_etrue_bounds;
150};
151
152
153/***********************************************************************//**
154 * @brief Return class name
155 *
156 * @return String containing the class name ("GCTAEdispRmf").
157 ***************************************************************************/
158inline
159std::string GCTAEdispRmf::classname(void) const
160{
161 return ("GCTAEdispRmf");
162}
163
164
165/***********************************************************************//**
166 * @brief Return filename
167 *
168 * @return Returns filename from which the Redistribution Matrix was loaded.
169 ***************************************************************************/
170inline
172{
173 return (m_filename);
174}
175
176
177/***********************************************************************//**
178 * @brief Return Redistribution Matrix File
179 *
180 * @return Reference to Redistribution Matrix File.
181 ***************************************************************************/
182inline
183const GRmf& GCTAEdispRmf::rmf(void) const
184{
185 return (m_rmf);
186}
187
188#endif /* GCTAEDISPRMF_HPP */
Abstract CTA energy dispersion base class definition.
Filename class interface definition.
Sparse matrix class definition.
Node array class interface definition.
XSPEC Redistribution Matrix File class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
CTA Redistribution Matrix File (RMF) energy dispersion class.
bool m_ereco_bounds_computed
int m_itrue2
Index of right Etrue.
void compute_ereco_bounds(void) const
Compute m_ereco_bounds vector.
bool m_etrue_bounds_computed
void compute_etrue_bounds(void) const
Compute m_etrue_bounds vector.
GCTAEdispRmf & operator=(const GCTAEdispRmf &edisp)
Assignment operator.
GCTAEdispRmf(void)
Void constructor.
GNodeArray m_ereco
Array of log10(Ereco)
GFilename filename(void) const
Return filename.
std::vector< GEbounds > m_ereco_bounds
double operator()(const GEnergy &ereco, const GEnergy &etrue, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const
Return energy dispersion in units of MeV .
int m_itrue1
Index of left Etrue.
double m_wgt3
Weight of lower right node.
void set_cache(void) const
Set interpolation cache.
std::string classname(void) const
Return class name.
GNodeArray m_etrue
Array of log10(Etrue)
void set_max_edisp(void)
Set maximum energy dispersion value.
virtual ~GCTAEdispRmf(void)
Destructor.
double m_wgt2
Weight of upper left node.
void init_members(void)
Initialise class members.
void set_matrix(void)
Set redistribution matrix.
GEbounds ereco_bounds(const GEnergy &etrue, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const
Return observed energy interval that contains the energy dispersion.
GRmf m_rmf
Redistribution matrix file.
std::vector< GEbounds > m_etrue_bounds
GEnergy m_last_etrue
Last true energy.
GEbounds etrue_bounds(const GEnergy &ereco, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const
Return true energy interval that contains the energy dispersion.
double m_wgt1
Weight of lower left node.
GCTAEdispRmf * clone(void) const
Clone instance.
std::string print(const GChatter &chatter=NORMAL) const
Print RMF information.
int m_ireco1
Index of left Ereco.
GFilename m_filename
Name of response file.
void load(const GFilename &filename)
Load energy dispersion from RMF file.
GMatrixSparse m_matrix
Normalised redistribution matrix.
GEnergy m_last_ereco_bounds
void copy_members(const GCTAEdispRmf &psf)
Copy class members.
GEnergy mc(GRan &ran, const GEnergy &etrue, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const
Simulate energy dispersion.
double prob_erecobin(const GEnergy &ereco_min, const GEnergy &ereco_max, const GEnergy &etrue, const double &theta) const
Return energy dispersion probability for reconstructed energy interval.
void update(const GEnergy &ereco, const GEnergy &etrue) const
Update cache.
GEnergy m_last_ereco
Last reconstructed energy.
GEnergy m_last_etrue_bounds
int m_ireco2
Index of right Ereco.
double m_max_edisp
Maximum energy dispersion value for MC.
void clear(void)
Clear instance.
double m_wgt4
Weight of upper right node.
const GRmf & rmf(void) const
Return Redistribution Matrix File.
void free_members(void)
Delete class members.
Abstract base class for the CTA energy dispersion.
Definition GCTAEdisp.hpp:49
Energy boundaries container class.
Definition GEbounds.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Filename class.
Definition GFilename.hpp:62
Single parameter function abstract base class.
Definition GFunction.hpp:44
Sparse matrix class interface definition.
Node array class.
Random number generator class.
Definition GRan.hpp:44
Redistribution Matrix File class.
Definition GRmf.hpp:55