GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
54 public:
55  // Constructors and destructors
57  explicit GCTAModelCubeBackground(const GXmlElement& xml);
60  const GModelTemporal& temporal);
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 
90 protected:
91  // Methods
92  void init_members(void);
93  void copy_members(const GCTAModelCubeBackground& bgd);
94  void free_members(void);
95  void set_pointers(void);
96  bool valid_model(void) const;
97  GModelSpectral* xml_spectral(const GXmlElement& spectral) const;
98  GModelTemporal* xml_temporal(const GXmlElement& temporal) 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  ***************************************************************************/
117 inline
118 std::string GCTAModelCubeBackground::classname(void) const
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  ***************************************************************************/
131 inline
132 std::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  ***************************************************************************/
146 inline
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  ***************************************************************************/
162 inline
164 {
165  return (m_spectral);
166 }
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  ***************************************************************************/
178 inline
180 {
181  return (m_temporal);
182 }
183 
184 #endif /* GCTAMODELCUBEBACKGROUND_HPP */
CTA event list class interface definition.
void init_members(void)
Initialise class members.
Abstract spectral model base class.
XML element node class interface definition.
GModelSpectral * spectral(void) const
Return spectral model component.
void set_pointers(void)
Set pointers.
Abstract temporal model base class.
virtual std::string classname(void) const
Return class name.
Abstract interface for the event classes.
Definition: GEvent.hpp:71
CTA event list class.
XML element node class.
Definition: GXmlElement.hpp:48
Abstract spatial model base class interface definition.
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:55
std::vector< GEnergy > m_npred_energies
Model energy.
virtual GCTAEventList * mc(const GObservation &obs, GRan &ran) const
Return simulated list of events.
virtual bool is_constant(void) const
Signals if sky model is temporally constant.
GModelTemporal * m_temporal
Temporal model.
Model parameter class interface definition.
bool valid_model(void) const
Verifies if model has all components.
std::vector< std::string > m_npred_names
Model names.
GCTAModelCubeBackground(void)
Void constructor.
Abstract temporal model base class interface definition.
GModelSpectral * xml_spectral(const GXmlElement &spectral) const
Return pointer to spectral model from XML element.
std::vector< GTime > m_npred_times
Model time.
Abstract data model base class interface definition.
CTA cube background model class.
Abstract event base class definition.
Abstract data model class.
Definition: GModelData.hpp:55
GChatter
Definition: GTypemaps.hpp:33
Abstract observation base class.
virtual void read(const GXmlElement &xml)
Read CTA cube background model from XML element.
GModelTemporal * xml_temporal(const GXmlElement &temporal) const
Return pointer to temporal model from XML element.
std::vector< double > m_npred_values
Model values.
CTA observation class interface definition.
Abstract observation base class interface definition.
Abstract spectral model base class interface definition.
virtual std::string type(void) const =0
void free_members(void)
Delete class members.
void copy_members(const GCTAModelCubeBackground &bgd)
Copy class members.
virtual GCTAModelCubeBackground & operator=(const GCTAModelCubeBackground &model)
Assignment operator.
virtual GCTAModelCubeBackground * clone(void) const
Clone CTA cube background model.
virtual std::string type(void) const
Return data model type.
virtual void write(GXmlElement &xml) const
Write CTA cube background model into XML element.
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 * m_spectral
Spectral model.
virtual void clear(void)
Clear CTA cube background model.
GModelTemporal * temporal(void) const
Return temporal model component.
virtual ~GCTAModelCubeBackground(void)
Destructor.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA cube background model information.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return background rate in units of events MeV s sr .