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-2025 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 save(const GFilename& filename, const bool& clobber = false) const;
74 std::string print(const GChatter& chatter = NORMAL) const;
75
76private:
77 // Private methods
78 void init_members(void);
79 void copy_members(const GCOMIaq& iaq);
80 void free_members(void);
81 void init_response(void);
82 void remove_cards(void);
83
84 // RESPSI methods
85 void compton_kinematics(const double& energy);
86 double compute_iaq_bin(const double& etrue1,
87 const double& etrue2,
88 const double& phibar);
89 void klein_nishina(const double& energy);
90 double klein_nishina_bin(const double& energy,
91 const double& phigeo);
92 double klein_nishina_integral(const double& v,
93 const double& a);
94 void weight_iaq(const double& energy);
95 void location_smearing(const double& zenith);
96 std::vector<double> location_spread(const double& zenith) const;
97
98 // Reponse integration kernel
99 class response_kernel : public GFunction {
100 public:
101 response_kernel(const GCOMD1Response& response_d1,
102 const GCOMD2Response& response_d2,
103 const double& etrue1,
104 const double& etrue2,
105 const double& phibar,
106 const double& etmin,
107 const double& etmax,
108 const double& e1min,
109 const double& e1max,
110 const double& e2min,
111 const double& e2max) :
112 m_response_d1(response_d1),
113 m_response_d2(response_d2),
114 m_etrue1(etrue1),
115 m_etrue2(etrue2),
116 m_cos_phibar(std::cos(phibar*gammalib::deg2rad)),
117 m_sin_phibar(std::sin(phibar*gammalib::deg2rad)),
118 m_etmin(etmin),
119 m_etmax(etmax),
120 m_e1min(e1min),
121 m_e1max(e1max),
122 m_e2min(e2min),
123 m_e2max(e2max) {}
124 double eval(const double& energy1);
125 protected:
126 const GCOMD1Response& m_response_d1; //!< Reference to D1 module response
127 const GCOMD2Response& m_response_d2; //!< Reference to D2 module response
128 double m_etrue1; //!< True D1 energy (MeV)
129 double m_etrue2; //!< True D2 energy (MeV)
130 double m_cos_phibar; //!< cos(phibar)
131 double m_sin_phibar; //!< sin(phibar)
132 double m_etmin; //!< Minimum total energy (MeV)
133 double m_etmax; //!< Maximum total energy (MeV)
134 double m_e1min; //!< Minimum D1 energy (MeV)
135 double m_e1max; //!< Maximum D1 energy (MeV)
136 double m_e2min; //!< Minimum D2 energy (MeV)
137 double m_e2max; //!< Maximum D2 energy (MeV)
138 };
139
140 // Smearing integration kernel
141 class smearing_kernel : public GFunction {
142 public:
143 smearing_kernel(const double& phigeo,
144 const double& sigma,
145 const GNodeArray& phigeos,
146 const std::vector<double>& values) :
147 m_phigeos(phigeos),
148 m_values(values),
149 m_phigeo(phigeo),
150 m_wgt(1.0/sigma),
151 m_norm(1.0/(sigma*gammalib::sqrt_twopi)) {}
152 double eval(const double& phigeo);
153 protected:
154 const GNodeArray& m_phigeos; //!< Geometrical scatter angles
155 const std::vector<double>& m_values; //!< IAQ values
156 double m_phigeo; //!< Current phigeo value
157 double m_wgt; //!< Inverse of Gaussian std (1/deg)
158 double m_norm; //!< Gaussian normalisation
159 };
160
161 // Private data members
162 GFitsImageFloat m_iaq; //!< Response
163 GEbounds m_ebounds; //!< Energy boundaries
164 GCOMD1Response m_response_d1; //!< D1 module response
165 GCOMD2Response m_response_d2; //!< D2 module response
166 GCOMInstChars m_ict; //!< Instrument characteristics
167 double m_phigeo_max; //!< Maximum geometrical scatter angle (deg)
168 double m_phibar_max; //!< Maximum Compton scatter angle (deg)
169 double m_phigeo_bin_size; //!< Bin size in geometrical scatter angle (deg)
170 double m_phibar_bin_size; //!< Bin size in Compton scatter angle (deg)
171 double m_phibar_resolution; //!< Bin size for oversampling (deg)
172 double m_e1min; //!< Minimum D1 energy (MeV)
173 double m_e1max; //!< Maximum D1 energy (MeV)
174 double m_e2min; //!< Minimum D2 energy (MeV)
175 double m_e2max; //!< Maximum D2 energy (MeV)
176 int m_num_energies; //!< Number of energies for continuum IAQ
177 bool m_psd_correct; //!< PSD correction usage flag
178 double m_zenith; //!< Zenith angle for location smearing (deg)
179};
180
181
182/***********************************************************************//**
183 * @brief Return class name
184 *
185 * @return String containing the class name ("GCOMIaq").
186 ***************************************************************************/
187inline
188std::string GCOMIaq::classname(void) const
189{
190 return ("GCOMIaq");
191}
192
193
194/***********************************************************************//**
195 * @brief Return IAQ FITS image
196 *
197 * @return IAQ FITS image.
198 ***************************************************************************/
199inline
201{
202 return m_iaq;
203}
204
205
206/***********************************************************************//**
207 * @brief Return IAQ FITS image (const version)
208 *
209 * @return IAQ FITS image.
210 ***************************************************************************/
211inline
213{
214 return m_iaq;
215}
216
217#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:126
double m_etrue1
True D1 energy (MeV)
Definition GCOMIaq.hpp:128
double m_cos_phibar
cos(phibar)
Definition GCOMIaq.hpp:130
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:134
double m_e1max
Maximum D1 energy (MeV)
Definition GCOMIaq.hpp:135
double m_etrue2
True D2 energy (MeV)
Definition GCOMIaq.hpp:129
double m_e2max
Maximum D2 energy (MeV)
Definition GCOMIaq.hpp:137
const GCOMD2Response & m_response_d2
Reference to D2 module response.
Definition GCOMIaq.hpp:127
double m_sin_phibar
sin(phibar)
Definition GCOMIaq.hpp:131
double m_etmin
Minimum total energy (MeV)
Definition GCOMIaq.hpp:132
double m_etmax
Maximum total energy (MeV)
Definition GCOMIaq.hpp:133
double m_e2min
Minimum D2 energy (MeV)
Definition GCOMIaq.hpp:136
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:101
double m_phigeo
Current phigeo value.
Definition GCOMIaq.hpp:156
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:143
const GNodeArray & m_phigeos
Geometrical scatter angles.
Definition GCOMIaq.hpp:154
double m_norm
Gaussian normalisation.
Definition GCOMIaq.hpp:158
double m_wgt
Inverse of Gaussian std (1/deg)
Definition GCOMIaq.hpp:157
const std::vector< double > & m_values
IAQ values.
Definition GCOMIaq.hpp:155
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
int m_num_energies
Number of energies for continuum IAQ.
Definition GCOMIaq.hpp:176
double m_phigeo_bin_size
Bin size in geometrical scatter angle (deg)
Definition GCOMIaq.hpp:169
double m_e2max
Maximum D2 energy (MeV)
Definition GCOMIaq.hpp:175
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:178
GCOMIaq * clone(void) const
Clone instance.
Definition GCOMIaq.cpp:237
GCOMD2Response m_response_d2
D2 module response.
Definition GCOMIaq.hpp:165
GEbounds m_ebounds
Energy boundaries.
Definition GCOMIaq.hpp:163
~GCOMIaq(void)
Destructor.
Definition GCOMIaq.cpp:162
double m_e2min
Minimum D2 energy (MeV)
Definition GCOMIaq.hpp:174
double m_phibar_max
Maximum Compton scatter angle (deg)
Definition GCOMIaq.hpp:168
double m_phigeo_max
Maximum geometrical scatter angle (deg)
Definition GCOMIaq.hpp:167
void klein_nishina(const double &energy)
Multiply IAQ matrix by the Klein-Nishina formula.
Definition GCOMIaq.cpp:886
GFitsImageFloat & image(void)
Return IAQ FITS image.
Definition GCOMIaq.hpp:200
GCOMD1Response m_response_d1
D1 module response.
Definition GCOMIaq.hpp:164
GCOMIaq & operator=(const GCOMIaq &iaq)
Assignment operator.
Definition GCOMIaq.cpp:184
GCOMInstChars m_ict
Instrument characteristics.
Definition GCOMIaq.hpp:166
std::string classname(void) const
Return class name.
Definition GCOMIaq.hpp:188
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:171
void weight_iaq(const double &energy)
Weight IAQ matrix.
Definition GCOMIaq.cpp:1056
GFitsImageFloat m_iaq
Response.
Definition GCOMIaq.hpp:162
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
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:172
double m_phibar_bin_size
Bin size in Compton scatter angle (deg)
Definition GCOMIaq.hpp:170
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:173
bool m_psd_correct
PSD correction usage flag.
Definition GCOMIaq.hpp:177
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.