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;
285 double sigma2 = sigma *
sigma;
287 double term1 = norm * term2;
288 double term3 = delta * delta / (2.0 * sigma2);
289 double term4 = delta / sigma2;
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();
416 eflux = integral.romberg(e_min, e_max);
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);
const double & factor_gradient(void) const
Return parameter factor gradient.
double norm(const GVector &vector)
Computes vector norm.
virtual GModelSpectralGauss & operator=(const GModelSpectralGauss &model)
Assignment operator.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print spectral model information.
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.
int size(void) const
Return number of parameters.
virtual GModelSpectral & operator=(const GModelSpectral &model)
Assignment operator.
void write(GXmlElement &xml) const
Set or update parameter attributes in XML element.
double gauss_integral(const double &x1, const double &x2)
Returns the integral of a Gaussian function.
std::vector< GModelPar * > m_pars
Parameter pointers.
virtual GEnergy mc(const GEnergy &emin, const GEnergy &emax, const GTime &time, GRan &ran) const
Returns MC energy between [emin, emax].
const GModelSpectralGauss g_spectral_gauss_seed
virtual void clear(void)
Clear Gaussian spectral model.
Spectral model registry class definition.
Random number generator class.
double MeV(void) const
Return energy in MeV.
GIntegral class interface definition.
double eval(const double &eng)
Kernel for energy flux integration.
double min(void) const
Return parameter minimum boundary.
bool is_free(void) const
Signal if parameter is free.
GModelPar m_norm
Normalization factor.
Gaussian spectral model class.
virtual double eflux(const GEnergy &emin, const GEnergy &emax) const
Returns model energy flux between emin, emax
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 GModelSpectralGauss * clone(void) const
Clone Gaussian spectral model.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const
Evaluate model value.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void copy_members(const GModelSpectralGauss &model)
Copy class members.
Single parameter function abstract base class definition.
virtual void read(const GXmlElement &xml)
Read model from XML element.
void free(void)
Free a parameter.
virtual void write(GXmlElement &xml) const
Write model into 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 init_members(void)
Initialise class members.
void check_energy_interval(const std::string &origin, const GEnergy &emin, const GEnergy &emax)
Checks energy interval.
void clear(void)
Clear parameter.
GEnergy mean(void) const
Return mean energy.
GModelPar m_sigma
Gaussian energy width.
void free_members(void)
Delete class members.
virtual ~GModelSpectralGauss(void)
Destructor.
double norm(void) const
Return normalization.
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.
double normal(void)
Returns normal deviates.
void autoscale(void)
Autoscale parameters.
virtual double flux(const GEnergy &emin, const GEnergy &emax) const
Returns model photon flux between emin, emax
virtual std::string type(void) const
Return model type.
void init_members(void)
Initialise class members.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
double value(void) const
Return parameter value.
double m_norm
Normalization.
const std::string & unit(void) const
Return parameter unit.
GModelSpectralGauss(void)
Void constructor.
Exception handler interface definition.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Integration class interface definition.
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.
Gaussian spectral model class interface definition.
GModelPar m_mean
Gaussian mean energy.
GEnergy sigma(void) const
Return energy width.
Mathematical function definitions.
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.