GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATPsfV3.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATPsfV3.hpp - Fermi/LAT point spread function version 3 class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2014 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 GLATPsfV3.hpp
23  * @brief Fermi/LAT point spread function version 3 class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GLATPSFV3_HPP
28 #define GLATPSFV3_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <vector>
32 #include <cmath>
33 #include "GLATPsfBase.hpp"
34 #include "GFits.hpp"
35 #include "GFitsTable.hpp"
36 #include "GFunction.hpp"
37 
38 
39 /***********************************************************************//**
40  * @class GLATPsfV3
41  *
42  * @brief Fermi/LAT point spread function version 3 class
43  *
44  * Version 3 of the Fermi/LAT PSF is the sum of two King model functions.
45  * In contrast to version 2, this class interpolates the distributions
46  * rather than the parameters.
47  *
48  * This class has been inspired by code from the Fermi/LAT ScienceTools.
49  * For comparison check the file irfs/latResponse/src/Psf3.h
50  ***************************************************************************/
51 class GLATPsfV3 : public GLATPsfBase {
52 
53 public:
54  // Constructors and destructors
55  GLATPsfV3(void);
56  GLATPsfV3(const GLATPsfV3& psf);
57  virtual ~GLATPsfV3(void);
58 
59  // Operators
60  GLATPsfV3& operator=(const GLATPsfV3& psf);
61 
62  // Methods
63  void clear(void);
64  GLATPsfV3* clone(void) const;
65  std::string classname(void) const;
66  void read(const GFitsTable& table);
67  void write(GFits& file) const;
68  double psf(const double& offset, const double& logE,
69  const double& ctheta);
70  int version(void) const;
71  std::string print(const GChatter& chatter = NORMAL) const;
72 
73 private:
74  // Methods
75  void init_members(void);
76  void copy_members(const GLATPsfV3& psf);
77  void free_members(void);
78  static double base_fct(const double& u, const double& gamma);
79  static double base_int(const double& u, const double& gamma);
80  double eval_psf(const double& offset, const double& energy,
81  const int& index);
82  double integrate_psf(const double& energy, const int& index);
83  void normalize_psf(void);
84 
85  // Integrand class. This class is used to perform the radial
86  // integration of the PSF to assure the proper normalization.
87  // Note that score and stail need to be scaled by energy.
88  class base_integrand : public GFunction {
89  public:
90  base_integrand(double ncore, double ntail,
91  double score, double stail,
92  double gcore, double gtail) :
93  m_ncore(ncore), m_ntail(ntail),
94  m_score(score), m_stail(stail),
95  m_gcore(gcore), m_gtail(gtail) { }
96  double eval(const double& x) {
97  double rc = x / m_score;
98  double uc = 0.5 * rc * rc;
99  double rt = x / m_stail;
100  double ut = 0.5 * rt * rt;
101  double f = m_ncore * (base_fct(uc, m_gcore) +
102  m_ntail * base_fct(ut, m_gtail));
103  return (f*std::sin(x));
104  }
105  private:
106  double m_ncore;
107  double m_ntail;
108  double m_score;
109  double m_stail;
110  double m_gcore;
111  double m_gtail;
112  };
113 
114  // Protected members
115  std::vector<double> m_ncore; //!< PSF ncore parameter
116  std::vector<double> m_ntail; //!< PSF ntail parameter
117  std::vector<double> m_score; //!< PSF score parameter
118  std::vector<double> m_stail; //!< PSF stail parameter
119  std::vector<double> m_gcore; //!< PSF gcore parameter
120  std::vector<double> m_gtail; //!< PSF gtail parameter
121 };
122 
123 
124 /***********************************************************************//**
125  * @brief Return class name
126  *
127  * @return String containing the class name ("GLATPsfV3").
128  ***************************************************************************/
129 inline
130 std::string GLATPsfV3::classname(void) const
131 {
132  return ("GLATPsfV3");
133 }
134 
135 
136 /***********************************************************************//**
137  * @brief Return point spread function version number
138  *
139  * @return Point spread function version number (3).
140  ***************************************************************************/
141 inline
142 int GLATPsfV3::version(void) const
143 {
144  return 3;
145 }
146 
147 #endif /* GLATPSFV3_HPP */
std::vector< double > m_ncore
PSF ncore parameter.
Definition: GLATPsfV3.hpp:115
GLATPsfV3 & operator=(const GLATPsfV3 &psf)
Assignment operator.
Definition: GLATPsfV3.cpp:114
double eval(const double &x)
Definition: GLATPsfV3.hpp:96
void read(const GFitsTable &table)
Read point spread function from FITS table.
Definition: GLATPsfV3.cpp:189
void write(GFits &file) const
Write point spread function into FITS file.
Definition: GLATPsfV3.cpp:284
void free_members(void)
Delete class members.
Definition: GLATPsfV3.cpp:466
base_integrand(double ncore, double ntail, double score, double stail, double gcore, double gtail)
Definition: GLATPsfV3.hpp:90
FITS file class.
Definition: GFits.hpp:63
FITS file class interface definition.
std::string classname(void) const
Return class name.
Definition: GLATPsfV3.hpp:130
GLATPsfV3(void)
Void constructor.
Definition: GLATPsfV3.cpp:61
double psf(const double &offset, const double &logE, const double &ctheta)
Return point spread function value.
Definition: GLATPsfV3.cpp:358
std::vector< double > m_gtail
PSF gtail parameter.
Definition: GLATPsfV3.hpp:120
static double base_int(const double &u, const double &gamma)
Return approximation of point spread base function integral.
Definition: GLATPsfV3.cpp:510
double integrate_psf(const double &energy, const int &index)
Integrates PSF for a specific set of parameters.
Definition: GLATPsfV3.cpp:585
Abstract Fermi/LAT point spread function base class.
Definition: GLATPsfBase.hpp:47
Single parameter function abstract base class definition.
std::vector< double > m_score
PSF score parameter.
Definition: GLATPsfV3.hpp:117
virtual ~GLATPsfV3(void)
Destructor.
Definition: GLATPsfV3.cpp:92
std::vector< double > m_ntail
PSF ntail parameter.
Definition: GLATPsfV3.hpp:116
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
int version(void) const
Return point spread function version number.
Definition: GLATPsfV3.hpp:142
GChatter
Definition: GTypemaps.hpp:33
double eval_psf(const double &offset, const double &energy, const int &index)
Evaluate PSF for a specific set of parameters.
Definition: GLATPsfV3.cpp:535
Abstract Fermi/LAT point spread function base class definition.
Single parameter function abstract base class.
Definition: GFunction.hpp:44
GVector sin(const GVector &vector)
Computes sine of vector elements.
Definition: GVector.cpp:1226
std::vector< double > m_gcore
PSF gcore parameter.
Definition: GLATPsfV3.hpp:119
void init_members(void)
Initialise class members.
Definition: GLATPsfV3.cpp:428
void copy_members(const GLATPsfV3 &psf)
Copy class members.
Definition: GLATPsfV3.cpp:448
void normalize_psf(void)
Normalize PSF for all parameters.
Definition: GLATPsfV3.cpp:655
std::vector< double > m_stail
PSF stail parameter.
Definition: GLATPsfV3.hpp:118
static double base_fct(const double &u, const double &gamma)
Return point spread base function value.
Definition: GLATPsfV3.cpp:483
GLATPsfV3 * clone(void) const
Clone point spread function.
Definition: GLATPsfV3.cpp:167
void clear(void)
Clear point spread function.
Definition: GLATPsfV3.cpp:147
std::string print(const GChatter &chatter=NORMAL) const
Print point spread function.
Definition: GLATPsfV3.cpp:401
Fermi/LAT point spread function version 3 class.
Definition: GLATPsfV3.hpp:51
FITS table abstract base class interface definition.