GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 _______________________________________________ */
43 class GFilename;
44 class GSkyDir;
45 class GPhoton;
46 class GEbounds;
47 class GEvent;
48 class GObservation;
49 class GRan;
50 class GCTAObservation;
51 class GCTAPointing;
52 class GCTAEventAtom;
53 class GCTARoi;
54 class GCTAInstDir;
55 
56 
57 /***********************************************************************//**
58  * @class GCTAResponseIrf
59  *
60  * @brief CTA instrument response function class
61  ***************************************************************************/
62 class GCTAResponseIrf : public GCTAResponse {
63 
64 public:
65  // Expose GCTAResponse::irf method
66  using GCTAResponse::irf;
67 
68  // Constructors and destructors
69  GCTAResponseIrf(void);
70  GCTAResponseIrf(const GCTAResponseIrf& rsp);
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;
119  void background(GCTABackground* background);
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 
162 private:
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  ***************************************************************************/
233 inline
234 std::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  ***************************************************************************/
245 inline
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  ***************************************************************************/
261 inline
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  ***************************************************************************/
273 inline
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  ***************************************************************************/
284 inline
285 void 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  ***************************************************************************/
297 inline
299 {
300  return false;
301 }
302 
303 
304 /***********************************************************************//**
305  * @brief Return calibration database
306  *
307  * @return Calibration database.
308  ***************************************************************************/
309 inline
310 const GCaldb& GCTAResponseIrf::caldb(void) const
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  ***************************************************************************/
323 inline
324 void GCTAResponseIrf::caldb(const GCaldb& caldb)
325 {
326  m_caldb = caldb;
327  return;
328 }
329 
330 
331 /***********************************************************************//**
332  * @brief Return response name
333  *
334  * @return Response name.
335  ***************************************************************************/
336 inline
337 const 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  ***************************************************************************/
348 inline
349 const GCTAAeff* GCTAResponseIrf::aeff(void) const
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  ***************************************************************************/
360 inline
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  ***************************************************************************/
373 inline
374 const GCTAPsf* GCTAResponseIrf::psf(void) const
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  ***************************************************************************/
385 inline
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  ***************************************************************************/
398 inline
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  ***************************************************************************/
410 inline
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  ***************************************************************************/
425 inline
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  ***************************************************************************/
437 inline
439 {
440  m_background = background->clone();
441  return;
442 }
443 
444 /***********************************************************************//**
445  * @brief Return low energy threshold from IRF
446  *
447  * @return Low energy threshold from IRF.
448  ***************************************************************************/
449 inline
450 const 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  ***************************************************************************/
460 inline
461 const double& GCTAResponseIrf::hi_safe_thres(void) const
462 {
463  return m_hi_safe_thres;
464 }
465 
466 #endif /* GCTARESPONSEIRF_HPP */
CTA background model base class definition.
void load_aeff(const GFilename &filename)
Load effective area.
GCTAResponseIrf(void)
Void constructor.
void load_background(const GFilename &filename)
Load background 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.
virtual GCTAEdisp * clone(void) const =0
Clones object.
double m_hi_safe_thres
Safe high energy threshold.
virtual bool apply_edisp(void) const
Signal if energy dispersion should be applied.
virtual void write(GXmlElement &xml) const
Write response information into XML element.
Energy value class definition.
double irf_elliptical(const GEvent &event, const GSource &source, const GObservation &obs) const
Return Irf value for elliptical source model.
virtual bool use_edisp(void) const
Signal if response uses energy dispersion.
virtual GCTAResponseIrf & operator=(const GCTAResponseIrf &rsp)
Assignment operator.
GCTAAeff * m_aeff
Effective area.
const GCTABackground * background(void) const
Return pointer to background model.
void free_members(void)
Delete class members.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
Abstract base class for the CTA point spread function.
Definition: GCTAPsf.hpp:47
XML element node class.
Definition: GXmlElement.hpp:48
Abstract base class for the CTA energy dispersion.
Definition: GCTAEdisp.hpp:49
const std::string & rspname(void) const
Return response name.
Random number generator class.
Definition: GRan.hpp:44
void init_members(void)
Initialise class members.
Interface for the CTA region of interest class.
Definition: GCTARoi.hpp:49
Time class.
Definition: GTime.hpp:55
const double & hi_safe_thres(void) const
Return high energy threshold from IRF.
const GCaldb & caldb(void) const
Return calibration database.
GCTABackground * m_background
Background.
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)
GCTAEdisp * m_edisp
Energy dispersion.
Class that handles photons.
Definition: GPhoton.hpp:47
virtual bool is_valid(void) const
Signal if response is valid.
bool m_apply_edisp
Apply energy dispersion.
const GCTAPsf * psf(void) const
Return pointer to point spread function.
CTA effective area base class definition.
double m_lo_safe_thres
Safe low energy threshold.
GFilename irf_filename(const std::string &filename) const
Return filename with appropriate extension.
Calibration database class.
Definition: GCaldb.hpp:66
Energy boundaries container class.
Definition: GEbounds.hpp:60
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const
Return value of instrument response function.
virtual GEbounds ebounds(const GEnergy &obsEnergy) const
Return true energy boundaries for a specific observed energy.
const GCTAAeff * aeff(void) const
Return pointer to effective area response.
Filename class.
Definition: GFilename.hpp:62
double nirf(const GPhoton &photon, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of Instrument Response Function.
const double & lo_safe_thres(void) const
Return low energy threshold from IRF.
CTA pointing class.
void load_psf(const GFilename &filename)
Load CTA PSF vector.
virtual GCTAResponseIrf * clone(void) const
Clone instance.
GChatter
Definition: GTypemaps.hpp:33
Abstract CTA energy dispersion base class definition.
virtual GCTAAeff * clone(void) const =0
Clones object.
Abstract observation base class.
virtual GCTABackground * clone(void) const =0
Clones object.
GCaldb m_caldb
Calibration database.
CTA response abstract base class definition.
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.
double offset_sigma(void) const
Return offset angle dependence (degrees)
CTA point spread function base class definition.
void load_edisp(const GFilename &filename)
Load energy dispersion information.
void load(const std::string &rspname)
Load CTA response.
Calibration database class interface definition.
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.
CTA instrument response function class.
virtual ~GCTAResponseIrf(void)
Destructor.
CTA instrument response function class.
Abstract base class for the CTA effective area.
Definition: GCTAAeff.hpp:54
std::string m_xml_rspname
Response name in XML file.
std::string m_rspname
Name of the instrument response.
double irf_radial(const GEvent &event, const GSource &source, const GObservation &obs) const
Return IRF value for radial source model.
Sky model class.
Definition: GModelSky.hpp:122
virtual void clear(void)
Clear instance.
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.
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.
std::string m_xml_caldb
Calibration database string in XML file.
CTA event atom class.
virtual GCTAPsf * clone(void) const =0
Clones object.
Abstract base class for the CTA background model.
virtual void read(const GXmlElement &xml)
Read response from XML element.
double irf_ptsrc(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of point source instrument response function.
CTA instrument direction class.
Definition: GCTAInstDir.hpp:63
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const =0
virtual bool use_tdisp(void) const
Signal if time dispersion will be used.
void copy_members(const GCTAResponseIrf &rsp)
Copy class members.
GCTAEventAtom * mc(const double &area, const GPhoton &photon, const GObservation &obs, GRan &ran) const
Simulate event from photon.
CTA observation class.
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.
const GCTAEdisp * edisp(void) const
Return pointer to energy dispersion.
Class that handles gamma-ray sources.
Definition: GSource.hpp:53
Sky direction class.
Definition: GSkyDir.hpp:62
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA response information.
Time class interface definition.
double irf_diffuse(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of diffuse source instrument response function.
virtual std::string classname(void) const
Return class name.
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.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
GCTAPsf * m_psf
Point spread function.