GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAPsfKing.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAPsfKing.hpp - King profile CTA point spread function class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2013-2017 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 GCTAPsfKing.hpp
23  * @brief King profile CTA point spread function class definition
24  * @author Michael Mayer
25  */
26 
27 #ifndef GCTAPsfKing_HPP
28 #define GCTAPsfKing_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 GFitsTable;
39 
40 /* __ Constants __________________________________________________________ */
41 namespace gammalib {
42  const std::string extname_cta_psfking = "POINT SPREAD FUNCTION";
43 }
44 
45 
46 /***********************************************************************//**
47  * @class GCTAPsfKing
48  *
49  * @brief CTA point spread function class with a King profile
50  *
51  * This class implements the CTA point spread function response as function
52  * of energy as determined from a FITS table.
53  ***************************************************************************/
54 class GCTAPsfKing : public GCTAPsf {
55 
56 public:
57  // Constructors and destructors
58  GCTAPsfKing(void);
59  explicit GCTAPsfKing(const GFilename& filename);
60  GCTAPsfKing(const GCTAPsfKing& psf);
61  virtual ~GCTAPsfKing(void);
62 
63  // Operators
64  GCTAPsfKing& operator=(const GCTAPsfKing& 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  GCTAPsfKing* 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 
100  std::string print(const GChatter& chatter = NORMAL) const;
101 
102  // Methods
103  const GCTAResponseTable& table(void) const;
104  void table(const GCTAResponseTable& table);
105  void read(const GFitsTable& table);
106  void write(GFitsBinTable& table) const;
107  void save(const GFilename& filename,
108  const bool& clobber = false) const;
109 
110 
111 
112 private:
113  // Methods
114  void init_members(void);
115  void copy_members(const GCTAPsfKing& psf);
116  void free_members(void);
117  void update(const double& logE, const double& theta) const;
118  double r_max(const double& logE, const double& theta) const;
119 
120  // Members
121  GFilename m_filename; //!< Name of Aeff response file
122  GCTAResponseTable m_psf; //!< PSF response table
123  int m_inx_energy; //!< Energy index
124  int m_inx_theta; //!< Theta index
125  int m_inx_gamma; //!< Gamma
126  int m_inx_sigma; //!< Sigma
127 
128  // Evaluation cache
129  mutable double m_par_logE; //!< Cache energy
130  mutable double m_par_theta; //!< Cache offset angle
131  mutable double m_par_norm; //!< King profile normalization
132  mutable double m_par_sigma; //!< King profile sigma (radians)
133  mutable double m_par_sigma2; //!< King profile sigma squared
134  mutable double m_par_gamma; //!< King profile gamma parameter
135  mutable double m_par_rmax; //!< Maximum PSF radius
136 };
137 
138 
139 /***********************************************************************//**
140  * @brief Return class name
141  *
142  * @return String containing the class name ("GCTAPsfKing").
143  ***************************************************************************/
144 inline
145 std::string GCTAPsfKing::classname(void) const
146 {
147  return ("GCTAPsfKing");
148 }
149 
150 
151 /***********************************************************************//**
152  * @brief Return filename
153  *
154  * @return Filename from which point spread function was loaded.
155  *
156  * Returns filename from which point spread function was loaded.
157  ***************************************************************************/
158 inline
160 {
161  return m_filename;
162 }
163 
164 /***********************************************************************//**
165  * @brief Return response table
166  *
167  * @return Response table.
168  ***************************************************************************/
169 inline
171 {
172  return m_psf;
173 }
174 
175 /***********************************************************************//**
176  * @brief Assign response table
177  *
178  * @param[in] table Response table.
179  ***************************************************************************/
180 inline
182 {
183  m_psf = table;
184 }
185 
186 
187 #endif /* GCTAPsfKing_HPP */
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)
void init_members(void)
Initialise class members.
GCTAPsfKing(void)
Void constructor.
Definition: GCTAPsfKing.cpp:71
GCTAPsfKing * clone(void) const
Clone point spread functions.
const GCTAResponseTable & table(void) const
Return response table.
void load(const GFilename &filename)
Load point spread function from FITS file.
double m_par_rmax
Maximum PSF radius.
Abstract base class for the CTA point spread function.
Definition: GCTAPsf.hpp:47
CTA point spread function class with a King profile.
Definition: GCTAPsfKing.hpp:54
Random number generator class.
Definition: GRan.hpp:44
int m_inx_gamma
Gamma.
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)
void read(const GFitsTable &table)
Read point spread function from FITS table.
GFilename filename(void) const
Return filename.
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)
GCTAResponseTable m_psf
PSF response table.
CTA response table class definition.
void clear(void)
Clear point spread function.
std::string classname(void) const
Return class name.
const std::string extname_cta_psfking
Definition: GCTAPsfKing.hpp:42
Filename class.
Definition: GFilename.hpp:62
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)
double r_max(const double &logE, const double &theta) const
Return maximum size of PSF (radians)
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
void copy_members(const GCTAPsfKing &psf)
Copy class members.
GChatter
Definition: GTypemaps.hpp:33
void write(GFitsBinTable &table) const
Write point spread function into FITS table.
GCTAPsfKing & operator=(const GCTAPsfKing &psf)
Assignment operator.
GFilename m_filename
Name of Aeff response file.
void save(const GFilename &filename, const bool &clobber=false) const
Save point spread function table into FITS file.
int m_inx_energy
Energy index.
CTA point spread function base class definition.
double m_par_sigma
King profile sigma (radians)
double m_par_sigma2
King profile sigma squared.
double m_par_norm
King profile normalization.
void free_members(void)
Delete class members.
FITS binary table class.
std::string print(const GChatter &chatter=NORMAL) const
Print point spread function information.
virtual ~GCTAPsfKing(void)
Destructor.
double m_par_theta
Cache offset angle.
void update(const double &logE, const double &theta) const
Update PSF parameter cache.
CTA response table class.
double m_par_gamma
King profile gamma parameter.
double m_par_logE
Cache energy.
int m_inx_theta
Theta index.
Filename class interface definition.
int m_inx_sigma
Sigma.