GammaLib
2.0.0
|
Exponential spectral model class. More...
#include <GModelSpectralExponential.hpp>
Classes | |
class | eflux_kern |
class | flux_kern |
Public Member Functions | |
GModelSpectralExponential (void) | |
Void constructor. More... | |
GModelSpectralExponential (const GXmlElement &xml) | |
XML constructor. More... | |
GModelSpectralExponential (const GModelSpectral *spec) | |
Model constructor. More... | |
GModelSpectralExponential (const GModelSpectralExponential &model) | |
Copy constructor. More... | |
virtual | ~GModelSpectralExponential (void) |
Destructor. More... | |
virtual GModelSpectralExponential & | operator= (const GModelSpectralExponential &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear Exponential spectral model. More... | |
virtual GModelSpectralExponential * | clone (void) const |
Clone Exponential spectral model 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 GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const |
Evaluate function. More... | |
virtual double | flux (const GEnergy &emin, const GEnergy &emax) const |
Returns model photon flux between emin, emax More... | |
virtual double | eflux (const GEnergy &emin, const GEnergy &emax) const |
Returns model energy flux between emin, emax More... | |
virtual GEnergy | mc (const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const |
Returns Monte Carlo energy between [emin, emax]. 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 Exponential spectral model information. More... | |
void | exponent (const GModelSpectral *spec) |
Set exponent. More... | |
const GModelSpectral * | exponent (void) const |
Return exponent. More... | |
Public Member Functions inherited from GModelSpectral | |
GModelSpectral (void) | |
Void constructor. More... | |
GModelSpectral (const GModelSpectral &model) | |
Copy constructor. More... | |
virtual | ~GModelSpectral (void) |
Destructor. More... | |
virtual GModelSpectral & | operator= (const GModelSpectral &model) |
Assignment operator. More... | |
virtual GModelPar & | operator[] (const int &index) |
Returns model parameter. More... | |
virtual const GModelPar & | operator[] (const int &index) const |
Returns model parameter (const version) More... | |
virtual GModelPar & | operator[] (const std::string &name) |
Returns reference to model parameter. More... | |
virtual const GModelPar & | operator[] (const std::string &name) const |
Returns reference to model parameter (const version) More... | |
GModelPar & | at (const int &index) |
Returns model parameter. More... | |
const GModelPar & | at (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 GModelSpectralExponential &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | update_mc_cache (const GEnergy &emin, const GEnergy &emax) const |
Update Monte Carlo pre computation cache. More... | |
Protected Member Functions inherited from GModelSpectral | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GModelSpectral &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
std::string | m_type |
Model type. More... | |
GModelSpectral * | m_exponent |
Exponent model component. More... | |
GModelSpectralNodes | m_mc_spectrum |
MC spectrum cache. More... | |
GEnergy | m_mc_emin |
Last minimum energy. More... | |
GEnergy | m_mc_emax |
Last maximum energy. More... | |
std::vector< double > | m_mc_values |
Parameter values. More... | |
Protected Attributes inherited from GModelSpectral | |
std::vector< GModelPar * > | m_pars |
Parameter pointers. More... | |
Exponential spectral model class.
This class implements a spectral model that is the exponential of a spectral model component. The spectral model component can be defined in an XML file, or using the exponent() method.
Definition at line 53 of file GModelSpectralExponential.hpp.
GModelSpectralExponential::GModelSpectralExponential | ( | void | ) |
Void constructor.
Definition at line 62 of file GModelSpectralExponential.cpp.
References init_members().
Referenced by clone().
|
explicit |
XML constructor.
[in] | xml | XML element containing spectral model information. |
Constructs an exponential spectral model by extracting information from an XML element.
Definition at line 81 of file GModelSpectralExponential.cpp.
References init_members(), and read().
|
explicit |
Model constructor.
[in] | spec | Spectral model |
Constructs exponential spectral model by setting the exponent model.
Definition at line 102 of file GModelSpectralExponential.cpp.
References exponent(), and init_members().
GModelSpectralExponential::GModelSpectralExponential | ( | const GModelSpectralExponential & | model | ) |
Copy constructor.
[in] | model | Exponential spectral model. |
Definition at line 121 of file GModelSpectralExponential.cpp.
References copy_members(), and init_members().
|
virtual |
Destructor.
Definition at line 138 of file GModelSpectralExponential.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GModelSpectral.
Definition at line 144 of file GModelSpectralExponential.hpp.
|
virtual |
Clear Exponential spectral model.
Implements GModelSpectral.
Definition at line 193 of file GModelSpectralExponential.cpp.
References free_members(), GModelSpectral::free_members(), init_members(), and GModelSpectral::init_members().
|
virtual |
Clone Exponential spectral model model.
Implements GModelSpectral.
Definition at line 213 of file GModelSpectralExponential.cpp.
References GModelSpectralExponential().
|
protected |
Copy class members.
[in] | model | Exponential spectral model. |
Definition at line 603 of file GModelSpectralExponential.cpp.
References exponent(), m_exponent, m_mc_emax, m_mc_emin, m_mc_spectrum, m_mc_values, and m_type.
Referenced by GModelSpectralExponential(), and operator=().
|
virtual |
Returns model energy flux between emin, emax
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
Computes the energy flux of Exponential spectral model
Implements GModelSpectral.
Definition at line 343 of file GModelSpectralExponential.cpp.
References GIntegral::eps(), m_exponent, GEnergy::MeV(), and GIntegral::romberg().
|
virtual |
Evaluate function.
[in] | srcEng | True photon energy. |
[in] | srcTime | True photon arrival time. |
[in] | gradients | Compute gradients? |
Evaluates
\[ \exp{M}(\rm srcEng, srcTime) \]
where \({M}\) is the exponent model component.
If the gradients
flag is true the method will also compute the partial derivatives of each parameter with respect to the parameters using
\[ \frac{\delta S}{\delta P_{\rm i}}\exp{M} \]
where \({P_{\rm i}}\) is the i-th parameter.
Implements GModelSpectral.
Definition at line 245 of file GModelSpectralExponential.cpp.
References GModelSpectral::eval(), exp(), GOptimizerPar::gradient(), gammalib::is_infinite(), gammalib::is_notanumber(), m_exponent, and GModelSpectral::size().
Referenced by update_mc_cache().
void GModelSpectralExponential::exponent | ( | const GModelSpectral * | spec | ) |
Set exponent.
[in] | spec | Spectral model to use as exponent. |
Set a spectral model as exponent
Definition at line 501 of file GModelSpectralExponential.cpp.
References GModelSpectral::clone(), m_exponent, GModelSpectral::m_pars, and GModelSpectral::size().
const GModelSpectral * GModelSpectralExponential::exponent | ( | void | ) | const |
Return exponent.
Returns pointer to exponent spectral model
Definition at line 530 of file GModelSpectralExponential.cpp.
References m_exponent.
Referenced by copy_members(), GModelSpectralExponential(), and read().
Returns model photon flux between emin, emax
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
Computes the photon flux of Exponential spectral model
Implements GModelSpectral.
Definition at line 305 of file GModelSpectralExponential.cpp.
References GIntegral::eps(), m_exponent, GEnergy::MeV(), and GIntegral::romberg().
|
protected |
Delete class members.
Definition at line 627 of file GModelSpectralExponential.cpp.
References m_exponent.
Referenced by clear(), operator=(), and ~GModelSpectralExponential().
|
protected |
Initialise class members.
Definition at line 579 of file GModelSpectralExponential.cpp.
References GEnergy::clear(), GModelSpectralNodes::clear(), m_exponent, m_mc_emax, m_mc_emin, m_mc_spectrum, m_mc_values, and m_type.
Referenced by clear(), GModelSpectralExponential(), and operator=().
|
virtual |
Returns Monte Carlo energy between [emin, emax].
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
[in] | time | True photon arrival time. |
[in,out] | ran | Random number generator. |
Returns Monte Carlo energy by randomly drawing from a Exponential spectral model.
Implements GModelSpectral.
Definition at line 384 of file GModelSpectralExponential.cpp.
References gammalib::check_energy_interval(), G_MC, m_exponent, m_mc_spectrum, GModelSpectralNodes::mc(), and update_mc_cache().
|
virtual |
Assignment operator.
[in] | model | Exponential spectral model. |
Definition at line 160 of file GModelSpectralExponential.cpp.
References copy_members(), free_members(), init_members(), and GModelSpectral::operator=().
Print Exponential spectral model information.
[in] | chatter | Chattiness. |
Implements GModelSpectral.
Definition at line 543 of file GModelSpectralExponential.cpp.
References GModelSpectral::m_pars, gammalib::parformat(), SILENT, GModelSpectral::size(), and gammalib::str().
|
virtual |
Read model from XML element.
[in] | xml | XML element. |
Reads the spectral information from an XML element. The XML element shall have the following format
<spectrum type="Exponential"> <spectrum type="Constant"> <parameter name="Normalization" scale="1" value="1" min="0" max="2" free="1"/> </spectrum> </spectrum>
Implements GModelSpectral.
Definition at line 424 of file GModelSpectralExponential.cpp.
References GModelSpectralRegistry::alloc(), GXmlNode::element(), GXmlNode::elements(), and exponent().
Referenced by GModelSpectralExponential().
|
inlinevirtual |
Return model type.
Returns the type of the spectral Multiplicative model.
Implements GModelSpectral.
Definition at line 158 of file GModelSpectralExponential.hpp.
References m_type.
Referenced by write().
|
protected |
Update Monte Carlo pre computation cache.
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
Updates the precomputation cache for Monte Carlo simulations. In case that the energy boundaries have changed or at least one of the model parameters has changed the method computes a spectral node function which has 100 nodes per decade containing the Exponential spectral model values and stores that into a Monte Carlo cache. This cache is then used by the mc() method for simulations.
Definition at line 653 of file GModelSpectralExponential.cpp.
References GModelSpectralNodes::append(), GModelSpectralNodes::clear(), eval(), GEnergy::log10MeV(), m_mc_emax, m_mc_emin, m_mc_spectrum, m_mc_values, GModelSpectral::m_pars, GEnergies::size(), and GModelSpectral::size().
Referenced by mc().
|
virtual |
Write model into XML element.
[in] | xml | XML element. |
Writes the spectral information into an XML element. The XML element will have the following format:
<spectrum type="Exponential"> <spectrum type="Constant"> <parameter name="Normalization" scale="1" value="1" min="0" max="2" free="1"/> </spectrum> </spectrum>
If no exponential model component is defined the method writes the following XML structure
<spectrum type="Exponential"> </spectrum>
Implements GModelSpectral.
Definition at line 473 of file GModelSpectralExponential.cpp.
References GXmlNode::append(), GXmlNode::element(), G_WRITE, m_exponent, type(), GModelSpectral::write(), and gammalib::xml_check_type().
|
protected |
Exponent model component.
Definition at line 128 of file GModelSpectralExponential.hpp.
Referenced by copy_members(), eflux(), eval(), exponent(), flux(), free_members(), init_members(), mc(), and write().
|
mutableprotected |
Last maximum energy.
Definition at line 133 of file GModelSpectralExponential.hpp.
Referenced by copy_members(), init_members(), and update_mc_cache().
|
mutableprotected |
Last minimum energy.
Definition at line 132 of file GModelSpectralExponential.hpp.
Referenced by copy_members(), init_members(), and update_mc_cache().
|
mutableprotected |
MC spectrum cache.
Definition at line 131 of file GModelSpectralExponential.hpp.
Referenced by copy_members(), init_members(), mc(), and update_mc_cache().
|
mutableprotected |
Parameter values.
Definition at line 134 of file GModelSpectralExponential.hpp.
Referenced by copy_members(), init_members(), and update_mc_cache().
|
protected |
Model type.
Definition at line 127 of file GModelSpectralExponential.hpp.
Referenced by copy_members(), init_members(), and type().