GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATResponseTable.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATResponseTable.hpp - Fermi-LAT Response table class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2008-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 GLATResponseTable.hpp
23  * @brief Fermi-LAT response table class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GLATRESPONSETABLE_HPP
28 #define GLATRESPONSETABLE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GBase.hpp"
34 #include "GNodeArray.hpp"
35 #include "GFitsTable.hpp"
36 
37 
38 /***********************************************************************//**
39  * @class GLATResponseTable
40  *
41  * @brief Interface for the Fermi LAT Response table class.
42  *
43  * A response table contains the binning information in energy and cos theta
44  * for the Fermi LAT response function. From this binning information,
45  * response values can be obtained using a bilinear interpolation in
46  * log10 of energy and in cos theta.
47  ***************************************************************************/
48 class GLATResponseTable : public GBase {
49 
50 public:
51  // Constructors and destructors
52  GLATResponseTable(void);
54  virtual ~GLATResponseTable(void);
55 
56  // Operators
58 
59  // Methods
60  void clear(void);
61  GLATResponseTable* clone(void) const;
62  std::string classname(void) const;
63  void read(const GFitsTable& hdu);
64  void write(GFitsTable& hdu) const;
65  int index(const int& ie, const int& ic) const;
66  double energy(const int& ie) const;
67  void set(const double& logE, const double& ctheta);
68  double interpolate(const double& logE, const double& ctheta,
69  const std::vector<double>& array);
70  double interpolate(const double& logE, const double& ctheta,
71  const std::vector<double>& array,
72  const int& offset, const int& size);
73  int size(void) const;
74  const int& nenergies(void) const;
75  const int& ncostheta(void) const;
76  double energy_lo(const int& inx) const;
77  double energy_hi(const int& inx) const;
78  double costheta_lo(const int& inx) const;
79  double costheta_hi(const int& inx) const;
80  std::vector<int> indices(void) const;
81  std::vector<double> energies(void) const;
82  std::vector<double> weights(void) const;
83  std::string print(const GChatter& chatter = NORMAL) const;
84 
85 private:
86  // Methods
87  void init_members(void);
88  void copy_members(const GLATResponseTable& table);
89  void free_members(void);
90 
91  // Table nodes
92  int m_energy_num; //!< Number of energy bins in table
93  int m_ctheta_num; //!< Number of cos theta bins in table
94  double* m_energy_lo; //!< Energy bins lower boundary (MeV)
95  double* m_energy_hi; //!< Energy bins upper boundary (MeV)
96  double* m_ctheta_lo; //!< cos(theta) bins lower boundary
97  double* m_ctheta_hi; //!< cos(theta) bins upper boundary
98  std::vector<double> m_energy; //!< Energy nodes (MeV)
99  GNodeArray m_logE; //!< Energy nodes (log10 mean energy)
100  GNodeArray m_ctheta; //!< cos(theta) nodes
101 
102  // Bi-linear interpolation data
103  double m_last_energy; //!< Last requested energy for interpolation
104  double m_last_ctheta; //!< Last requested cos(theta) for interpolation
105  int m_inx1; //!< Index 1
106  int m_inx2; //!< Index 2
107  int m_inx3; //!< Index 3
108  int m_inx4; //!< Index 4
109  double m_wgt1; //!< Weighting factor 1
110  double m_wgt2; //!< Weighting factor 2
111  double m_wgt3; //!< Weighting factor 3
112  double m_wgt4; //!< Weighting factor 4
113 };
114 
115 
116 /***********************************************************************//**
117  * @brief Return class name
118  *
119  * @return String containing the class name ("GLATResponseTable").
120  ***************************************************************************/
121 inline
122 std::string GLATResponseTable::classname(void) const
123 {
124  return ("GLATResponseTable");
125 }
126 
127 
128 /***********************************************************************//**
129  * @brief Return number of bins in response table
130  *
131  * @return Number of bins in response table.
132  ***************************************************************************/
133 inline
134 int GLATResponseTable::size(void) const
135 {
136  return m_energy_num*m_ctheta_num;
137 }
138 
139 
140 /***********************************************************************//**
141  * @brief Return number of energies in response table
142  *
143  * @return Number of energies in response table.
144  ***************************************************************************/
145 inline
146 const int& GLATResponseTable::nenergies(void) const
147 {
148  return m_energy_num;
149 }
150 
151 
152 /***********************************************************************//**
153  * @brief Return number of cosine theta bins in response table
154  *
155  * @return Number of cosine theta bins in response table.
156  ***************************************************************************/
157 inline
158 const int& GLATResponseTable::ncostheta(void) const
159 {
160  return m_ctheta_num;
161 }
162 
163 #endif /* GLATRESPONSETABLE_HPP */
int m_ctheta_num
Number of cos theta bins in table.
Node array class.
Definition: GNodeArray.hpp:60
double costheta_hi(const int &inx) const
Return upper bin cos theta.
std::string classname(void) const
Return class name.
void read(const GFitsTable &hdu)
Read response table from FITS table HDU.
double m_wgt4
Weighting factor 4.
std::vector< double > energies(void) const
Return energies of 4 corners used for interpolation.
Definition of interface for all GammaLib classes.
void clear(void)
Clear instance.
void write(GFitsTable &hdu) const
Write response table into FITS table.
GNodeArray m_logE
Energy nodes (log10 mean energy)
GLATResponseTable(void)
Void constructor.
void init_members(void)
Initialise class members.
GNodeArray m_ctheta
cos(theta) nodes
double m_last_ctheta
Last requested cos(theta) for interpolation.
virtual ~GLATResponseTable(void)
Destructor.
double interpolate(const double &logE, const double &ctheta, const std::vector< double > &array)
Perform bi-linear interpolation of 2D array.
double energy_hi(const int &inx) const
Return upper bin energy (units: MeV)
void free_members(void)
Delete class members.
std::string print(const GChatter &chatter=NORMAL) const
Print response table information.
Node array class interface definition.
const int & nenergies(void) const
Return number of energies in response table.
GLATResponseTable * clone(void) const
Clone instance.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
Interface for the Fermi LAT Response table class.
void copy_members(const GLATResponseTable &table)
Copy class members.
const int & ncostheta(void) const
Return number of cosine theta bins in response table.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
GChatter
Definition: GTypemaps.hpp:33
GLATResponseTable & operator=(const GLATResponseTable &table)
Assignment operator.
int m_energy_num
Number of energy bins in table.
double * m_ctheta_lo
cos(theta) bins lower boundary
double * m_energy_hi
Energy bins upper boundary (MeV)
std::vector< double > m_energy
Energy nodes (MeV)
void set(const double &logE, const double &ctheta)
Set indices and weighting for bi-linear interpolation of 2D array.
int index(const int &ie, const int &ic) const
Return table index.
double m_wgt1
Weighting factor 1.
double costheta_lo(const int &inx) const
Return lower bin cos theta [.
double * m_energy_lo
Energy bins lower boundary (MeV)
double m_wgt2
Weighting factor 2.
double energy_lo(const int &inx) const
Return lower bin energy (units: MeV)
double * m_ctheta_hi
cos(theta) bins upper boundary
double energy(const int &ie) const
Return mean energy of bin (units: MeV)
double m_last_energy
Last requested energy for interpolation.
std::vector< double > weights(void) const
Return weights of 4 corners used for interpolation.
int size(void) const
Return number of bins in response table.
std::vector< int > indices(void) const
Return indices of 4 corners used for interpolation.
double m_wgt3
Weighting factor 3.
FITS table abstract base class interface definition.