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();
Smoothly broken power law spectrum class definition.
const GModelSpectralSmoothBrokenPlaw g_spectral_sblaw_seed1("SmoothBrokenPowerLaw","Prefactor","Index1","PivotEnergy","Index2","BreakEnergy","BreakSmoothness")
double m_last_ebreak_pow
Last pow(E/Ebreakenergy,(index1-index2)/beta)
GModelPar m_beta
Break smoothness.
void init_members(void)
Initialise class members.
const GModelSpectralSmoothBrokenPlaw g_spectral_sblaw_seed2("SmoothBrokenPowerLaw","Prefactor","Index1","Scale","Index2","BreakValue","Beta")
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 gradient(void) const
Return parameter gradient.
GModelPar m_norm
Normalization factor.
GModelPar m_breakenergy
Energy of spectral break.
int size(void) const
Return number of parameters.
virtual GModelSpectral & operator=(const GModelSpectral &model)
Assignment operator.
virtual ~GModelSpectralSmoothBrokenPlaw(void)
Destructor.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
std::vector< GModelPar * > m_pars
Parameter pointers.
double prefactor(void) const
Return pre factor.
Spectral model registry class definition.
double m_last_ebreak_norm
Last E/Ebreakenergy value.
double m_mc_index1
Last first index.
Random number generator class.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between emin, emax
double MeV(void) const
Return energy in MeV.
Smoothly broken power law spectral model class.
GIntegral class interface definition.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate function.
double m_last_pivot
Last pivot parameter.
void free_members(void)
Delete class members.
double min(void) const
Return parameter minimum boundary.
double m_last_beta
Last beta parameter.
bool is_free(void) const
Signal if parameter is free.
void copy_members(const GModelSpectralSmoothBrokenPlaw &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_epivot_norm
Last E/Epivot value.
bool is_notanumber(const double &x)
Signal if argument is not a number.
double m_last_index1
Last index1 parameter.
const double & scale(void) const
Return parameter scale.
bool is_infinite(const double &x)
Signal if argument is infinite.
double m_last_log_epivot_norm
Last ln(E/Epivot) value.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
double index1(void) const
Return smoothly broken power law index1.
void free(void)
Free a parameter.
double m_last_epivot_pow
Last pow(E/Epivot,index1) value.
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.
GModelSpectralSmoothBrokenPlaw(void)
Void constructor.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns Monte Carlo energy between [emin, emax].
double m_mc_index2
Last second index.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print smooth broken powerlaw information.
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.
void clear(void)
Clear parameter.
GModelPar m_pivot
Pivot energy.
virtual GModelSpectralSmoothBrokenPlaw * clone(void) const
Clone smoothly broken power law model.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual GModelSpectralSmoothBrokenPlaw & operator=(const GModelSpectralSmoothBrokenPlaw &model)
Assignment operator.
Broken power law spectral model class.
GEnergy pivot(void) const
Return 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.
virtual void clear(void)
Clear smoothly broken power law model.
void autoscale(void)
Autoscale parameters.
double index2(void) const
Return smoothly broken power law index2.
GEnergy breakenergy(void) const
Return breakenergy energy.
void eps(const double &eps)
Set relative precision.
std::string m_type
Model type.
void init_members(void)
Initialise class members.
virtual std::string type(void) const
Return model type.
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.
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_log_ebreak_norm
Last ln(E/Ebreakenergy) value.
Exception handler interface definition.
double beta(void) const
Returns break smoothness parameter beta.
GModelPar m_index2
Spectral index2.
double m_mc_breakenergy
Last break energy.
double m_last_breakenergy
Last breakenergy parameter.
GModelSpectralBrokenPlaw m_mc_brokenplaw
Broken power plaw.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate function.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between emin, emax
GEnergy m_last_energy
Last energy value.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
double m_last_index2
Last index2 parameter.
virtual void write(GXmlElement &xml) const
Write model into XML element.
Integration class interface definition.
double m_mc_pivot
Last pivot energy.
void update_eval_cache(const GEnergy &energy) const
Update eval precomputation cache.
double m_mc_prefactor
Last pre factor.
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 update_mc_cache(void) const
Update Monte Carlo pre computation cache.
GModelPar m_index1
Spectral index1.
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.