GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAModelIrfBackground.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAModelIrfBackground.hpp - CTA IRF background model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2014-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 GCTAModelIrfBackground.hpp
23 * @brief CTA IRF background model class definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCTAMODELIRFBACKGROUND_HPP
28#define GCTAMODELIRFBACKGROUND_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 "GCTABackground.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 GCTAModelIrfBackground(const GXmlElement& xml);
55 virtual ~GCTAModelIrfBackground(void);
56
57 // Operators
59
60 // Implemented pure virtual methods
61 virtual void clear(void);
62 virtual GCTAModelIrfBackground* clone(void) const;
63 virtual std::string classname(void) const;
64 virtual std::string type(void) const;
65 virtual bool is_constant(void) const;
66 virtual double eval(const GEvent& event,
67 const GObservation& obs,
68 const bool& gradients = false) const;
69 virtual double npred(const GEnergy& obsEng,
70 const GTime& obsTime,
71 const GObservation& obs) const;
72 virtual GCTAEventList* mc(const GObservation& obs, GRan& ran) const;
73 virtual void read(const GXmlElement& xml);
74 virtual void write(GXmlElement& xml) const;
75 virtual std::string print(const GChatter& chatter = NORMAL) const;
76
77 // Other methods
78 GModelSpectral* spectral(void) const;
79 GModelTemporal* temporal(void) const;
80 void spectral(const GModelSpectral* spectral);
81 void temporal(const GModelTemporal* temporal);
82
83private:
84 // Methods
85 void init_members(void);
86 void copy_members(const GCTAModelIrfBackground& bgd);
87 void free_members(void);
88 void set_pointers(void);
89 bool valid_model(void) const;
92
93 // ROI integration kernel over theta
95 public:
97 const double& logE,
98 const GCTAInstDir& roi_centre,
99 const int& iter) :
100 m_bgd(bgd),
101 m_logE(logE),
102 m_roi_centre(roi_centre),
103 m_iter(iter) { }
104 double eval(const double& theta);
105 protected:
106 const GCTABackground* m_bgd; //!< Pointer to background
107 double m_logE; //!< Log10 of energy
108 GCTAInstDir m_roi_centre; //!< RoI centre
109 int m_iter; //!< Romberg iterations
110 };
111
112 // ROI integration kernel over phi
114 public:
116 const double& logE,
117 const GCTAInstDir& roi_centre,
118 const double& theta) :
119 m_bgd(bgd),
120 m_logE(logE),
121 m_roi_centre(roi_centre),
122 m_theta(theta) { }
123 double eval(const double& phi);
124 protected:
125 const GCTABackground* m_bgd; //!< Pointer to background
126 double m_logE; //!< Log10 of energy
127 GCTAInstDir m_roi_centre; //!< RoI centre
128 double m_theta; //!< Offset angle (radians)
129 };
130
131 // Members
132 GModelSpectral* m_spectral; //!< Spectral model
133 GModelTemporal* m_temporal; //!< Temporal model
134
135 // Npred cache
136 mutable std::vector<std::string> m_npred_names; //!< Model names
137 mutable std::vector<GEnergy> m_npred_energies; //!< Model energy
138 mutable std::vector<GTime> m_npred_times; //!< Model time
139 mutable std::vector<double> m_npred_values; //!< Model values
140};
141
142
143/***********************************************************************//**
144 * @brief Return class name
145 *
146 * @return String containing the class name ("GCTAModelIrfBackground").
147 ***************************************************************************/
148inline
150{
151 return ("GCTAModelIrfBackground");
152}
153
154
155/***********************************************************************//**
156 * @brief Return data model type
157 *
158 * @return Data model type.
159 *
160 * Returns the type of the data model.
161 ***************************************************************************/
162inline
163std::string GCTAModelIrfBackground::type(void) const
164{
165 return ("CTAIrfBackground");
166}
167
168
169/***********************************************************************//**
170 * @brief Signals if sky model is temporally constant
171 *
172 * @return True if sky model is temporally constant, false otherwise.
173 *
174 * Signals if the sky model is temporally constant. A temporally constant
175 * model is a model that has a temporal component of type "Constant".
176 ***************************************************************************/
177inline
179{
180 return (m_temporal != NULL && m_temporal->type() == "Constant");
181}
182
183
184/***********************************************************************//**
185 * @brief Return spectral model component
186 *
187 * @return Pointer to spectral model component.
188 *
189 * Returns a pointer to the spectral model component of the model. The
190 * pointer is of type GModelSpectral. Note that a NULL pointer may be
191 * returned if the sky model has no spectral model component.
192 ***************************************************************************/
193inline
195{
196 return (m_spectral);
197}
198
199
200/***********************************************************************//**
201 * @brief Return temporal model component
202 *
203 * @return Pointer to temporal model component.
204 *
205 * Returns a pointer to the temporal model component of the model. The
206 * pointer is of type GModelTemporal. Note that a NULL pointer may be
207 * returned if the sky model has no temporal model component.
208 ***************************************************************************/
209inline
211{
212 return (m_temporal);
213}
214
215#endif /* GCTAMODELIRFBACKGROUND_HPP */
CTA background model 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 background model.
CTA event list class.
CTA instrument direction class.
double eval(const double &phi)
Kernel for azimuth angle integration of background model.
const GCTABackground * m_bgd
Pointer to background.
npred_roi_kern_phi(const GCTABackground *bgd, const double &logE, const GCTAInstDir &roi_centre, const double &theta)
npred_roi_kern_theta(const GCTABackground *bgd, const double &logE, const GCTAInstDir &roi_centre, const int &iter)
double eval(const double &theta)
Kernel for offset angle integration of background model.
const GCTABackground * m_bgd
Pointer to background.
CTA IRF background model class.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
virtual std::string type(void) const
Return data model type.
virtual bool is_constant(void) const
Signals if sky model is temporally constant.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated background rate in units of events MeV s .
virtual void write(GXmlElement &xml) const
Write CTA instrument background model into XML element.
GCTAModelIrfBackground & operator=(const GCTAModelIrfBackground &bgd)
Assignment operator.
GModelTemporal * temporal(void) const
Return temporal model component.
std::vector< GTime > m_npred_times
Model time.
GModelTemporal * m_temporal
Temporal model.
std::vector< double > m_npred_values
Model values.
GModelSpectral * m_spectral
Spectral model.
GCTAModelIrfBackground(void)
Void constructor.
void set_pointers(void)
Set pointers.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
void free_members(void)
Delete class members.
virtual std::string classname(void) const
Return class name.
bool valid_model(void) const
Verifies if model has all components.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
GModelSpectral * spectral(void) const
Return spectral model component.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA instrument background model information.
void init_members(void)
Initialise class members.
virtual void clear(void)
Clear CTA instrument background model.
virtual ~GCTAModelIrfBackground(void)
Destructor.
virtual void read(const GXmlElement &xml)
Read CTA instrument background model from XML element.
std::vector< GEnergy > m_npred_energies
Model energy.
std::vector< std::string > m_npred_names
Model names.
virtual GCTAModelIrfBackground * clone(void) const
Clone CTA instrument background model.
void copy_members(const GCTAModelIrfBackground &bgd)
Copy class members.
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.