GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCOMD1Response.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCOMD1Response.hpp - COMPTEL D1 module response class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-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 GCOMD1Response.hpp
23  * @brief COMPTEL D1 module response class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCOMD1RESPONSE_HPP
28 #define GCOMD1RESPONSE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <vector>
32 #include <string>
33 #include "GCaldb.hpp"
34 #include "GNodeArray.hpp"
35 
36 /* __ Type definitions ___________________________________________________ */
37 
38 /* __ Forward declarations _______________________________________________ */
39 class GFitsTable;
40 class GFitsBinTable;
41 
42 
43 /***********************************************************************//**
44  * @class GCOMD1Response
45  *
46  * @brief Interface for the COMPTEL D1 module response class
47  ***************************************************************************/
48 class GCOMD1Response : public GBase {
49 
50 public:
51  // Constructors and destructors
52  GCOMD1Response(void);
53  GCOMD1Response(const GCOMD1Response& rsp);
54  GCOMD1Response(const GCaldb& caldb, const std::string& sdaname);
55  ~GCOMD1Response(void);
56 
57  // Operators
59  double operator()(const double& etrue, const double& ereco) const;
60 
61  // Methods
62  void clear(void);
63  GCOMD1Response* clone(void) const;
64  std::string classname(void) const;
65  void caldb(const GCaldb& caldb);
66  const GCaldb& caldb(void) const;
67  void load(const std::string& sdaname);
68  void read(const GFitsTable& table);
69  void write(GFitsBinTable& table);
70  double position(const double& etrue) const;
71  double sigma(const double& etrue) const;
72  double amplitude(const double& etrue) const;
73  double emin(const double& etrue) const;
74  double ewidth(const double& etrue) const;
75  double emax(const double& etrue) const;
76  double emin(void) const;
77  double emax(void) const;
78  std::string print(const GChatter& chatter = NORMAL) const;
79 
80 private:
81  // Private methods
82  void init_members(void);
83  void copy_members(const GCOMD1Response& rsp);
84  void free_members(void);
85  void update_cache(const double& etrue) const;
86 
87  // Private data members
88  GCaldb m_caldb; //!< Calibration database
89  GNodeArray m_energies; //!< Input energies
90  std::vector<double> m_positions; //!< Photo peak position in MeV
91  std::vector<double> m_sigmas; //!< Photo peak width in MeV
92  std::vector<double> m_amplitudes; //!< Photo peak amplitude
93  std::vector<double> m_emins; //!< Lower energy threshold of D1
94  std::vector<double> m_ewidths; //!< Lower energy threshold width of D1
95  std::vector<double> m_emaxs; //!< Upper energy limit of D1
96 
97  // Pre-computation cache
98  mutable double m_energy;
99  mutable double m_position;
100  mutable double m_sigma;
101  mutable double m_amplitude;
102  mutable double m_emin;
103  mutable double m_ewidth;
104  mutable double m_emax;
105 };
106 
107 
108 /***********************************************************************//**
109  * @brief Return class name
110  *
111  * @return String containing the class name ("GCOMD1Response").
112  ***************************************************************************/
113 inline
114 std::string GCOMD1Response::classname(void) const
115 {
116  return ("GCOMD1Response");
117 }
118 
119 
120 /***********************************************************************//**
121  * @brief Return calibration database
122  *
123  * @return Calibration database.
124  ***************************************************************************/
125 inline
126 const GCaldb& GCOMD1Response::caldb(void) const
127 {
128  return (m_caldb);
129 }
130 
131 
132 /***********************************************************************//**
133  * @brief Set calibration database
134  *
135  * @param[in] caldb Calibration database.
136  *
137  * Sets the calibration database containing the COMPTEL D1 module response.
138  ***************************************************************************/
139 inline
140 void GCOMD1Response::caldb(const GCaldb& caldb)
141 {
142  m_caldb = caldb;
143  return;
144 }
145 
146 
147 /***********************************************************************//**
148  * @brief Return photo peak position
149  *
150  * @param[in] etrue True energy (MeV).
151  * @return Photo peak position (MeV).
152  ***************************************************************************/
153 inline
154 double GCOMD1Response::position(const double& etrue) const
155 {
156  update_cache(etrue);
157  return (m_position);
158 }
159 
160 
161 /***********************************************************************//**
162  * @brief Return photo peak standard deviation
163  *
164  * @param[in] etrue True energy (MeV).
165  * @return Photo peak standard deviation (MeV).
166  ***************************************************************************/
167 inline
168 double GCOMD1Response::sigma(const double& etrue) const
169 {
170  update_cache(etrue);
171  return (m_sigma);
172 }
173 
174 
175 /***********************************************************************//**
176  * @brief Return photo peak amplitude
177  *
178  * @param[in] etrue True energy (MeV).
179  * @return Photo peak amplitude.
180  ***************************************************************************/
181 inline
182 double GCOMD1Response::amplitude(const double& etrue) const
183 {
184  update_cache(etrue);
185  return (m_amplitude);
186 }
187 
188 
189 /***********************************************************************//**
190  * @brief Return minimum energy
191  *
192  * @param[in] etrue True energy (MeV).
193  * @return Minimum energy (MeV).
194  ***************************************************************************/
195 inline
196 double GCOMD1Response::emin(const double& etrue) const
197 {
198  update_cache(etrue);
199  return (m_emin);
200 }
201 
202 
203 /***********************************************************************//**
204  * @brief Return energy threshold width
205  *
206  * @param[in] etrue True energy (MeV).
207  * @return Energy threshold width (MeV).
208  ***************************************************************************/
209 inline
210 double GCOMD1Response::ewidth(const double& etrue) const
211 {
212  update_cache(etrue);
213  return (m_ewidth);
214 }
215 
216 
217 /***********************************************************************//**
218  * @brief Return maximum energy
219  *
220  * @param[in] etrue True energy (MeV).
221  * @return Maximum energy (MeV).
222  ***************************************************************************/
223 inline
224 double GCOMD1Response::emax(const double& etrue) const
225 {
226  update_cache(etrue);
227  return (m_emax);
228 }
229 
230 
231 /***********************************************************************//**
232  * @brief Return minimum D1 input energy (MeV)
233  *
234  * @return Minimum energy D1 input energy (MeV).
235  *
236  * Returns the minimum D1 input energy (MeV). In case that no information
237  * has been read from a SDA file so far, the method returns 0.
238  ***************************************************************************/
239 inline
240 double GCOMD1Response::emin(void) const
241 {
242  double emin = (m_energies.size() > 0) ? m_energies[0] : 0.0;
243  return (emin);
244 }
245 
246 
247 /***********************************************************************//**
248  * @brief Return maximum D1 input energy (MeV)
249  *
250  * @return Maximum energy D1 input energy (MeV).
251  *
252  * Returns the maximum D1 input energy (MeV). In case that no information
253  * has been read from a SDA file so far, the method returns 0.
254  ***************************************************************************/
255 inline
256 double GCOMD1Response::emax(void) const
257 {
258  double emax = (m_energies.size() > 0) ? m_energies[m_energies.size()-1] : 0.0;
259  return (emax);
260 }
261 
262 #endif /* GCOMD1RESPONSE_HPP */
void read(const GFitsTable &table)
Read COMPTEL D1 module response.
int size(void) const
Return number of nodes in node array.
Definition: GNodeArray.hpp:192
void load(const std::string &sdaname)
Load COMPTEL D1 module response.
~GCOMD1Response(void)
Destructor.
Node array class.
Definition: GNodeArray.hpp:60
std::vector< double > m_emaxs
Upper energy limit of D1.
const GCaldb & caldb(void) const
Return calibration database.
GCOMD1Response * clone(void) const
Clone instance.
void write(GFitsBinTable &table)
Write COMPTEL D1 module response.
GCaldb m_caldb
Calibration database.
GNodeArray m_energies
Input energies.
std::string classname(void) const
Return class name.
std::vector< double > m_ewidths
Lower energy threshold width of D1.
Node array class interface definition.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
Calibration database class.
Definition: GCaldb.hpp:66
void update_cache(const double &etrue) const
Update computation cache.
double emax(void) const
Return maximum D1 input energy (MeV)
Interface for the COMPTEL D1 module response class.
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
double sigma(const double &etrue) const
Return photo peak standard deviation.
double ewidth(const double &etrue) const
Return energy threshold width.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
std::vector< double > m_sigmas
Photo peak width in MeV.
GChatter
Definition: GTypemaps.hpp:33
GCOMD1Response(void)
Void constructor.
std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL D1 module response information.
std::vector< double > m_amplitudes
Photo peak amplitude.
void copy_members(const GCOMD1Response &rsp)
Copy class members.
Calibration database class interface definition.
double amplitude(const double &etrue) const
Return photo peak amplitude.
double position(const double &etrue) const
Return photo peak position.
std::vector< double > m_positions
Photo peak position in MeV.
FITS binary table class.
double emin(void) const
Return minimum D1 input energy (MeV)
GCOMD1Response & operator=(const GCOMD1Response &rsp)
Assignment operator.
void clear(void)
Clear instance.
double operator()(const double &etrue, const double &ereco) const
D1 module response evaluation operator.
std::vector< double > m_emins
Lower energy threshold of D1.