GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAPsf2D.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAPsf2D.hpp - CTA 2D point spread function class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2017 by Juergen Knoedlseder *
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 GCTAPsf2D.hpp
23  * @brief CTA 2D point spread function class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAPSF2D_HPP
28 #define GCTAPSF2D_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GFilename.hpp"
33 #include "GCTAPsf.hpp"
34 #include "GCTAResponseTable.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 class GRan;
38 class GFitsBinTable;
39 
40 /* __ Constants __________________________________________________________ */
41 namespace gammalib {
42  const std::string extname_cta_psf2d = "POINT SPREAD FUNCTION";
43 }
44 
45 
46 /***********************************************************************//**
47  * @class GCTAPsf2D
48  *
49  * @brief CTA 2D point spread function class
50  *
51  * This class implements the CTA point spread function response as function
52  * of energy and offset angle.
53  ***************************************************************************/
54 class GCTAPsf2D : public GCTAPsf {
55 
56 public:
57  // Constructors and destructors
58  GCTAPsf2D(void);
59  explicit GCTAPsf2D(const GFilename& filename);
60  GCTAPsf2D(const GCTAPsf2D& psf);
61  virtual ~GCTAPsf2D(void);
62 
63  // Operators
64  GCTAPsf2D& operator=(const GCTAPsf2D& psf);
65  double operator()(const double& delta,
66  const double& logE,
67  const double& theta = 0.0,
68  const double& phi = 0.0,
69  const double& zenith = 0.0,
70  const double& azimuth = 0.0,
71  const bool& etrue = true) const;
72 
73  // Implemented pure virtual methods
74  void clear(void);
75  GCTAPsf2D* clone(void) const;
76  std::string classname(void) const;
77  void load(const GFilename& filename);
78  GFilename filename(void) const;
79  double mc(GRan& ran,
80  const double& logE,
81  const double& theta = 0.0,
82  const double& phi = 0.0,
83  const double& zenith = 0.0,
84  const double& azimuth = 0.0,
85  const bool& etrue = true) const;
86  double delta_max(const double& logE,
87  const double& theta = 0.0,
88  const double& phi = 0.0,
89  const double& zenith = 0.0,
90  const double& azimuth = 0.0,
91  const bool& etrue = true) const;
92  double containment_radius(const double& fraction,
93  const double& logE,
94  const double& theta = 0.0,
95  const double& phi = 0.0,
96  const double& zenith = 0.0,
97  const double& azimuth = 0.0,
98  const bool& etrue = true) const;
99  std::string print(const GChatter& chatter = NORMAL) const;
100 
101  // Methods
102  const GCTAResponseTable& table(void) const;
103  void table(const GCTAResponseTable& table);
104  void read(const GFitsTable& table);
105  void write(GFitsBinTable& table) const;
106  void save(const GFilename& filename,
107  const bool& clobber = false) const;
108 
109 
110 private:
111  // Methods
112  void init_members(void);
113  void copy_members(const GCTAPsf2D& psf);
114  void free_members(void);
115  void update(const double& logE, const double& theta) const;
116 
117  // Members
118  GFilename m_filename; //!< Name of Aeff response file
119  GCTAResponseTable m_psf; //!< PSF response table
120  int m_inx_energy; //!< Energy index
121  int m_inx_theta; //!< Theta index
122  int m_inx_sigma1; //!< 1st Gaussian sigma
123  int m_inx_ampl2; //!< 2nd Gaussian relative amplitude
124  int m_inx_sigma2; //!< 2nd Gaussian sigma
125  int m_inx_ampl3; //!< 3nd Gaussian relative amplitude
126  int m_inx_sigma3; //!< 3nd Gaussian sigma
127 
128  // Precomputation cache
129  mutable double m_par_logE; //!< Cache energy
130  mutable double m_par_theta; //!< Cache offset angle
131  mutable double m_norm; //!< Global normalization
132  mutable double m_norm2; //!< Gaussian 2 normalization
133  mutable double m_norm3; //!< Gaussian 3 normalization
134  mutable double m_sigma1; //!< Gaussian 1 sigma
135  mutable double m_sigma2; //!< Gaussian 2 sigma
136  mutable double m_sigma3; //!< Gaussian 3 sigma
137  mutable double m_width1; //!< Gaussian 1 width
138  mutable double m_width2; //!< Gaussian 2 width
139  mutable double m_width3; //!< Gaussian 3 width
140 };
141 
142 
143 /***********************************************************************//**
144  * @brief Return class name
145  *
146  * @return String containing the class name ("GCTAPsf2D").
147  ***************************************************************************/
148 inline
149 std::string GCTAPsf2D::classname(void) const
150 {
151  return ("GCTAPsf2D");
152 }
153 
154 
155 /***********************************************************************//**
156  * @brief Return filename
157  *
158  * @return Returns filename from which point spread function was loaded
159  ***************************************************************************/
160 inline
162 {
163  return m_filename;
164 }
165 
166 /***********************************************************************//**
167  * @brief Return response table
168  *
169  * @return Response table.
170  ***************************************************************************/
171 inline
173 {
174  return m_psf;
175 }
176 
177 /***********************************************************************//**
178  * @brief Assign response table
179  *
180  * @param[in] table Response table.
181  ***************************************************************************/
182 inline
184 {
185  m_psf = table;
186 }
187 
188 
189 #endif /* GCTAPSF2D_HPP */
virtual ~GCTAPsf2D(void)
Destructor.
Definition: GCTAPsf2D.cpp:124
GCTAResponseTable m_psf
PSF response table.
Definition: GCTAPsf2D.hpp:119
GCTAPsf2D & operator=(const GCTAPsf2D &psf)
Assignment operator.
Definition: GCTAPsf2D.cpp:148
GFilename filename(void) const
Return filename.
Definition: GCTAPsf2D.hpp:161
double operator()(const double &delta, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
Return point spread function (in units of sr^-1)
Definition: GCTAPsf2D.cpp:187
void read(const GFitsTable &table)
Read point spread function from FITS table.
Definition: GCTAPsf2D.cpp:311
GCTAPsf2D(void)
Void constructor.
Definition: GCTAPsf2D.cpp:68
Abstract base class for the CTA point spread function.
Definition: GCTAPsf.hpp:47
int m_inx_energy
Energy index.
Definition: GCTAPsf2D.hpp:120
double m_width1
Gaussian 1 width.
Definition: GCTAPsf2D.hpp:137
Random number generator class.
Definition: GRan.hpp:44
double m_norm
Global normalization.
Definition: GCTAPsf2D.hpp:131
double m_sigma2
Gaussian 2 sigma.
Definition: GCTAPsf2D.hpp:135
double m_par_theta
Cache offset angle.
Definition: GCTAPsf2D.hpp:130
int m_inx_ampl3
3nd Gaussian relative amplitude
Definition: GCTAPsf2D.hpp:125
CTA 2D point spread function class.
Definition: GCTAPsf2D.hpp:54
void copy_members(const GCTAPsf2D &psf)
Copy class members.
Definition: GCTAPsf2D.cpp:779
const GCTAResponseTable & table(void) const
Return response table.
Definition: GCTAPsf2D.hpp:172
void update(const double &logE, const double &theta) const
Update PSF parameter cache.
Definition: GCTAPsf2D.cpp:826
int m_inx_ampl2
2nd Gaussian relative amplitude
Definition: GCTAPsf2D.hpp:123
int m_inx_sigma3
3nd Gaussian sigma
Definition: GCTAPsf2D.hpp:126
CTA response table class definition.
const std::string extname_cta_psf2d
Definition: GCTAPsf2D.hpp:42
Filename class.
Definition: GFilename.hpp:62
double m_width2
Gaussian 2 width.
Definition: GCTAPsf2D.hpp:138
std::string print(const GChatter &chatter=NORMAL) const
Print point spread function information.
Definition: GCTAPsf2D.cpp:689
double mc(GRan &ran, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
Simulate PSF offset (radians)
Definition: GCTAPsf2D.cpp:484
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
double m_norm3
Gaussian 3 normalization.
Definition: GCTAPsf2D.hpp:133
double m_sigma3
Gaussian 3 sigma.
Definition: GCTAPsf2D.hpp:136
double delta_max(const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
Return maximum size of PSF (radians)
Definition: GCTAPsf2D.cpp:531
void save(const GFilename &filename, const bool &clobber=false) const
Save point spread function table into FITS file.
Definition: GCTAPsf2D.cpp:437
void load(const GFilename &filename)
Load point spread function from FITS file.
Definition: GCTAPsf2D.cpp:397
CTA point spread function base class definition.
void init_members(void)
Initialise class members.
Definition: GCTAPsf2D.cpp:745
int m_inx_sigma1
1st Gaussian sigma
Definition: GCTAPsf2D.hpp:122
int m_inx_sigma2
2nd Gaussian sigma
Definition: GCTAPsf2D.hpp:124
void clear(void)
Clear point spread function.
Definition: GCTAPsf2D.cpp:259
void write(GFitsBinTable &table) const
Write point spread function into FITS binary table.
Definition: GCTAPsf2D.cpp:363
FITS binary table class.
int m_inx_theta
Theta index.
Definition: GCTAPsf2D.hpp:121
double containment_radius(const double &fraction, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
Return the radius that contains a fraction of the events (radians)
Definition: GCTAPsf2D.cpp:586
double m_par_logE
Cache energy.
Definition: GCTAPsf2D.hpp:129
void free_members(void)
Delete class members.
Definition: GCTAPsf2D.cpp:811
CTA response table class.
GCTAPsf2D * clone(void) const
Clone point spread functions.
Definition: GCTAPsf2D.cpp:281
std::string classname(void) const
Return class name.
Definition: GCTAPsf2D.hpp:149
double m_sigma1
Gaussian 1 sigma.
Definition: GCTAPsf2D.hpp:134
double m_width3
Gaussian 3 width.
Definition: GCTAPsf2D.hpp:139
GFilename m_filename
Name of Aeff response file.
Definition: GCTAPsf2D.hpp:118
Filename class interface definition.
double m_norm2
Gaussian 2 normalization.
Definition: GCTAPsf2D.hpp:132