61#define G_MC "GModelSpectralSmoothBrokenPlaw::mc(GEnergy&, GEnergy&, GTime&,"\
63#define G_READ "GModelSpectralSmoothBrokenPlaw::read(GXmlElement&)"
64#define G_WRITE "GModelSpectralSmoothBrokenPlaw::write(GXmlElement&)"
105 const std::string& type,
106 const std::string& prefactor,
107 const std::string& index1,
108 const std::string& pivot,
109 const std::string& index2,
110 const std::string& breakenergy,
111 const std::string& beta) :
152 const double& prefactor,
153 const double& index1,
155 const double& index2,
157 const double& beta) :
251 if (
this != &model) {
381 const GTime& srcTime,
382 const bool& gradients)
const
438 #if defined(G_NAN_CHECK)
440 std::cout <<
"*** ERROR: GModelSpectralSmoothBrokenPlaw::eval";
441 std::cout <<
"(srcEng=" << srcEng;
442 std::cout <<
", srcTime=" << srcTime <<
"):";
443 std::cout <<
" NaN/Inf encountered";
444 std::cout <<
" (value=" << value;
457 std::cout <<
")" << std::endl;
501 integral.
eps(1.0e-8);
548 integral.
eps(1.0e-8);
590 double acceptance_fraction(0.0);
604 }
while (ran.
uniform() > acceptance_fraction);
692 result.append(
"=== GModelSpectralSmoothBrokenPlaw ===");
697 for (
int i = 0; i <
size(); ++i) {
720 m_type =
"SmoothBrokenPowerLaw";
915 double eng = energy.
MeV();
Exception handler interface definition.
Integration class interface definition.
Spectral model registry class definition.
const GModelSpectralSmoothBrokenPlaw g_spectral_sblaw_seed2("SmoothBrokenPowerLaw", "Prefactor", "Index1", "Scale", "Index2", "BreakValue", "Beta")
const GModelSpectralSmoothBrokenPlaw g_spectral_sblaw_seed1("SmoothBrokenPowerLaw", "Prefactor", "Index1", "PivotEnergy", "Index2", "BreakEnergy", "BreakSmoothness")
Smoothly broken power law spectrum 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.
Broken power law spectral model class.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate function.
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.
Smoothly broken power law spectral model class.
GModelPar m_index1
Spectral index1.
void copy_members(const GModelSpectralSmoothBrokenPlaw &model)
Copy class members.
GEnergy breakenergy(void) const
Return breakenergy energy.
double index1(void) const
Return smoothly broken power law index1.
double m_last_log_epivot_norm
Last ln(E/Epivot) value.
double m_last_epivot_norm
Last E/Epivot value.
double m_mc_prefactor
Last pre factor.
virtual GModelSpectralSmoothBrokenPlaw * clone(void) const
Clone smoothly broken power law model.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns Monte Carlo energy between [emin, emax].
double beta(void) const
Returns break smoothness parameter beta.
double m_mc_breakenergy
Last break energy.
double m_last_beta
Last beta parameter.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate function.
double m_last_pivot
Last pivot parameter.
virtual std::string type(void) const
Return model type.
GEnergy m_last_energy
Last energy value.
GEnergy pivot(void) const
Return pivot energy.
double index2(void) const
Return smoothly broken power law index2.
double m_last_epivot_pow
Last pow(E/Epivot,index1) value.
virtual void read(const GXmlElement &xml)
Read model from XML element.
double m_last_breakenergy
Last breakenergy parameter.
double m_last_ebreak_norm
Last E/Ebreakenergy value.
double prefactor(void) const
Return pre factor.
double m_mc_index2
Last second index.
GModelPar m_index2
Spectral index2.
void update_eval_cache(const GEnergy &energy) const
Update eval precomputation cache.
GModelPar m_breakenergy
Energy of spectral break.
void init_members(void)
Initialise class members.
double m_mc_pivot
Last pivot energy.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print smooth broken powerlaw information.
GModelSpectralSmoothBrokenPlaw(void)
Void constructor.
GModelPar m_pivot
Pivot energy.
GModelPar m_beta
Break smoothness.
double m_last_index2
Last index2 parameter.
virtual ~GModelSpectralSmoothBrokenPlaw(void)
Destructor.
virtual void clear(void)
Clear smoothly broken power law model.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between [emin, emax] (units: ph/cm2/s)
void update_mc_cache(void) const
Update Monte Carlo pre computation cache.
double m_last_log_ebreak_norm
Last ln(E/Ebreakenergy) value.
double m_mc_index1
Last first index.
void free_members(void)
Delete class members.
GModelPar m_norm
Normalization factor.
double m_last_ebreak_pow
Last pow(E/Ebreakenergy,(index1-index2)/beta)
double m_last_index1
Last index1 parameter.
std::string m_type
Model type.
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] (units: erg/cm2/s)
GModelSpectralBrokenPlaw m_mc_brokenplaw
Broken power plaw.
virtual GModelSpectralSmoothBrokenPlaw & operator=(const GModelSpectralSmoothBrokenPlaw &model)
Assignment operator.
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.
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.