GammaLib 2.2.0.dev
Loading...
Searching...
No Matches
GCOMIaq.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCOMIaq.hpp - COMPTEL instrument response representation *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2017-2026 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 GCOMIaq.hpp
23 * @brief COMPTEL instrument response representation class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCOMIAQ_HPP
28#define GCOMIAQ_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GMath.hpp"
33#include "GEbounds.hpp"
34#include "GFunction.hpp"
35#include "GFitsImageFloat.hpp"
36#include "GCOMD1Response.hpp"
37#include "GCOMD2Response.hpp"
38#include "GCOMInstChars.hpp"
39
40/* __ Type definitions ___________________________________________________ */
41
42/* __ Forward declarations _______________________________________________ */
43class GFilename;
44class GModelSpectral;
45
46
47/***********************************************************************//**
48 * @class GCOMIaq
49 *
50 * @brief Interface for the COMPTEL instrument response representation class
51 ***************************************************************************/
52class GCOMIaq : public GBase {
53
54public:
55 // Constructors and destructors
56 GCOMIaq(void);
57 GCOMIaq(const GCOMIaq& iaq);
58 GCOMIaq(const double& phigeo_max, const double& phigeo_bin_size,
59 const double& phibar_max, const double& phibar_bin_size);
60 ~GCOMIaq(void);
61
62 // Operators
63 GCOMIaq& operator=(const GCOMIaq & iaq);
64
65 // Methods
66 void clear(void);
67 GCOMIaq* clone(void) const;
68 std::string classname(void) const;
69 void set(const GEnergy& energy, const GEbounds& ebounds);
70 void set(const GModelSpectral& spectrum, const GEbounds& ebounds);
72 const GFitsImageFloat& image(void) const;
73 void e1min(const double& e1min);
74 const double& e1min(void) const;
75 void e1max(const double& e1max);
76 const double& e1max(void) const;
77 void e2min(const double& e2min);
78 const double& e2min(void) const;
79 void e2max(const double& e2max);
80 const double& e2max(void) const;
81 void save(const GFilename& filename, const bool& clobber = false) const;
82 std::string print(const GChatter& chatter = NORMAL) const;
83
84private:
85 // Private methods
86 void init_members(void);
87 void copy_members(const GCOMIaq& iaq);
88 void free_members(void);
89 void init_response(void);
90 void remove_cards(void);
91
92 // RESPSI methods
93 void compton_kinematics(const double& energy);
94 double compute_iaq_bin(const double& etrue1,
95 const double& etrue2,
96 const double& phibar);
97 void klein_nishina(const double& energy);
98 double klein_nishina_bin(const double& energy,
99 const double& phigeo);
100 double klein_nishina_integral(const double& v,
101 const double& a);
102 void weight_iaq(const double& energy);
103 void location_smearing(const double& zenith);
104 std::vector<double> location_spread(const double& zenith) const;
105
106 // Reponse integration kernel
107 class response_kernel : public GFunction {
108 public:
109 response_kernel(const GCOMD1Response& response_d1,
110 const GCOMD2Response& response_d2,
111 const double& etrue1,
112 const double& etrue2,
113 const double& phibar,
114 const double& etmin,
115 const double& etmax,
116 const double& e1min,
117 const double& e1max,
118 const double& e2min,
119 const double& e2max) :
120 m_response_d1(response_d1),
121 m_response_d2(response_d2),
122 m_etrue1(etrue1),
123 m_etrue2(etrue2),
124 m_cos_phibar(std::cos(phibar*gammalib::deg2rad)),
125 m_sin_phibar(std::sin(phibar*gammalib::deg2rad)),
126 m_etmin(etmin),
127 m_etmax(etmax),
128 m_e1min(e1min),
129 m_e1max(e1max),
130 m_e2min(e2min),
131 m_e2max(e2max) {}
132 double eval(const double& energy1);
133 protected:
134 const GCOMD1Response& m_response_d1; //!< Reference to D1 module response
135 const GCOMD2Response& m_response_d2; //!< Reference to D2 module response
136 double m_etrue1; //!< True D1 energy (MeV)
137 double m_etrue2; //!< True D2 energy (MeV)
138 double m_cos_phibar; //!< cos(phibar)
139 double m_sin_phibar; //!< sin(phibar)
140 double m_etmin; //!< Minimum total energy (MeV)
141 double m_etmax; //!< Maximum total energy (MeV)
142 double m_e1min; //!< Minimum D1 energy (MeV)
143 double m_e1max; //!< Maximum D1 energy (MeV)
144 double m_e2min; //!< Minimum D2 energy (MeV)
145 double m_e2max; //!< Maximum D2 energy (MeV)
146 };
147
148 // Smearing integration kernel
149 class smearing_kernel : public GFunction {
150 public:
151 smearing_kernel(const double& phigeo,
152 const double& sigma,
153 const GNodeArray& phigeos,
154 const std::vector<double>& values) :
155 m_phigeos(phigeos),
156 m_values(values),
157 m_phigeo(phigeo),
158 m_wgt(1.0/sigma),
159 m_norm(1.0/(sigma*gammalib::sqrt_twopi)) {}
160 double eval(const double& phigeo);
161 protected:
162 const GNodeArray& m_phigeos; //!< Geometrical scatter angles
163 const std::vector<double>& m_values; //!< IAQ values
164 double m_phigeo; //!< Current phigeo value
165 double m_wgt; //!< Inverse of Gaussian std (1/deg)
166 double m_norm; //!< Gaussian normalisation
167 };
168
169 // Private data members
170 GFitsImageFloat m_iaq; //!< Response
171 GEbounds m_ebounds; //!< Energy boundaries
172 GCOMD1Response m_response_d1; //!< D1 module response
173 GCOMD2Response m_response_d2; //!< D2 module response
174 GCOMInstChars m_ict; //!< Instrument characteristics
175 double m_phigeo_max; //!< Maximum geometrical scatter angle (deg)
176 double m_phibar_max; //!< Maximum Compton scatter angle (deg)
177 double m_phigeo_bin_size; //!< Bin size in geometrical scatter angle (deg)
178 double m_phibar_bin_size; //!< Bin size in Compton scatter angle (deg)
179 double m_phibar_resolution; //!< Bin size for oversampling (deg)
180 double m_e1min; //!< Minimum D1 energy (MeV)
181 double m_e1max; //!< Maximum D1 energy (MeV)
182 double m_e2min; //!< Minimum D2 energy (MeV)
183 double m_e2max; //!< Maximum D2 energy (MeV)
184 int m_num_energies; //!< Number of energies for continuum IAQ
185 bool m_psd_correct; //!< PSD correction usage flag
186 double m_zenith; //!< Zenith angle for location smearing (deg)
187};
188
189
190/***********************************************************************//**
191 * @brief Return class name
192 *
193 * @return String containing the class name ("GCOMIaq").
194 ***************************************************************************/
195inline
196std::string GCOMIaq::classname(void) const
197{
198 return ("GCOMIaq");
199}
200
201
202/***********************************************************************//**
203 * @brief Return IAQ FITS image
204 *
205 * @return IAQ FITS image.
206 ***************************************************************************/
207inline
209{
210 return m_iaq;
211}
212
213
214/***********************************************************************//**
215 * @brief Return IAQ FITS image (const version)
216 *
217 * @return IAQ FITS image.
218 ***************************************************************************/
219inline
221{
222 return m_iaq;
223}
224
225
226/***********************************************************************//**
227 * @brief Set minimum D1 energy
228 *
229 * @param[in] e1min Minimum D1 energy (MeV).
230 ***************************************************************************/
231inline
232void GCOMIaq::e1min(const double& e1min)
233{
234 m_e1min = e1min;
235 return;
236}
237
238
239/***********************************************************************//**
240 * @brief Return minimum D1 energy
241 *
242 * @return Minimum D1 energy (MeV).
243 ***************************************************************************/
244inline
245const double& GCOMIaq::e1min(void) const
246{
247 return m_e1min;
248}
249
250
251/***********************************************************************//**
252 * @brief Set maximum D1 energy
253 *
254 * @param[in] e1max Maximum D1 energy (MeV).
255 ***************************************************************************/
256inline
257void GCOMIaq::e1max(const double& e1max)
258{
259 m_e1max = e1max;
260 return;
261}
262
263
264/***********************************************************************//**
265 * @brief Return maximum D1 energy
266 *
267 * @return Maximum D1 energy (MeV).
268 ***************************************************************************/
269inline
270const double& GCOMIaq::e1max(void) const
271{
272 return m_e1max;
273}
274
275
276/***********************************************************************//**
277 * @brief Set minimum D2 energy
278 *
279 * @param[in] e2min Minimum D2 energy (MeV).
280 ***************************************************************************/
281inline
282void GCOMIaq::e2min(const double& e2min)
283{
284 m_e2min = e2min;
285 return;
286}
287
288
289/***********************************************************************//**
290 * @brief Return minimum D2 energy
291 *
292 * @return Minimum D2 energy (MeV).
293 ***************************************************************************/
294inline
295const double& GCOMIaq::e2min(void) const
296{
297 return m_e2min;
298}
299
300
301/***********************************************************************//**
302 * @brief Set maximum D2 energy
303 *
304 * @param[in] e2max Maximum D2 energy (MeV).
305 ***************************************************************************/
306inline
307void GCOMIaq::e2max(const double& e2max)
308{
309 m_e2max = e2max;
310 return;
311}
312
313
314/***********************************************************************//**
315 * @brief Return maximum D2 energy
316 *
317 * @return Maximum D2 energy (MeV).
318 ***************************************************************************/
319inline
320const double& GCOMIaq::e2max(void) const
321{
322 return m_e2max;
323}
324
325#endif /* GCOMIAQ_HPP */
COMPTEL D1 module response class interface definition.
COMPTEL D2 module response class interface definition.
COMPTEL Instrument Characteristics interface definition.
Energy boundaries class interface definition.
Single precision FITS image class definition.
Single parameter function abstract base class definition.
Mathematical function definitions.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
GVector cos(const GVector &vector)
Computes cosine of vector elements.
Definition GVector.cpp:1258
GVector sin(const GVector &vector)
Computes sine of vector elements.
Definition GVector.cpp:1384
Interface class for all GammaLib classes.
Definition GBase.hpp:52
Interface for the COMPTEL D1 module response class.
Interface for the COMPTEL D2 module response class.
const GCOMD1Response & m_response_d1
Reference to D1 module response.
Definition GCOMIaq.hpp:134
double m_etrue1
True D1 energy (MeV)
Definition GCOMIaq.hpp:136
double m_cos_phibar
cos(phibar)
Definition GCOMIaq.hpp:138
double eval(const double &energy1)
Computes product of D1 and D2 responses at energy E1 and phibar.
Definition GCOMIaq.cpp:1605
double m_e1min
Minimum D1 energy (MeV)
Definition GCOMIaq.hpp:142
double m_e1max
Maximum D1 energy (MeV)
Definition GCOMIaq.hpp:143
double m_etrue2
True D2 energy (MeV)
Definition GCOMIaq.hpp:137
double m_e2max
Maximum D2 energy (MeV)
Definition GCOMIaq.hpp:145
const GCOMD2Response & m_response_d2
Reference to D2 module response.
Definition GCOMIaq.hpp:135
double m_sin_phibar
sin(phibar)
Definition GCOMIaq.hpp:139
double m_etmin
Minimum total energy (MeV)
Definition GCOMIaq.hpp:140
double m_etmax
Maximum total energy (MeV)
Definition GCOMIaq.hpp:141
double m_e2min
Minimum D2 energy (MeV)
Definition GCOMIaq.hpp:144
response_kernel(const GCOMD1Response &response_d1, const GCOMD2Response &response_d2, const double &etrue1, const double &etrue2, const double &phibar, const double &etmin, const double &etmax, const double &e1min, const double &e1max, const double &e2min, const double &e2max)
Definition GCOMIaq.hpp:109
double m_phigeo
Current phigeo value.
Definition GCOMIaq.hpp:164
double eval(const double &phigeo)
Convolves response with Gaussian kernel.
Definition GCOMIaq.cpp:1702
smearing_kernel(const double &phigeo, const double &sigma, const GNodeArray &phigeos, const std::vector< double > &values)
Definition GCOMIaq.hpp:151
const GNodeArray & m_phigeos
Geometrical scatter angles.
Definition GCOMIaq.hpp:162
double m_norm
Gaussian normalisation.
Definition GCOMIaq.hpp:166
double m_wgt
Inverse of Gaussian std (1/deg)
Definition GCOMIaq.hpp:165
const std::vector< double > & m_values
IAQ values.
Definition GCOMIaq.hpp:163
Interface for the COMPTEL instrument response representation class.
Definition GCOMIaq.hpp:52
double klein_nishina_integral(const double &v, const double &a)
Computes Klein-Nishina integral.
Definition GCOMIaq.cpp:1023
void free_members(void)
Delete class members.
Definition GCOMIaq.cpp:616
const double & e2min(void) const
Return minimum D2 energy.
Definition GCOMIaq.hpp:295
int m_num_energies
Number of energies for continuum IAQ.
Definition GCOMIaq.hpp:184
double m_phigeo_bin_size
Bin size in geometrical scatter angle (deg)
Definition GCOMIaq.hpp:177
double m_e2max
Maximum D2 energy (MeV)
Definition GCOMIaq.hpp:183
void copy_members(const GCOMIaq &iaq)
Copy class members.
Definition GCOMIaq.cpp:585
double m_zenith
Zenith angle for location smearing (deg)
Definition GCOMIaq.hpp:186
GCOMIaq * clone(void) const
Clone instance.
Definition GCOMIaq.cpp:237
GCOMD2Response m_response_d2
D2 module response.
Definition GCOMIaq.hpp:173
GEbounds m_ebounds
Energy boundaries.
Definition GCOMIaq.hpp:171
~GCOMIaq(void)
Destructor.
Definition GCOMIaq.cpp:162
double m_e2min
Minimum D2 energy (MeV)
Definition GCOMIaq.hpp:182
double m_phibar_max
Maximum Compton scatter angle (deg)
Definition GCOMIaq.hpp:176
const double & e2max(void) const
Return maximum D2 energy.
Definition GCOMIaq.hpp:320
double m_phigeo_max
Maximum geometrical scatter angle (deg)
Definition GCOMIaq.hpp:175
void klein_nishina(const double &energy)
Multiply IAQ matrix by the Klein-Nishina formula.
Definition GCOMIaq.cpp:886
const double & e1max(void) const
Return maximum D1 energy.
Definition GCOMIaq.hpp:270
GFitsImageFloat & image(void)
Return IAQ FITS image.
Definition GCOMIaq.hpp:208
GCOMD1Response m_response_d1
D1 module response.
Definition GCOMIaq.hpp:172
GCOMIaq & operator=(const GCOMIaq &iaq)
Assignment operator.
Definition GCOMIaq.cpp:184
GCOMInstChars m_ict
Instrument characteristics.
Definition GCOMIaq.hpp:174
std::string classname(void) const
Return class name.
Definition GCOMIaq.hpp:196
double klein_nishina_bin(const double &energy, const double &phigeo)
Computes Klein-Nishina probability for one bin.
Definition GCOMIaq.cpp:955
void init_response(void)
Initialise COMPTEL response function and instrument characteristics.
Definition GCOMIaq.cpp:626
double m_phibar_resolution
Bin size for oversampling (deg)
Definition GCOMIaq.hpp:179
void weight_iaq(const double &energy)
Weight IAQ matrix.
Definition GCOMIaq.cpp:1056
GFitsImageFloat m_iaq
Response.
Definition GCOMIaq.hpp:170
std::vector< double > location_spread(const double &zenith) const
Compute location spread vector.
Definition GCOMIaq.cpp:1487
void location_smearing(const double &zenith)
Perform location smearing.
Definition GCOMIaq.cpp:1376
const double & e1min(void) const
Return minimum D1 energy.
Definition GCOMIaq.hpp:245
void compton_kinematics(const double &energy)
Generate IAQ matrix based on Compton kinematics.
Definition GCOMIaq.cpp:686
std::string print(const GChatter &chatter=NORMAL) const
Print COMPTEL instrument response representation information.
Definition GCOMIaq.cpp:469
void remove_cards(void)
Remove any extra header cards.
Definition GCOMIaq.cpp:644
void save(const GFilename &filename, const bool &clobber=false) const
Save COMPTEL instrument response representation into FITS file.
Definition GCOMIaq.cpp:426
void set(const GEnergy &energy, const GEbounds &ebounds)
Set mono-energetic IAQ.
Definition GCOMIaq.cpp:254
GCOMIaq(void)
Void constructor.
Definition GCOMIaq.cpp:79
void clear(void)
Clear instance.
Definition GCOMIaq.cpp:218
void init_members(void)
Initialise class members.
Definition GCOMIaq.cpp:552
double m_e1min
Minimum D1 energy (MeV)
Definition GCOMIaq.hpp:180
double m_phibar_bin_size
Bin size in Compton scatter angle (deg)
Definition GCOMIaq.hpp:178
double compute_iaq_bin(const double &etrue1, const double &etrue2, const double &phibar)
Computes the IAQ for one bin.
Definition GCOMIaq.cpp:811
double m_e1max
Maximum D1 energy (MeV)
Definition GCOMIaq.hpp:181
bool m_psd_correct
PSD correction usage flag.
Definition GCOMIaq.hpp:185
Interface for the COMPTEL Instrument Characteristics class.
Energy boundaries container class.
Definition GEbounds.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Filename class.
Definition GFilename.hpp:62
Single precision FITS image class.
Single parameter function abstract base class.
Definition GFunction.hpp:44
Abstract spectral model base class.
Node array class.