#include <GModelSpectralPlaw2.hpp>
Inheritance diagram for GModelSpectralPlaw2:
Public Member Functions | |
GModelSpectralPlaw2 (void) | |
Void constructor. | |
GModelSpectralPlaw2 (const std::string &type, const std::string &integral, const std::string &index, const std::string &emin, const std::string &emax) | |
Model type and parameter name constructor. | |
GModelSpectralPlaw2 (const double &integral, const double &index, const GEnergy &emin, const GEnergy &emax) | |
Constructor. | |
GModelSpectralPlaw2 (const GXmlElement &xml) | |
XML constructor. | |
GModelSpectralPlaw2 (const GModelSpectralPlaw2 &model) | |
Copy constructor. | |
virtual | ~GModelSpectralPlaw2 (void) |
Destructor. | |
virtual GModelSpectralPlaw2 & | operator= (const GModelSpectralPlaw2 &model) |
Assignment operator. | |
virtual void | clear (void) |
Clear power law model. | |
virtual GModelSpectralPlaw2 * | clone (void) const |
Clone power law model. | |
virtual std::string | classname (void) const |
Return class name. | |
virtual std::string | type (void) const |
Return model type. | |
virtual double | eval (const GEnergy &srcEng, const GTime &srcTime=GTime()) const |
Evaluate function. | |
virtual double | eval_gradients (const GEnergy &srcEng, const GTime &srcTime=GTime()) |
Evaluate function and gradients. | |
virtual double | flux (const GEnergy &emin, const GEnergy &emax) const |
Returns model photon flux between [emin, emax] (units: ph/cm2/s). | |
virtual double | eflux (const GEnergy &emin, const GEnergy &emax) const |
Returns model energy flux between [emin, emax] (units: ph/cm2/s). | |
virtual GEnergy | mc (const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const |
Returns MC energy between [emin, emax]. | |
virtual void | read (const GXmlElement &xml) |
Read model from XML element. | |
virtual void | write (GXmlElement &xml) const |
Write model into XML element. | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print power law information. | |
double | integral (void) const |
Return integral flux. | |
void | integral (const double &integral) |
Set integral flux. | |
double | index (void) const |
Return power law index. | |
void | index (const double &index) |
Set power law index. | |
GEnergy | emin (void) const |
Return minimum energy. | |
void | emin (const GEnergy &emin) |
Set minimum energy. | |
GEnergy | emax (void) const |
Return maximum energy. | |
void | emax (const GEnergy &emax) |
Set maximum energy. | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. | |
void | copy_members (const GModelSpectralPlaw2 &model) |
Copy class members. | |
void | free_members (void) |
Delete class members. | |
void | update (const GEnergy &srcEng) const |
Update precomputed values. | |
Protected Attributes | |
std::string | m_type |
Model type. | |
GModelPar | m_integral |
Integral flux. | |
GModelPar | m_index |
Spectral index. | |
GModelPar | m_emin |
Lower energy limit (MeV). | |
GModelPar | m_emax |
Upper energy limit (MeV). | |
double | m_log_emin |
Log(emin). | |
double | m_log_emax |
Log(emax). | |
double | m_pow_emin |
emin^(index+1) | |
double | m_pow_emax |
emax^(index+1) | |
double | m_norm |
Power-law normalization (for pivot energy 1 MeV). | |
double | m_g_norm |
Power-law normalization gradient. | |
double | m_power |
Power-law factor. | |
double | m_last_integral |
Last integral flux. | |
double | m_last_index |
Last spectral index (MeV). | |
GEnergy | m_last_emin |
Last lower energy limit. | |
GEnergy | m_last_emax |
Last upper energy limit. | |
GEnergy | m_last_energy |
Last source energy. | |
double | m_last_value |
Last function value. | |
double | m_last_g_integral |
Last integral flux gradient. | |
double | m_last_g_index |
Last spectral index gradient. |
This class implements a power law spectrum. The model is defined by
for and
for , where
Definition at line 73 of file GModelSpectralPlaw2.hpp.
GModelSpectralPlaw2::GModelSpectralPlaw2 | ( | void | ) |
Void constructor.
Constructs empty power law photon flux model.
Definition at line 82 of file GModelSpectralPlaw2.cpp.
References init_members().
Referenced by clone().
GModelSpectralPlaw2::GModelSpectralPlaw2 | ( | const std::string & | type, | |
const std::string & | integral, | |||
const std::string & | index, | |||
const std::string & | emin, | |||
const std::string & | emax | |||
) |
Model type and parameter name constructor.
[in] | type | Model type. |
[in] | integral | Name of integral parameter. |
[in] | index | Name of index parameter. |
[in] | emin | Name of emin parameter. |
[in] | emax | Name of emax parameter. |
Definition at line 101 of file GModelSpectralPlaw2.cpp.
References init_members(), m_emax, m_emin, m_index, m_integral, m_type, and GOptimizerPar::name().
GModelSpectralPlaw2::GModelSpectralPlaw2 | ( | const double & | integral, | |
const double & | index, | |||
const GEnergy & | emin, | |||
const GEnergy & | emax | |||
) |
Constructor.
[in] | integral | Integral flux (ph/cm2/s). |
[in] | index | Power law index. |
[in] | emin | Minimum energy. |
[in] | emax | Maximum energy. |
Definition at line 139 of file GModelSpectralPlaw2.cpp.
References emax(), emin(), init_members(), m_emax, m_emin, m_index, m_integral, GEnergy::MeV(), and GOptimizerPar::value().
GModelSpectralPlaw2::GModelSpectralPlaw2 | ( | const GXmlElement & | xml | ) | [explicit] |
XML constructor.
[in] | xml | XML element. |
Definition at line 168 of file GModelSpectralPlaw2.cpp.
References init_members(), and read().
GModelSpectralPlaw2::GModelSpectralPlaw2 | ( | const GModelSpectralPlaw2 & | model | ) |
Copy constructor.
[in] | model | Spectral power law model. |
Definition at line 187 of file GModelSpectralPlaw2.cpp.
References copy_members(), and init_members().
GModelSpectralPlaw2::~GModelSpectralPlaw2 | ( | void | ) | [virtual] |
std::string GModelSpectralPlaw2::classname | ( | void | ) | const [inline, virtual] |
Return class name.
Implements GModelSpectral.
Definition at line 164 of file GModelSpectralPlaw2.hpp.
void GModelSpectralPlaw2::clear | ( | void | ) | [virtual] |
Clear power law model.
Implements GModelSpectral.
Definition at line 259 of file GModelSpectralPlaw2.cpp.
References GModelSpectral::free_members(), free_members(), init_members(), and GModelSpectral::init_members().
GModelSpectralPlaw2 * GModelSpectralPlaw2::clone | ( | void | ) | const [virtual] |
Clone power law model.
Implements GModelSpectral.
Definition at line 279 of file GModelSpectralPlaw2.cpp.
References GModelSpectralPlaw2().
void GModelSpectralPlaw2::copy_members | ( | const GModelSpectralPlaw2 & | model | ) | [protected] |
Copy class members.
[in] | model | Spectral power law model. |
Definition at line 823 of file GModelSpectralPlaw2.cpp.
References m_emax, m_emin, m_index, m_integral, m_last_emax, m_last_emin, m_last_energy, m_last_g_index, m_last_g_integral, m_last_index, m_last_integral, m_last_value, m_log_emax, m_log_emin, m_norm, GModelSpectral::m_pars, m_pow_emax, m_pow_emin, m_power, and m_type.
Referenced by GModelSpectralPlaw2(), and operator=().
Returns model energy flux between [emin, emax] (units: ph/cm2/s).
[in] | emin | Minimum photon energy. |
[in] | emax | Minimum photon energy. |
where
emin
, emax
] is an energy interval, andImplements GModelSpectral.
Definition at line 534 of file GModelSpectralPlaw2.cpp.
References emax(), emin(), index(), log(), m_index, m_integral, GEnergy::MeV(), gammalib::MeV2erg, norm(), pow(), and GOptimizerPar::value().
void GModelSpectralPlaw2::emax | ( | const GEnergy & | emax | ) | [inline] |
Set maximum energy.
[in] | emax | Maximum energy. |
Definition at line 299 of file GModelSpectralPlaw2.hpp.
References emax(), m_emax, GEnergy::MeV(), and GOptimizerPar::value().
GEnergy GModelSpectralPlaw2::emax | ( | void | ) | const [inline] |
Return maximum energy.
Definition at line 283 of file GModelSpectralPlaw2.hpp.
References m_emax, GEnergy::MeV(), and GOptimizerPar::value().
Referenced by eflux(), emax(), flux(), GModelSpectralPlaw2(), mc(), read(), update(), and write().
void GModelSpectralPlaw2::emin | ( | const GEnergy & | emin | ) | [inline] |
Set minimum energy.
[in] | emin | Minimum energy. |
Definition at line 268 of file GModelSpectralPlaw2.hpp.
References emin(), m_emin, GEnergy::MeV(), and GOptimizerPar::value().
GEnergy GModelSpectralPlaw2::emin | ( | void | ) | const [inline] |
Return minimum energy.
Definition at line 252 of file GModelSpectralPlaw2.hpp.
References m_emin, GEnergy::MeV(), and GOptimizerPar::value().
Referenced by eflux(), emin(), flux(), GModelSpectralPlaw2(), mc(), read(), update(), and write().
double GModelSpectralPlaw2::eval | ( | const GEnergy & | srcEng, | |
const GTime & | srcTime = GTime() | |||
) | const [virtual] |
Evaluate function.
[in] | srcEng | True photon energy. |
[in] | srcTime | True photon arrival time. |
for and
for , where
Implements GModelSpectral.
Definition at line 319 of file GModelSpectralPlaw2.cpp.
References integral(), gammalib::is_infinite(), gammalib::is_notanumber(), m_integral, m_norm, m_power, update(), and GOptimizerPar::value().
double GModelSpectralPlaw2::eval_gradients | ( | const GEnergy & | srcEng, | |
const GTime & | srcTime = GTime() | |||
) | [virtual] |
Evaluate function and gradients.
[in] | srcEng | True photon energy. |
[in] | srcTime | True photon arrival time. |
for and
for , where
The method also evaluates the partial derivatives of the model with respect to the parameters using
for and
for .
No partial derivatives are supported for the energy boundaries.
Implements GModelSpectral.
Definition at line 411 of file GModelSpectralPlaw2.cpp.
References GOptimizerPar::factor_gradient(), GOptimizerPar::factor_value(), integral(), GOptimizerPar::is_free(), gammalib::is_infinite(), gammalib::is_notanumber(), gammalib::ln10, GEnergy::log10MeV(), m_g_norm, m_index, m_integral, m_norm, m_power, GOptimizerPar::scale(), update(), and GOptimizerPar::value().
Returns model photon flux between [emin, emax] (units: ph/cm2/s).
[in] | emin | Minimum photon energy. |
[in] | emax | Minimum photon energy. |
where
emin
, emax
] is an energy interval, andImplements GModelSpectral.
Definition at line 478 of file GModelSpectralPlaw2.cpp.
References emax(), emin(), index(), log(), m_index, m_integral, GEnergy::MeV(), pow(), and GOptimizerPar::value().
void GModelSpectralPlaw2::free_members | ( | void | ) | [protected] |
Delete class members.
Reimplemented from GModelSpectral.
Definition at line 863 of file GModelSpectralPlaw2.cpp.
Referenced by clear(), operator=(), and ~GModelSpectralPlaw2().
void GModelSpectralPlaw2::index | ( | const double & | index | ) | [inline] |
Set power law index.
[in] | index | Power law index. |
Definition at line 237 of file GModelSpectralPlaw2.hpp.
References m_index, and GOptimizerPar::value().
double GModelSpectralPlaw2::index | ( | void | ) | const [inline] |
Return power law index.
Definition at line 223 of file GModelSpectralPlaw2.hpp.
References m_index, and GOptimizerPar::value().
Referenced by eflux(), flux(), mc(), read(), update(), and write().
void GModelSpectralPlaw2::init_members | ( | void | ) | [protected] |
Initialise class members.
Reimplemented from GModelSpectral.
Definition at line 742 of file GModelSpectralPlaw2.cpp.
References GOptimizerPar::clear(), GOptimizerPar::fix(), GOptimizerPar::free(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_emax, m_emin, m_index, m_integral, m_last_emax, m_last_emin, m_last_energy, m_last_g_index, m_last_g_integral, m_last_index, m_last_integral, m_last_value, m_log_emax, m_log_emin, m_norm, GModelSpectral::m_pars, m_pow_emax, m_pow_emin, m_power, m_type, GEnergy::MeV(), GOptimizerPar::name(), GOptimizerPar::range(), GOptimizerPar::scale(), GOptimizerPar::unit(), and GOptimizerPar::value().
Referenced by clear(), GModelSpectralPlaw2(), and operator=().
void GModelSpectralPlaw2::integral | ( | const double & | integral | ) | [inline] |
Set integral flux.
[in] | integral | Integral flux (ph/cm2/s). |
Definition at line 206 of file GModelSpectralPlaw2.hpp.
References m_integral, and GOptimizerPar::value().
double GModelSpectralPlaw2::integral | ( | void | ) | const [inline] |
Return integral flux.
Definition at line 192 of file GModelSpectralPlaw2.hpp.
References m_integral, and GOptimizerPar::value().
Referenced by eval(), eval_gradients(), read(), and write().
GEnergy GModelSpectralPlaw2::mc | ( | const GEnergy & | emin, | |
const GEnergy & | emax, | |||
const GTime & | time, | |||
GRan & | ran | |||
) | const [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). |
Implements GModelSpectral.
Definition at line 596 of file GModelSpectralPlaw2.cpp.
References emax(), emin(), exp(), G_MC, index(), log(), GEnergy::MeV(), pow(), and GRan::uniform().
GModelSpectralPlaw2 & GModelSpectralPlaw2::operator= | ( | const GModelSpectralPlaw2 & | model | ) | [virtual] |
Assignment operator.
[in] | model | Spectral power law model. |
Definition at line 226 of file GModelSpectralPlaw2.cpp.
References copy_members(), free_members(), init_members(), and GModelSpectral::operator=().
std::string GModelSpectralPlaw2::print | ( | const GChatter & | chatter = NORMAL |
) | const [virtual] |
Print power law information.
[in] | chatter | Chattiness (defaults to NORMAL). |
Implements GModelSpectral.
Definition at line 708 of file GModelSpectralPlaw2.cpp.
References GModelSpectral::m_pars, gammalib::parformat(), SILENT, GModelSpectral::size(), and gammalib::str().
void GModelSpectralPlaw2::read | ( | const GXmlElement & | xml | ) | [virtual] |
Read model from XML element.
[in] | xml | XML element. |
Implements GModelSpectral.
Definition at line 643 of file GModelSpectralPlaw2.cpp.
References emax(), emin(), G_READ, index(), integral(), m_emax, m_emin, m_index, m_integral, GOptimizerPar::name(), GModelPar::read(), and gammalib::xml_get_par().
Referenced by GModelSpectralPlaw2().
std::string GModelSpectralPlaw2::type | ( | void | ) | const [inline, virtual] |
Return model type.
Implements GModelSpectral.
Definition at line 178 of file GModelSpectralPlaw2.hpp.
References m_type.
Referenced by write().
void GModelSpectralPlaw2::update | ( | const GEnergy & | srcEng | ) | const [protected] |
Update precomputed values.
[in] | srcEng | Source energy |
Definition at line 875 of file GModelSpectralPlaw2.cpp.
References emax(), emin(), index(), log(), m_g_norm, m_last_emax, m_last_emin, m_last_energy, m_last_index, m_log_emax, m_log_emin, m_norm, m_pow_emax, m_pow_emin, m_power, GEnergy::MeV(), and pow().
Referenced by eval(), and eval_gradients().
void GModelSpectralPlaw2::write | ( | GXmlElement & | xml | ) | const [virtual] |
Write model into XML element.
[in] | xml | XML element. |
GException::model_invalid_spectral | Existing XML element is not of type "PowerLaw2" |
Implements GModelSpectral.
Definition at line 672 of file GModelSpectralPlaw2.cpp.
References GXmlElement::attribute(), emax(), emin(), G_WRITE, index(), integral(), m_emax, m_emin, m_index, m_integral, GOptimizerPar::name(), type(), GModelPar::write(), and gammalib::xml_need_par().
GModelPar GModelSpectralPlaw2::m_emax [protected] |
Upper energy limit (MeV).
Definition at line 137 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), emax(), GModelSpectralPlaw2(), init_members(), read(), and write().
GModelPar GModelSpectralPlaw2::m_emin [protected] |
Lower energy limit (MeV).
Definition at line 136 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), emin(), GModelSpectralPlaw2(), init_members(), read(), and write().
double GModelSpectralPlaw2::m_g_norm [mutable, protected] |
Power-law normalization gradient.
Definition at line 145 of file GModelSpectralPlaw2.hpp.
Referenced by eval_gradients(), and update().
GModelPar GModelSpectralPlaw2::m_index [protected] |
Spectral index.
Definition at line 135 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), eflux(), eval_gradients(), flux(), GModelSpectralPlaw2(), index(), init_members(), read(), and write().
GModelPar GModelSpectralPlaw2::m_integral [protected] |
Integral flux.
Definition at line 134 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), eflux(), eval(), eval_gradients(), flux(), GModelSpectralPlaw2(), init_members(), integral(), read(), and write().
GEnergy GModelSpectralPlaw2::m_last_emax [mutable, protected] |
Last upper energy limit.
Definition at line 150 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), init_members(), and update().
GEnergy GModelSpectralPlaw2::m_last_emin [mutable, protected] |
Last lower energy limit.
Definition at line 149 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), init_members(), and update().
GEnergy GModelSpectralPlaw2::m_last_energy [mutable, protected] |
Last source energy.
Definition at line 151 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), init_members(), and update().
double GModelSpectralPlaw2::m_last_g_index [mutable, protected] |
Last spectral index gradient.
Definition at line 154 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), and init_members().
double GModelSpectralPlaw2::m_last_g_integral [mutable, protected] |
Last integral flux gradient.
Definition at line 153 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), and init_members().
double GModelSpectralPlaw2::m_last_index [mutable, protected] |
Last spectral index (MeV).
Definition at line 148 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), init_members(), and update().
double GModelSpectralPlaw2::m_last_integral [mutable, protected] |
Last integral flux.
Definition at line 147 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), and init_members().
double GModelSpectralPlaw2::m_last_value [mutable, protected] |
Last function value.
Definition at line 152 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), and init_members().
double GModelSpectralPlaw2::m_log_emax [mutable, protected] |
Log(emax).
Definition at line 141 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), init_members(), and update().
double GModelSpectralPlaw2::m_log_emin [mutable, protected] |
Log(emin).
Definition at line 140 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), init_members(), and update().
double GModelSpectralPlaw2::m_norm [mutable, protected] |
Power-law normalization (for pivot energy 1 MeV).
Definition at line 144 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), eval(), eval_gradients(), init_members(), and update().
double GModelSpectralPlaw2::m_pow_emax [mutable, protected] |
emax^(index+1)
Definition at line 143 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), init_members(), and update().
double GModelSpectralPlaw2::m_pow_emin [mutable, protected] |
emin^(index+1)
Definition at line 142 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), init_members(), and update().
double GModelSpectralPlaw2::m_power [mutable, protected] |
Power-law factor.
Definition at line 146 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), eval(), eval_gradients(), init_members(), and update().
std::string GModelSpectralPlaw2::m_type [protected] |
Model type.
Definition at line 133 of file GModelSpectralPlaw2.hpp.
Referenced by copy_members(), GModelSpectralPlaw2(), init_members(), and type().