48 #if defined(G_LEGACY_XML_FORMAT)
64 #define G_FLUX "GModelSpectralLogParabola::flux(GEnergy&, GEnergy&)"
65 #define G_EFLUX "GModelSpectralLogParabola::eflux(GEnergy&, GEnergy&)"
66 #define G_MC "GModelSpectralLogParabola::mc(GEnergy&, GEnergy&, GTime&,"\
68 #define G_READ "GModelSpectralLogParabola::read(GXmlElement&)"
69 #define G_WRITE "GModelSpectralLogParabola::write(GXmlElement&)"
107 const std::string& prefactor,
108 const std::string& index,
109 const std::string& pivot,
110 const std::string& curvature) :
147 const double& curvature) :
237 if (
this != &model) {
344 const GTime& srcTime,
345 const bool& gradients)
const
377 #if defined(G_NAN_CHECK)
379 std::cout <<
"*** ERROR: GModelSpectralLogParabola::eval";
380 std::cout <<
"(srcEng=" << srcEng;
381 std::cout <<
", srcTime=" << srcTime <<
"):";
382 std::cout <<
" NaN/Inf encountered";
383 std::cout <<
" (value=" << value;
385 std::cout <<
")" << std::endl;
428 integral.
eps(1.0e-8);
474 integral.
eps(1.0e-8);
518 double acceptance_fraction;
555 acceptance_fraction = logparabola / plaw;
557 }
while (ran.
uniform() > acceptance_fraction);
623 if (inx.
name() ==
"alpha") {
628 if (crv.
name() ==
"beta") {
643 crv.
write(*curvature);
666 result.append(
"=== GModelSpectralLogParabola ===");
671 for (
int i = 0; i <
size(); ++i) {
850 double eng = energy.
MeV();
874 const GTime& time)
const
910 if (index_pl != -1.0) {
const double & factor_gradient(void) const
Return parameter factor gradient.
double norm(const GVector &vector)
Computes vector norm.
double romberg(std::vector< double > bounds, const int &order=5)
Perform Romberg integration.
const std::string & name(void) const
Return parameter name.
Random number generator class definition.
Abstract spectral model base class.
double m_mc_emax
Maximum energy.
GModelSpectralLogParabola(void)
Void constructor.
double gradient(void) const
Return parameter gradient.
int size(void) const
Return number of parameters.
virtual GModelSpectral & operator=(const GModelSpectral &model)
Assignment operator.
double m_mc_exponent
Exponent (index+1)
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
GModelPar m_index
Spectral index.
virtual void clear(void)
Clear log parabola model.
void copy_members(const GModelSpectralLogParabola &model)
Copy class members.
std::vector< GModelPar * > m_pars
Parameter pointers.
virtual GModelSpectralLogParabola * clone(void) const
Clone log parabola model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print LogParabola information.
double m_last_exponent
Last exponent.
Spectral model registry class definition.
double max(void) const
Return parameter maximum boundary.
void update_eval_cache(const GEnergy &energy) const
Update eval precomputation cache.
GEnergy pivot(void) const
Return pivot energy.
Random number generator class.
double MeV(void) const
Return energy in MeV.
GIntegral class interface definition.
LogParabola spectral model class.
double m_last_log_e_norm
Last ln(E/Epivot) value.
double min(void) const
Return parameter minimum boundary.
double m_last_curvature
Last curvature parameters.
bool is_free(void) const
Signal if parameter is free.
GModelPar m_pivot
Pivot energy.
virtual std::string type(void) const
Return model type.
bool is_notanumber(const double &x)
Signal if argument is not a number.
double prefactor(void) const
Return pre factor.
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void free(void)
Free a parameter.
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 curvature(void) const
Return spectral curvature.
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.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between emin, emax
void check_energy_interval(const std::string &origin, const GEnergy &emin, const GEnergy &emax)
Checks energy interval.
void clear(void)
Clear parameter.
void init_members(void)
Initialise class members.
GModelPar m_norm
Normalization factor.
virtual void read(const GXmlElement &xml)
Read model from XML element.
void free_members(void)
Delete class members.
std::string m_type
Model type.
double m_last_pivot
Last pivot parameter.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns Monte Carlo energy between [emin, emax].
Interface definition for the spectral model registry class.
GModelPar m_curvature
Curvature.
void autoscale(void)
Autoscale parameters.
double m_mc_emin
Minimum energy.
double m_mc_pow_emin
Power of minimum energy.
bool xml_has_par(const GXmlElement &xml, const std::string &name)
Checks if parameter with given name in XML element exists.
double index(void) const
Return spectral index.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate model.
double m_last_e_norm
Last E/Epivot value.
void eps(const double &eps)
Set relative precision.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between emin, emax
void init_members(void)
Initialise class members.
GEnergy m_last_energy
Last energy value.
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double m_last_index
Last index parameter.
double value(void) const
Return parameter value.
const std::string & unit(void) const
Return parameter unit.
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
double m_mc_pow_ewidth
Power of energy width.
Exception handler interface definition.
Log parabola spectral model class definition.
virtual ~GModelSpectralLogParabola(void)
Destructor.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
const GModelSpectralLogParabola g_spectral_logp_seed1("LogParabola","Prefactor","Index","PivotEnergy","Curvature")
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void update_mc_cache(const GEnergy &emin, const GEnergy &emax, const GTime &time) const
Update Monte Carlo pre computation cache.
Integration class interface definition.
virtual GModelSpectralLogParabola & operator=(const GModelSpectralLogParabola &model)
Assignment operator.
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.
void free_members(void)
Delete class members.
void clear(void)
Clear instance.
double m_last_power
Last power value.
double m_mc_norm
Norm of powerlaw model at logparabola pivot energy.
const double & factor_value(void) const
Return parameter factor value.
Class that handles energies in a unit independent way.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.