46 #if defined(G_LEGACY_XML_FORMAT)
55 #define G_EVAL "GModelSpectralPlaw::eval(GEnergy&, GTime&, bool&)"
56 #define G_MC "GModelSpectralPlaw::mc(GEnergy&, GEnergy&, GTime&, GRan&)"
57 #define G_READ "GModelSpectralPlaw::read(GXmlElement&)"
58 #define G_WRITE "GModelSpectralPlaw::write(GXmlElement&)"
95 const std::string& prefactor,
96 const std::string& index,
97 const std::string& pivot) :
218 if (
this != &model) {
317 const GTime& srcTime,
318 const bool& gradients)
const
345 #if defined(G_NAN_CHECK)
347 std::string msg =
"Model value not a number:";
348 for (
int i = 0; i <
m_pars.size(); ++i) {
349 msg +=
" " +
m_pars[i]->name() +
"=";
352 msg +=
" srcEng=" + srcEng.
print();
353 msg +=
" srcTime=" + srcTime.
print();
477 if (
index() != -1.0) {
570 result.append(
"=== GModelSpectralPlaw ===");
575 for (
int i = 0; i <
size(); ++i) {
734 double eng = energy.
MeV();
759 if (
index() != -1.0) {
void update_eval_cache(const GEnergy &energy) const
Update eval precomputation cache.
virtual GModelSpectralPlaw & operator=(const GModelSpectralPlaw &model)
Assignment operator.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns Monte Carlo energy between [emin, emax].
const double & factor_gradient(void) const
Return parameter factor gradient.
double norm(const GVector &vector)
Computes vector norm.
virtual ~GModelSpectralPlaw(void)
Destructor.
const std::string & name(void) const
Return parameter name.
Random number generator class definition.
void warning(const std::string &origin, const std::string &message)
Emits warning.
Abstract spectral model base class.
double gradient(void) const
Return parameter gradient.
std::string m_type
Model type.
int size(void) const
Return number of parameters.
virtual GModelSpectral & operator=(const GModelSpectral &model)
Assignment operator.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
double m_last_log_e_norm
Last ln(E/Epivot) value.
void update_mc_cache(const GEnergy &emin, const GEnergy &emax) const
Update Monte Carlo pre computation cache.
std::vector< GModelPar * > m_pars
Parameter pointers.
Spectral model registry class definition.
double m_last_index
Last index parameter.
Random number generator class.
double MeV(void) const
Return energy in MeV.
double min(void) const
Return parameter minimum boundary.
double plaw_energy_flux(const double &emin, const double &emax, const double &epivot, const double &gamma)
Compute energy flux between two energies for a power law.
bool is_free(void) const
Signal if parameter is free.
Power law spectral model class.
bool is_notanumber(const double &x)
Signal if argument is not a number.
double m_last_power
Last power value.
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
double m_mc_exponent
Exponent (index+1)
virtual void clear(void)
Clear spectral power law model.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
virtual void read(const GXmlElement &xml)
Read model from XML element.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
void free(void)
Free a parameter.
GEnergy pivot(void) const
Return pivot energy.
void fix(void)
Fix a parameter.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
double m_last_e_norm
Last E/Epivot value.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void check_energy_interval(const std::string &origin, const GEnergy &emin, const GEnergy &emax)
Checks energy interval.
void clear(void)
Clear parameter.
Power law spectral model class interface definition.
double m_mc_emin
Minimum energy.
GModelSpectralPlaw(void)
Void constructor.
const GModelSpectralPlaw g_spectral_plaw_seed1("PowerLaw","Prefactor","Index","PivotEnergy")
std::string print(const GChatter &chatter=NORMAL) const
Print time.
virtual GModelSpectralPlaw * clone(void) const
Clone spectral power law model.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
Interface definition for the spectral model registry class.
void init_members(void)
Initialise class members.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between emin, emax
void autoscale(void)
Autoscale parameters.
GEnergy m_last_energy
Last energy value.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between emin, emax
double m_mc_pow_emin
Power of minimum energy.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print powerlaw information.
double m_last_pivot
Last pivot parameter.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
const std::string & unit(void) const
Return parameter unit.
GModelPar m_pivot
Pivot energy.
Exception handler interface definition.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate function.
double m_mc_pow_ewidth
Power of energy width.
double index(void) const
Return power law index.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
double m_mc_emax
Maximum energy.
virtual std::string type(void) const
Return model type.
GModelPar m_norm
Normalization factor.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
GModelPar m_index
Spectral index.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void free_members(void)
Delete class members.
double m_last_norm
Last norm parameter.
void clear(void)
Clear instance.
const double & factor_value(void) const
Return parameter factor value.
Class that handles energies in a unit independent way.
double plaw_photon_flux(const double &emin, const double &emax, const double &epivot, const double &gamma)
Compute photon flux between two energies for a power law.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
void copy_members(const GModelSpectralPlaw &model)
Copy class members.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.