52 #define G_READ "GCTAModelRadialPolynom::read(GXmlElement&)"
53 #define G_WRITE "GCTAModelRadialPolynom::write(GXmlElement&)"
94 for (
int i = 0; i < coeffs.size(); ++i) {
100 par.
value(coeffs[i]);
193 if (
this != &model) {
271 const bool& gradients)
const
283 value =
m_coeffs[ncoeffs-1].value();
284 for (
int i = ncoeffs-2; i >= 0; i--) {
285 value = value * offset +
m_coeffs[i].value();
292 double offset_power = 1.0;
295 for (
int i = 0; i < ncoeffs; ++i) {
298 double grad = offset_power *
m_coeffs[i].scale();
304 offset_power *= offset;
313 #if defined(G_NAN_CHECK)
315 std::cout <<
"*** ERROR: GCTAModelRadialPolynom::eval";
316 std::cout <<
"(offset=" << offset <<
"): NaN/Inf encountered";
317 std::cout <<
" (value=" << value;
318 for (
int i = 0; i < ncoeffs; ++i) {
319 std::cout <<
", c" << i <<
"=" <<
m_coeffs[i].value();
321 std::cout <<
")" << std::endl;
360 #if defined(G_DEBUG_MC)
374 value =
std::sin(offset * gammalib::deg2rad) *
eval(offset);
380 #if defined(G_DEBUG_MC)
387 #if defined(G_DEBUG_MC)
388 std::cout <<
"#=" << n_samples <<
" ";
392 double phi = 360.0 * ran.
uniform();
493 int max_coeffs = xml.
elements(
"parameter");
496 if (max_coeffs < 1) {
497 std::string msg =
"Radial polynomial model requires at least one "
498 "coefficient. Please verify the XML format.";
504 std::vector<int> npar;
505 npar.assign(max_coeffs, 0);
506 for (
int i = 0; i < max_coeffs; ++i) {
512 if (par->
attribute(
"name").compare(0,5,
"Coeff") != 0) {
513 std::string msg =
"Invalid parameter \""+par->
attribute(
"name")+
514 "\" encountered. Parameter name needs to start "
515 "with \"Coeff\". Please verify the XML format.";
521 size_t nchars = par->
attribute(
"name").length() - 5;
526 std::string msg =
"Radial polynomial \"Coeff\" parameter has no "
527 "index. Please verify the XML format.";
531 std::string msg =
"Radial polynomial \"Coeff\" parameter has "
533 "verify the XML format.";
536 if (index >= max_coeffs) {
538 " parameters, hence polynomial coefficients are "
539 "expected to run from 0 to "+
542 "encountered. Please verify the XML format.";
550 if (index+1 > ncoeffs) {
557 if (ncoeffs < 0 || ncoeffs > max_coeffs) {
558 std::string msg =
"Radial polynomial model requires between 1 and "+
560 "verify the XML format.";
565 for (
int i = 0; i < ncoeffs; ++i) {
568 "\" not found in XML file. Please verify the "
572 else if (npar[i] > 1) {
573 std::string msg =
"Multiple parameters \"Coeff"+
gammalib::str(i)+
574 "\" found in XML file. Please verify the XML "
581 for (
int i = 0; i < ncoeffs; ++i) {
588 for (
int k = 0; k < ncoeffs; ++k) {
590 if (element->
attribute(
"name") == name) {
599 std::string msg =
"Required parameter \""+name+
"\" not found. "
600 "Please verify the XML format.";
651 for (
int i = 0; i < ncoeffs; ++i) {
684 result.append(
"=== GCTAModelRadialPolynom ===");
689 for (
int i = 0; i <
size(); ++i) {
762 for (
int i = 0; i < ncoeffs; ++i) {
void free_members(void)
Delete class members.
virtual double omega(void) const
Returns integral over radial model (in steradians)
double romberg(std::vector< double > bounds, const int &order=5)
Perform Romberg integration.
Radial Polynom model class interface definition.
const std::string & name(void) const
Return parameter name.
Random number generator class definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print point source information.
void free_members(void)
Delete class members.
double gradient(void) const
Return parameter gradient.
virtual void write(GXmlElement &xml) const
Write model into XML element.
void copy_members(const GCTAModelRadialPolynom &model)
Copy class members.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
virtual double mc_max_value(const GCTAObservation &obs) const
Return maximum function value for Monte Carlo simulations.
Random number generator class.
void init_members(void)
Initialise class members.
const GCTAModelRadialPolynom g_cta_radial_polynom_seed
virtual int elements(void) const
Return number of GXMLElement children of node.
GIntegral class interface definition.
CTA radial model registry class definition.
Interface definition for the spatial model registry class.
void update_pars(void)
Update parameter mapping.
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 ~GCTAModelRadialPolynom(void)
Destructor.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
void init_members(void)
Initialise class members.
virtual GCTAInstDir mc(GRan &ran) const
Returns MC instrument direction.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
Radial Polynom CTA model class.
void free(void)
Free 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.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
CTA instrument direction class interface definition.
int size(void) const
Return number of model parameters.
GCTAModelRadialPolynom(void)
Void constructor.
CTA observation class interface definition.
virtual GCTAModelRadialPolynom & operator=(const GCTAModelRadialPolynom &model)
Assignment operator.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual void clear(void)
Clear instance.
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.
Interface definition for the CTA radial model registry class.
GVector sin(const GVector &vector)
Computes sine of vector elements.
Exception handler interface definition.
virtual std::string type(void) const
Return model type.
CTA instrument direction class.
int toint(const std::string &arg)
Convert string into integer value.
Abstract radial acceptance model class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::vector< GModelPar * > m_pars
Parameter pointers.
Integration class interface definition.
std::vector< GModelPar > m_coeffs
Coefficients.
virtual double eval(const double &offset, const bool &gradients=false) const
Evaluate function.
virtual GCTAModelRadial & operator=(const GCTAModelRadial &model)
Assignment operator.
Spatial model registry class definition.
virtual GCTAModelRadialPolynom * clone(void) const
Clone instance.
Mathematical function definitions.
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.
const double g_cta_radial_polynom_offset_max