49#if defined(G_LEGACY_XML_FORMAT)
60#define G_MC "GModelSpectralSuperExpPlaw::mc(GEnergy&, GEnergy&, GTime&,"\
62#define G_READ "GModelSpectralSuperExpPlaw::read(GXmlElement&)"
63#define G_WRITE "GModelSpectralSuperExpPlaw::write(GXmlElement&)"
103 const std::string& prefactor,
104 const std::string& index1,
105 const std::string& pivot,
106 const std::string& cutoff,
107 const std::string& index2) :
145 const double& index1,
148 const double& index2) :
239 if (
this != &model) {
356 const GTime& srcTime,
357 const bool& gradients)
const
399 #if defined(G_NAN_CHECK)
401 std::cout <<
"*** ERROR: GModelSpectralSuperExpPlaw::eval";
402 std::cout <<
"(srcEng=" << srcEng;
403 std::cout <<
", srcTime=" << srcTime <<
"):";
404 std::cout <<
" NaN/Inf encountered";
405 std::cout <<
" (value=" << value;
407 std::cout <<
")" << std::endl;
449 double e_min = emin.
MeV();
450 double e_max = emax.
MeV();
495 double e_min = emin.
MeV();
496 double e_max = emax.
MeV();
544 double acceptance_fraction;
552 double norm_emin = std::exp(- std::pow(emin.
MeV() * inv_ecut,
m_index2.
value()));
553 double norm_emax = std::exp(- std::pow(emax.
MeV() * inv_ecut,
m_index2.
value()));
554 double norm = (norm_emin > norm_emax) ? norm_emin : norm_emax;
557 #if defined(G_DEBUG_MC)
569 #if defined(G_DEBUG_MC)
593 acceptance_fraction = std::exp(- std::pow(eng * inv_ecut,
m_index2.
value()));
595 }
while (ran.
uniform() *
norm > acceptance_fraction);
601 #if defined(G_DEBUG_MC)
602 std::cout <<
"GModelSpectralSuperExpPlaw::mc(";
603 std::cout << emin.
print() <<
"," << emax.
print() <<
"," << time.
print() <<
"):";
604 std::cout <<
" energy=" << energy.
print();
605 std::cout <<
" samples=" << samples << std::endl;
690 result.append(
"=== GModelSpectralSuperExpPlaw ===");
695 for (
int i = 0; i <
size(); ++i) {
718 m_type =
"SuperExponentialCutoffPowerLaw";
891 double eng = energy.
MeV();
960 double exponent = std::pow(e_cut,
m_index2);
961 double power = std::pow(e_norm,
m_index1) * std::exp(-exponent);
962 double value =
m_norm * power;
977 double e_norm = energy * m_inv_pivot;
978 double e_cut = energy * m_inv_ecut;
979 double exponent = std::pow(e_cut,
m_index2);
980 double power = std::pow(e_norm,
m_index1) * std::exp(-exponent);
981 double value =
m_norm * power * energy;
Exception handler interface definition.
Integration class interface definition.
Spectral model registry class definition.
const GModelSpectralSuperExpPlaw g_spectral_seplaw_seed1("SuperExponentialCutoffPowerLaw", "Prefactor", "Index1", "PivotEnergy", "CutoffEnergy", "Index2")
Super exponential cut off power law spectral class interface 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.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
void clear(void)
Clear instance.
GIntegral class interface definition.
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.
Interface definition for the spectral model registry class.
double eval(const double &eng)
Kernel for energy flux integration.
double m_inv_pivot
1 / Pivot energy
double m_norm
Normalization.
double m_inv_ecut
1 / Cut off energy
double eval(const double &eng)
Kernel for photon flux integration.
Super exponential cut off power law spectral class.
virtual GModelSpectralSuperExpPlaw * clone(void) const
Clone super exponentially cut off power law model.
double prefactor(void) const
Return pre factor.
void update_eval_cache(const GEnergy &energy) const
Update eval precomputation cache.
double m_last_ecut
Last energy cut-off parameter.
virtual GModelSpectralSuperExpPlaw & operator=(const GModelSpectralSuperExpPlaw &model)
Assignment operator.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void init_members(void)
Initialise class members.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual ~GModelSpectralSuperExpPlaw(void)
Destructor.
double m_last_power
Last power value.
GEnergy cutoff(void) const
Return exponential cut-off energy.
GModelSpectralSuperExpPlaw(void)
Void constructor.
double m_mc_pow_ewidth
Power of energy width.
double m_mc_pow_emin
Power of minimum energy.
double m_mc_emin
Minimum energy.
void copy_members(const GModelSpectralSuperExpPlaw &model)
Copy class members.
GModelPar m_pivot
Pivot energy.
virtual void clear(void)
Clear exponentially cut off power law model.
GEnergy m_last_energy
Last energy value.
std::string m_type
Model type.
GModelPar m_index2
Index of cutoff.
double m_mc_emax
Maximum energy.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between [emin, emax] (units: ph/cm2/s)
double m_mc_exponent
Exponent (index+1)
void free_members(void)
Delete class members.
double m_last_pivot
Last pivot parameter.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns MC energy between [emin, emax].
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate function.
double index1(void) const
Return power law index.
double m_last_exponent
last pow(E/Ecut,index2) value
double m_last_index1
Last index1 parameter.
double index2(void) const
Return cut off index.
double m_last_e_cut
Last E/Ecut value.
GEnergy pivot(void) const
Return pivot energy.
GModelPar m_ecut
Exponential cut off energy.
double m_last_e_norm
Last E/Epivot value.
void update_mc_cache(const GEnergy &emin, const GEnergy &emax) const
Update Monte Carlo pre computation cache.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between [emin, emax] (units: erg/cm2/s)
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
GModelPar m_norm
Normalization factor.
GModelPar m_index1
Spectral index.
virtual std::string type(void) const
Return model type.
double m_last_index2
Last index2 parameter.
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 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.
std::string print(const GChatter &chatter=NORMAL) const
Print time.
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.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.