GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAEdispPerfTable.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAEdispPerfTable.hpp - CTA performance table 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 GCTAEdispPerfTable.hpp
23  * @brief CTA performance table energy dispersion class definition
24  * @author Christoph Deil & Ellis Owen
25  */
26 
27 #ifndef GCTAEDISPPERFTABLE_HPP
28 #define GCTAEDISPPERFTABLE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GFits.hpp"
33 #include "GFilename.hpp"
34 #include "GNodeArray.hpp"
35 #include "GCTAEdisp.hpp"
36 
37 /* __ Forward declarations _______________________________________________ */
38 class GRan;
39 
40 
41 /***********************************************************************//**
42  * @class GCTAEdispPerfTable
43  *
44  * @brief CTA performance table energy dispersion class
45  *
46  * This class implements the CTA energy dispersion response as function
47  * of true energy as determined from a performance table. A performance
48  * table is an ASCII file that represent a table, specifying the CTA
49  * performance parameters as function of true photon energy.
50  *
51  * The energy dispersion is defined as
52  *
53  * \f[
54  * E_{\rm disp}(E_{\rm true}, E_{\rm reco}) =
55  * \frac{1}{\sqrt{2\pi}\sigma(E_{\rm true})}
56  * \exp \left(\frac{-(\log_{10} E_{\rm reco} - \log_{10} E_{\rm true})^2}
57  * {2 \sigma(E_{\rm true})^2} \right) \times
58  * \frac{1}{\log_{10} E_{\rm reco}}
59  * \f]
60  *
61  * and given in units of MeV\f$^{-1}\f$, where
62  * \f$E_{\rm reco}\f$ is the reconstructed energy in units of MeV,
63  * \f$E_{\rm true}\f$ is the true energy in units of MeV, and
64  * \f$\sigma(E_{\rm true})\f$ is the standard deviation of the energy
65  * dispersion that depends on the true photon energy.
66  ***************************************************************************/
67 class GCTAEdispPerfTable : public GCTAEdisp {
68 
69 public:
70  // Constructors and destructors
71  GCTAEdispPerfTable(void);
72  explicit GCTAEdispPerfTable(const GFilename& filename);
74  virtual ~GCTAEdispPerfTable(void);
75 
76  // Operators
78  double operator()(const GEnergy& ereco,
79  const GEnergy& etrue,
80  const double& theta = 0.0,
81  const double& phi = 0.0,
82  const double& zenith = 0.0,
83  const double& azimuth = 0.0) const;
84 
85  // Implemented pure virtual methods
86  void clear(void);
87  GCTAEdispPerfTable* clone(void) const;
88  std::string classname(void) const;
89  void load(const GFilename& filename);
90  GFilename filename(void) const;
91  GEnergy mc(GRan& ran,
92  const GEnergy& etrue,
93  const double& theta = 0.0,
94  const double& phi = 0.0,
95  const double& zenith = 0.0,
96  const double& azimuth = 0.0) const;
97  GEbounds ereco_bounds(const GEnergy& etrue,
98  const double& theta = 0.0,
99  const double& phi = 0.0,
100  const double& zenith = 0.0,
101  const double& azimuth = 0.0) const;
102  GEbounds etrue_bounds(const GEnergy& ereco,
103  const double& theta = 0.0,
104  const double& phi = 0.0,
105  const double& zenith = 0.0,
106  const double& azimuth = 0.0) const;
107  double prob_erecobin(const GEnergy& ereco_min,
108  const GEnergy& ereco_max,
109  const GEnergy& etrue,
110  const double& theta) const;
111  std::string print(const GChatter& chatter = NORMAL) const;
112 
113 private:
114  // Methods
115  void init_members(void);
116  void copy_members(const GCTAEdispPerfTable& psf);
117  void free_members(void);
118  void update(const double& logE) const;
119 
120  // Members
121  mutable GFilename m_filename; //!< Name of response file
122  GNodeArray m_logE; //!< log(E) nodes for interpolation
123  std::vector<double> m_sigma; //!< Sigma value (rms) of energy resolution
124 
125  // Precomputation cache
126  mutable double m_par_logE; //!< Energy for which precomputation is done
127  mutable double m_par_scale; //!< Gaussian normalization
128  mutable double m_par_sigma; //!< Gaussian sigma
129  mutable double m_par_width; //!< Gaussian width parameter
130 };
131 
132 
133 /***********************************************************************//**
134  * @brief Return class name
135  *
136  * @return String containing the class name ("GCTAEdispPerfTable").
137  ***************************************************************************/
138 inline
139 std::string GCTAEdispPerfTable::classname(void) const
140 {
141  return ("GCTAEdispPerfTable");
142 }
143 
144 
145 /***********************************************************************//**
146  * @brief Return filename
147  *
148  * @return Returns filename from which the energy resolution was loaded
149  ***************************************************************************/
150 inline
152 {
153  return m_filename;
154 }
155 
156 #endif /* GCTAEDISPPERFTABLE_HPP */
void free_members(void)
Delete class members.
std::string print(const GChatter &chatter=NORMAL) const
Print energy dispersion information.
Node array class.
Definition: GNodeArray.hpp:60
std::vector< double > m_sigma
Sigma value (rms) of energy resolution.
Abstract base class for the CTA energy dispersion.
Definition: GCTAEdisp.hpp:49
double m_par_width
Gaussian width parameter.
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.
Random number generator class.
Definition: GRan.hpp:44
GCTAEdispPerfTable & operator=(const GCTAEdispPerfTable &psf)
Assignment operator.
FITS file class interface definition.
GCTAEdispPerfTable * clone(void) const
Clone instance.
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.
void copy_members(const GCTAEdispPerfTable &psf)
Copy class members.
Node array class interface definition.
void clear(void)
Clear instance.
double m_par_logE
Energy for which precomputation is done.
Energy boundaries container class.
Definition: GEbounds.hpp:60
GFilename filename(void) const
Return filename.
CTA performance table energy dispersion class.
virtual ~GCTAEdispPerfTable(void)
Destructor.
Filename class.
Definition: GFilename.hpp:62
double m_par_sigma
Gaussian sigma.
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 .
GChatter
Definition: GTypemaps.hpp:33
Abstract CTA energy dispersion base class definition.
double m_par_scale
Gaussian normalization.
void load(const GFilename &filename)
Load energy dispersion from performance table.
std::string classname(void) const
Return class name.
GCTAEdispPerfTable(void)
Void constructor.
GNodeArray m_logE
log(E) nodes for interpolation
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 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.
GFilename m_filename
Name of response file.
void update(const double &logE) const
Update energy dispersion parameter cache.
void init_members(void)
Initialise class members.
Filename class interface definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48