GCTAResponseIrf.hpp
17.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
/***************************************************************************
* GCTAResponseIrf.hpp - CTA instrument response function class *
* ----------------------------------------------------------------------- *
* copyright (C) 2010-2018 by Juergen Knoedlseder *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
***************************************************************************/
/**
* @file GCTAResponseIrf.hpp
* @brief CTA instrument response function class definition
* @author Juergen Knoedlseder
*/
#ifndef GCTARESPONSEIRF_HPP
#define GCTARESPONSEIRF_HPP
/* __ Includes ___________________________________________________________ */
#include <vector>
#include <string>
#include "GEnergy.hpp"
#include "GTime.hpp"
#include "GCaldb.hpp"
#include "GCTAResponse.hpp"
#include "GCTAAeff.hpp"
#include "GCTAPsf.hpp"
#include "GCTAEdisp.hpp"
#include "GCTABackground.hpp"
/* __ Forward declarations _______________________________________________ */
class GFilename;
class GSkyDir;
class GPhoton;
class GEbounds;
class GEvent;
class GObservation;
class GRan;
class GCTAObservation;
class GCTAPointing;
class GCTAEventAtom;
class GCTARoi;
class GCTAInstDir;
/***********************************************************************//**
* @class GCTAResponseIrf
*
* @brief CTA instrument response function class
***************************************************************************/
class GCTAResponseIrf : public GCTAResponse {
public:
// Expose GCTAResponse::irf method
using GCTAResponse::irf;
// Constructors and destructors
GCTAResponseIrf(void);
GCTAResponseIrf(const GCTAResponseIrf& rsp);
explicit GCTAResponseIrf(const GXmlElement& xml);
GCTAResponseIrf(const std::string& rspname, const GCaldb& caldb);
virtual ~GCTAResponseIrf(void);
// Operators
virtual GCTAResponseIrf& operator=(const GCTAResponseIrf & rsp);
// Methods
virtual void clear(void);
virtual GCTAResponseIrf* clone(void) const;
virtual std::string classname(void) const;
virtual bool is_valid(void) const;
virtual bool use_edisp(void) const;
virtual bool use_tdisp(void) const;
virtual bool apply_edisp(void) const;
virtual void apply_edisp(const bool& apply_edisp) const;
virtual double irf(const GEvent& event,
const GPhoton& photon,
const GObservation& obs) const;
virtual double nroi(const GModelSky& model,
const GEnergy& obsEng,
const GTime& obsTime,
const GObservation& obs) const;
virtual GEbounds ebounds(const GEnergy& obsEnergy) const;
virtual void read(const GXmlElement& xml);
virtual void write(GXmlElement& xml) const;
virtual std::string print(const GChatter& chatter = NORMAL) const;
// Other Methods
GCTAEventAtom* mc(const double& area, const GPhoton& photon,
const GObservation& obs, GRan& ran) const;
void caldb(const GCaldb& caldb);
const GCaldb& caldb(void) const;
const std::string& rspname(void) const;
void load(const std::string& rspname);
void load_aeff(const GFilename& filename);
void load_psf(const GFilename& filename);
void load_edisp(const GFilename& filename);
void load_background(const GFilename& filename);
void offset_sigma(const double& sigma);
double offset_sigma(void) const;
const GCTAAeff* aeff(void) const;
void aeff(GCTAAeff* aeff);
const GCTAPsf* psf(void) const;
void psf(GCTAPsf* psf);
const GCTAEdisp* edisp(void) const;
void edisp(GCTAEdisp* edisp);
const GCTABackground* background(void) const;
void background(GCTABackground* background);
const double& lo_save_thres(void) const;
const double& hi_save_thres(void) const;
// Low-level response methods
double aeff(const double& theta,
const double& phi,
const double& zenith,
const double& azimuth,
const double& srcLogEng) const;
double psf(const double& delta,
const double& theta,
const double& phi,
const double& zenith,
const double& azimuth,
const double& srcLogEng) const;
double psf_delta_max(const double& theta,
const double& phi,
const double& zenith,
const double& azimuth,
const double& srcLogEng) const;
double edisp(const GEnergy& ereco,
const GEnergy& etrue,
const double& theta,
const double& phi,
const double& zenith,
const double& azimuth) const;
double nroi(const GModelSky& model,
const GEnergy& srcEng,
const GTime& srcTime,
const GEnergy& obsEng,
const GTime& obsTime,
const GObservation& obs) const;
double nirf(const GPhoton& photon,
const GEnergy& obsEng,
const GTime& obsTime,
const GObservation& obs) const;
double npsf(const GSkyDir& srcDir,
const double& srcLogEng,
const GTime& srcTime,
const GCTAPointing& pnt,
const GCTARoi& roi) const;
private:
// Private methods
void init_members(void);
void copy_members(const GCTAResponseIrf& rsp);
void free_members(void);
GFilename irf_filename(const std::string& filename) const;
double irf_ptsrc(const GEvent& event,
const GSource& source,
const GObservation& obs) const;
double irf_radial(const GEvent& event,
const GSource& source,
const GObservation& obs) const;
double irf_elliptical(const GEvent& event,
const GSource& source,
const GObservation& obs) const;
double irf_diffuse(const GEvent& event,
const GSource& source,
const GObservation& obs) const;
double nroi_ptsrc(const GModelSky& model,
const GEnergy& srcEng,
const GTime& srcTime,
const GEnergy& obsEng,
const GTime& obsTime,
const GObservation& obs) const;
double nroi_radial(const GModelSky& model,
const GEnergy& srcEng,
const GTime& srcTime,
const GEnergy& obsEng,
const GTime& obsTime,
const GObservation& obs) const;
double nroi_elliptical(const GModelSky& model,
const GEnergy& srcEng,
const GTime& srcTime,
const GEnergy& obsEng,
const GTime& obsTime,
const GObservation& obs) const;
double nroi_diffuse(const GModelSky& model,
const GEnergy& srcEng,
const GTime& srcTime,
const GEnergy& obsEng,
const GTime& obsTime,
const GObservation& obs) const;
double nroi_composite(const GModelSky& model,
const GEnergy& srcEng,
const GTime& srcTime,
const GEnergy& obsEng,
const GTime& obsTime,
const GObservation& obs) const;
// Private data members
GCaldb m_caldb; //!< Calibration database
std::string m_rspname; //!< Name of the instrument response
GCTAAeff* m_aeff; //!< Effective area
GCTAPsf* m_psf; //!< Point spread function
GCTAEdisp* m_edisp; //!< Energy dispersion
GCTABackground* m_background; //!< Background
mutable bool m_apply_edisp; //!< Apply energy dispersion
double m_lo_save_thres; //!< Save low energy threshold
double m_hi_save_thres; //!< Save high energy threshold
// XML response filename
std::string m_xml_caldb; //!< Calibration database string in XML file
std::string m_xml_rspname; //!< Response name in XML file
// Npred cache
mutable std::vector<std::string> m_npred_names; //!< Model names
mutable std::vector<GEnergy> m_npred_energies; //!< Model energy
mutable std::vector<GTime> m_npred_times; //!< Model time
mutable std::vector<double> m_npred_values; //!< Model values
};
/***********************************************************************//**
* @brief Return class name
*
* @return String containing the class name ("GCTAResponseIrf").
***************************************************************************/
inline
std::string GCTAResponseIrf::classname(void) const
{
return ("GCTAResponseIrf");
}
/***********************************************************************//**
* @brief Signal if response is valid
*
* @return True if response is valid
***************************************************************************/
inline
bool GCTAResponseIrf::is_valid(void) const
{
return ((m_aeff != NULL) && (m_psf != NULL));
}
/***********************************************************************//**
* @brief Signal if response uses energy dispersion
*
* @return True if response uses energy dispersion
*
* Signals if the response uses energy dispersion. This implies that the
* apply_edisp flag has been set to true and that energy dispersion response
* information is available.
***************************************************************************/
inline
bool GCTAResponseIrf::use_edisp(void) const
{
return (m_apply_edisp && (m_edisp != NULL));
}
/***********************************************************************//**
* @brief Signal if energy dispersion should be applied
*
* @return True if energy dispersion should be applied
***************************************************************************/
inline
bool GCTAResponseIrf::apply_edisp(void) const
{
return m_apply_edisp;
}
/***********************************************************************//**
* @brief Signal if energy dispersion should be applied
*
* @param[in] apply_edisp Set true if energy dispersion should be applied
***************************************************************************/
inline
void GCTAResponseIrf::apply_edisp(const bool& apply_edisp) const
{
m_apply_edisp = apply_edisp;
return;
}
/***********************************************************************//**
* @brief Signal if time dispersion will be used
*
* @return False.
***************************************************************************/
inline
bool GCTAResponseIrf::use_tdisp(void) const
{
return false;
}
/***********************************************************************//**
* @brief Return calibration database
*
* @return Calibration database.
***************************************************************************/
inline
const GCaldb& GCTAResponseIrf::caldb(void) const
{
return m_caldb;
}
/***********************************************************************//**
* @brief Set calibration database
*
* @param[in] caldb Calibration database.
*
* Sets the calibration database for the CTA response.
***************************************************************************/
inline
void GCTAResponseIrf::caldb(const GCaldb& caldb)
{
m_caldb = caldb;
return;
}
/***********************************************************************//**
* @brief Return response name
*
* @return Response name.
***************************************************************************/
inline
const std::string& GCTAResponseIrf::rspname(void) const
{
return m_rspname;
}
/***********************************************************************//**
* @brief Return pointer to effective area response
*
* @return Pointer to effective area response.
***************************************************************************/
inline
const GCTAAeff* GCTAResponseIrf::aeff(void) const
{
return m_aeff;
}
/***********************************************************************//**
* @brief Set pointer to effective area response
*
* @param[in] aeff Pointer to effective area response.
***************************************************************************/
inline
void GCTAResponseIrf::aeff(GCTAAeff* aeff)
{
m_aeff = aeff->clone();
return;
}
/***********************************************************************//**
* @brief Return pointer to point spread function
*
* @return Pointer to point spread function.
***************************************************************************/
inline
const GCTAPsf* GCTAResponseIrf::psf(void) const
{
return m_psf;
}
/***********************************************************************//**
* @brief Set pointer to point spread function
*
* @param[in] psf Pointer to point spread function.
***************************************************************************/
inline
void GCTAResponseIrf::psf(GCTAPsf* psf)
{
m_psf = psf->clone();
return;
}
/***********************************************************************//**
* @brief Return pointer to energy dispersion
*
* @return Pointer to energy dispersion.
***************************************************************************/
inline
const GCTAEdisp* GCTAResponseIrf::edisp(void) const
{
return m_edisp;
}
/***********************************************************************//**
* @brief Set pointer to energy dispersion
*
* @param[in] edisp Pointer to energy dispersion.
***************************************************************************/
inline
void GCTAResponseIrf::edisp(GCTAEdisp* edisp)
{
m_edisp = edisp->clone();
return;
}
/***********************************************************************//**
* @brief Return pointer to background model
*
* @return Pointer to background model.
***************************************************************************/
inline
const GCTABackground* GCTAResponseIrf::background(void) const
{
return m_background;
}
/***********************************************************************//**
* @brief Set pointer to background model
*
* @param[in] background Pointer to background model.
***************************************************************************/
inline
void GCTAResponseIrf::background(GCTABackground* background)
{
m_background = background->clone();
return;
}
/***********************************************************************//**
* @brief Return low energy threshold from IRF
*
* @return Low energy threshold from IRF.
***************************************************************************/
inline
const double& GCTAResponseIrf::lo_save_thres(void) const
{
return m_lo_save_thres;
}
/***********************************************************************//**
* @brief Return high energy threshold from IRF
*
* @return High energy threshold from IRF.
***************************************************************************/
inline
const double& GCTAResponseIrf::hi_save_thres(void) const
{
return m_hi_save_thres;
}
#endif /* GCTARESPONSEIRF_HPP */