GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAResponseIrf.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAResponseIrf.hpp - CTA instrument response function class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2010-2020 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 GCTAResponseIrf.hpp
23 * @brief CTA instrument response function class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCTARESPONSEIRF_HPP
28#define GCTARESPONSEIRF_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <vector>
32#include <string>
33#include "GEnergy.hpp"
34#include "GTime.hpp"
35#include "GCaldb.hpp"
36#include "GCTAResponse.hpp"
37#include "GCTAAeff.hpp"
38#include "GCTAPsf.hpp"
39#include "GCTAEdisp.hpp"
40#include "GCTABackground.hpp"
41
42/* __ Forward declarations _______________________________________________ */
43class GFilename;
44class GSkyDir;
45class GPhoton;
46class GEbounds;
47class GEvent;
48class GObservation;
49class GRan;
50class GCTAObservation;
51class GCTAPointing;
52class GCTAEventAtom;
53class GCTARoi;
54class GCTAInstDir;
55
56
57/***********************************************************************//**
58 * @class GCTAResponseIrf
59 *
60 * @brief CTA instrument response function class
61 ***************************************************************************/
63
64public:
65 // Expose GCTAResponse::irf method
67
68 // Constructors and destructors
69 GCTAResponseIrf(void);
71 explicit GCTAResponseIrf(const GXmlElement& xml);
72 GCTAResponseIrf(const std::string& rspname, const GCaldb& caldb);
73 virtual ~GCTAResponseIrf(void);
74
75 // Operators
76 virtual GCTAResponseIrf& operator=(const GCTAResponseIrf & rsp);
77
78 // Methods
79 virtual void clear(void);
80 virtual GCTAResponseIrf* clone(void) const;
81 virtual std::string classname(void) const;
82 virtual bool is_valid(void) const;
83 virtual bool use_edisp(void) const;
84 virtual bool use_tdisp(void) const;
85 virtual bool apply_edisp(void) const;
86 virtual void apply_edisp(const bool& apply_edisp) const;
87 virtual double irf(const GEvent& event,
88 const GPhoton& photon,
89 const GObservation& obs) const;
90 virtual double nroi(const GModelSky& model,
91 const GEnergy& obsEng,
92 const GTime& obsTime,
93 const GObservation& obs) const;
94 virtual GEbounds ebounds(const GEnergy& obsEnergy) const;
95 virtual void read(const GXmlElement& xml);
96 virtual void write(GXmlElement& xml) const;
97 virtual std::string print(const GChatter& chatter = NORMAL) const;
98
99 // Other Methods
100 GCTAEventAtom* mc(const double& area, const GPhoton& photon,
101 const GObservation& obs, GRan& ran) const;
102 void caldb(const GCaldb& caldb);
103 const GCaldb& caldb(void) const;
104 const std::string& rspname(void) const;
105 void load(const std::string& rspname);
106 void load_aeff(const GFilename& filename);
107 void load_psf(const GFilename& filename);
108 void load_edisp(const GFilename& filename);
109 void load_background(const GFilename& filename);
110 void offset_sigma(const double& sigma);
111 double offset_sigma(void) const;
112 const GCTAAeff* aeff(void) const;
113 void aeff(GCTAAeff* aeff);
114 const GCTAPsf* psf(void) const;
115 void psf(GCTAPsf* psf);
116 const GCTAEdisp* edisp(void) const;
117 void edisp(GCTAEdisp* edisp);
118 const GCTABackground* background(void) const;
120 const double& lo_safe_thres(void) const;
121 const double& hi_safe_thres(void) const;
122
123 // Low-level response methods
124 double aeff(const double& theta,
125 const double& phi,
126 const double& zenith,
127 const double& azimuth,
128 const double& srcLogEng) const;
129 double psf(const double& delta,
130 const double& theta,
131 const double& phi,
132 const double& zenith,
133 const double& azimuth,
134 const double& srcLogEng) const;
135 double psf_delta_max(const double& theta,
136 const double& phi,
137 const double& zenith,
138 const double& azimuth,
139 const double& srcLogEng) const;
140 double edisp(const GEnergy& ereco,
141 const GEnergy& etrue,
142 const double& theta,
143 const double& phi,
144 const double& zenith,
145 const double& azimuth) const;
146 double nroi(const GModelSky& model,
147 const GEnergy& srcEng,
148 const GTime& srcTime,
149 const GEnergy& obsEng,
150 const GTime& obsTime,
151 const GObservation& obs) const;
152 double nirf(const GPhoton& photon,
153 const GEnergy& obsEng,
154 const GTime& obsTime,
155 const GObservation& obs) const;
156 double npsf(const GSkyDir& srcDir,
157 const double& srcLogEng,
158 const GTime& srcTime,
159 const GCTAPointing& pnt,
160 const GCTARoi& roi) const;
161
162private:
163 // Private methods
164 void init_members(void);
165 void copy_members(const GCTAResponseIrf& rsp);
166 void free_members(void);
167 GFilename irf_filename(const std::string& filename) const;
168 double irf_ptsrc(const GEvent& event,
169 const GSource& source,
170 const GObservation& obs) const;
171 double irf_radial(const GEvent& event,
172 const GSource& source,
173 const GObservation& obs) const;
174 double irf_elliptical(const GEvent& event,
175 const GSource& source,
176 const GObservation& obs) const;
177 double irf_diffuse(const GEvent& event,
178 const GSource& source,
179 const GObservation& obs) const;
180 double nroi_ptsrc(const GModelSky& model,
181 const GEnergy& srcEng,
182 const GTime& srcTime,
183 const GEnergy& obsEng,
184 const GTime& obsTime,
185 const GObservation& obs) const;
186 double nroi_radial(const GModelSky& model,
187 const GEnergy& srcEng,
188 const GTime& srcTime,
189 const GEnergy& obsEng,
190 const GTime& obsTime,
191 const GObservation& obs) const;
192 double nroi_elliptical(const GModelSky& model,
193 const GEnergy& srcEng,
194 const GTime& srcTime,
195 const GEnergy& obsEng,
196 const GTime& obsTime,
197 const GObservation& obs) const;
198 double nroi_diffuse(const GModelSky& model,
199 const GEnergy& srcEng,
200 const GTime& srcTime,
201 const GEnergy& obsEng,
202 const GTime& obsTime,
203 const GObservation& obs) const;
204 double nroi_composite(const GModelSky& model,
205 const GEnergy& srcEng,
206 const GTime& srcTime,
207 const GEnergy& obsEng,
208 const GTime& obsTime,
209 const GObservation& obs) const;
210
211 // Private data members
212 GCaldb m_caldb; //!< Calibration database
213 std::string m_rspname; //!< Name of the instrument response
214 GCTAAeff* m_aeff; //!< Effective area
215 GCTAPsf* m_psf; //!< Point spread function
216 GCTAEdisp* m_edisp; //!< Energy dispersion
217 GCTABackground* m_background; //!< Background
218 mutable bool m_apply_edisp; //!< Apply energy dispersion
219 double m_lo_safe_thres; //!< Safe low energy threshold
220 double m_hi_safe_thres; //!< Safe high energy threshold
221
222 // XML response filename
223 std::string m_xml_caldb; //!< Calibration database string in XML file
224 std::string m_xml_rspname; //!< Response name in XML file
225};
226
227
228/***********************************************************************//**
229 * @brief Return class name
230 *
231 * @return String containing the class name ("GCTAResponseIrf").
232 ***************************************************************************/
233inline
234std::string GCTAResponseIrf::classname(void) const
235{
236 return ("GCTAResponseIrf");
237}
238
239
240/***********************************************************************//**
241 * @brief Signal if response is valid
242 *
243 * @return True if response is valid
244 ***************************************************************************/
245inline
247{
248 return ((m_aeff != NULL) && (m_psf != NULL));
249}
250
251
252/***********************************************************************//**
253 * @brief Signal if response uses energy dispersion
254 *
255 * @return True if response uses energy dispersion
256 *
257 * Signals if the response uses energy dispersion. This implies that the
258 * apply_edisp flag has been set to true and that energy dispersion response
259 * information is available.
260 ***************************************************************************/
261inline
263{
264 return (m_apply_edisp && (m_edisp != NULL));
265}
266
267
268/***********************************************************************//**
269 * @brief Signal if energy dispersion should be applied
270 *
271 * @return True if energy dispersion should be applied
272 ***************************************************************************/
273inline
275{
276 return m_apply_edisp;
277}
278
279/***********************************************************************//**
280 * @brief Signal if energy dispersion should be applied
281 *
282 * @param[in] apply_edisp Set true if energy dispersion should be applied
283 ***************************************************************************/
284inline
285void GCTAResponseIrf::apply_edisp(const bool& apply_edisp) const
286{
288 return;
289}
290
291
292/***********************************************************************//**
293 * @brief Signal if time dispersion will be used
294 *
295 * @return False.
296 ***************************************************************************/
297inline
299{
300 return false;
301}
302
303
304/***********************************************************************//**
305 * @brief Return calibration database
306 *
307 * @return Calibration database.
308 ***************************************************************************/
309inline
311{
312 return m_caldb;
313}
314
315
316/***********************************************************************//**
317 * @brief Set calibration database
318 *
319 * @param[in] caldb Calibration database.
320 *
321 * Sets the calibration database for the CTA response.
322 ***************************************************************************/
323inline
325{
326 m_caldb = caldb;
327 return;
328}
329
330
331/***********************************************************************//**
332 * @brief Return response name
333 *
334 * @return Response name.
335 ***************************************************************************/
336inline
337const std::string& GCTAResponseIrf::rspname(void) const
338{
339 return m_rspname;
340}
341
342
343/***********************************************************************//**
344 * @brief Return pointer to effective area response
345 *
346 * @return Pointer to effective area response.
347 ***************************************************************************/
348inline
350{
351 return m_aeff;
352}
353
354
355/***********************************************************************//**
356 * @brief Set pointer to effective area response
357 *
358 * @param[in] aeff Pointer to effective area response.
359 ***************************************************************************/
360inline
362{
363 m_aeff = aeff->clone();
364 return;
365}
366
367
368/***********************************************************************//**
369 * @brief Return pointer to point spread function
370 *
371 * @return Pointer to point spread function.
372 ***************************************************************************/
373inline
375{
376 return m_psf;
377}
378
379
380/***********************************************************************//**
381 * @brief Set pointer to point spread function
382 *
383 * @param[in] psf Pointer to point spread function.
384 ***************************************************************************/
385inline
387{
388 m_psf = psf->clone();
389 return;
390}
391
392
393/***********************************************************************//**
394 * @brief Return pointer to energy dispersion
395 *
396 * @return Pointer to energy dispersion.
397 ***************************************************************************/
398inline
400{
401 return m_edisp;
402}
403
404
405/***********************************************************************//**
406 * @brief Set pointer to energy dispersion
407 *
408 * @param[in] edisp Pointer to energy dispersion.
409 ***************************************************************************/
410inline
412{
413 m_edisp = edisp->clone();
414 return;
415}
416
417
418
419
420/***********************************************************************//**
421 * @brief Return pointer to background model
422 *
423 * @return Pointer to background model.
424 ***************************************************************************/
425inline
427{
428 return m_background;
429}
430
431
432/***********************************************************************//**
433 * @brief Set pointer to background model
434 *
435 * @param[in] background Pointer to background model.
436 ***************************************************************************/
437inline
439{
441 return;
442}
443
444/***********************************************************************//**
445 * @brief Return low energy threshold from IRF
446 *
447 * @return Low energy threshold from IRF.
448 ***************************************************************************/
449inline
450const double& GCTAResponseIrf::lo_safe_thres(void) const
451{
452 return m_lo_safe_thres;
453}
454
455/***********************************************************************//**
456 * @brief Return high energy threshold from IRF
457 *
458 * @return High energy threshold from IRF.
459 ***************************************************************************/
460inline
461const double& GCTAResponseIrf::hi_safe_thres(void) const
462{
463 return m_hi_safe_thres;
464}
465
466#endif /* GCTARESPONSEIRF_HPP */
CTA effective area base class definition.
CTA background model base class definition.
Abstract CTA energy dispersion base class definition.
CTA point spread function base class definition.
CTA response abstract base class definition.
Calibration database class interface definition.
Energy value class definition.
Time class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Abstract base class for the CTA effective area.
Definition GCTAAeff.hpp:54
virtual GCTAAeff * clone(void) const =0
Clones object.
Abstract base class for the CTA background model.
virtual GCTABackground * clone(void) const =0
Clones object.
Abstract base class for the CTA energy dispersion.
Definition GCTAEdisp.hpp:49
virtual GCTAEdisp * clone(void) const =0
Clones object.
CTA event atom class.
CTA instrument direction class.
CTA observation class.
CTA pointing class.
Abstract base class for the CTA point spread function.
Definition GCTAPsf.hpp:47
virtual GCTAPsf * clone(void) const =0
Clones object.
CTA instrument response function class.
const double & lo_safe_thres(void) const
Return low energy threshold from IRF.
const GCTAAeff * aeff(void) const
Return pointer to effective area response.
virtual bool apply_edisp(void) const
Signal if energy dispersion should be applied.
double nroi_composite(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of composite source model.
void load_edisp(const GFilename &filename)
Load energy dispersion information.
double offset_sigma(void) const
Return offset angle dependence (degrees)
virtual bool use_edisp(void) const
Signal if response uses energy dispersion.
double nroi_diffuse(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of diffuse source model.
GCTAAeff * m_aeff
Effective area.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA response information.
void load_psf(const GFilename &filename)
Load CTA PSF vector.
bool m_apply_edisp
Apply energy dispersion.
double irf_ptsrc(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of point source instrument response function.
GCTABackground * m_background
Background.
GCTAEventAtom * mc(const double &area, const GPhoton &photon, const GObservation &obs, GRan &ran) const
Simulate event from photon.
GFilename irf_filename(const std::string &filename) const
Return filename with appropriate extension.
virtual bool is_valid(void) const
Signal if response is valid.
double psf_delta_max(const double &theta, const double &phi, const double &zenith, const double &azimuth, const double &srcLogEng) const
Return maximum angular separation (in radians)
const GCTABackground * background(void) const
Return pointer to background model.
virtual GCTAResponseIrf * clone(void) const
Clone instance.
std::string m_xml_rspname
Response name in XML file.
const GCTAPsf * psf(void) const
Return pointer to point spread function.
void copy_members(const GCTAResponseIrf &rsp)
Copy class members.
double irf_elliptical(const GEvent &event, const GSource &source, const GObservation &obs) const
Return Irf value for elliptical source model.
virtual double nroi(const GModelSky &model, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return integral of event probability for a given sky model over ROI.
double m_lo_safe_thres
Safe low energy threshold.
void init_members(void)
Initialise class members.
GCTAEdisp * m_edisp
Energy dispersion.
void free_members(void)
Delete class members.
void load(const std::string &rspname)
Load CTA response.
void load_aeff(const GFilename &filename)
Load effective area.
double npsf(const GSkyDir &srcDir, const double &srcLogEng, const GTime &srcTime, const GCTAPointing &pnt, const GCTARoi &roi) const
Return result of PSF integration over ROI.
virtual std::string classname(void) const
Return class name.
virtual void clear(void)
Clear instance.
virtual GEbounds ebounds(const GEnergy &obsEnergy) const
Return true energy boundaries for a specific observed energy.
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const
Return value of instrument response function.
const GCaldb & caldb(void) const
Return calibration database.
GCaldb m_caldb
Calibration database.
const double & hi_safe_thres(void) const
Return high energy threshold from IRF.
double nroi_ptsrc(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of point source model.
double m_hi_safe_thres
Safe high energy threshold.
const std::string & rspname(void) const
Return response name.
std::string m_xml_caldb
Calibration database string in XML file.
void load_background(const GFilename &filename)
Load background model.
double irf_radial(const GEvent &event, const GSource &source, const GObservation &obs) const
Return IRF value for radial source model.
virtual void read(const GXmlElement &xml)
Read response from XML element.
double nirf(const GPhoton &photon, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of Instrument Response Function.
GCTAResponseIrf(void)
Void constructor.
const GCTAEdisp * edisp(void) const
Return pointer to energy dispersion.
double irf_diffuse(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of diffuse source instrument response function.
double nroi_elliptical(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of elliptical source model.
virtual void write(GXmlElement &xml) const
Write response information into XML element.
GCTAPsf * m_psf
Point spread function.
double nroi_radial(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of radial source model.
std::string m_rspname
Name of the instrument response.
virtual bool use_tdisp(void) const
Signal if time dispersion will be used.
virtual ~GCTAResponseIrf(void)
Destructor.
virtual GCTAResponseIrf & operator=(const GCTAResponseIrf &rsp)
Assignment operator.
CTA instrument response function class.
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const =0
Interface for the CTA region of interest class.
Definition GCTARoi.hpp:49
Calibration database class.
Definition GCaldb.hpp:66
Energy boundaries container class.
Definition GEbounds.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract interface for the event classes.
Definition GEvent.hpp:71
Filename class.
Definition GFilename.hpp:62
Sky model class.
Abstract observation base class.
Class that handles photons.
Definition GPhoton.hpp:47
Random number generator class.
Definition GRan.hpp:44
Sky direction class.
Definition GSkyDir.hpp:62
Class that handles gamma-ray sources.
Definition GSource.hpp:53
Time class.
Definition GTime.hpp:55
XML element node class.