GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelTemporalConst Class Reference

Constant temporal model class. More...

#include <GModelTemporalConst.hpp>

Inheritance diagram for GModelTemporalConst:
GModelTemporal GBase

Public Member Functions

 GModelTemporalConst (void)
 Void constructor. More...
 
 GModelTemporalConst (const GXmlElement &xml)
 XML constructor. More...
 
 GModelTemporalConst (const double &norm)
 Value constructor. More...
 
 GModelTemporalConst (const GModelTemporalConst &model)
 Copy constructor. More...
 
virtual ~GModelTemporalConst (void)
 Destructor. More...
 
virtual GModelTemporalConstoperator= (const GModelTemporalConst &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear constant temporal model. More...
 
virtual GModelTemporalConstclone (void) const
 Clone constant temporal model. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual std::string type (void) const
 Return model type. More...
 
virtual double eval (const GTime &srcTime, const bool &gradients=false) const
 Evaluate function. More...
 
virtual GTimes mc (const double &rate, const GTime &tmin, const GTime &tmax, GRan &ran) const
 Returns vector of random event times. More...
 
virtual void read (const GXmlElement &xml)
 Read model from XML element. More...
 
virtual void write (GXmlElement &xml) const
 Write model into XML element. More...
 
virtual std::string print (const GChatter &chatter=NORMAL) const
 Print constant information. More...
 
double norm (void) const
 Return normalization factor. More...
 
void norm (const double &norm)
 Set normalization factor. More...
 
- Public Member Functions inherited from GModelTemporal
 GModelTemporal (void)
 Void constructor. More...
 
 GModelTemporal (const GModelTemporal &model)
 Copy constructor. More...
 
virtual ~GModelTemporal (void)
 Destructor. More...
 
virtual GModelTemporaloperator= (const GModelTemporal &model)
 Assignment operator. More...
 
virtual GModelParoperator[] (const int &index)
 Returns model parameter. More...
 
virtual const GModelParoperator[] (const int &index) const
 Returns model parameter (const version) More...
 
virtual GModelParoperator[] (const std::string &name)
 Returns reference to model parameter. More...
 
virtual const GModelParoperator[] (const std::string &name) const
 Returns reference to model parameter (const version) More...
 
GModelParat (const int &index)
 Returns model parameter. More...
 
const GModelParat (const int &index) const
 Returns model parameter (const version) More...
 
bool has_par (const std::string &name) const
 Checks if parameter name exists. More...
 
int size (void) const
 Return number of parameters. More...
 
void autoscale (void)
 Autoscale parameters. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelTemporalConst &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
- Protected Member Functions inherited from GModelTemporal
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelTemporal &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Protected Attributes

GModelPar m_norm
 Constant. More...
 
- Protected Attributes inherited from GModelTemporal
std::vector< GModelPar * > m_pars
 Parameter pointers. More...
 

Detailed Description

Constant temporal model class.

This class implements a constant light curve. The model is defined by

\[ S_{\rm t}(t) = {\tt m\_norm} \]

where \({\tt m\_norm}\) is the normalization constant which by default is set to unity. The parameter \({\tt m\_norm}\) is not supposed to be fitted.

Definition at line 55 of file GModelTemporalConst.hpp.

Constructor & Destructor Documentation

GModelTemporalConst::GModelTemporalConst ( void  )

Void constructor.

Definition at line 62 of file GModelTemporalConst.cpp.

References init_members().

Referenced by clone().

GModelTemporalConst::GModelTemporalConst ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs constant temporal model by extracting information from an XML element. See the read() method for more information about the expected structure of the XML element.

Definition at line 81 of file GModelTemporalConst.cpp.

References init_members(), and read().

GModelTemporalConst::GModelTemporalConst ( const double &  norm)
explicit

Value constructor.

Parameters
[in]normNormalization factor.

Constructs constant temporal model by setting the normalization factor.

Definition at line 104 of file GModelTemporalConst.cpp.

References init_members(), m_norm, and GOptimizerPar::value().

GModelTemporalConst::GModelTemporalConst ( const GModelTemporalConst model)

Copy constructor.

Parameters
[in]modelConstant temporal model

Definition at line 125 of file GModelTemporalConst.cpp.

References copy_members(), and init_members().

GModelTemporalConst::~GModelTemporalConst ( void  )
virtual

Destructor.

Definition at line 142 of file GModelTemporalConst.cpp.

References free_members().

Member Function Documentation

std::string GModelTemporalConst::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GModelTemporalConst").

Implements GModelTemporal.

Definition at line 102 of file GModelTemporalConst.hpp.

void GModelTemporalConst::clear ( void  )
virtual

Clear constant temporal model.

Implements GModelTemporal.

Definition at line 197 of file GModelTemporalConst.cpp.

References free_members(), GModelTemporal::free_members(), init_members(), and GModelTemporal::init_members().

void GModelTemporalConst::copy_members ( const GModelTemporalConst model)
protected

Copy class members.

Parameters
[in]modelConstant temporal model

Definition at line 432 of file GModelTemporalConst.cpp.

References m_norm, and GModelTemporal::m_pars.

Referenced by GModelTemporalConst(), and operator=().

double GModelTemporalConst::eval ( const GTime srcTime,
const bool &  gradients = false 
) const
virtual

Evaluate function.

Parameters
[in]srcTimeTrue photon arrival time (not used).
[in]gradientsCompute gradients?
Returns
Value to temporal model.

Computes

\[ S_{\rm t}(t) = {\tt m\_norm} \]

where \({\tt m\_norm}\) is the normalization constant.

If the gradients flag is true the method will also evaluate the partial derivatives of the model with respect to the normalization parameter using

\[ \frac{\delta S_{\rm t}(t)}{\delta {\tt m\_norm}} = 1 \]

Implements GModelTemporal.

Definition at line 247 of file GModelTemporalConst.cpp.

References GOptimizerPar::factor_gradient(), GOptimizerPar::is_free(), m_norm, GOptimizerPar::scale(), and GOptimizerPar::value().

void GModelTemporalConst::free_members ( void  )
protected

Delete class members.

Definition at line 449 of file GModelTemporalConst.cpp.

Referenced by clear(), operator=(), and ~GModelTemporalConst().

void GModelTemporalConst::init_members ( void  )
protected
GTimes GModelTemporalConst::mc ( const double &  rate,
const GTime tmin,
const GTime tmax,
GRan ran 
) const
virtual

Returns vector of random event times.

Parameters
[in]rateMean event rate (events per second).
[in]tminMinimum event time.
[in]tmaxMaximum event time.
[in,out]ranRandom number generator.

This method returns a vector of random event times assuming a constant event rate that is specified by the rate parameter.

Implements GModelTemporal.

Definition at line 280 of file GModelTemporalConst.cpp.

References GTimes::append(), GRan::exp(), norm(), and GTime::secs().

double GModelTemporalConst::norm ( void  ) const
inline

Return normalization factor.

Returns
Normalization factor.

Returns the normalization factor.

Definition at line 130 of file GModelTemporalConst.hpp.

References m_norm, and GOptimizerPar::value().

Referenced by mc(), read(), write(), GCTAModelBackground::write(), and GModelSky::write().

void GModelTemporalConst::norm ( const double &  norm)
inline

Set normalization factor.

Parameters
[in]normNormalization factor.

Sets the normalization factor.

Definition at line 144 of file GModelTemporalConst.hpp.

References m_norm, and GOptimizerPar::value().

GModelTemporalConst & GModelTemporalConst::operator= ( const GModelTemporalConst model)
virtual

Assignment operator.

Parameters
[in]modelConstant temporal model.
Returns
Constant temporal model.

Definition at line 164 of file GModelTemporalConst.cpp.

References copy_members(), free_members(), init_members(), and GModelTemporal::operator=().

std::string GModelTemporalConst::print ( const GChatter chatter = NORMAL) const
virtual

Print constant information.

Parameters
[in]chatterChattiness.
Returns
String containing model information.

Implements GModelTemporal.

Definition at line 373 of file GModelTemporalConst.cpp.

References GModelTemporal::m_pars, gammalib::parformat(), SILENT, GModelTemporal::size(), and gammalib::str().

void GModelTemporalConst::read ( const GXmlElement xml)
virtual

Read model from XML element.

Parameters
[in]xmlXML element.

Writes the temporal information from an XML element having the format

<temporal type="Constant">
  <parameter name="Normalization" scale="1" value="1" min="0.1" max="10" free="1"/>
</temporal>

Implements GModelTemporal.

Definition at line 324 of file GModelTemporalConst.cpp.

References G_READ, m_norm, GOptimizerPar::name(), norm(), GModelPar::read(), gammalib::xml_check_parnum(), and gammalib::xml_get_par().

Referenced by GModelTemporalConst().

std::string GModelTemporalConst::type ( void  ) const
inlinevirtual

Return model type.

Returns
"ConstantValue".

Returns the type of the constant temporal model.

Implements GModelTemporal.

Definition at line 116 of file GModelTemporalConst.hpp.

Referenced by write().

void GModelTemporalConst::write ( GXmlElement xml) const
virtual

Write model into XML element.

Parameters
[in]xmlXML element.

Writes the temporal information into an XML element in the format

<temporal type="Constant">
  <parameter name="Normalization" scale="1" value="1" min="0.1" max="10" free="1"/>
</temporal>

Implements GModelTemporal.

Definition at line 351 of file GModelTemporalConst.cpp.

References G_WRITE, m_norm, GOptimizerPar::name(), norm(), type(), GModelPar::write(), gammalib::xml_check_type(), and gammalib::xml_need_par().

Member Data Documentation

GModelPar GModelTemporalConst::m_norm
protected

Constant.

Definition at line 92 of file GModelTemporalConst.hpp.

Referenced by copy_members(), eval(), GModelTemporalConst(), init_members(), norm(), read(), and write().


The documentation for this class was generated from the following files: