45#define G_READ "GModelSpatialComposite::read(GXmlElement&)"
46#define G_WRITE "GModelSpatialComposite::write(GXmlElement&)"
47#define G_APPEND "GModelSpatialComposite::append(GModelSpatial&, "\
48 "std::string&, GModelPar&)"
49#define G_COMPONENT_INDEX "GModelSpatialComposite::component(int&)"
50#define G_COMPONENT_NAME "GModelSpatialComposite::component(std::string&)"
51#define G_NAME "GModelSpatialComposite::name(int&) const"
52#define G_SCALE "GModelSpatialComposite::scale(int&) const"
99 const std::string& type) :
183 if (
this != &model) {
252 const bool& gradients)
const
320 for (
int i = 0; i <
m_scales.size(); ++i) {
351 const double& margin)
const
354 bool containment =
false;
380 int n_comp = xml.
elements(
"spatialModel");
383 for (
int i = 0; i < n_comp; ++i) {
452 std::string arg = xml.
attribute(
"normalize");
490 for (
int k = 0; k < spatial->
size(); ++k) {
498 int found =
name.find(
":");
499 if (found != std::string::npos) {
500 name =
name.substr(found+1, std::string::npos);
508 for (
int k = 0; k < xml.
elements(
"spatialModel"); ++k) {
511 matching_model = xml.
element(
"spatialModel", k);
518 if (matching_model == NULL) {
530 matching_model = xml.
element(
"spatialModel",
536 spatial->
write(*matching_model);
592 const std::string& name,
602 std::string component_name = !
name.empty() ?
name
607 std::string msg =
"Attempt to append component \""+component_name+
"\" "
608 "to composite spatial model, but a component with the "
609 "same name exists already. Each component needs a "
615 m_names.push_back(component_name);
621 for (
int ipar = 0; ipar < npars; ++ipar) {
627 p->
name(component_name+
":"+p->
name());
691 for (
int i = 0; i <
m_names.size(); ++i) {
700 std::string msg =
"Model component \""+
name+
"\" not found in composite "
724 if (index < 0 || index >=
m_scales.size()) {
748 if (index < 0 || index >=
m_scales.size()) {
773 for (
int i = 0; i <
m_scales.size(); ++i) {
800 const GTime& srcTime)
const
839 result.append(
"=== GModelSpatialComposite ===");
850 for (
int i = 0; i <
size(); ++i) {
916 for (
int ipar = 0; ipar < npars; ++ipar) {
924 for (
int i = 0; i < model.
m_scales.size(); ++i) {
961 for (
int i = 0; i <
m_scales.size(); ++i) {
Exception handler interface definition.
Mathematical function definitions.
#define G_COMPONENT_INDEX
const GModelSpatialComposite g_spatial_comp_seed
Spatial composite model class interface definition.
Spatial model registry class definition.
double min(const GVector &vector)
Computes minimum vector element.
double sum(const GVector &vector)
Computes vector sum.
double max(const GVector &vector)
Computes maximum vector element.
Class that handles energies in a unit independent way.
void free_members(void)
Delete class members.
std::vector< std::string > m_names
Component names.
virtual void clear(void)
Clear spatial composite model.
std::vector< GModelSpatial * > m_components
Components.
bool m_normalize
Normalize component.
virtual double flux(const GSkyRegion ®ion, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
Returns flux integrated in sky region.
GModelSpatialComposite(const bool &normalize=true)
Void constructor.
void copy_members(const GModelSpatialComposite &model)
Copy class members.
const GModelSpatial * component(const int &index) const
Returns pointer to spatial component element.
void append(const GModelSpatial &component, const std::string &name="", const GModelPar &par=GModelPar("", 1.0))
Append spatial component.
virtual GModelSpatialComposite * clone(void) const
Clone spatial composite model.
const GModelPar * scale(const int &index) const
Returns scale parameter of spatial component.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
virtual void read(const GXmlElement &xml)
Read model from XML element.
int components(void) const
Return number of model components.
virtual double eval(const GPhoton &photon, const bool &gradients=false) const
Evaluate function.
virtual void set_region(void) const
Set boundary sky region.
std::vector< GModelPar * > m_scales
Component scales.
void init_members(void)
Initialise class members.
double sum_of_scales(void) const
Returns sum of all model scales.
virtual ~GModelSpatialComposite(void)
Destructor.
const bool & normalize(void) const
Return normalisation flag.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
std::string name(const int &index) const
Returns names of spatial component.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print composite spatial model information.
bool m_has_normalize
XML has normalize attribute.
virtual GModelSpatialComposite & operator=(const GModelSpatialComposite &model)
Assignment operator.
Interface definition for the spatial model registry class.
GModelSpatial * alloc(const GXmlElement &xml) const
Allocate spatial model that is found in XML element.
Abstract spatial model base class.
std::string m_type
Spatial model type.
std::string type(void) const
Return model type.
const GSkyRegion * region(void) const
Return boundary sky region.
virtual void write(GXmlElement &xml) const =0
virtual GModelSpatial * clone(void) const =0
Clones object.
std::vector< GModelPar * > m_pars
Parameter pointers.
virtual GModelSpatial & operator=(const GModelSpatial &model)
Assignment operator.
void init_members(void)
Initialise class members.
int size(void) const
Return number of parameters.
void free_members(void)
Delete class members.
GSkyRegionCircle m_region
Bounding circle.
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.
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
void remove_min(void)
Removes minimum boundary.
double max(void) const
Return parameter maximum boundary.
double min(void) const
Return parameter minimum boundary.
void fix(void)
Fix a parameter.
void remove_max(void)
Removes maximum boundary.
double gradient(void) const
Return parameter gradient.
double value(void) const
Return parameter value.
const std::string & name(void) const
Return parameter name.
Class that handles photons.
Random number generator class.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
Interface for the circular sky region class.
Abstract interface for the sky region class.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
bool has_attribute(const std::string &name) const
Check if element has a given 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.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
double todouble(const std::string &arg)
Convert string into double precision value.
std::string tolower(const std::string &s)
Convert string to lower case.
int toint(const std::string &arg)
Convert string into integer value.
bool contains(const std::string &str, const std::string &substring)
Checks if a substring is in a string.
void xml_check_type(const std::string &origin, GXmlElement &xml, const std::string &type)
Checks the model type.