GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GResponse.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GResponse.hpp - Abstract response base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2008-2018 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 GResponse.hpp
23  * @brief Abstract response base class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GRESPONSE_HPP
28 #define GRESPONSE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GBase.hpp"
33 #include "GFunction.hpp"
34 #include "GTime.hpp"
35 
36 /* __ Forward declarations _______________________________________________ */
37 class GEvent;
38 class GPhoton;
39 class GSource;
40 class GEnergy;
41 class GEbounds;
42 class GObservation;
43 class GModelSky;
44 
45 
46 /***********************************************************************//**
47  * @class GResponse
48  *
49  * @brief Abstract instrument response base class
50  *
51  * The response function provides conversion between physical parameters
52  * (such as source position, flux, ...) and the measured instrumental
53  * parameters (such as measured energy, photon interaction, ...).
54  *
55  * For a given observation, the irf method returns the instrument response
56  * for a given event and photon. An alternative method exists that returns
57  * the response for a specific source.
58  *
59  * The nroi method returns the spatial integral of the instrument response
60  * function times the sky model over the region of interest. This method is
61  * only required for unbinned analysis.
62  *
63  * The ebounds method returns the true energy boundaries for a specified
64  * measured event energy. This method is used for computing the energy
65  * dispersion.
66  ***************************************************************************/
67 class GResponse : public GBase {
68 
69 public:
70  // Constructors and destructors
71  GResponse(void);
72  GResponse(const GResponse& rsp);
73  virtual ~GResponse(void);
74 
75  // Operators
76  virtual GResponse& operator=(const GResponse& rsp);
77 
78  // Pure virtual methods
79  virtual void clear(void) = 0;
80  virtual GResponse* clone(void) const = 0;
81  virtual std::string classname(void) const = 0;
82  virtual bool use_edisp(void) const = 0;
83  virtual bool use_tdisp(void) const = 0;
84  virtual double irf(const GEvent& event,
85  const GPhoton& photon,
86  const GObservation& obs) const = 0;
87  virtual double irf(const GEvent& event,
88  const GSource& source,
89  const GObservation& obs) const = 0;
90  virtual double nroi(const GModelSky& model,
91  const GEnergy& obsEng,
92  const GTime& obsTime,
93  const GObservation& obs) const = 0;
94  virtual GEbounds ebounds(const GEnergy& obsEng) const = 0;
95  virtual std::string print(const GChatter& chatter = NORMAL) const = 0;
96 
97  // Virtual methods
98  virtual double convolve(const GModelSky& model,
99  const GEvent& event,
100  const GObservation& obs,
101  const bool& grad = true) const;
102 
103 protected:
104  // Protected methods
105  void init_members(void);
106  void copy_members(const GResponse& rsp);
107  void free_members(void);
108  double eval_prob(const GModelSky& model,
109  const GEvent& event,
110  const GEnergy& srcEng,
111  const GTime& srcTime,
112  const GObservation& obs,
113  const bool& grad) const;
114 
115  // Protected classes
116  class edisp_kern : public GFunction {
117  public:
118  edisp_kern(const GResponse* parent,
119  const GObservation* obs,
120  const GModelSky* model,
121  const GEvent* event,
122  const GTime& srcTime,
123  const bool& grad) :
124  m_parent(parent),
125  m_obs(obs),
126  m_model(model),
127  m_event(event),
128  m_srcTime(srcTime),
129  m_grad(grad) { }
130  double eval(const double& etrue);
131  protected:
132  const GResponse* m_parent; //!< Response
133  const GObservation* m_obs; //!< Observation
134  const GModelSky* m_model; //!< Sky model
135  const GEvent* m_event; //!< Event
136  GTime m_srcTime; //!< True arrival time
137  bool m_grad; //!< Gradient flag
138  };
139 };
140 
141 #endif /* GRESPONSE_HPP */
GResponse(void)
Void constructor.
Definition: GResponse.cpp:72
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const =0
const GResponse * m_parent
Response.
Definition: GResponse.hpp:132
Abstract interface for the event classes.
Definition: GEvent.hpp:71
Definition of interface for all GammaLib classes.
virtual void clear(void)=0
Clear object.
bool m_grad
Gradient flag.
Definition: GResponse.hpp:137
Time class.
Definition: GTime.hpp:54
void init_members(void)
Initialise class members.
Definition: GResponse.cpp:260
Class that handles photons.
Definition: GPhoton.hpp:47
Energy boundaries container class.
Definition: GEbounds.hpp:60
Single parameter function abstract base class definition.
const GModelSky * m_model
Sky model.
Definition: GResponse.hpp:134
edisp_kern(const GResponse *parent, const GObservation *obs, const GModelSky *model, const GEvent *event, const GTime &srcTime, const bool &grad)
Definition: GResponse.hpp:118
Interface class for all GammaLib classes.
Definition: GBase.hpp:52
const GEvent * m_event
Event.
Definition: GResponse.hpp:135
virtual ~GResponse(void)
Destructor.
Definition: GResponse.cpp:103
virtual GEbounds ebounds(const GEnergy &obsEng) const =0
GChatter
Definition: GTypemaps.hpp:33
Abstract observation base class.
void free_members(void)
Delete class members.
Definition: GResponse.cpp:282
virtual bool use_edisp(void) const =0
virtual GResponse & operator=(const GResponse &rsp)
Assignment operator.
Definition: GResponse.cpp:125
virtual double nroi(const GModelSky &model, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const =0
double eval_prob(const GModelSky &model, const GEvent &event, const GEnergy &srcEng, const GTime &srcTime, const GObservation &obs, const bool &grad) const
Convolve sky model with the instrument response.
Definition: GResponse.cpp:308
Sky model class.
Definition: GModelSky.hpp:120
const GObservation * m_obs
Observation.
Definition: GResponse.hpp:133
GTime m_srcTime
True arrival time.
Definition: GResponse.hpp:136
Single parameter function abstract base class.
Definition: GFunction.hpp:44
void copy_members(const GResponse &rsp)
Copy class members.
Definition: GResponse.cpp:272
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual std::string classname(void) const =0
Return class name.
Abstract instrument response base class.
Definition: GResponse.hpp:67
Class that handles gamma-ray sources.
Definition: GSource.hpp:53
double eval(const double &etrue)
Integration kernel for GResponse::edisp_kern() class.
Definition: GResponse.cpp:438
virtual bool use_tdisp(void) const =0
virtual double convolve(const GModelSky &model, const GEvent &event, const GObservation &obs, const bool &grad=true) const
Convolve sky model with the instrument response.
Definition: GResponse.cpp:172
Time class interface definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual GResponse * clone(void) const =0
Clones object.