GammaLib 2.0.0
Loading...
Searching...
No Matches
GCTAModelSkyCube.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GCTAModelSkyCube.hpp - CTA sky cube model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 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 GCTAModelSkyCube.hpp
23 * @brief CTA sky cube model class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GCTAMODELSKYCUBE_HPP
28#define GCTAMODELSKYCUBE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <vector>
33#include "GModelData.hpp"
34#include "GFilename.hpp"
35#include "GSkyMap.hpp"
36#include "GEbounds.hpp"
37#include "GNodeArray.hpp"
38#include "GModelPar.hpp"
39#include "GModelSpectral.hpp"
40#include "GModelTemporal.hpp"
41#include "GCTAEventList.hpp"
42
43/* __ Forward declarations _______________________________________________ */
44class GEvent;
45class GObservation;
46class GXmlElement;
47
48
49/***********************************************************************//**
50 * @class GCTAModelSkyCube
51 *
52 * @brief CTA sky cube model class
53 *
54 * This class implements a sky cube model for CTA.
55 ***************************************************************************/
57
58public:
59 // Constructors and destructors
60 GCTAModelSkyCube(void);
61 explicit GCTAModelSkyCube(const GXmlElement& xml);
68 virtual ~GCTAModelSkyCube(void);
69
70 // Operators
71 virtual GCTAModelSkyCube& operator=(const GCTAModelSkyCube& model);
72
73 // Implemented pure virtual methods
74 virtual void clear(void);
75 virtual GCTAModelSkyCube* clone(void) const;
76 virtual std::string classname(void) const;
77 virtual std::string type(void) const;
78 virtual bool is_constant(void) const;
79 virtual double eval(const GEvent& event,
80 const GObservation& obs,
81 const bool& gradients = false) const;
82 virtual double npred(const GEnergy& obsEng,
83 const GTime& obsTime,
84 const GObservation& obs) const;
85 virtual GCTAEventList* mc(const GObservation& obs, GRan& ran) const;
86 virtual void read(const GXmlElement& xml);
87 virtual void write(GXmlElement& xml) const;
88 virtual std::string print(const GChatter& chatter = NORMAL) const;
89
90 // Other methods
91 void load(const GFilename& filename);
92 const GFilename& filename(void) const;
93 GModelSpectral* spectral(void) const;
94 GModelTemporal* temporal(void) const;
95 void spectral(const GModelSpectral* spectral);
96 void temporal(const GModelTemporal* temporal);
97
98protected:
99 // Methods
100 void init_members(void);
101 void copy_members(const GCTAModelSkyCube& bgd);
102 void free_members(void);
103 void set_pointers(void);
104 bool valid_model(void) const;
105 void read_xml_spatial(const GXmlElement& xml);
106 void write_xml_spatial(GXmlElement& xml) const;
109
110 // Members
111 GFilename m_filename; //!< Filename
112 GSkyMap m_cube; //!< Sky cube
113 GEbounds m_ebounds; //!< Energy boundaries of sky cube
114 GNodeArray m_elogmeans; //!< Mean log10(TeV) energies for the sky cube
115 GModelPar m_norm; //!< Normalisation parameter
116 GModelSpectral* m_spectral; //!< Spectral model
117 GModelTemporal* m_temporal; //!< Temporal model
118
119 // Npred cache
120 mutable std::vector<std::string> m_npred_names; //!< Model names
121 mutable std::vector<GEnergy> m_npred_energies; //!< Model energy
122 mutable std::vector<GTime> m_npred_times; //!< Model time
123 mutable std::vector<double> m_npred_values; //!< Model values
124};
125
126
127/***********************************************************************//**
128 * @brief Return class name
129 *
130 * @return String containing the class name ("GCTAModelSkyCube").
131 ***************************************************************************/
132inline
133std::string GCTAModelSkyCube::classname(void) const
134{
135 return ("GCTAModelSkyCube");
136}
137
138
139/***********************************************************************//**
140 * @brief Return data model type
141 *
142 * @return Data model type.
143 *
144 * Returns the type of the data model.
145 ***************************************************************************/
146inline
147std::string GCTAModelSkyCube::type(void) const
148{
149 return ("CTASkyCube");
150}
151
152
153/***********************************************************************//**
154 * @brief Signals if sky model is temporally constant
155 *
156 * @return True if sky model is temporally constant, false otherwise.
157 *
158 * Signals if the sky model is temporally constant. A temporally constant
159 * model is a model that has a temporal component of type "Constant". If
160 * the model has no temporal component it is also consider being constant.
161 ***************************************************************************/
162inline
164{
165 return ((m_temporal != NULL && m_temporal->type() == "Constant") ||
166 (m_temporal == NULL));
167}
168
169
170/***********************************************************************//**
171 * @brief Return filename
172 *
173 * @return Filename.
174 ***************************************************************************/
175inline
177{
178 return (m_filename);
179}
180
181
182/***********************************************************************//**
183 * @brief Return spectral model component
184 *
185 * @return Pointer to spectral model component.
186 *
187 * Returns a pointer to the spectral model component of the model. The
188 * pointer is of type GModelSpectral. Note that a NULL pointer may be
189 * returned if the sky model has no spectral model component.
190 ***************************************************************************/
191inline
193{
194 return (m_spectral);
195}
196
197
198/***********************************************************************//**
199 * @brief Return temporal model component
200 *
201 * @return Pointer to temporal model component.
202 *
203 * Returns a pointer to the temporal model component of the model. The
204 * pointer is of type GModelTemporal. Note that a NULL pointer may be
205 * returned if the sky model has no temporal model component.
206 ***************************************************************************/
207inline
209{
210 return (m_temporal);
211}
212
213#endif /* GCTAMODELSKYCUBE_HPP */
CTA event list class interface definition.
Energy boundaries class interface definition.
Filename class interface definition.
Abstract data model base class interface definition.
Model parameter class interface definition.
Abstract spectral model base class interface definition.
Abstract temporal model base class interface definition.
Node array class interface definition.
Sky map class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
CTA event list class.
CTA sky cube model class.
virtual std::string classname(void) const
Return class name.
void init_members(void)
Initialise class members.
GModelSpectral * spectral(void) const
Return spectral model component.
std::vector< GTime > m_npred_times
Model time.
bool valid_model(void) const
Verifies if model has all components.
GNodeArray m_elogmeans
Mean log10(TeV) energies for the sky cube.
std::vector< GEnergy > m_npred_energies
Model energy.
void copy_members(const GCTAModelSkyCube &bgd)
Copy class members.
GModelTemporal * m_temporal
Temporal model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA cube background model information.
virtual void read(const GXmlElement &xml)
Read CTA sky cube model from XML element.
GModelTemporal * temporal(void) const
Return temporal model component.
void write_xml_spatial(GXmlElement &xml) const
Write spatial model into XML element.
virtual ~GCTAModelSkyCube(void)
Destructor.
virtual bool is_constant(void) const
Signals if sky model is temporally constant.
virtual void write(GXmlElement &xml) const
Write CTA cube background model into XML element.
GFilename m_filename
Filename.
const GFilename & filename(void) const
Return filename.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
GEbounds m_ebounds
Energy boundaries of sky cube.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
GSkyMap m_cube
Sky cube.
void free_members(void)
Delete class members.
virtual GCTAModelSkyCube & operator=(const GCTAModelSkyCube &model)
Assignment operator.
virtual std::string type(void) const
Return data model type.
void read_xml_spatial(const GXmlElement &xml)
Read spatial model from XML element.
std::vector< std::string > m_npred_names
Model names.
virtual void clear(void)
Clear CTA sky cube model.
virtual GCTAModelSkyCube * clone(void) const
Clone CTA sky cube model.
GModelSpectral * m_spectral
Spectral model.
GModelPar m_norm
Normalisation parameter.
void load(const GFilename &filename)
Load sky cube.
GCTAModelSkyCube(void)
Void constructor.
std::vector< double > m_npred_values
Model values.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return event rate in units of events MeV s sr .
void set_pointers(void)
Set pointers.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated event rate in units of events MeV s .
Energy boundaries container class.
Definition GEbounds.hpp:60
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract interface for the event classes.
Definition GEvent.hpp:71
Filename class.
Definition GFilename.hpp:62
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
Node array class.
Abstract observation base class.
Random number generator class.
Definition GRan.hpp:44
Sky map class.
Definition GSkyMap.hpp:89
Time class.
Definition GTime.hpp:55
XML element node class.