GammaLib
2.1.0.dev
|
Exponential cut off power law spectral class. More...
#include <GModelSpectralExpInvPlaw.hpp>
Classes | |
class | eflux_kernel |
class | flux_kernel |
Public Member Functions | |
GModelSpectralExpInvPlaw (void) | |
Void constructor. More... | |
GModelSpectralExpInvPlaw (const std::string &type, const std::string &prefactor, const std::string &index, const std::string &pivot, const std::string &lambda) | |
Model type and parameter name constructor. More... | |
GModelSpectralExpInvPlaw (const double &prefactor, const double &index, const GEnergy &pivot, const double &lambda) | |
Constructor. More... | |
GModelSpectralExpInvPlaw (const double &prefactor, const double &index, const GEnergy &pivot, const GEnergy &cutoff) | |
Constructor (construct model via cut-off energy) More... | |
GModelSpectralExpInvPlaw (const GXmlElement &xml) | |
XML constructor. More... | |
GModelSpectralExpInvPlaw (const GModelSpectralExpInvPlaw &model) | |
Copy constructor. More... | |
virtual | ~GModelSpectralExpInvPlaw (void) |
Destructor. More... | |
virtual GModelSpectralExpInvPlaw & | operator= (const GModelSpectralExpInvPlaw &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear exponentially cut off power law model. More... | |
virtual GModelSpectralExpInvPlaw * | clone (void) const |
Clone exponentially cut off power law 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 MC 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 model information. More... | |
void | type (const std::string &type) |
Set model type. More... | |
double | prefactor (void) const |
Return pre factor. More... | |
void | prefactor (const double &prefactor) |
Set pre factor. More... | |
double | index (void) const |
Return power law index. More... | |
void | index (const double &index) |
Set power law index. More... | |
double | inverse_cutoff (void) const |
Return exponential cut-off parameter. More... | |
void | inverse_cutoff (const double &lambda) |
Set exponential cut-off parameter. More... | |
GEnergy | cutoff (void) const |
Return cut-off energy. More... | |
void | cutoff (const GEnergy &cutoff) |
Set exponential cut-off energy. More... | |
GEnergy | pivot (void) const |
Return pivot energy. More... | |
void | pivot (const GEnergy &pivot) |
Set pivot energy. 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 GModelSpectralExpInvPlaw &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
void | update_eval_cache (const GEnergy &energy) const |
Update eval precomputation cache. 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... | |
GModelPar | m_norm |
Normalization factor. More... | |
GModelPar | m_index |
Spectral index. More... | |
GModelPar | m_lambda |
Cut-off parameter. More... | |
GModelPar | m_pivot |
Pivot energy. More... | |
GEnergy | m_last_energy |
Last energy value. More... | |
double | m_last_index |
Last index parameter. More... | |
double | m_last_lambda |
Last cut-off parameter. More... | |
double | m_last_pivot |
Last pivot parameter. More... | |
double | m_last_e_norm |
Last E/Epivot value. More... | |
double | m_last_e_lambda |
Last E*lambda value. More... | |
double | m_last_power |
Last power value. More... | |
double | m_mc_emin |
Minimum energy. More... | |
double | m_mc_emax |
Maximum energy. More... | |
double | m_mc_exponent |
Exponent (index+1) More... | |
double | m_mc_pow_emin |
Power of minimum energy. More... | |
double | m_mc_pow_ewidth |
Power of energy width. More... | |
Protected Attributes inherited from GModelSpectral | |
std::vector< GModelPar * > | m_pars |
Parameter pointers. More... | |
Exponential cut off power law spectral class.
This class implements a power law spectrum with exponential cut off. The model is defined by
\[ S_{\rm E}(E | t) = {\tt m\_norm} \left( \frac{E}{\tt m\_pivot} \right)^{\tt m\_index} \exp \left( -{\tt m\_lambda}*E \right) \]
where
Definition at line 63 of file GModelSpectralExpInvPlaw.hpp.
GModelSpectralExpInvPlaw::GModelSpectralExpInvPlaw | ( | void | ) |
Void constructor.
Definition at line 72 of file GModelSpectralExpInvPlaw.cpp.
References init_members().
Referenced by clone().
GModelSpectralExpInvPlaw::GModelSpectralExpInvPlaw | ( | const std::string & | type, |
const std::string & | prefactor, | ||
const std::string & | index, | ||
const std::string & | pivot, | ||
const std::string & | lambda | ||
) |
Model type and parameter name constructor.
[in] | type | Model type. |
[in] | prefactor | Name of prefactor parameter. |
[in] | index | Name of index parameter. |
[in] | pivot | Name of pivot parameter. |
[in] | lambda | Name of cutoff parameter. |
Definition at line 91 of file GModelSpectralExpInvPlaw.cpp.
References init_members(), m_index, m_lambda, m_norm, m_pivot, m_type, GOptimizerPar::name(), and type().
GModelSpectralExpInvPlaw::GModelSpectralExpInvPlaw | ( | const double & | prefactor, |
const double & | index, | ||
const GEnergy & | pivot, | ||
const double & | lambda | ||
) |
Constructor.
[in] | prefactor | Pre factor normalization (ph/cm2/s/MeV). |
[in] | index | Power law index. |
[in] | pivot | Pivot energy. |
[in] | lambda | Cut-off parameter (1/MeV). |
Construct an exponentially cut off power law from
Definition at line 129 of file GModelSpectralExpInvPlaw.cpp.
References GModelSpectral::autoscale(), init_members(), m_index, m_lambda, m_norm, m_pivot, GEnergy::MeV(), and GOptimizerPar::value().
GModelSpectralExpInvPlaw::GModelSpectralExpInvPlaw | ( | const double & | prefactor, |
const double & | index, | ||
const GEnergy & | pivot, | ||
const GEnergy & | cutoff | ||
) |
Constructor (construct model via cut-off energy)
[in] | prefactor | Pre factor normalization (ph/cm2/s/MeV). |
[in] | index | Power law index. |
[in] | pivot | Pivot energy. |
[in] | cutoff | Cut-off energy. |
Construct an exponentially cut off power law from
Definition at line 166 of file GModelSpectralExpInvPlaw.cpp.
References GModelSpectral::autoscale(), init_members(), m_index, m_lambda, m_norm, m_pivot, GEnergy::MeV(), and GOptimizerPar::value().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Constructs an exponentially cut off power law spectral 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 198 of file GModelSpectralExpInvPlaw.cpp.
References init_members(), and read().
GModelSpectralExpInvPlaw::GModelSpectralExpInvPlaw | ( | const GModelSpectralExpInvPlaw & | model | ) |
Copy constructor.
[in] | model | Exponentially cut off power law model. |
Definition at line 217 of file GModelSpectralExpInvPlaw.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GModelSpectral.
Definition at line 196 of file GModelSpectralExpInvPlaw.hpp.
|
virtual |
Clear exponentially cut off power law model.
Implements GModelSpectral.
Definition at line 289 of file GModelSpectralExpInvPlaw.cpp.
References GModelSpectral::free_members(), free_members(), GModelSpectral::init_members(), and init_members().
|
virtual |
Clone exponentially cut off power law model.
Implements GModelSpectral.
Definition at line 309 of file GModelSpectralExpInvPlaw.cpp.
References GModelSpectralExpInvPlaw().
|
protected |
Copy class members.
[in] | model | Exponential cut off power law model. |
Definition at line 800 of file GModelSpectralExpInvPlaw.cpp.
References m_index, m_lambda, m_last_e_lambda, m_last_e_norm, m_last_energy, m_last_index, m_last_lambda, m_last_pivot, m_last_power, m_mc_emax, m_mc_emin, m_mc_exponent, m_mc_pow_emin, m_mc_pow_ewidth, m_norm, GModelSpectral::m_pars, m_pivot, and m_type.
Referenced by GModelSpectralExpInvPlaw(), and operator=().
|
inline |
Return cut-off energy.
Returns the exponential cut-off energy as derived from the cut-off parameter.
Definition at line 358 of file GModelSpectralExpInvPlaw.hpp.
References m_lambda, GEnergy::MeV(), and GOptimizerPar::value().
|
inline |
Set exponential cut-off energy.
[in] | cutoff | Exponential cut-off energy. |
Sets the exponential cut-off parameter from the cut-off energy.
Definition at line 374 of file GModelSpectralExpInvPlaw.hpp.
References m_lambda, GEnergy::MeV(), and GOptimizerPar::value().
Returns model energy flux between emin, emax
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
Computes
\[ \int_{\tt emin}^{\tt emax} S_{\rm E}(E | t) E \, dE \]
where
emin
, emax
] is an energy interval, andImplements GModelSpectral.
Definition at line 485 of file GModelSpectralExpInvPlaw.cpp.
References m_index, m_lambda, m_norm, m_pivot, GEnergy::MeV(), gammalib::MeV2erg, and GOptimizerPar::value().
|
virtual |
Evaluate function.
[in] | srcEng | True photon energy. |
[in] | srcTime | True photon arrival time. |
[in] | gradients | Compute gradients? |
Evaluates
\[ S_{\rm E}(E | t) = {\tt m\_norm} \left( \frac{E}{\tt m\_pivot} \right)^{\tt m\_index} \exp \left( -{\tt m\_lambda}*E \right) \]
where
If the gradients
flag is true the method will also compute the partial derivatives of the model with respect to the parameters using
\[ \frac{\delta S_{\rm E}(E | t)}{\delta {\tt m\_norm}} = \frac{S_{\rm E}(E | t)}{{\tt m\_norm}} \]
\[ \frac{\delta S_{\rm E}(E | t)}{\delta {\tt m\_index}} = S_{\rm E}(E | t) \, \ln(E/{\tt m_pivot}) \]
\[ \frac{\delta S_{\rm E}(E | t)}{\delta {\tt m\_lambda}} = S_{\rm E}(E | t) \, \left( -E \right) \]
\[ \frac{\delta S_{\rm E}(E | t)}{\delta {\tt m\_pivot}} = -S_{\rm E}(E | t) \, \left( \frac{{\tt m\_index}}{{\tt m\_pivot}} \right) \]
Implements GModelSpectral.
Definition at line 366 of file GModelSpectralExpInvPlaw.cpp.
References GOptimizerPar::factor_gradient(), GOptimizerPar::factor_value(), GOptimizerPar::is_free(), gammalib::is_infinite(), gammalib::is_notanumber(), log(), m_index, m_lambda, m_last_e_norm, m_last_energy, m_last_index, m_last_power, m_norm, m_pivot, GEnergy::MeV(), GOptimizerPar::scale(), update_eval_cache(), and GOptimizerPar::value().
Returns model photon flux between emin, emax
[in] | emin | Minimum photon energy. |
[in] | emax | Maximum photon energy. |
Computes
\[ \int_{\tt emin}^{\tt emax} S_{\rm E}(E | t) dE \]
where
emin
, emax
] is an energy interval, andImplements GModelSpectral.
Definition at line 439 of file GModelSpectralExpInvPlaw.cpp.
References m_index, m_lambda, m_norm, m_pivot, GEnergy::MeV(), and GOptimizerPar::value().
|
protected |
Delete class members.
Definition at line 840 of file GModelSpectralExpInvPlaw.cpp.
Referenced by clear(), operator=(), and ~GModelSpectralExpInvPlaw().
|
inline |
Return power law index.
Returns the power law index.
Definition at line 268 of file GModelSpectralExpInvPlaw.hpp.
References m_index, and GOptimizerPar::value().
Referenced by mc(), read(), update_eval_cache(), update_mc_cache(), and write().
|
inline |
Set power law index.
[in] | index | Power law index. |
Sets the power law index.
Definition at line 282 of file GModelSpectralExpInvPlaw.hpp.
References m_index, and GOptimizerPar::value().
|
protected |
Initialise class members.
Definition at line 719 of file GModelSpectralExpInvPlaw.cpp.
References GEnergy::clear(), GOptimizerPar::clear(), GOptimizerPar::fix(), GOptimizerPar::free(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_index, m_lambda, m_last_e_lambda, m_last_e_norm, m_last_energy, m_last_index, m_last_lambda, m_last_pivot, m_last_power, m_mc_emax, m_mc_emin, m_mc_exponent, m_mc_pow_emin, m_mc_pow_ewidth, m_norm, GModelSpectral::m_pars, m_pivot, m_type, GOptimizerPar::max(), GOptimizerPar::min(), GOptimizerPar::name(), GOptimizerPar::range(), GOptimizerPar::scale(), GOptimizerPar::unit(), and GOptimizerPar::value().
Referenced by clear(), GModelSpectralExpInvPlaw(), and operator=().
|
inline |
Return exponential cut-off parameter.
Returns the exponential cut-off parameter.
Definition at line 328 of file GModelSpectralExpInvPlaw.hpp.
References m_lambda, and GOptimizerPar::value().
|
inline |
Set exponential cut-off parameter.
[in] | lambda | Exponential cut-off parameter. |
Sets the exponential cut-off parameter.
Definition at line 342 of file GModelSpectralExpInvPlaw.hpp.
References m_lambda, and GOptimizerPar::value().
|
virtual |
Returns MC 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. |
GException::erange_invalid | Energy range is invalid (emin < emax required). |
Simulates a random energy in the interval [emin, emax] for an exponentially cut off power law. The simulation is done using a rejection method. First, a random energy within [emin, emax] is drawn from an power law distribution. Then the energy is accepted or rejected based on an acceptance fraction that is computed from the exponential cut off.
Implements GModelSpectral.
Definition at line 534 of file GModelSpectralExpInvPlaw.cpp.
References gammalib::check_energy_interval(), exp(), G_MC, index(), log(), m_lambda, m_mc_exponent, m_mc_pow_emin, m_mc_pow_ewidth, GEnergy::MeV(), norm(), GEnergy::print(), GTime::print(), GRan::uniform(), update_mc_cache(), and GOptimizerPar::value().
|
virtual |
Assignment operator.
[in] | model | Exponentially cut off power law model. |
Definition at line 256 of file GModelSpectralExpInvPlaw.cpp.
References copy_members(), free_members(), init_members(), and GModelSpectral::operator=().
|
inline |
Return pivot energy.
Returns the pivot energy.
Definition at line 297 of file GModelSpectralExpInvPlaw.hpp.
References m_pivot, GEnergy::MeV(), and GOptimizerPar::value().
Referenced by read(), update_eval_cache(), and write().
|
inline |
Set pivot energy.
[in] | pivot | Pivot energy. |
Sets the pivot energy.
Definition at line 313 of file GModelSpectralExpInvPlaw.hpp.
References m_pivot, GEnergy::MeV(), and GOptimizerPar::value().
|
inline |
Return pre factor.
Returns the pre factor.
Definition at line 239 of file GModelSpectralExpInvPlaw.hpp.
References m_norm, and GOptimizerPar::value().
|
inline |
Set pre factor.
[in] | prefactor | Pre factor (ph/cm2/s/MeV). |
Sets the pre factor.
Definition at line 253 of file GModelSpectralExpInvPlaw.hpp.
References m_norm, and GOptimizerPar::value().
Print model information.
[in] | chatter | Chattiness. |
Implements GModelSpectral.
Definition at line 685 of file GModelSpectralExpInvPlaw.cpp.
References GModelSpectral::m_pars, gammalib::parformat(), SILENT, GModelSpectral::size(), and gammalib::str().
|
virtual |
Read model from XML element.
[in] | xml | XML element containing power law model information. |
Reads the spectral information from an XML element.
Implements GModelSpectral.
Definition at line 628 of file GModelSpectralExpInvPlaw.cpp.
References G_READ, index(), m_index, m_lambda, m_norm, m_pivot, GOptimizerPar::name(), norm(), pivot(), GModelPar::read(), gammalib::xml_check_parnum(), and gammalib::xml_get_par().
Referenced by GModelSpectralExpInvPlaw().
|
inlinevirtual |
Return model type.
Returns the type of the exponentially cut off power law model.
Implements GModelSpectral.
Definition at line 210 of file GModelSpectralExpInvPlaw.hpp.
References m_type.
Referenced by GModelSpectralExpInvPlaw(), type(), and write().
|
inline |
Set model type.
[in] | type | Model type. |
Set the type of the exponentially cut off power law model.
Definition at line 224 of file GModelSpectralExpInvPlaw.hpp.
|
protected |
Update eval precomputation cache.
[in] | energy | Energy. |
Updates the precomputation cache for eval() method.
Definition at line 854 of file GModelSpectralExpInvPlaw.cpp.
References exp(), index(), m_index, m_lambda, m_last_e_lambda, m_last_e_norm, m_last_energy, m_last_index, m_last_lambda, m_last_pivot, m_last_power, m_pivot, GEnergy::MeV(), pivot(), pow(), and GOptimizerPar::value().
Referenced by eval().
|
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.
Definition at line 896 of file GModelSpectralExpInvPlaw.cpp.
References index(), log(), m_mc_emax, m_mc_emin, m_mc_exponent, m_mc_pow_emin, m_mc_pow_ewidth, GEnergy::MeV(), and pow().
Referenced by mc().
|
virtual |
Write model into XML element.
[in] | xml | XML element into which model information is written. |
Writes the spectral information into an XML element.
Implements GModelSpectral.
Definition at line 657 of file GModelSpectralExpInvPlaw.cpp.
References G_WRITE, index(), m_index, m_lambda, m_norm, m_pivot, GOptimizerPar::name(), norm(), pivot(), type(), GModelPar::write(), gammalib::xml_check_type(), and gammalib::xml_need_par().
|
protected |
Spectral index.
Definition at line 170 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), eflux(), eval(), GModelSpectralExpInvPlaw::eflux_kernel::eval(), flux(), GModelSpectralExpInvPlaw(), index(), init_members(), read(), update_eval_cache(), and write().
|
protected |
Cut-off parameter.
Definition at line 171 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), cutoff(), eflux(), eval(), GModelSpectralExpInvPlaw::eflux_kernel::eval(), flux(), GModelSpectralExpInvPlaw(), init_members(), inverse_cutoff(), mc(), read(), update_eval_cache(), and write().
|
mutableprotected |
Last E*lambda value.
Definition at line 180 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), init_members(), and update_eval_cache().
|
mutableprotected |
Last E/Epivot value.
Definition at line 179 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), eval(), init_members(), and update_eval_cache().
|
mutableprotected |
Last energy value.
Definition at line 175 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), eval(), init_members(), and update_eval_cache().
|
mutableprotected |
Last index parameter.
Definition at line 176 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), eval(), init_members(), and update_eval_cache().
|
mutableprotected |
Last cut-off parameter.
Definition at line 177 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), init_members(), and update_eval_cache().
|
mutableprotected |
Last pivot parameter.
Definition at line 178 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), init_members(), and update_eval_cache().
|
mutableprotected |
Last power value.
Definition at line 181 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), eval(), init_members(), and update_eval_cache().
|
mutableprotected |
Maximum energy.
Definition at line 183 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), init_members(), and update_mc_cache().
|
mutableprotected |
Minimum energy.
Definition at line 182 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), init_members(), and update_mc_cache().
|
mutableprotected |
Exponent (index+1)
Definition at line 184 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), init_members(), mc(), and update_mc_cache().
|
mutableprotected |
Power of minimum energy.
Definition at line 185 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), init_members(), mc(), and update_mc_cache().
|
mutableprotected |
Power of energy width.
Definition at line 186 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), init_members(), mc(), and update_mc_cache().
|
protected |
Normalization factor.
Definition at line 169 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), eflux(), eval(), GModelSpectralExpInvPlaw::eflux_kernel::eval(), flux(), GModelSpectralExpInvPlaw(), init_members(), prefactor(), read(), and write().
|
protected |
Pivot energy.
Definition at line 172 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), eflux(), eval(), flux(), GModelSpectralExpInvPlaw(), init_members(), pivot(), read(), update_eval_cache(), and write().
|
protected |
Model type.
Definition at line 168 of file GModelSpectralExpInvPlaw.hpp.
Referenced by copy_members(), GModelSpectralExpInvPlaw(), init_members(), and type().