GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAModelAeffBackground.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAModelAeffBackground.hpp - CTA Aeff background model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2015-2020 by Michael Mayer *
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 GCTAModelAeffBackground.hpp
23 * @brief CTA Aeff background model class definition
24 * @author Michael Mayer
25 */
26
27#ifndef GCTAMODELAEFFBACKGROUND_HPP
28#define GCTAMODELAEFFBACKGROUND_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GModelData.hpp"
33#include "GModelSpectral.hpp"
34#include "GModelTemporal.hpp"
35#include "GFunction.hpp"
36#include "GCTAEventList.hpp"
37#include "GCTAAeff.hpp"
38
39/* __ Forward declarations _______________________________________________ */
40
41
42/***********************************************************************//**
43 * @class GCTAModelIrfBackground
44 *
45 * @brief CTA IRF background model class
46 ***************************************************************************/
48
49public:
50 // Constructors and destructors
52 explicit GCTAModelAeffBackground(const GXmlElement& xml);
57 virtual ~GCTAModelAeffBackground(void);
58
59 // Operators
61
62 // Implemented pure virtual methods
63 virtual void clear(void);
64 virtual GCTAModelAeffBackground* clone(void) const;
65 virtual std::string classname(void) const;
66 virtual std::string type(void) const;
67 virtual bool is_constant(void) const;
68 virtual double eval(const GEvent& event,
69 const GObservation& obs,
70 const bool& gradients = false) const;
71 virtual double npred(const GEnergy& obsEng,
72 const GTime& obsTime,
73 const GObservation& obs) const;
74 virtual GCTAEventList* mc(const GObservation& obs, GRan& ran) const;
75 virtual void read(const GXmlElement& xml);
76 virtual void write(GXmlElement& xml) const;
77 virtual std::string print(const GChatter& chatter = NORMAL) const;
78
79 // Other methods
80 GModelSpectral* spectral(void) const;
81 GModelTemporal* temporal(void) const;
82 void spectral(const GModelSpectral* spectral);
83 void temporal(const GModelTemporal* temporal);
84
85private:
86 // Methods
87 void init_members(void);
89 void free_members(void);
90 void set_pointers(void);
91 bool valid_model(void) const;
94 double aeff_integral(const GObservation& obs, const double& logE) const;
95
96 // ROI integration kernel over theta
98 public:
100 const double& logE,
101 const GCTAInstDir& roi_centre,
102 const int& iter) :
103 m_aeff(aeff),
104 m_logE(logE),
105 m_roi_centre(roi_centre),
106 m_iter(iter) { }
107 double eval(const double& theta);
108 protected:
109 const GCTAAeff* m_aeff; //!< Pointer to effectve area
110 double m_logE; //!< Log10 of energy
111 GCTAInstDir m_roi_centre; //!< RoI centre
112 int m_iter; //!< Romberg iterations
113 };
114
115 // ROI integration kernel over phi
117 public:
119 const double& logE,
120 const GCTAInstDir& roi_centre,
121 const double& theta) :
122 m_aeff(aeff),
123 m_logE(logE),
124 m_roi_centre(roi_centre),
125 m_theta(theta) { }
126 double eval(const double& phi);
127 protected:
128 const GCTAAeff* m_aeff; //!< Pointer to effective area
129 double m_logE; //!< Log10 of energy
130 GCTAInstDir m_roi_centre; //!< RoI centre
131 double m_theta; //!< Offset angle (radians)
132 };
133
134 // Members
135 GModelSpectral* m_spectral; //!< Spectral model
136 GModelTemporal* m_temporal; //!< Temporal model
137 int m_n_mc_energies; //!< Energy sampling for MC spectrum
138
139 // Npred cache
140 mutable std::vector<std::string> m_npred_names; //!< Model names
141 mutable std::vector<GEnergy> m_npred_energies; //!< Model energy
142 mutable std::vector<GTime> m_npred_times; //!< Model time
143 mutable std::vector<double> m_npred_values; //!< Model values
144};
145
146
147/***********************************************************************//**
148 * @brief Return class name
149 *
150 * @return String containing the class name ("GCTAModelAeffBackground").
151 ***************************************************************************/
152inline
154{
155 return ("GCTAModelAeffBackground");
156}
157
158
159/***********************************************************************//**
160 * @brief Return data model type
161 *
162 * @return Data model type.
163 *
164 * Returns the type of the data model.
165 ***************************************************************************/
166inline
167std::string GCTAModelAeffBackground::type(void) const
168{
169 return ("CTAAeffBackground");
170}
171
172
173/***********************************************************************//**
174 * @brief Signals if sky model is temporally constant
175 *
176 * @return True if sky model is temporally constant, false otherwise.
177 *
178 * Signals if the sky model is temporally constant. A temporally constant
179 * model is a model that has a temporal component of type "Constant".
180 ***************************************************************************/
181inline
183{
184 return (m_temporal != NULL && m_temporal->type() == "Constant");
185}
186
187
188/***********************************************************************//**
189 * @brief Return spectral model component
190 *
191 * @return Pointer to spectral model component.
192 *
193 * Returns a pointer to the spectral model component of the model. The
194 * pointer is of type GModelSpectral. Note that a NULL pointer may be
195 * returned if the sky model has no spectral model component.
196 ***************************************************************************/
197inline
202
203
204/***********************************************************************//**
205 * @brief Return temporal model component
206 *
207 * @return Pointer to temporal model component.
208 *
209 * Returns a pointer to the temporal model component of the model. The
210 * pointer is of type GModelTemporal. Note that a NULL pointer may be
211 * returned if the sky model has no temporal model component.
212 ***************************************************************************/
213inline
218
219#endif /* GCTAMODELAEFFBACKGROUND_HPP */
CTA effective area base class definition.
CTA event list class interface definition.
Single parameter function abstract base class definition.
Abstract data model base class interface definition.
Abstract spectral model base class interface definition.
Abstract temporal model base 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
CTA event list class.
CTA instrument direction class.
const GCTAAeff * m_aeff
Pointer to effective area.
double eval(const double &phi)
Kernel for azimuth angle integration of effective area background model.
npred_roi_kern_phi(const GCTAAeff *aeff, const double &logE, const GCTAInstDir &roi_centre, const double &theta)
const GCTAAeff * m_aeff
Pointer to effectve area.
npred_roi_kern_theta(const GCTAAeff *aeff, const double &logE, const GCTAInstDir &roi_centre, const int &iter)
double eval(const double &theta)
Kernel for offset angle integration of effective area background model.
virtual GCTAModelAeffBackground * clone(void) const
Clone CTA effective area background model.
void copy_members(const GCTAModelAeffBackground &bgd)
Copy class members.
GModelTemporal * temporal(void) const
Return temporal model component.
void init_members(void)
Initialise class members.
virtual void read(const GXmlElement &xml)
Read CTA effective area background model from XML element.
virtual ~GCTAModelAeffBackground(void)
Destructor.
GCTAModelAeffBackground & operator=(const GCTAModelAeffBackground &bgd)
Assignment operator.
virtual std::string classname(void) const
Return class name.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .
GModelSpectral * spectral(void) const
Return spectral model component.
GModelSpectral * m_spectral
Spectral model.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
virtual void clear(void)
Clear CTA effective area background model.
GCTAModelAeffBackground(void)
Void constructor.
void free_members(void)
Delete class members.
virtual void write(GXmlElement &xml) const
Write CTA effective area background model into XML element.
std::vector< GTime > m_npred_times
Model time.
virtual bool is_constant(void) const
Signals if sky model is temporally constant.
virtual std::string type(void) const
Return data model type.
int m_n_mc_energies
Energy sampling for MC spectrum.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA effective area background model information.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
std::vector< GEnergy > m_npred_energies
Model energy.
void set_pointers(void)
Set pointers.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated background rate in units of events MeV s .
std::vector< double > m_npred_values
Model values.
bool valid_model(void) const
Verifies if model has all components.
GModelTemporal * m_temporal
Temporal model.
std::vector< std::string > m_npred_names
Model names.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
double aeff_integral(const GObservation &obs, const double &logE) const
Spatially integrate effective area for given energy.
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract interface for the event classes.
Definition GEvent.hpp:71
Single parameter function abstract base class.
Definition GFunction.hpp:44
Abstract data model class.
Abstract spectral model base class.
Abstract temporal model base class.
virtual std::string type(void) const =0
Abstract observation base class.
Random number generator class.
Definition GRan.hpp:44
Time class.
Definition GTime.hpp:55
XML element node class.