GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATPsfV1.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATPsfV1.hpp - Fermi/LAT point spread function version 1 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 GLATPsfV1.hpp
23  * @brief Fermi/LAT point spread function version 1 class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GLATPSFV1_HPP
28 #define GLATPSFV1_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 GLATPsfV1
41  *
42  * @brief Fermi/LAT point spread function version 1 class
43  *
44  * This class has been inspired by code from the Fermi/LAT ScienceTools.
45  * For comparison check the file irfs/latResponse/src/Psf.h
46  ***************************************************************************/
47 class GLATPsfV1 : public GLATPsfBase {
48 
49 public:
50  // Constructors and destructors
51  GLATPsfV1(void);
52  GLATPsfV1(const GLATPsfV1& psf);
53  virtual ~GLATPsfV1(void);
54 
55  // Operators
56  GLATPsfV1& operator=(const GLATPsfV1& psf);
57 
58  // Methods
59  void clear(void);
60  GLATPsfV1* clone(void) const;
61  std::string classname(void) const;
62  void read(const GFitsTable& table);
63  void write(GFits& file) const;
64  double psf(const double& offset, const double& logE,
65  const double& ctheta);
66  int version(void) const;
67  std::string print(const GChatter& chatter = NORMAL) const;
68 
69 private:
70  // Methods
71  void init_members(void);
72  void copy_members(const GLATPsfV1& psf);
73  void free_members(void);
74  static double base_fct(const double& u, const double& gamma);
75  static double base_int(const double& u, const double& gamma);
76 
77  // Integrand class. This class is used to perform the radial
78  // integration of the PSF that assures the proper normalization
79  // of the PSF at low energies.
80  class base_integrand : public GFunction {
81  public:
82  base_integrand(double ncore, double ntail, double sigma,
83  double gcore, double gtail) :
84  m_ncore(ncore), m_ntail(ntail), m_sigma(sigma),
85  m_gcore(gcore), m_gtail(gtail) { }
86  double eval(const double& x) {
87  double r = x / m_sigma;
88  double u = 0.5 * r * r;
89  double f = m_ncore * base_fct(u, m_gcore) +
90  m_ntail * base_fct(u, m_gtail);
91  return (f*std::sin(x));
92  }
93  private:
94  double m_ncore;
95  double m_ntail;
96  double m_sigma;
97  double m_gcore;
98  double m_gtail;
99  };
100 
101  // Protected members
102  std::vector<double> m_ncore; //!< PSF ncore parameter
103  std::vector<double> m_sigma; //!< PSF sigma parameter
104  std::vector<double> m_gcore; //!< PSF gcore parameter
105  std::vector<double> m_gtail; //!< PSF gtail parameter
106 };
107 
108 
109 /***********************************************************************//**
110  * @brief Return class name
111  *
112  * @return String containing the class name ("GLATPsfV1").
113  ***************************************************************************/
114 inline
115 std::string GLATPsfV1::classname(void) const
116 {
117  return ("GLATPsfV1");
118 }
119 
120 
121 /***********************************************************************//**
122  * @brief Return point spread function version number
123  *
124  * @return Point spread function version number (1).
125  ***************************************************************************/
126 inline
127 int GLATPsfV1::version(void) const
128 {
129  return 1;
130 }
131 
132 #endif /* GLATPSFV1_HPP */
void read(const GFitsTable &table)
Read point spread function from FITS table.
Definition: GLATPsfV1.cpp:184
double eval(const double &x)
Definition: GLATPsfV1.hpp:86
std::vector< double > m_sigma
PSF sigma parameter.
Definition: GLATPsfV1.hpp:103
Fermi/LAT point spread function version 1 class.
Definition: GLATPsfV1.hpp:47
void copy_members(const GLATPsfV1 &psf)
Copy class members.
Definition: GLATPsfV1.cpp:462
void write(GFits &file) const
Write point spread function into FITS file.
Definition: GLATPsfV1.cpp:276
int version(void) const
Return point spread function version number.
Definition: GLATPsfV1.hpp:127
std::vector< double > m_ncore
PSF ncore parameter.
Definition: GLATPsfV1.hpp:102
FITS file class.
Definition: GFits.hpp:63
void init_members(void)
Initialise class members.
Definition: GLATPsfV1.cpp:444
GLATPsfV1 * clone(void) const
Clone point spread function.
Definition: GLATPsfV1.cpp:166
FITS file class interface definition.
std::vector< double > m_gtail
PSF gtail parameter.
Definition: GLATPsfV1.hpp:105
void clear(void)
Clear point spread function.
Definition: GLATPsfV1.cpp:146
std::string print(const GChatter &chatter=NORMAL) const
Print point spread function.
Definition: GLATPsfV1.cpp:417
double psf(const double &offset, const double &logE, const double &ctheta)
Return point spread function value.
Definition: GLATPsfV1.cpp:342
Abstract Fermi/LAT point spread function base class.
Definition: GLATPsfBase.hpp:47
Single parameter function abstract base class definition.
virtual ~GLATPsfV1(void)
Destructor.
Definition: GLATPsfV1.cpp:91
GLATPsfV1(void)
Void constructor.
Definition: GLATPsfV1.cpp:60
GLATPsfV1 & operator=(const GLATPsfV1 &psf)
Assignment operator.
Definition: GLATPsfV1.cpp:113
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
void free_members(void)
Delete class members.
Definition: GLATPsfV1.cpp:478
std::vector< double > m_gcore
PSF gcore parameter.
Definition: GLATPsfV1.hpp:104
static double base_fct(const double &u, const double &gamma)
Return point spread base function value.
Definition: GLATPsfV1.cpp:495
static double base_int(const double &u, const double &gamma)
Return approximation of point spread base function integral.
Definition: GLATPsfV1.cpp:522
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:1316
std::string classname(void) const
Return class name.
Definition: GLATPsfV1.hpp:115
base_integrand(double ncore, double ntail, double sigma, double gcore, double gtail)
Definition: GLATPsfV1.hpp:82
FITS table abstract base class interface definition.