GammaLib 2.0.0
Loading...
Searching...
No Matches
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 _______________________________________________ */
39class GFitsTable;
40class GFitsBinTable;
41
42
43/***********************************************************************//**
44 * @class GCOMD1Response
45 *
46 * @brief Interface for the COMPTEL D1 module response class
47 ***************************************************************************/
48class GCOMD1Response : public GBase {
49
50public:
51 // Constructors and destructors
52 GCOMD1Response(void);
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
80private:
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 ***************************************************************************/
113inline
114std::string GCOMD1Response::classname(void) const
115{
116 return ("GCOMD1Response");
117}
118
119
120/***********************************************************************//**
121 * @brief Return calibration database
122 *
123 * @return Calibration database.
124 ***************************************************************************/
125inline
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 ***************************************************************************/
139inline
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 ***************************************************************************/
153inline
154double 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 ***************************************************************************/
167inline
168double 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 ***************************************************************************/
181inline
182double 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 ***************************************************************************/
195inline
196double 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 ***************************************************************************/
209inline
210double 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 ***************************************************************************/
223inline
224double 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 ***************************************************************************/
239inline
240double 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 ***************************************************************************/
255inline
256double 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 */
Calibration database class interface definition.
Node array class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Interface class for all GammaLib classes.
Definition GBase.hpp:52
Interface for the COMPTEL D1 module response class.
const GCaldb & caldb(void) const
Return calibration database.
void load(const std::string &sdaname)
Load COMPTEL D1 module response.
~GCOMD1Response(void)
Destructor.
void read(const GFitsTable &table)
Read COMPTEL D1 module response.
double emax(void) const
Return maximum D1 input energy (MeV)
std::vector< double > m_sigmas
Photo peak width in MeV.
std::vector< double > m_emaxs
Upper energy limit of D1.
double emin(void) const
Return minimum D1 input energy (MeV)
void write(GFitsBinTable &table)
Write COMPTEL D1 module response.
double operator()(const double &etrue, const double &ereco) const
D1 module response evaluation operator.
GNodeArray m_energies
Input energies.
void copy_members(const GCOMD1Response &rsp)
Copy class members.
std::string classname(void) const
Return class name.
double ewidth(const double &etrue) const
Return energy threshold width.
GCaldb m_caldb
Calibration database.
double sigma(const double &etrue) const
Return photo peak standard deviation.
GCOMD1Response(void)
Void constructor.
std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL D1 module response information.
GCOMD1Response * clone(void) const
Clone instance.
std::vector< double > m_ewidths
Lower energy threshold width of D1.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
std::vector< double > m_positions
Photo peak position in MeV.
double position(const double &etrue) const
Return photo peak position.
std::vector< double > m_amplitudes
Photo peak amplitude.
void clear(void)
Clear instance.
void update_cache(const double &etrue) const
Update computation cache.
std::vector< double > m_emins
Lower energy threshold of D1.
GCOMD1Response & operator=(const GCOMD1Response &rsp)
Assignment operator.
double amplitude(const double &etrue) const
Return photo peak amplitude.
Calibration database class.
Definition GCaldb.hpp:66
FITS binary table class.
Abstract interface for FITS table.
Node array class.
int size(void) const
Return number of nodes in node array.