GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAModelCubeBackground.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAModelCubeBackground.hpp - CTA cube background model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2013-2018 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 GCTAModelCubeBackground.hpp
23 * @brief CTA cube background model class interface definition
24 * @author Michael Mayer
25 */
26
27#ifndef GCTAMODELCUBEBACKGROUND_HPP
28#define GCTAMODELCUBEBACKGROUND_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <cmath>
33#include "GModelData.hpp"
34#include "GModelPar.hpp"
35#include "GModelSpectral.hpp"
36#include "GModelTemporal.hpp"
37#include "GEvent.hpp"
38#include "GObservation.hpp"
39#include "GXmlElement.hpp"
40#include "GCTAObservation.hpp"
41#include "GCTAEventList.hpp"
42#include "GModelSpatial.hpp"
43
44
45/***********************************************************************//**
46 * @class GCTAModelCubeBackground
47 *
48 * @brief CTA cube background model class
49 *
50 * This class implements a cube background model for CTA.
51 ***************************************************************************/
53
54public:
55 // Constructors and destructors
57 explicit GCTAModelCubeBackground(const GXmlElement& xml);
62 virtual ~GCTAModelCubeBackground(void);
63
64 // Operators
66
67 // Implemented pure virtual methods
68 virtual void clear(void);
69 virtual GCTAModelCubeBackground* clone(void) const;
70 virtual std::string classname(void) const;
71 virtual std::string type(void) const;
72 virtual bool is_constant(void) const;
73 virtual double eval(const GEvent& event,
74 const GObservation& obs,
75 const bool& gradients = false) const;
76 virtual double npred(const GEnergy& obsEng,
77 const GTime& obsTime,
78 const GObservation& obs) const;
79 virtual GCTAEventList* mc(const GObservation& obs, GRan& ran) const;
80 virtual void read(const GXmlElement& xml);
81 virtual void write(GXmlElement& xml) const;
82 virtual std::string print(const GChatter& chatter = NORMAL) const;
83
84 // Other methods
85 GModelSpectral* spectral(void) const;
86 GModelTemporal* temporal(void) const;
87 void spectral(const GModelSpectral* spectral);
88 void temporal(const GModelTemporal* temporal);
89
90protected:
91 // Methods
92 void init_members(void);
94 void free_members(void);
95 void set_pointers(void);
96 bool valid_model(void) const;
99
100 // Members
101 GModelSpectral* m_spectral; //!< Spectral model
102 GModelTemporal* m_temporal; //!< Temporal model
103
104 // Npred cache
105 mutable std::vector<std::string> m_npred_names; //!< Model names
106 mutable std::vector<GEnergy> m_npred_energies; //!< Model energy
107 mutable std::vector<GTime> m_npred_times; //!< Model time
108 mutable std::vector<double> m_npred_values; //!< Model values
109};
110
111
112/***********************************************************************//**
113 * @brief Return class name
114 *
115 * @return String containing the class name ("GCTAModelCubeBackground").
116 ***************************************************************************/
117inline
119{
120 return ("GCTAModelCubeBackground");
121}
122
123
124/***********************************************************************//**
125 * @brief Return data model type
126 *
127 * @return Data model type.
128 *
129 * Returns the type of the data model.
130 ***************************************************************************/
131inline
132std::string GCTAModelCubeBackground::type(void) const
133{
134 return ("CTACubeBackground");
135}
136
137
138/***********************************************************************//**
139 * @brief Signals if sky model is temporally constant
140 *
141 * @return True if sky model is temporally constant, false otherwise.
142 *
143 * Signals if the sky model is temporally constant. A temporally constant
144 * model is a model that has a temporal component of type "Constant".
145 ***************************************************************************/
146inline
148{
149 return (m_temporal != NULL && m_temporal->type() == "Constant");
150}
151
152
153/***********************************************************************//**
154 * @brief Return spectral model component
155 *
156 * @return Pointer to spectral model component.
157 *
158 * Returns a pointer to the spectral model component of the model. The
159 * pointer is of type GModelSpectral. Note that a NULL pointer may be
160 * returned if the sky model has no spectral model component.
161 ***************************************************************************/
162inline
167
168
169/***********************************************************************//**
170 * @brief Return temporal model component
171 *
172 * @return Pointer to temporal model component.
173 *
174 * Returns a pointer to the temporal model component of the model. The
175 * pointer is of type GModelTemporal. Note that a NULL pointer may be
176 * returned if the sky model has no temporal model component.
177 ***************************************************************************/
178inline
183
184#endif /* GCTAMODELCUBEBACKGROUND_HPP */
CTA event list class interface definition.
CTA observation class interface definition.
Abstract event base class definition.
Abstract data model base class interface definition.
Model parameter class interface definition.
Abstract spatial model base class interface definition.
Abstract spectral model base class interface definition.
Abstract temporal model base class interface definition.
Abstract observation base class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
XML element node class interface definition.
CTA event list class.
CTA cube background model class.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
std::vector< double > m_npred_values
Model values.
GModelSpectral * spectral(void) const
Return spectral model component.
virtual ~GCTAModelCubeBackground(void)
Destructor.
void free_members(void)
Delete class members.
virtual GCTAModelCubeBackground * clone(void) const
Clone CTA cube background model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA cube background model information.
GCTAModelCubeBackground(void)
Void constructor.
void init_members(void)
Initialise class members.
virtual std::string type(void) const
Return data model type.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
GModelTemporal * temporal(void) const
Return temporal model component.
void copy_members(const GCTAModelCubeBackground &bgd)
Copy class members.
bool valid_model(void) const
Verifies if model has all components.
virtual void clear(void)
Clear CTA cube background model.
virtual void read(const GXmlElement &xml)
Read CTA cube background model from XML element.
std::vector< std::string > m_npred_names
Model names.
virtual std::string classname(void) const
Return class name.
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 .
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
std::vector< GEnergy > m_npred_energies
Model energy.
virtual GCTAModelCubeBackground & operator=(const GCTAModelCubeBackground &model)
Assignment operator.
virtual void write(GXmlElement &xml) const
Write CTA cube background model into XML element.
GModelTemporal * m_temporal
Temporal model.
void set_pointers(void)
Set pointers.
GModelSpectral * m_spectral
Spectral model.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .
std::vector< GTime > m_npred_times
Model time.
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.
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.