GammaLib 2.0.0
Loading...
Searching...
No Matches
GModelSpectralConst.hpp
Go to the documentation of this file.
1/***************************************************************************
2 * GModelSpectralConst.hpp - Spectral constant model class *
3 * ----------------------------------------------------------------------- *
4 * copyright (C) 2009-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 GModelSpectralConst.hpp
23 * @brief Constant spectral model class interface definition
24 * @author Juergen Knoedlseder
25 */
26
27#ifndef GMODELSPECTRALCONST_HPP
28#define GMODELSPECTRALCONST_HPP
29
30/* __ Includes ___________________________________________________________ */
31#include <string>
32#include "GModelSpectral.hpp"
33#include "GModelPar.hpp"
34#include "GEnergy.hpp"
35
36/* __ Forward declarations _______________________________________________ */
37class GRan;
38class GTime;
39class GXmlElement;
40
41
42/***********************************************************************//**
43 * @class GModelSpectralConst
44 *
45 * @brief Constant spectral model class
46 *
47 * This class implements a constant spectrum. The model is defined by
48 *
49 * \f[
50 * S_{\rm E}(E | t) = {\tt m\_norm}
51 * \f]
52 *
53 * where
54 * \f${\tt m\_norm}\f$ is the normalization constant in units of
55 * ph/cm2/s/MeV.
56 ***************************************************************************/
58
59public:
60 // Constructors and destructors
62 GModelSpectralConst(const std::string& type, const std::string& value);
63 explicit GModelSpectralConst(const GXmlElement& xml);
64 explicit GModelSpectralConst(const double& value);
66 virtual ~GModelSpectralConst(void);
67
68 // Operators
70
71 // Implemented pure virtual base class methods
72 virtual void clear(void);
73 virtual GModelSpectralConst* clone(void) const;
74 virtual std::string classname(void) const;
75 virtual std::string type(void) const;
76 virtual double eval(const GEnergy& srcEng,
77 const GTime& srcTime = GTime(),
78 const bool& gradients = false) const;
79 virtual double flux(const GEnergy& emin,
80 const GEnergy& emax) const;
81 virtual double eflux(const GEnergy& emin,
82 const GEnergy& emax) const;
83 virtual GEnergy mc(const GEnergy& emin,
84 const GEnergy& emax,
85 const GTime& time,
86 GRan& ran) const;
87 virtual void read(const GXmlElement& xml);
88 virtual void write(GXmlElement& xml) const;
89 virtual std::string print(const GChatter& chatter = NORMAL) const;
90
91 // Other methods
92 void type(const std::string& type);
93 double value(void) const;
94 void value(const double& value);
95
96protected:
97 // Protected methods
98 void init_members(void);
99 void copy_members(const GModelSpectralConst& model);
100 void free_members(void);
101
102 // Protected members
103 std::string m_type; //!< Model type
104 GModelPar m_norm; //!< Normalization factor
105};
106
107
108/***********************************************************************//**
109 * @brief Return class name
110 *
111 * @return String containing the class name ("GModelSpectralConst").
112 ***************************************************************************/
113inline
114std::string GModelSpectralConst::classname(void) const
115{
116 return ("GModelSpectralConst");
117}
118
119
120/***********************************************************************//**
121 * @brief Return model type
122 *
123 * @return Model type.
124 *
125 * Returns the type of the constant spectral model.
126 ***************************************************************************/
127inline
128std::string GModelSpectralConst::type(void) const
129{
130 return (m_type);
131}
132
133
134/***********************************************************************//**
135 * @brief Set model type
136 *
137 * @param[in] type Model type.
138 *
139 * Set the type of the constant spectral model.
140 ***************************************************************************/
141inline
142void GModelSpectralConst::type(const std::string& type)
143{
144 m_type = type;
145 return;
146}
147
148
149/***********************************************************************//**
150 * @brief Return model value
151 *
152 * @return Model value (ph/cm2/s/MeV).
153 *
154 * Returns the model value.
155 ***************************************************************************/
156inline
158{
159 return (m_norm.value());
160}
161
162
163/***********************************************************************//**
164 * @brief Set model value
165 *
166 * @param[in] value Model value (ph/cm2/s/MeV).
167 *
168 * Sets the model value.
169 ***************************************************************************/
170inline
171void GModelSpectralConst::value(const double& value)
172{
174 return;
175}
176
177#endif /* GMODELSPECTRALCONST_HPP */
Energy value class definition.
Model parameter class interface definition.
Abstract spectral 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
Model parameter class.
Definition GModelPar.hpp:87
Constant spectral model class.
virtual std::string classname(void) const
Return class name.
double value(void) const
Return model value.
GModelPar m_norm
Normalization factor.
void free_members(void)
Delete class members.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print spectral model information.
virtual void clear(void)
Clear constant spectral model.
virtual std::string type(void) const
Return model type.
virtual GModelSpectralConst & operator=(const GModelSpectralConst &model)
Assignment operator.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between [emin, emax] (erg/cm2/s)
virtual GModelSpectralConst * clone(void) const
Clone constant spectral model.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual ~GModelSpectralConst(void)
Destructor.
std::string m_type
Model type.
GModelSpectralConst(void)
Void constructor.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void init_members(void)
Initialise class members.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns MC energy between [emin, emax].
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate model value.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between [emin, emax] (ph/cm2/s)
void copy_members(const GModelSpectralConst &model)
Copy class members.
Abstract spectral model base class.
double value(void) const
Return parameter value.
Random number generator class.
Definition GRan.hpp:44
Time class.
Definition GTime.hpp:55
XML element node class.