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) {
CTA instrument direction class interface definition.
const GCTAModelSpatialMultiplicative g_cta_spatial_multi_seed
Multiplicative spatial model class interface definition.
Spatial model registry class definition.
CTA observation class interface definition.
CTA region of interest class interface definition.
Energy value class definition.
Exception handler interface definition.
Mathematical function definitions.
#define G_COMPONENT_INDEX
Random number generator class definition.
Time class interface definition.
XML element node class interface definition.
CTA instrument direction class.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print instrument direction information.
Multiplicative spatial model class.
virtual GCTAModelSpatialMultiplicative & operator=(const GCTAModelSpatialMultiplicative &model)
Assignment operator.
int components(void) const
Return number of spatial components.
void init_members(void)
Initialise class members.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print multiplicative spatial model information.
void append(const GCTAModelSpatial &spatial, const std::string &name="")
Append spatial component.
virtual void clear(void)
Clear instance.
std::vector< GCTAModelSpatial * > m_spatial
Container of spatial models.
const GCTAModelSpatial * component(const int &index) const
Return spatial model component by index.
std::string m_type
Model type.
void copy_members(const GCTAModelSpatialMultiplicative &model)
Copy class members.
virtual double eval(const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
Evaluate function (in units of sr^-1)
virtual double mc_max_value(const GCTAObservation &obs) const
Return maximum function value for Monte Carlo simulations.
virtual std::string type(void) const
Return model type.
virtual void write(GXmlElement &xml) const
Write model into XML element.
GCTAModelSpatialMultiplicative(void)
Void constructor.
void free_members(void)
Delete class members.
virtual GCTAModelSpatialMultiplicative * clone(void) const
Clone instance.
std::vector< std::string > m_components
Names of components.
virtual void read(const GXmlElement &xml)
Read model from XML element.
virtual ~GCTAModelSpatialMultiplicative(void)
Destructor.
Interface definition for the spatial model registry class.
GCTAModelSpatial * alloc(const GXmlElement &xml) const
Allocate spatial model that is found in XML element.
Abstract spatial model class.
void init_members(void)
Initialise class members.
std::vector< GModelPar * > m_pars
Parameter pointers.
int size(void) const
Return number of model parameters.
virtual GCTAModelSpatial & operator=(const GCTAModelSpatial &model)
Assignment operator.
virtual void write(GXmlElement &xml) const =0
void free_members(void)
Delete class members.
virtual GCTAModelSpatial * clone(void) const =0
Clones object.
Class that handles energies in a unit independent way.
double gradient(void) const
Return parameter gradient.
const std::string & name(void) const
Return parameter name.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
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.
bool contains(const std::string &str, const std::string &substring)
Checks if a substring is in a string.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.