GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAResponseCube.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAResponseCube.hpp - CTA cube analysis response function class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2014-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 GCTAResponseCube.hpp
23  * @brief CTA cube-style response function class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GCTARESPONSECUBE_HPP
28 #define GCTARESPONSECUBE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include <vector>
33 #include "GCTAResponse.hpp"
34 #include "GCTACubeExposure.hpp"
35 #include "GCTACubePsf.hpp"
36 #include "GCTACubeEdisp.hpp"
37 #include "GCTACubeBackground.hpp"
38 #include "GCTACubeSource.hpp"
39 
40 /* __ Type definitions ___________________________________________________ */
41 
42 /* __ Forward declarations _______________________________________________ */
43 class GPhoton;
44 class GEvent;
45 class GObservation;
46 class GCTAObservation;
47 class GCTAInstDir;
50 
51 
52 /***********************************************************************//**
53  * @class GCTAResponseCube
54  *
55  * @brief CTA cube-style response function class
56  ***************************************************************************/
58 
59 public:
60  // Expose GCTAResponse::irf method
61  using GCTAResponse::irf;
62 
63  // Constructors and destructors
64  GCTAResponseCube(void);
66  explicit GCTAResponseCube(const GXmlElement& xml);
68  const GCTACubePsf& psf,
70  GCTAResponseCube(const GCTACubeExposure& exposure,
71  const GCTACubePsf& psf,
72  const GCTACubeEdisp& edisp,
73  const GCTACubeBackground& background);
74  virtual ~GCTAResponseCube(void);
75 
76  // Operators
77  virtual GCTAResponseCube& operator=(const GCTAResponseCube & rsp);
78 
79  // Implement pure virtual base class methods
80  virtual void clear(void);
81  virtual GCTAResponseCube* 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& obsEng) 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  const GCTACubeExposure& exposure(void) const;
102  void exposure(const GCTACubeExposure& exposure);
103  const GCTACubePsf& psf(void) const;
104  void psf(const GCTACubePsf& psf);
105  const GCTACubeEdisp& edisp(void) const;
106  void edisp(const GCTACubeEdisp& edisp);
107  const GCTACubeBackground& background(void) const;
108  void background(const GCTACubeBackground& background);
109 
110 private:
111  // Private methods
112  void init_members(void);
113  void copy_members(const GCTAResponseCube& rsp);
114  void free_members(void);
115  int cache_index(const std::string& name) const;
116  double psf_radial(const GModelSpatialRadial* model,
117  const double& rho_obs,
118  const GSkyDir& obsDir,
119  const GEnergy& srcEng,
120  const GTime& srcTime) const;
121  double psf_elliptical(const GModelSpatialElliptical* model,
122  const double& rho_obs,
123  const double& posangle_obs,
124  const GSkyDir& obsDir,
125  const GEnergy& srcEng,
126  const GTime& srcTime) const;
127  double psf_diffuse(const GModelSpatial* model,
128  const GSkyDir& obsDir,
129  const GEnergy& srcEng,
130  const GTime& srcTime) const;
131  double irf_ptsrc(const GEvent& event,
132  const GSource& source,
133  const GObservation& obs) const;
134  double irf_radial(const GEvent& event,
135  const GSource& source,
136  const GObservation& obs) const;
137  double irf_elliptical(const GEvent& event,
138  const GSource& source,
139  const GObservation& obs) const;
140  double irf_diffuse(const GEvent& event,
141  const GSource& source,
142  const GObservation& obs) const;
143 
144  // Private data members
145  GCTACubeExposure m_exposure; //!< Exposure cube
146  GCTACubePsf m_psf; //!< Mean point spread function
147  GCTACubeBackground m_background; //!< Background cube
148  GCTACubeEdisp m_edisp; //!< Energy dispersion cube
149  mutable bool m_apply_edisp; //!< Apply energy dispersion
150  mutable bool m_has_edisp; //!< Flag to indicate if energy
151  // dispersion is available
152 
153  // Response cache
154  mutable std::vector<GCTACubeSource*> m_cache; //!< Response cache
155  mutable GNodeArray m_diffuse_logE; //!< Diffuse energy
156  // bounds
157  // computation
158  // cache
159 };
160 
161 
162 /***********************************************************************//**
163  * @brief Return class name
164  *
165  * @return String containing the class name ("GCTAResponseCube").
166  ***************************************************************************/
167 inline
168 std::string GCTAResponseCube::classname(void) const
169 {
170  return ("GCTAResponseCube");
171 }
172 
173 
174 /***********************************************************************//**
175  * @brief Signal if response is valid
176  *
177  * @return True if response is valid
178  *
179  * @todo: To be implemented (check if GCTACubeExposure and GCTACubePsf is loaded)
180  ***************************************************************************/
181 inline
183 {
184  return (true);
185 }
186 
187 
188 /***********************************************************************//**
189  * @brief Signal if response uses energy dispersion
190  *
191  * @return True if response uses energy dispersion
192  *
193  * Signals if the response uses energy dispersion. This implies that the
194  * apply_edisp flag has been set to true and that energy dispersion response
195  * information is available.
196  ***************************************************************************/
197 inline
199 {
200  return (m_apply_edisp && m_has_edisp);
201 }
202 
203 
204 /***********************************************************************//**
205  * @brief Signal if time dispersion will be used
206  *
207  * @return False.
208  ***************************************************************************/
209 inline
211 {
212  return false;
213 }
214 
215 
216 /***********************************************************************//**
217  * @brief Signal if energy dispersion should be applied
218  *
219  * @return True if energy dispersion should be applied
220  ***************************************************************************/
221 inline
223 {
224  return m_apply_edisp;
225 }
226 
227 /***********************************************************************//**
228  * @brief Signal if energy dispersion should be applied
229  *
230  * @param[in] apply_edisp Set true if energy dispersion should be applied
231  ***************************************************************************/
232 inline
233 void GCTAResponseCube::apply_edisp(const bool& apply_edisp) const
234 {
236  return;
237 }
238 
239 
240 /***********************************************************************//**
241  * @brief Return exposure cube
242  *
243  * @return Reference to exposure cube.
244  ***************************************************************************/
245 inline
247 {
248  return (m_exposure);
249 }
250 
251 
252 /***********************************************************************//**
253  * @brief Set exposure cube
254  *
255  * @param[in] exposure Exposure cube.
256  ***************************************************************************/
257 inline
259 {
261  return;
262 }
263 
264 
265 /***********************************************************************//**
266  * @brief Return cube analysis point spread function
267  *
268  * @return Reference to cube analysis point spread function.
269  ***************************************************************************/
270 inline
272 {
273  return (m_psf);
274 }
275 
276 
277 /***********************************************************************//**
278  * @brief Set cube analysis point spread function cube
279  *
280  * @param[in] psf Cube analysis point spread function.
281  ***************************************************************************/
282 inline
284 {
285  m_psf = psf;
286  return;
287 }
288 
289 
290 /***********************************************************************//**
291  * @brief Set cube analysis energy dispersion cube
292  *
293  * @param[in] edisp Cube analysis energy dispersion cube.
294  ***************************************************************************/
295 inline
297 {
298  m_edisp = edisp;
299  m_has_edisp = true;
300  return;
301 }
302 
303 
304 /***********************************************************************//**
305  * @brief Return cube analysis energy dispersion cube
306  *
307  * @return Reference to cube analysis energy dispersion cube.
308  ***************************************************************************/
309 inline
311 {
312  return (m_edisp);
313 }
314 
315 
316 /***********************************************************************//**
317  * @brief Set cube analysis background cube
318  *
319  * @param[in] background Cube analysis background cube.
320  ***************************************************************************/
321 inline
323 {
325  return;
326 }
327 
328 
329 /***********************************************************************//**
330  * @brief Return cube analysis background cube
331  *
332  * @return Reference to cube analysis background cube.
333  ***************************************************************************/
334 inline
336 {
337  return (m_background);
338 }
339 
340 
341 #endif /* GCTARESPONSECUBE_HPP */
void copy_members(const GCTAResponseCube &rsp)
Copy class members.
CTA exposure cube class.
double irf_radial(const GEvent &event, const GSource &source, const GObservation &obs) const
Return instrument response to radial source.
Node array class.
Definition: GNodeArray.hpp:60
GCTACubePsf m_psf
Mean point spread function.
virtual bool use_edisp(void) const
Signal if response uses energy dispersion.
Abstract elliptical spatial model base class.
GCTACubeExposure m_exposure
Exposure cube.
CTA cube analysis point spread function class definition.
const GCTACubeBackground & background(void) const
Return cube analysis background cube.
CTA cube background class.
CTA cube-style response function class.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
XML element node class.
Definition: GXmlElement.hpp:47
double psf_radial(const GModelSpatialRadial *model, const double &rho_obs, const GSkyDir &obsDir, const GEnergy &srcEng, const GTime &srcTime) const
Integrate Psf over radial model.
virtual GCTAResponseCube & operator=(const GCTAResponseCube &rsp)
Assignment operator.
Time class.
Definition: GTime.hpp:54
GNodeArray m_diffuse_logE
Diffuse energy.
double irf_diffuse(const GEvent &event, const GSource &source, const GObservation &obs) const
Return instrument response to diffuse source.
virtual void write(GXmlElement &xml) const
Write response information into XML element.
std::vector< GCTACubeSource * > m_cache
Response cache.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print response information.
CTA cube background class definition.
void init_members(void)
Initialise class members.
Class that handles photons.
Definition: GPhoton.hpp:47
const GCTACubeExposure & exposure(void) const
Return exposure cube.
virtual std::string classname(void) const
Return class name.
Energy boundaries container class.
Definition: GEbounds.hpp:60
virtual ~GCTAResponseCube(void)
Destructor.
const GCTACubePsf & psf(void) const
Return cube analysis point spread function.
Abstract CTA cube analysis source base class definition.
GCTACubeBackground m_background
Background cube.
bool m_has_edisp
Flag to indicate if energy.
double psf_elliptical(const GModelSpatialElliptical *model, const double &rho_obs, const double &posangle_obs, const GSkyDir &obsDir, const GEnergy &srcEng, const GTime &srcTime) const
Integrate Psf over elliptical model.
void free_members(void)
Delete class members.
const GCTACubeEdisp & edisp(void) const
Return cube analysis energy dispersion cube.
virtual GCTAResponseCube * clone(void) const
Clone instance.
virtual GEbounds ebounds(const GEnergy &obsEng) const
Return true energy boundaries for a specific observed energy.
CTA energy dispersion for stacked analysis.
GChatter
Definition: GTypemaps.hpp:33
virtual void clear(void)
Clear instance.
Abstract observation base class.
double psf_diffuse(const GModelSpatial *model, const GSkyDir &obsDir, const GEnergy &srcEng, const GTime &srcTime) const
Integrate PSF over diffuse model.
CTA response abstract base class definition.
double irf_ptsrc(const GEvent &event, const GSource &source, const GObservation &obs) const
Return instrument response to point source.
CTA instrument response function class.
CTA point spread function for cube analysis.
Definition: GCTACubePsf.hpp:62
Sky model class.
Definition: GModelSky.hpp:120
virtual bool use_tdisp(void) const
Signal if time dispersion will be used.
virtual bool is_valid(void) const
Signal if response is valid.
bool m_apply_edisp
Apply energy dispersion.
GCTACubeEdisp m_edisp
Energy dispersion cube.
virtual void read(const GXmlElement &xml)
Read response information from XML element.
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const
Return instrument response.
CTA instrument direction class.
Definition: GCTAInstDir.hpp:59
Abstract spatial model base class.
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const =0
Abstract radial spatial model base class.
GCTAResponseCube(void)
Void constructor.
double irf_elliptical(const GEvent &event, const GSource &source, const GObservation &obs) const
Return instrument response to elliptical source.
CTA cube analysis exposure class definition.
CTA observation class.
virtual bool apply_edisp(void) const
Signal if energy dispersion should be applied.
Class that handles gamma-ray sources.
Definition: GSource.hpp:53
int cache_index(const std::string &name) const
Determine cache index for model.
Sky direction class.
Definition: GSkyDir.hpp:62
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.
CTA cube analysis energy disperson class definition.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48