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") {
666 result.append(
"=== GModelSpectralLogParabola ===");
671 for (
int i = 0; i <
size(); ++i) {
850 double eng = energy.
MeV();
874 const GTime& time)
const
901 index_pl = std::log(
eval(emin,time)/
eval(emax,time)) /
902 std::log(emin.
MeV()/emax.
MeV());
910 if (index_pl != -1.0) {
Exception handler interface definition.
Integration class interface definition.
const GModelSpectralLogParabola g_spectral_logp_seed1("LogParabola", "Prefactor", "Index", "PivotEnergy", "Curvature")
Log parabola spectral model class definition.
Spectral model registry class definition.
Random number generator class definition.
double norm(const GVector &vector)
Computes vector norm.
Class that handles energies in a unit independent way.
double MeV(void) const
Return energy in MeV.
void clear(void)
Clear instance.
GIntegral class interface definition.
void eps(const double &eps)
Set relative precision.
double romberg(std::vector< double > bounds, const int &order=5)
Perform Romberg integration.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
LogParabola spectral model class.
void free_members(void)
Delete class members.
double m_last_exponent
Last exponent.
virtual void write(GXmlElement &xml) const
Write model into XML element.
double m_last_e_norm
Last E/Epivot value.
void copy_members(const GModelSpectralLogParabola &model)
Copy class members.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns Monte Carlo energy between [emin, emax].
double m_last_index
Last index parameter.
void update_eval_cache(const GEnergy &energy) const
Update eval precomputation cache.
double index(void) const
Return spectral index.
virtual ~GModelSpectralLogParabola(void)
Destructor.
GModelPar m_norm
Normalization factor.
double m_last_power
Last power value.
double m_mc_emin
Minimum energy.
GModelSpectralLogParabola(void)
Void constructor.
GModelPar m_pivot
Pivot energy.
void update_mc_cache(const GEnergy &emin, const GEnergy &emax, const GTime &time) const
Update Monte Carlo pre computation cache.
double m_last_pivot
Last pivot parameter.
GEnergy m_last_energy
Last energy value.
double m_last_curvature
Last curvature parameters.
double m_mc_pow_ewidth
Power of energy width.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between [emin, emax] (units: erg/cm2/s)
virtual std::string type(void) const
Return model type.
virtual void clear(void)
Clear log parabola model.
double prefactor(void) const
Return pre factor.
double m_mc_exponent
Exponent (index+1)
virtual GModelSpectralLogParabola & operator=(const GModelSpectralLogParabola &model)
Assignment operator.
virtual void read(const GXmlElement &xml)
Read model from XML element.
double m_mc_norm
Norm of powerlaw model at logparabola pivot energy.
virtual GModelSpectralLogParabola * clone(void) const
Clone log parabola model.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate model.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print LogParabola information.
GModelPar m_index
Spectral index.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between [emin, emax] (units: ph/cm2/s)
void init_members(void)
Initialise class members.
double curvature(void) const
Return spectral curvature.
std::string m_type
Model type.
double m_mc_emax
Maximum energy.
GEnergy pivot(void) const
Return pivot energy.
double m_mc_pow_emin
Power of minimum energy.
GModelPar m_curvature
Curvature.
double m_last_log_e_norm
Last ln(E/Epivot) value.
Interface definition for the spectral model registry class.
Abstract spectral model base class.
void free_members(void)
Delete class members.
virtual GModelSpectral & operator=(const GModelSpectral &model)
Assignment operator.
std::vector< GModelPar * > m_pars
Parameter pointers.
void autoscale(void)
Autoscale parameters.
int size(void) const
Return number of parameters.
void init_members(void)
Initialise class members.
const double & factor_value(void) const
Return parameter factor value.
bool is_free(void) const
Signal if parameter is free.
void free(void)
Free a parameter.
const double & scale(void) const
Return parameter scale.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
const std::string & unit(void) const
Return parameter unit.
double max(void) const
Return parameter maximum boundary.
double min(void) const
Return parameter minimum boundary.
const double & factor_gradient(void) const
Return parameter factor gradient.
void fix(void)
Fix a parameter.
double gradient(void) const
Return parameter gradient.
void clear(void)
Clear parameter.
double value(void) const
Return parameter value.
const std::string & name(void) const
Return parameter name.
Random number generator class.
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.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
bool is_infinite(const double &x)
Signal if argument is infinite.
bool is_notanumber(const double &x)
Signal if argument is not a number.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
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.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
void xml_check_parnum(const std::string &origin, const GXmlElement &xml, const int &number)
Checks number of parameters.
bool xml_has_par(const GXmlElement &xml, const std::string &name)
Checks if parameter with given name in XML element exists.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.