45 #define G_READ "GModelSpatialComposite::read(GXmlElement&)"
46 #define G_WRITE "GModelSpatialComposite::write(GXmlElement&)"
47 #define G_COMPONENT_INDEX "GModelSpatialComposite::component(int&)"
48 #define G_COMPONENT_NAME "GModelSpatialComposite::component(std::string&)"
49 #define G_APPEND "GModelSpatialComposite::append(GModelSpatial&, "\
50 "std::string&, GModelPar&)"
89 const std::string& type) :
173 if (
this != &model) {
241 const bool& gradients)
const
285 for (
int i = 0; i <
m_scales.size(); ++i) {
316 const double& margin)
const
319 bool containment =
false;
345 int n_comp = xml.
elements(
"spatialModel");
348 for (
int i = 0; i < n_comp; ++i) {
360 std::string name = spec->
attribute(
"component");
364 scale.
range(1.0e-10, 1.0e10);
405 append(*ptr, name, scale);
436 if (component == NULL) {
444 for (
int k = 0; k < spatial->
size(); ++k) {
451 std::string name = par.
name();
452 int found = name.find(
":");
453 if (found != std::string::npos) {
454 name = name.substr(found+1, std::string::npos);
462 for (
int k = 0; k < xml.
elements(
"spatialModel"); ++k) {
465 matching_model = xml.
element(
"spatialModel", k);
472 if (matching_model == NULL) {
484 matching_model = xml.
element(
"spatialModel",
490 spatial->
write(*matching_model);
536 const std::string& name,
546 std::string component_name = !name.empty() ? name
551 std::string msg =
"Attempt to append component \""+component_name+
"\" "
552 "to composite spatial model, but a component with the "
553 "same name exists already. Each component needs a "
559 m_names.push_back(component_name);
565 for (
int ipar = 0; ipar < npars; ++ipar) {
571 p->
name(component_name+
":"+p->
name());
580 scale->
name(component_name +
":scale");
635 for (
int i = 0; i <
m_names.size(); ++i) {
644 std::string msg =
"Model component \""+name+
"\" not found in composite "
668 if (index < 0 || index >=
m_scales.size()) {
689 for (
int i = 0; i <
m_scales.size(); ++i) {
712 const GTime& srcTime)
const
719 flux +=
m_components[i]->flux(region, srcEng, srcTime) *
748 result.append(
"=== GModelSpatialComposite ===");
757 for (
int i = 0; i <
size(); ++i) {
819 for (
int ipar = 0; ipar < npars; ++ipar) {
827 for (
int i = 0; i < model.
m_scales.size(); ++i) {
864 for (
int i = 0; i <
m_scales.size(); ++i) {
bool contains(const std::string &str, const std::string &substring)
Checks if a substring is in a string.
virtual double flux(const GSkyRegion ®ion, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
Returns flux integrated in sky region.
void remove_min(void)
Removes minimum boundary.
#define G_COMPONENT_INDEX
virtual void read(const GXmlElement &xml)
Read model from XML element.
const std::string & name(void) const
Return parameter name.
double gradient(void) const
Return parameter gradient.
int size(void) const
Return number of parameters.
const GModelSpatial * component(const int &index) const
Returns pointer to spatial component element.
virtual void write(GXmlElement &xml) const
Write model into XML element.
virtual void clear(void)
Clear spatial composite model.
GModelSpatialComposite(void)
Void constructor.
double max(void) const
Return parameter maximum boundary.
virtual GModelSpatial & operator=(const GModelSpatial &model)
Assignment operator.
double sum(const GVector &vector)
Computes vector sum.
Random number generator class.
virtual int elements(void) const
Return number of GXMLElement children of node.
Interface for the circular sky region class.
double min(const GVector &vector)
Computes minimum vector element.
Interface definition for the spatial model registry class.
double min(void) const
Return parameter minimum boundary.
GSkyRegionCircle m_region
Bounding circle.
double sum_of_scales(void) const
Returns sum of all model scales.
Class that handles photons.
const double & scale(void) const
Return parameter scale.
virtual GModelSpatialComposite * clone(void) const
Clone spatial composite model.
std::vector< std::string > m_names
Component names.
bool has_grad(void) const
Signal if parameter gradient is computed analytically.
Abstract interface for the sky region class.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
void free(void)
Free a parameter.
std::vector< GModelSpatial * > m_components
Components.
std::vector< GModelPar * > m_pars
Parameter pointers.
const GModelSpatialComposite g_spatial_comp_seed
void fix(void)
Fix a parameter.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
Spatial model registry class definition.
void remove_max(void)
Removes maximum boundary.
virtual GSkyDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC sky direction.
GModelSpatial * alloc(const GXmlElement &xml) const
Allocate spatial model that is found in XML element.
Spatial composite model class interface definition.
void copy_members(const GModelSpatialComposite &model)
Copy class members.
std::string type(void) const
Return model type.
virtual GModelSpatialComposite & operator=(const GModelSpatialComposite &model)
Assignment operator.
double max(const GVector &vector)
Computes maximum vector element.
void append(const GModelSpatial &component, const std::string &name="", const GModelPar &par=GModelPar("", 1.0))
Append spatial component.
std::vector< GModelPar * > m_scales
Component scales.
int components(void) const
Return number of model components.
const GSkyRegion * region(void) const
Return boundary sky region.
void free_members(void)
Delete class members.
void free_members(void)
Delete class members.
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
std::string m_type
Spatial model type.
void range(const double &min, const double &max)
Set minimum and maximum parameter boundaries.
double value(void) const
Return parameter value.
Exception handler interface definition.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print composite spatial model information.
Abstract spatial model base class.
virtual void write(GXmlElement &xml) const =0
int toint(const std::string &arg)
Convert string into integer value.
void init_members(void)
Initialise class members.
virtual bool contains(const GSkyDir &dir, const double &margin=0.0) const
Checks where model contains specified sky direction.
virtual double eval(const GPhoton &photon, const bool &gradients=false) const
Evaluate function.
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.
virtual void set_region(void) const
Set boundary sky region.
virtual GModelSpatial * clone(void) const =0
Clones object.
double scale(const int &index) const
Returns scale of spatial component.
Mathematical function definitions.
virtual ~GModelSpatialComposite(void)
Destructor.
double todouble(const std::string &arg)
Convert string into double precision value.
Class that handles energies in a unit independent way.
void init_members(void)
Initialise class members.
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.