GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GModelDataMultiplicative.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelDataMultiplicative.hpp - Multiplicative data model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2025 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 GModelDataMultiplicative.hpp
23 * @brief Multiplicative data model class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GMODELDATAMULTIPLICATIVE_HPP
28#define GMODELDATAMULTIPLICATIVE_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include <vector>
33#include "GModelData.hpp"
34
35/* __ Forward declarations _______________________________________________ */
36class GRan;
37class GEnergy;
38class GTime;
39class GEvent;
40class GObservation;
41class GXmlElement;
42
43
44/***********************************************************************//**
45 * @class GModelDataMultiplicative
46 *
47 * @brief Multiplicative data model class
48 *
49 * This class implements a multiplicative data model. The data model
50 * components can be defined in an XML file, or added using the append()
51 * method.
52 ***************************************************************************/
54
55public:
56 // Constructors and destructors
58 explicit GModelDataMultiplicative(const GXmlElement& xml);
60 virtual ~GModelDataMultiplicative(void);
61
62 // Operators
64
65 // Implemented pure virtual methods
66 virtual void clear(void);
67 virtual GModelDataMultiplicative* clone(void) const;
68 virtual std::string classname(void) const;
69 virtual std::string type(void) const;
70 virtual bool is_constant(void) const;
71 virtual double eval(const GEvent& event,
72 const GObservation& obs,
73 const bool& gradients = false) const;
74 virtual double npred(const GEnergy& obsEng, const GTime& obsTime,
75 const GObservation& obs) const;
76 virtual GEvents* mc(const GObservation& obs, GRan& ran) const;
77 virtual void read(const GXmlElement& xml);
78 virtual void write(GXmlElement& xml) const;
79 virtual std::string print(const GChatter& chatter = NORMAL) const;
80
81 // Implemented pure virtual base class methods
82 virtual GVector eval(const GObservation& obs,
83 GMatrixSparse* gradients = NULL,
84 const int& offset = 0) const;
85
86 // Other methods
87 void append(const GModelData& model);
88 int components(void) const;
89 const GModelData* component(const int& index) const;
90 const GModelData* component(const std::string& name) const;
91
92protected:
93 // Protected methods
94 void init_members(void);
95 void copy_members(const GModelDataMultiplicative& model);
96 void free_members(void);
97
98 // Protected members
99 std::string m_type; //!< Model type
100 std::vector<GModelData*> m_models; //!< Container of data models
101};
102
103
104/***********************************************************************//**
105 * @brief Return class name
106 *
107 * @return String containing the class name ("GModelDataMultiplicative").
108 ***************************************************************************/
109inline
111{
112 return ("GModelDataMultiplicative");
113}
114
115
116/***********************************************************************//**
117 * @brief Return model type
118 *
119 * @return Model type.
120 *
121 * Returns the type of the multiplicative data model.
122 ***************************************************************************/
123inline
124std::string GModelDataMultiplicative::type(void) const
125{
126 return (m_type);
127}
128
129
130/***********************************************************************//**
131 * @brief Return number of data model components
132 *
133 * @return Number of data model components.
134 *
135 * Returns the number of data model components.
136 ***************************************************************************/
137inline
139{
140 return ((int)m_models.size());
141}
142
143#endif /* GMODELDATAMULTIPLICATIVE_HPP */
Abstract data model base class interface definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Class that handles energies in a unit independent way.
Definition GEnergy.hpp:48
Abstract interface for the event classes.
Definition GEvent.hpp:71
Abstract event container class.
Definition GEvents.hpp:66
Sparse matrix class interface definition.
Multiplicative data model class.
void copy_members(const GModelDataMultiplicative &model)
Copy class members.
virtual bool is_constant(void) const
Return if model is constant.
virtual GModelDataMultiplicative & operator=(const GModelDataMultiplicative &model)
Assignment operator.
virtual ~GModelDataMultiplicative(void)
Destructor.
virtual GEvents * mc(const GObservation &obs, GRan &ran) const
Return simulated events.
GModelDataMultiplicative(void)
Void constructor.
virtual void clear(void)
Clear multiplicative data model.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void init_members(void)
Initialise class members.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print multiplicative data model information.
virtual GModelDataMultiplicative * clone(void) const
Clone multiplicative data model.
virtual void read(const GXmlElement &xml)
Read model from XML element.
int components(void) const
Return number of data model components.
virtual std::string classname(void) const
Return class name.
void append(const GModelData &model)
Append data model component.
void free_members(void)
Delete class members.
const GModelData * component(const int &index) const
Return data model by index.
virtual double eval(const GEvent &event, const GObservation &obs, const bool &gradients=false) const
Return model values and gradients.
std::vector< GModelData * > m_models
Container of data models.
virtual std::string type(void) const
Return model type.
virtual double npred(const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatially integrated data model.
Abstract data model class.
const std::string & name(void) const
Return parameter name.
Definition GModel.hpp:265
Abstract observation base class.
Random number generator class.
Definition GRan.hpp:44
Time class.
Definition GTime.hpp:55
Vector class.
Definition GVector.hpp:46
XML element node class.