GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAModelBackground.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAModelBackground.hpp - Background model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 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 GCTAModelBackground.hpp
23 * @brief Background model class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCTAMODELBACKGROUND_HPP
28#define GCTAMODELBACKGROUND_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <cmath>
33#include "GModelData.hpp"
34#include "GModelSpectral.hpp"
35#include "GModelTemporal.hpp"
36#include "GFunction.hpp"
37#include "GCTAModelSpatial.hpp"
38#include "GCTAEventList.hpp"
39
40/* __ Forward declarations _______________________________________________ */
41class GEvent;
42class GObservation;
43class GModelPar;
44class GXmlElement;
45
46
47/***********************************************************************//**
48 * @class GCTAModelBackground
49 *
50 * @brief Background model class
51 *
52 * This class implements a background model for CTA.
53 ***************************************************************************/
55
56public:
57 // Constructors and destructors
59 explicit GCTAModelBackground(const GXmlElement& xml);
66 virtual ~GCTAModelBackground(void);
67
68 // Operators
70
71 // Implemented pure virtual methods
72 virtual void clear(void);
73 virtual GCTAModelBackground* clone(void) const;
74 virtual std::string classname(void) const;
75 virtual std::string type(void) const;
76 virtual bool is_constant(void) const;
77 virtual double eval(const GEvent& event,
78 const GObservation& obs,
79 const bool& gradients = false) const;
80 virtual double npred(const GEnergy& energy,
81 const GTime& time,
82 const GObservation& obs) const;
83 virtual GCTAEventList* mc(const GObservation& obs, GRan& ran) const;
84 virtual void read(const GXmlElement& xml);
85 virtual void write(GXmlElement& xml) const;
86 virtual std::string print(const GChatter& chatter = NORMAL) const;
87
88 // Other methods
89 GCTAModelSpatial* spatial(void) const;
90 GModelSpectral* spectral(void) const;
91 GModelTemporal* temporal(void) const;
92 void spatial(const GCTAModelSpatial* spatial);
93 void spectral(const GModelSpectral* spectral);
94 void temporal(const GModelTemporal* temporal);
95
96protected:
97 // Protected methods
98 void init_members(void);
99 void copy_members(const GCTAModelBackground& model);
100 void free_members(void);
101 void set_pointers(void);
105 bool valid_model(void) const;
106
107 // Proteced data members
108 GCTAModelSpatial* m_spatial; //!< Spatial model
109 GModelSpectral* m_spectral; //!< Spectral model
110 GModelTemporal* m_temporal; //!< Temporal model
111};
112
113
114/***********************************************************************//**
115 * @brief Return class name
116 *
117 * @return String containing the class name ("GCTAModelBackground").
118 ***************************************************************************/
119inline
120std::string GCTAModelBackground::classname(void) const
121{
122 return ("GCTAModelBackground");
123}
124
125
126/***********************************************************************//**
127 * @brief Return model type
128 *
129 * @return Model type.
130 *
131 * Returns "CTABackground" as the type of the model.
132 ***************************************************************************/
133inline
134std::string GCTAModelBackground::type(void) const
135{
136 return ("CTABackground");
137}
138
139
140/***********************************************************************//**
141 * @brief Signals if model is temporally constant
142 *
143 * @return True if model is temporally constant, false otherwise.
144 *
145 * Signals if the model is temporally constant. A temporally constant model
146 * is a model that has a temporal component of type "Constant".
147 ***************************************************************************/
148inline
150{
151 return (m_temporal != NULL && m_temporal->type() == "Constant");
152}
153
154
155/***********************************************************************//**
156 * @brief Return spatial model component
157 *
158 * @return Pointer to spatial model component.
159 *
160 * Returns a pointer to the spatial model component of the model. The pointer
161 * is of type GCTAModelSpatial. Note that a NULL pointer may be returned if
162 * the model has no spatial model component.
163 ***************************************************************************/
164inline
166{
167 return (m_spatial);
168}
169
170
171/***********************************************************************//**
172 * @brief Return spectral model component
173 *
174 * @return Pointer to spectral model component.
175 *
176 * Returns a pointer to the spectral model component of the model. The
177 * pointer is of type GModelSpectral. Note that a NULL pointer may be
178 * returned if the model has no spectral model component.
179 ***************************************************************************/
180inline
182{
183 return (m_spectral);
184}
185
186
187/***********************************************************************//**
188 * @brief Return temporal model component
189 *
190 * @return Pointer to temporal model component.
191 *
192 * Returns a pointer to the temporal model component of the model. The
193 * pointer is of type GModelTemporal. Note that a NULL pointer may be
194 * returned if the model has no temporal model component.
195 ***************************************************************************/
196inline
198{
199 return (m_temporal);
200}
201
202#endif /* GCTAMODELBACKGROUND_HPP */
CTA event list class interface definition.
Abstract spatial model 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
CTA event list class.
Background model class.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual std::string type(void) const
Return model type.
virtual bool is_constant(void) const
Signals if model is temporally constant.
GCTAModelSpatial * xml_spatial(const GXmlElement &spatial) const
Return pointer to spatial model from XML element.
virtual void clear(void)
Clear instance.
GModelTemporal * m_temporal
Temporal model.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
GModelSpectral * m_spectral
Spectral model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
void set_pointers(void)
Set pointers.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
GCTAModelSpatial * m_spatial
Spatial model.
void copy_members(const GCTAModelBackground &model)
Copy class members.
virtual std::string classname(void) const
Return class name.
virtual GCTAModelBackground * clone(void) const
Clone instance.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .
GCTAModelSpatial * spatial(void) const
Return spatial model component.
GModelSpectral * spectral(void) const
Return spectral model component.
virtual GCTAModelBackground & operator=(const GCTAModelBackground &model)
Assignment operator.
virtual double npred(const GEnergy &energy, const GTime &time, const GObservation &obs) const
Return spatially integrated background rate in units of events MeV s .
GModelTemporal * temporal(void) const
Return temporal model component.
virtual ~GCTAModelBackground(void)
Destructor.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void init_members(void)
Initialise class members.
bool valid_model(void) const
Verifies if model has all components.
GCTAModelBackground(void)
Void constructor.
void free_members(void)
Delete class members.
Abstract spatial model class.
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract interface for the event classes.
Definition GEvent.hpp:71
Abstract data model class.
Model parameter class.
Definition GModelPar.hpp:87
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.