52 #define G_READ "GCTAModelSpatialMultiplicative::read(GXmlElement&)"
53 #define G_WRITE "GCTAModelSpatialMultiplicative::write(GXmlElement&)"
54 #define G_COMPONENT_INDEX "GCTAModelSpatialMultiplicative::component(int&)"
55 #define G_COMPONENT_NAME "GCTAModelSpatialMultiplicative::component"\
57 #define G_APPEND "GCTAModelSpatialMultiplicative::append(GCTAModelSpatial&, "\
157 if (
this != &model) {
225 const bool& gradients)
const
234 std::vector<double> values(
m_spatial.size(), 0.0);
237 for (
int i = 0; i <
m_spatial.size(); ++i) {
238 values[i] =
m_spatial[i]->eval(dir, energy, time, gradients);
251 for (
int i = 0; i <
m_spatial.size(); ++i) {
257 for (
int j = 0; j <
m_spatial.size(); ++j) {
264 for (
int ipar = 0; ipar <
m_spatial[i]->size(); ++ipar) {
281 #if defined(G_NAN_CHECK)
283 std::cout <<
"*** ERROR: GCTAModelSpatialMultiplicative::eval";
284 std::cout <<
"(dir=" << dir.
print();
285 std::cout <<
", energy=" << energy;
286 std::cout <<
", time=" << time <<
"):";
287 std::cout <<
" NaN/Inf encountered";
288 std::cout <<
" (value=" << value;
289 std::cout <<
")" << std::endl;
310 for (
int i = 0; i <
m_spatial.size(); ++i) {
311 value *=
m_spatial[i]->mc_max_value(obs);
329 int n_spatials = xml.
elements(
"spatialModel");
332 for (
int i = 0; i < n_spatials; ++i) {
344 std::string component_name = spatial->
attribute(
"component");
347 append(*ptr, component_name);
372 for (
int i = 0; i <
m_spatial.size(); i++) {
389 for (
int j = 0; j < cpy->
size(); ++j) {
393 std::string parname = par.
name();
409 cpy->
write(*spatial);
440 const std::string& name)
449 std::string component_name = !name.empty() ? name
454 std::string msg =
"Attempt to append component with name \""+
455 component_name+
"\" to multiplicative spatial model "
456 "container, but a component with the same name exists "
457 "already. Every component in the container needs a "
458 "unique name. On default the system will increment "
459 "an integer if no component name is provided.";
470 for (
int ipar = 0; ipar < npars; ++ipar) {
476 par->
name(component_name+
":"+par->
name());
502 if (index >=
m_spatial.size() || index < 0) {
536 std::string msg =
"Model component \""+name+
"\" not found in "
537 "multiplicative spatial model.";
561 result.append(
"=== GCTAModelSpatialMultiplicative ===");
570 for (
int i = 0; i <
size(); ++i) {
593 m_type =
"Multiplicative";
617 for (
int i = 0; i < model.
components(); ++i) {
623 for (
int i = 0; i < model.
components(); ++i) {
629 for (
int ipar = 0; ipar < spatial->
size(); ++ipar) {
632 GModelPar& par = spatial->operator[](ipar);
650 for (
int i = 0; i <
m_spatial.size(); ++i) {
const GCTAModelSpatialMultiplicative g_cta_spatial_multi_seed
bool contains(const std::string &str, const std::string &substring)
Checks if a substring is in a string.
void free_members(void)
Delete class members.
Abstract spatial model class.
int components(void) const
Return number of spatial components.
Energy value class definition.
const std::string & name(void) const
Return parameter name.
Random number generator class definition.
XML element node class interface definition.
virtual void clear(void)
Clear instance.
double gradient(void) const
Return parameter gradient.
Multiplicative spatial model class.
virtual void write(GXmlElement &xml) const =0
virtual GCTAModelSpatial & operator=(const GCTAModelSpatial &model)
Assignment operator.
const GCTAModelSpatial * component(const int &index) const
Return spatial model component by index.
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
void copy_members(const GCTAModelSpatialMultiplicative &model)
Copy class members.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
virtual int elements(void) const
Return number of GXMLElement children of node.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual double mc_max_value(const GCTAObservation &obs) const
Return maximum function value for Monte Carlo simulations.
Interface definition for the spatial model registry class.
bool is_notanumber(const double &x)
Signal if argument is not a number.
std::vector< std::string > m_components
Names of components.
bool is_infinite(const double &x)
Signal if argument is infinite.
virtual void read(const GXmlElement &xml)
Read model from XML element.
Multiplicative spatial model class interface definition.
std::string m_type
Model type.
void init_members(void)
Initialise class members.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print multiplicative spatial model information.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
void free_members(void)
Delete class members.
virtual GCTAModelSpatialMultiplicative & operator=(const GCTAModelSpatialMultiplicative &model)
Assignment operator.
void init_members(void)
Initialise class members.
CTA instrument direction class interface definition.
virtual GCTAModelSpatialMultiplicative * clone(void) const
Clone instance.
int size(void) const
Return number of model parameters.
virtual ~GCTAModelSpatialMultiplicative(void)
Destructor.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print instrument direction information.
#define G_COMPONENT_INDEX
CTA region of interest class interface definition.
CTA observation class interface definition.
virtual std::string type(void) const
Return model type.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
void append(const GCTAModelSpatial &spatial, const std::string &name="")
Append spatial component.
GCTAModelSpatialMultiplicative(void)
Void constructor.
Exception handler interface definition.
CTA instrument direction class.
GCTAModelSpatial * alloc(const GXmlElement &xml) const
Allocate spatial model that is found in XML element.
virtual GCTAModelSpatial * clone(void) const =0
Clones object.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::vector< GModelPar * > m_pars
Parameter pointers.
std::vector< GCTAModelSpatial * > m_spatial
Container of spatial models.
Time class interface definition.
Spatial model registry class definition.
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.