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)
380 #if defined(G_DEBUG_MC)
387 #if defined(G_DEBUG_MC)
388 std::cout <<
"#=" << n_samples <<
" ";
392 double phi = 360.0 * ran.
uniform();
402 detx = offset * std::cos(phi);
403 dety = offset * std::sin(phi);
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) {
CTA instrument direction class interface definition.
const double g_cta_radial_polynom_offset_max
const GCTAModelRadialPolynom g_cta_radial_polynom_seed
Radial Polynom model class interface definition.
CTA radial model registry class definition.
Spatial model registry class definition.
CTA observation class interface definition.
Exception handler interface definition.
Integration class interface definition.
Mathematical function definitions.
Random number generator class definition.
CTA instrument direction class.
Radial Polynom CTA model class.
virtual double eval(const double &offset, const bool &gradients=false) const
Evaluate function.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual void clear(void)
Clear instance.
virtual double mc_max_value(const GCTAObservation &obs) const
Return maximum function value for Monte Carlo simulations.
std::vector< GModelPar > m_coeffs
Coefficients.
void free_members(void)
Delete class members.
void copy_members(const GCTAModelRadialPolynom &model)
Copy class members.
virtual GCTAModelRadialPolynom & operator=(const GCTAModelRadialPolynom &model)
Assignment operator.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual GCTAModelRadialPolynom * clone(void) const
Clone instance.
virtual GCTAInstDir mc(GRan &ran) const
Returns MC instrument direction.
virtual ~GCTAModelRadialPolynom(void)
Destructor.
GCTAModelRadialPolynom(void)
Void constructor.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print point source information.
void update_pars(void)
Update parameter mapping.
void init_members(void)
Initialise class members.
virtual std::string type(void) const
Return model type.
virtual double omega(void) const
Returns integral over radial model (in steradians)
Interface definition for the CTA radial model registry class.
Abstract radial acceptance model class.
virtual GCTAModelRadial & operator=(const GCTAModelRadial &model)
Assignment operator.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
Interface definition for the spatial model registry class.
std::vector< GModelPar * > m_pars
Parameter pointers.
int size(void) const
Return number of model parameters.
GIntegral class interface definition.
double romberg(std::vector< double > bounds, const int &order=5)
Perform Romberg integration.
void read(const GXmlElement &xml)
Extract parameter attributes from XML element.
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 gradient(void) const
Return parameter gradient.
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.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
virtual int elements(void) const
Return number of GXMLElement children of node.
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.
int toint(const std::string &arg)
Convert string into integer value.
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_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.