47#define G_FLUX "GModelSpectralGauss::flux(GEnergy&, GEnergy&)"
48#define G_EFLUX "GModelSpectralGauss::eflux(GEnergy&, GEnergy&)"
49#define G_MC "GModelSpectralGauss::mc(GEnergy&, GEnergy&, GRan&)"
50#define G_READ "GModelSpectralGauss::read(GXmlElement&)"
51#define G_WRITE "GModelSpectralGauss::write(GXmlElement&)"
177 if (
this != &model) {
274 const GTime& srcTime,
275 const bool& gradients)
const
278 double energy = srcEng.
MeV();
284 double delta = energy -
mean;
287 double term1 =
norm * term2;
288 double term3 = delta * delta / (2.0 * sigma2);
289 double term4 = delta / sigma2;
291 double eterm3 = std::exp(-term3);
294 double value = term1 * eterm3;
306 ? -term5 * eterm3 * (1.0 - (2.0 * term3)) *
m_sigma.
scale()
317 #if defined(G_NAN_CHECK)
319 std::cout <<
"*** ERROR: GModelSpectralGauss::eval";
320 std::cout <<
"(srcEng=" << srcEng;
321 std::cout <<
", srcTime=" << srcTime <<
"):";
322 std::cout <<
" NaN/Inf encountered";
323 std::cout <<
" (value=" << value;
324 std::cout <<
")" << std::endl;
361 double energy_min = emin.
MeV();
362 double energy_max = emax.
MeV();
366 double zmin = (energy_min -
mean) /
sigma;
367 double zmax = (energy_max -
mean) /
sigma;
412 double e_min = emin.
MeV();
413 double e_max = emax.
MeV();
457 double xmax = emax.
MeV();
458 double xmin = emin.
MeV();
467 double val = ran.
normal();
472 }
while (energy < xmin || energy > xmax);
564 result.append(
"=== GModelSpectralGauss ===");
569 for (
int i = 0; i <
size(); ++i) {
675 double delta = energy -
m_mean;
678 double value = term1 * std::exp(- term2);
Exception handler interface definition.
Single parameter function abstract base class definition.
Integration class interface definition.
Mathematical function definitions.
const GModelSpectralGauss g_spectral_gauss_seed
Gaussian spectral model class interface 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.
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.
double m_norm
Normalization.
double eval(const double &eng)
Kernel for energy flux integration.
Gaussian spectral model class.
GModelPar m_sigma
Gaussian energy width.
GEnergy mean(void) const
Return mean energy.
GModelPar m_norm
Normalization factor.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between [emin, emax] (ph/cm2/s)
virtual ~GModelSpectralGauss(void)
Destructor.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print spectral model information.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns MC energy between [emin, emax].
void init_members(void)
Initialise class members.
virtual void clear(void)
Clear Gaussian spectral model.
GModelPar m_mean
Gaussian mean energy.
GModelSpectralGauss(void)
Void constructor.
void copy_members(const GModelSpectralGauss &model)
Copy class members.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate model value.
void free_members(void)
Delete class members.
virtual GModelSpectralGauss * clone(void) const
Clone Gaussian spectral model.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual std::string type(void) const
Return model type.
double norm(void) const
Return normalization.
virtual GModelSpectralGauss & operator=(const GModelSpectralGauss &model)
Assignment operator.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between [emin, emax] (erg/cm2/s)
GEnergy sigma(void) const
Return energy width.
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.
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.
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.
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 normal(void)
Returns normal deviates.
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.
double gauss_integral(const double &x1, const double &x2)
Returns the integral of a Gaussian function.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.