GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAPsfTable.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAPsfTable.hpp - CTA point spread function table class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2016-2018 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 GCTAPsfTable.hpp
23  * @brief CTA point spread function table class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTAPSFTABLE_HPP
28 #define GCTAPSFTABLE_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_psftable = "PSF_2D_TABLE";
43 }
44 
45 
46 /***********************************************************************//**
47  * @class GCTAPsfTable
48  *
49  * @brief CTA point spread function table class
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 GCTAPsfTable : public GCTAPsf {
55 
56 public:
57  // Constructors and destructors
58  GCTAPsfTable(void);
59  explicit GCTAPsfTable(const GFilename& filename);
60  GCTAPsfTable(const GCTAPsfTable& psf);
61  virtual ~GCTAPsfTable(void);
62 
63  // Operators
64  GCTAPsfTable& operator=(const GCTAPsfTable& 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  GCTAPsfTable* 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 private:
110  // Methods
111  void init_members(void);
112  void copy_members(const GCTAPsfTable& psf);
113  void free_members(void);
114  void precompute(void);
115  int element(const int& ieng, const int& itheta, const int& idelta);
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_delta; //!< Delta index
123  int m_inx_rpsf; //!< PSF histogram
124  double m_delta_max; //!< Maximum delta angle (radians)
125  double m_psf_max; //!< Maximum PSF value
126 };
127 
128 
129 /***********************************************************************//**
130  * @brief Return class name
131  *
132  * @return String containing the class name ("GCTAPsfTable").
133  ***************************************************************************/
134 inline
135 std::string GCTAPsfTable::classname(void) const
136 {
137  return ("GCTAPsfTable");
138 }
139 
140 
141 /***********************************************************************//**
142  * @brief Return filename
143  *
144  * @return Filename from which point spread function was loaded.
145  *
146  * Returns filename from which point spread function was loaded.
147  ***************************************************************************/
148 inline
150 {
151  return m_filename;
152 }
153 
154 /***********************************************************************//**
155  * @brief Return response table
156  *
157  * @return Response table.
158  ***************************************************************************/
159 inline
161 {
162  return m_psf;
163 }
164 
165 /***********************************************************************//**
166  * @brief Assign response table
167  *
168  * @param[in] table Response table.
169  ***************************************************************************/
170 inline
172 {
173  m_psf = table;
174 }
175 
176 #endif /* GCTAPSFTABLE_HPP */
int m_inx_energy
Energy index.
GCTAPsfTable & operator=(const GCTAPsfTable &psf)
Assignment operator.
double m_psf_max
Maximum PSF value.
std::string print(const GChatter &chatter=NORMAL) const
Print point spread function information.
GCTAResponseTable m_psf
PSF response table.
int m_inx_theta
Theta index.
const GCTAResponseTable & table(void) const
Return response table.
Abstract base class for the CTA point spread function.
Definition: GCTAPsf.hpp:47
GCTAPsfTable(void)
Void constructor.
Random number generator class.
Definition: GRan.hpp:44
void copy_members(const GCTAPsfTable &psf)
Copy class members.
void save(const GFilename &filename, const bool &clobber=false) const
Save point spread function table into FITS file.
int m_inx_delta
Delta index.
std::string classname(void) const
Return class name.
void free_members(void)
Delete class members.
CTA response table class definition.
int element(const int &ieng, const int &itheta, const int &idelta)
Return element index.
void read(const GFitsTable &table)
Read point spread function from FITS table.
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)
GFilename filename(void) const
Return filename.
int m_inx_rpsf
PSF histogram.
const std::string extname_cta_psftable
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)
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
void load(const GFilename &filename)
Load point spread function from FITS file.
GChatter
Definition: GTypemaps.hpp:33
virtual ~GCTAPsfTable(void)
Destructor.
CTA point spread function base class definition.
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)
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)
GCTAPsfTable * clone(void) const
Clone point spread functions.
void write(GFitsBinTable &table) const
Write point spread function into FITS table.
FITS binary table class.
GFilename m_filename
Name of Aeff response file.
CTA response table class.
CTA point spread function table class.
void precompute(void)
Performs precomputations for point spread function.
double m_delta_max
Maximum delta angle (radians)
Filename class interface definition.
void clear(void)
Clear point spread function.
void init_members(void)
Initialise class members.