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();
453 flux = integral.romberg(e_min, e_max);
495 double e_min = emin.
MeV();
496 double e_max = emax.
MeV();
499 eflux = integral.romberg(e_min, e_max);
544 double acceptance_fraction;
554 double norm = (norm_emin > norm_emax) ? norm_emin : norm_emax;
557 #if defined(G_DEBUG_MC)
569 #if defined(G_DEBUG_MC)
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();
962 double value =
m_norm * power;
977 double e_norm = energy * m_inv_pivot;
978 double e_cut = energy * m_inv_ecut;
981 double value =
m_norm * power * energy;
const GModelSpectralSuperExpPlaw g_spectral_seplaw_seed1("SuperExponentialCutoffPowerLaw","Prefactor","Index1","PivotEnergy","CutoffEnergy","Index2")
void free_members(void)
Delete class members.
GModelPar m_index2
Index of cutoff.
const double & factor_gradient(void) const
Return parameter factor gradient.
double norm(const GVector &vector)
Computes vector norm.
double eval(const double &eng)
Kernel for energy flux integration.
GModelPar m_ecut
Exponential cut off energy.
const std::string & name(void) const
Return parameter name.
Random number generator class definition.
virtual void clear(void)
Clear exponentially cut off power law model.
Abstract spectral model base class.
void update_mc_cache(const GEnergy &emin, const GEnergy &emax) const
Update Monte Carlo pre computation cache.
double m_mc_emax
Maximum energy.
double gradient(void) const
Return parameter gradient.
double m_last_exponent
last pow(E/Ecut,index2) value
int size(void) const
Return number of parameters.
GEnergy pivot(void) const
Return pivot energy.
virtual GModelSpectral & operator=(const GModelSpectral &model)
Assignment operator.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between emin, emax
std::vector< GModelPar * > m_pars
Parameter pointers.
double m_last_index2
Last index2 parameter.
void update_eval_cache(const GEnergy &energy) const
Update eval precomputation cache.
double m_last_e_norm
Last E/Epivot value.
virtual std::string type(void) const
Return model type.
double m_mc_pow_ewidth
Power of energy width.
Spectral model registry class definition.
Random number generator class.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate function.
double MeV(void) const
Return energy in MeV.
GIntegral class interface definition.
void init_members(void)
Initialise class members.
double min(void) const
Return parameter minimum boundary.
bool is_free(void) const
Signal if parameter is free.
void copy_members(const GModelSpectralSuperExpPlaw &model)
Copy class members.
virtual void read(const GXmlElement &xml)
Read model from XML element.
bool is_notanumber(const double &x)
Signal if argument is not a number.
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
virtual GModelSpectralSuperExpPlaw * clone(void) const
Clone super exponentially cut off power law model.
virtual ~GModelSpectralSuperExpPlaw(void)
Destructor.
GEnergy m_last_energy
Last energy value.
Super exponential cut off power law spectral class interface definition.
std::string m_type
Model type.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print model information.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
virtual void write(GXmlElement &xml) const
Write model into XML element.
double m_mc_pow_emin
Power of minimum energy.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
void free(void)
Free a parameter.
GModelPar m_norm
Normalization factor.
void fix(void)
Fix a parameter.
double m_last_pivot
Last pivot 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.
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.
double m_mc_emin
Minimum energy.
void clear(void)
Clear parameter.
double eval(const double &eng)
Kernel for photon flux integration.
GModelSpectralSuperExpPlaw(void)
Void constructor.
std::string print(const GChatter &chatter=NORMAL) const
Print time.
double m_inv_pivot
1 / Pivot energy
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 autoscale(void)
Autoscale parameters.
GModelPar m_pivot
Pivot energy.
void init_members(void)
Initialise class members.
double m_inv_ecut
1 / Cut off energy
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 value(void) const
Return parameter value.
virtual GModelSpectralSuperExpPlaw & operator=(const GModelSpectralSuperExpPlaw &model)
Assignment operator.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between emin, emax
double m_last_e_cut
Last E/Ecut 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_last_ecut
Last energy cut-off parameter.
Exception handler interface definition.
Super exponential cut off power law spectral class.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
double m_norm
Normalization.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Integration class interface definition.
double m_last_power
Last power value.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns MC energy between [emin, emax].
double m_mc_exponent
Exponent (index+1)
GModelPar m_index1
Spectral index.
double index2(void) const
Return cut off index.
double m_last_index1
Last index1 parameter.
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.
double index1(void) const
Return power law index.
void clear(void)
Clear instance.
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.