GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATAeff.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATAeff.hpp - Fermi LAT effective area *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2010-2017 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 GLATAeff.hpp
23  * @brief Fermi LAT effective area class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GLATAEFF_HPP
28 #define GLATAEFF_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GBase.hpp"
34 #include "GLATResponseTable.hpp"
35 #include "GLATEfficiency.hpp"
36 
37 /* __ Forward declarations _______________________________________________ */
38 class GFilename;
39 class GEnergy;
40 class GFits;
41 class GFitsTable;
42 
43 /* __ Constants __________________________________________________________ */
44 namespace gammalib {
45  const std::string extname_lat_aeff = "EFFECTIVE AREA";
46  const std::string extname_lat_efficiency = "EFFICIENCY_PARAMS";
47 }
48 
49 
50 /***********************************************************************//**
51  * @class GLATAeff
52  *
53  * @brief Interface for the Fermi/LAT effective area
54  *
55  * This class handles the effective area information for Fermi/LAT. It also
56  * handles the IRF efficiency information that has been introduced for
57  * Pass 7 data analysis.
58  ***************************************************************************/
59 class GLATAeff : public GBase {
60 
61 public:
62  // Constructors and destructors
63  GLATAeff(void);
64  GLATAeff(const GFilename& filename, const std::string& evtype);
65  GLATAeff(const GLATAeff& aeff);
66  virtual ~GLATAeff(void);
67 
68  // Operators
69  GLATAeff& operator=(const GLATAeff& aeff);
70  double operator()(const double& logE, const double& ctheta);
71  double operator()(const double& logE, const double& ctheta,
72  const double& phi);
73 
74  // Methods
75  void clear(void);
76  GLATAeff* clone(void) const;
77  std::string classname(void) const;
78  const std::string& evtype(void) const;
79  void load(const GFilename& filename,
80  const std::string& evtype);
81  void save(const GFilename& filename,
82  const bool& clobber = false);
83  void read(const GFits& file, const std::string& evtype);
84  void write(GFits& file) const;
85  int size(void) const;
86  int nenergies(void) const;
87  int ncostheta(void) const;
88  const double& costhetamin(void) const;
89  void costhetamin(const double& ctheta);
90  bool has_phi(void) const;
91  bool has_efficiency(void) const;
92  double efficiency_factor1(const GEnergy& srcEng) const;
93  double efficiency_factor2(const GEnergy& srcEng) const;
94  std::string print(const GChatter& chatter = NORMAL) const;
95 
96 private:
97  // Methods
98  void init_members(void);
99  void copy_members(const GLATAeff& aeff);
100  void free_members(void);
101  void read_aeff(const GFitsTable& hdu);
102  void read_efficiency(const GFitsTable& hdu);
103  void write_aeff(GFits& file) const;
104  void write_efficiency(GFits& file) const;
105 
106  // Protected members
107  std::string m_evtype; //!< Event type
108  GLATResponseTable m_aeff_bins; //!< Aeff energy and cos theta binning
109  std::vector<double> m_aeff; //!< Aeff array
110  double m_min_ctheta; //!< Minimum valid cos(theta)
111  GLATEfficiency* m_eff_func1; //!< Efficiency functor 1
112  GLATEfficiency* m_eff_func2; //!< Efficiency functor 2
113 };
114 
115 
116 /***********************************************************************//**
117  * @brief Return class name
118  *
119  * @return String containing the class name ("GLATAeff").
120  ***************************************************************************/
121 inline
122 std::string GLATAeff::classname(void) const
123 {
124  return ("GLATAeff");
125 }
126 
127 
128 /***********************************************************************//**
129  * @brief Return event type
130  *
131  * @return Event type.
132  ***************************************************************************/
133 inline
134 const std::string& GLATAeff::evtype(void) const
135 {
136  return (m_evtype);
137 }
138 
139 
140 /***********************************************************************//**
141  * @brief Return number of bins in effective area response
142  *
143  * @return Number of bins in effective area response.
144  ***************************************************************************/
145 inline
146 int GLATAeff::size(void) const
147 {
148  return nenergies()*ncostheta();
149 }
150 
151 
152 /***********************************************************************//**
153  * @brief Return number of energies in effective area response
154  *
155  * @return Number of energies in effective area response.
156  ***************************************************************************/
157 inline
158 int GLATAeff::nenergies(void) const
159 {
160  return m_aeff_bins.nenergies();
161 }
162 
163 
164 /***********************************************************************//**
165  * @brief Return number of cosine theta bins in effective area response
166  *
167  * @return Number of cosine theta bins in effective area response.
168  ***************************************************************************/
169 inline
170 int GLATAeff::ncostheta(void) const
171 {
172  return m_aeff_bins.ncostheta();
173 }
174 
175 
176 /***********************************************************************//**
177  * @brief Return cosine theta minimum
178  *
179  * @return Cosine theta minimum.
180  ***************************************************************************/
181 inline
182 const double& GLATAeff::costhetamin(void) const
183 {
184  return m_min_ctheta;
185 }
186 
187 
188 /***********************************************************************//**
189  * @brief Set minimum cos(theta) angle for effective area access
190  *
191  * @param[in] ctheta Cosine of maximum zenith angle.
192  ***************************************************************************/
193 inline
194 void GLATAeff::costhetamin(const double& ctheta)
195 {
196  m_min_ctheta = ctheta;
197  return;
198 }
199 
200 
201 /***********************************************************************//**
202  * @brief Signal that effective area has Phi dependence
203  *
204  * @return True if effective area has Phi dependence.
205  ***************************************************************************/
206 inline
207 bool GLATAeff::has_phi(void) const
208 {
209  return false;
210 }
211 
212 #endif /* GLATAEFF_HPP */
GLATEfficiency * m_eff_func1
Efficiency functor 1.
Definition: GLATAeff.hpp:111
int size(void) const
Return number of bins in effective area response.
Definition: GLATAeff.hpp:146
void load(const GFilename &filename, const std::string &evtype)
Load effective area from FITS file.
Definition: GLATAeff.cpp:263
GLATAeff & operator=(const GLATAeff &aeff)
Assignment operator.
Definition: GLATAeff.cpp:139
void free_members(void)
Delete class members.
Definition: GLATAeff.cpp:536
double m_min_ctheta
Minimum valid cos(theta)
Definition: GLATAeff.hpp:110
const std::string extname_lat_aeff
Definition: GLATAeff.hpp:45
Definition of interface for all GammaLib classes.
const std::string extname_lat_efficiency
Definition: GLATAeff.hpp:46
Fermi-LAT response table class definition.
const double & costhetamin(void) const
Return cosine theta minimum.
Definition: GLATAeff.hpp:182
Interface for the Fermi/LAT efficiency factor functor.
void write_efficiency(GFits &file) const
Write efficiency factors into FITS file.
Definition: GLATAeff.cpp:742
std::string print(const GChatter &chatter=NORMAL) const
Print effective area information.
Definition: GLATAeff.cpp:455
FITS file class.
Definition: GFits.hpp:63
GLATAeff(void)
Void constructor.
Definition: GLATAeff.cpp:63
Fermi/LAT IRF efficiency factor functor class definition.
const int & nenergies(void) const
Return number of energies in response table.
Filename class.
Definition: GFilename.hpp:62
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
Interface for the Fermi LAT Response table class.
void read_aeff(const GFitsTable &hdu)
Read effective area from FITS table.
Definition: GLATAeff.cpp:561
void copy_members(const GLATAeff &aeff)
Copy class members.
Definition: GLATAeff.cpp:516
void read_efficiency(const GFitsTable &hdu)
Read efficiency factor parameters from FITS table.
Definition: GLATAeff.cpp:672
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
Interface for the Fermi/LAT effective area.
Definition: GLATAeff.hpp:59
void write_aeff(GFits &file) const
Write effective area into FITS file.
Definition: GLATAeff.cpp:616
double operator()(const double &logE, const double &ctheta)
Return effective area in units of cm2.
Definition: GLATAeff.cpp:171
void write(GFits &file) const
Write effective area into FITS file.
Definition: GLATAeff.cpp:360
bool has_phi(void) const
Signal that effective area has Phi dependence.
Definition: GLATAeff.hpp:207
double efficiency_factor1(const GEnergy &srcEng) const
Returns efficiency factor 1.
Definition: GLATAeff.cpp:403
int nenergies(void) const
Return number of energies in effective area response.
Definition: GLATAeff.hpp:158
int ncostheta(void) const
Return number of cosine theta bins in effective area response.
Definition: GLATAeff.hpp:170
GLATResponseTable m_aeff_bins
Aeff energy and cos theta binning.
Definition: GLATAeff.hpp:108
void clear(void)
Clear effective area.
Definition: GLATAeff.cpp:229
std::string classname(void) const
Return class name.
Definition: GLATAeff.hpp:122
const std::string & evtype(void) const
Return event type.
Definition: GLATAeff.hpp:134
std::vector< double > m_aeff
Aeff array.
Definition: GLATAeff.hpp:109
GLATEfficiency * m_eff_func2
Efficiency functor 2.
Definition: GLATAeff.hpp:112
void save(const GFilename &filename, const bool &clobber=false)
Save effective area into FITS file.
Definition: GLATAeff.cpp:286
virtual ~GLATAeff(void)
Destructor.
Definition: GLATAeff.cpp:117
void read(const GFits &file, const std::string &evtype)
Read effective area from FITS file.
Definition: GLATAeff.cpp:317
void init_members(void)
Initialise class members.
Definition: GLATAeff.cpp:496
std::string m_evtype
Event type.
Definition: GLATAeff.hpp:107
GLATAeff * clone(void) const
Clone effective area.
Definition: GLATAeff.cpp:247
bool has_efficiency(void) const
Signals whether efficiency factors are present.
Definition: GLATAeff.cpp:384
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
double efficiency_factor2(const GEnergy &srcEng) const
Returns efficiency factor 2.
Definition: GLATAeff.cpp:432