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