GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelTemporalConst.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GModelTemporalConst.hpp - Temporal constant model class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2009-2016 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 GModelTemporalConst.hpp
23  * @brief Constant temporal model class interface definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GMODELTEMPORALCONST_HPP
28 #define GMODELTEMPORALCONST_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <string>
32 #include "GModelPar.hpp"
33 #include "GModelTemporal.hpp"
34 #include "GTime.hpp"
35 #include "GTimes.hpp"
36 #include "GXmlElement.hpp"
37 
38 
39 /***********************************************************************//**
40  * @class GModelTemporalConst
41  *
42  * @brief Constant temporal model class
43  *
44  * This class implements a constant light curve. The model is defined by
45  *
46  * \f[
47  * S_{\rm t}(t) = {\tt m\_norm}
48  * \f]
49  *
50  * where
51  * \f${\tt m\_norm}\f$ is the normalization constant which by default is
52  * set to unity. The parameter \f${\tt m\_norm}\f$ is not supposed to be
53  * fitted.
54  ***************************************************************************/
56 
57 public:
58  // Constructors and destructors
59  GModelTemporalConst(void);
60  explicit GModelTemporalConst(const GXmlElement& xml);
61  explicit GModelTemporalConst(const double& norm);
63  virtual ~GModelTemporalConst(void);
64 
65  // Operators
66  virtual GModelTemporalConst& operator= (const GModelTemporalConst& model);
67 
68  // Implemented virtual base class methods
69  virtual void clear(void);
70  virtual GModelTemporalConst* clone(void) const;
71  virtual std::string classname(void) const;
72  virtual std::string type(void) const;
73  virtual double eval(const GTime& srcTime,
74  const bool& gradients = false) const;
75  virtual GTimes mc(const double& rate, const GTime& tmin,
76  const GTime& tmax, 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  // Other methods
82  double norm(void) const;
83  void norm(const double& norm);
84 
85 protected:
86  // Protected methods
87  void init_members(void);
88  void copy_members(const GModelTemporalConst& model);
89  void free_members(void);
90 
91  // Protected members
92  GModelPar m_norm; //!< Constant
93 };
94 
95 
96 /***********************************************************************//**
97  * @brief Return class name
98  *
99  * @return String containing the class name ("GModelTemporalConst").
100  ***************************************************************************/
101 inline
102 std::string GModelTemporalConst::classname(void) const
103 {
104  return ("GModelTemporalConst");
105 }
106 
107 
108 /***********************************************************************//**
109  * @brief Return model type
110  *
111  * @return "ConstantValue".
112  *
113  * Returns the type of the constant temporal model.
114  ***************************************************************************/
115 inline
116 std::string GModelTemporalConst::type(void) const
117 {
118  return "Constant";
119 }
120 
121 
122 /***********************************************************************//**
123  * @brief Return normalization factor
124  *
125  * @return Normalization factor.
126  *
127  * Returns the normalization factor.
128  ***************************************************************************/
129 inline
130 double GModelTemporalConst::norm(void) const
131 {
132  return (m_norm.value());
133 }
134 
135 
136 /***********************************************************************//**
137  * @brief Set normalization factor
138  *
139  * @param[in] norm Normalization factor.
140  *
141  * Sets the normalization factor.
142  ***************************************************************************/
143 inline
144 void GModelTemporalConst::norm(const double& norm)
145 {
146  m_norm.value(norm);
147  return;
148 }
149 
150 #endif /* GMODELTEMPORALCONST_HPP */
double norm(const GVector &vector)
Computes vector norm.
Definition: GVector.cpp:821
XML element node class interface definition.
virtual std::string type(void) const
Return model type.
Abstract temporal model base class.
virtual GModelTemporalConst & operator=(const GModelTemporalConst &model)
Assignment operator.
XML element node class.
Definition: GXmlElement.hpp:47
Random number generator class.
Definition: GRan.hpp:44
Time class.
Definition: GTime.hpp:54
Time container class definition.
virtual GModelTemporalConst * clone(void) const
Clone constant temporal model.
void copy_members(const GModelTemporalConst &model)
Copy class members.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Time container class.
Definition: GTimes.hpp:45
virtual void clear(void)
Clear constant temporal model.
Model parameter class interface definition.
virtual ~GModelTemporalConst(void)
Destructor.
Model parameter class.
Definition: GModelPar.hpp:87
Abstract temporal model base class interface definition.
virtual std::string classname(void) const
Return class name.
GModelPar m_norm
Constant.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print constant information.
GModelTemporalConst(void)
Void constructor.
GChatter
Definition: GTypemaps.hpp:33
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
double value(void) const
Return parameter value.
virtual void read(const GXmlElement &xml)
Read model from XML element.
double norm(void) const
Return normalization factor.
virtual double eval(const GTime &srcTime, const bool &gradients=false) const
Evaluate function.
Time class interface definition.
Constant temporal model class.
virtual GTimes mc(const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) const
Returns vector of random event times.