GammaLib
2.0.0
|
Spatial composite model. More...
#include <GModelSpatialComposite.hpp>
Public Member Functions | |
GModelSpatialComposite (void) | |
Void constructor. More... | |
GModelSpatialComposite (const bool &dummy, const std::string &type) | |
Model type constructor. More... | |
GModelSpatialComposite (const GXmlElement &xml) | |
XML constructor. More... | |
GModelSpatialComposite (const GModelSpatialComposite &model) | |
Copy constructor. More... | |
virtual | ~GModelSpatialComposite (void) |
Destructor. More... | |
virtual GModelSpatialComposite & | operator= (const GModelSpatialComposite &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear spatial composite model. More... | |
virtual GModelSpatialComposite * | clone (void) const |
Clone spatial composite model. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual GClassCode | code (void) const |
Return class code. More... | |
virtual double | eval (const GPhoton &photon, const bool &gradients=false) const |
Evaluate function. More... | |
virtual GSkyDir | mc (const GEnergy &energy, const GTime &time, GRan &ran) const |
Returns MC sky direction. More... | |
virtual double | mc_norm (const GSkyDir &dir, const double &radius) const |
Return normalization of composite source for Monte Carlo simulations. More... | |
virtual bool | contains (const GSkyDir &dir, const double &margin=0.0) const |
Checks where model contains specified sky direction. More... | |
virtual void | read (const GXmlElement &xml) |
Read model from XML element. More... | |
virtual void | write (GXmlElement &xml) const |
Write model into XML element. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print composite spatial model information. More... | |
virtual double | flux (const GSkyRegion ®ion, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const |
Returns flux integrated in sky region. More... | |
int | components (void) const |
Return number of model components. More... | |
void | append (const GModelSpatial &component, const std::string &name="", const GModelPar &par=GModelPar("", 1.0)) |
Append spatial component. More... | |
const GModelSpatial * | component (const int &index) const |
Returns pointer to spatial component element. More... | |
const GModelSpatial * | component (const std::string &name) const |
Returns pointer to specific spatial component. More... | |
double | scale (const int &index) const |
Returns scale of spatial component. More... | |
double | sum_of_scales (void) const |
Returns sum of all model scales. More... | |
Public Member Functions inherited from GModelSpatial | |
GModelSpatial (void) | |
Void constructor. More... | |
GModelSpatial (const GModelSpatial &model) | |
Copy constructor. More... | |
virtual | ~GModelSpatial (void) |
Destructor. More... | |
virtual GModelSpatial & | operator= (const GModelSpatial &model) |
Assignment operator. More... | |
virtual GModelPar & | operator[] (const int &index) |
Returns model parameter. More... | |
virtual const GModelPar & | operator[] (const int &index) const |
Returns model parameter (const version) More... | |
virtual GModelPar & | operator[] (const std::string &name) |
Returns model parameter. More... | |
virtual const GModelPar & | operator[] (const std::string &name) const |
Returns model parameter (const version) More... | |
std::string | type (void) const |
Return model type. More... | |
void | type (const std::string &type) |
Set model type. More... | |
GModelPar & | at (const int &index) |
Returns model parameter. More... | |
const GModelPar & | at (const int &index) const |
Returns model parameter (const version) More... | |
bool | has_par (const std::string &name) const |
Checks if parameter name exists. More... | |
bool | has_free_pars (void) const |
Checks if the spatial model has free parameters. More... | |
int | size (void) const |
Return number of parameters. More... | |
void | autoscale (void) |
Autoscale parameters. More... | |
const GSkyRegion * | region (void) const |
Return boundary sky region. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GModelSpatialComposite &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
virtual void | set_region (void) const |
Set boundary sky region. More... | |
Protected Member Functions inherited from GModelSpatial | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GModelSpatial &model) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
std::vector< GModelSpatial * > | m_components |
Components. More... | |
std::vector< std::string > | m_names |
Component names. More... | |
std::vector< GModelPar * > | m_scales |
Component scales. More... | |
Protected Attributes inherited from GModelSpatial | |
std::string | m_type |
Spatial model type. More... | |
GSkyRegionCircle | m_region |
Bounding circle. More... | |
std::vector< GModelPar * > | m_pars |
Parameter pointers. More... | |
Spatial composite model.
This class implements the spatial model for a composition of spatial models.
Definition at line 47 of file GModelSpatialComposite.hpp.
GModelSpatialComposite::GModelSpatialComposite | ( | void | ) |
Void constructor.
Constructs empty spatial composite model.
Definition at line 70 of file GModelSpatialComposite.cpp.
References init_members().
Referenced by clone().
GModelSpatialComposite::GModelSpatialComposite | ( | const bool & | dummy, |
const std::string & | type | ||
) |
Model type constructor.
[in] | dummy | Dummy flag. |
[in] | type | Model type. |
Constructs empty spatial composite model by specifying a model type
.
Definition at line 88 of file GModelSpatialComposite.cpp.
References init_members(), GModelSpatial::m_type, and GModelSpatial::type().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Construct a spatial composite model by extracting information from an XML element. See the read() method for more information about the expected structure of the XML element.
Definition at line 112 of file GModelSpatialComposite.cpp.
References init_members(), and read().
GModelSpatialComposite::GModelSpatialComposite | ( | const GModelSpatialComposite & | model | ) |
Copy constructor.
[in] | model | Spatial composite model. |
Definition at line 131 of file GModelSpatialComposite.cpp.
References copy_members(), and init_members().
|
virtual |
void GModelSpatialComposite::append | ( | const GModelSpatial & | component, |
const std::string & | name = "" , |
||
const GModelPar & | par = GModelPar("", 1.0) |
||
) |
Append spatial component.
[in] | component | Spatial model component to append. |
[in] | name | Name of spatial model. |
[in] | par | Model scaling parameter. |
Appends a spatial component to the composite model
Definition at line 535 of file GModelSpatialComposite.cpp.
References GModelSpatial::clone(), gammalib::contains(), G_APPEND, GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_components, m_names, GModelSpatial::m_pars, m_scales, GOptimizerPar::name(), scale(), GOptimizerPar::scale(), and gammalib::str().
Referenced by read().
|
inlinevirtual |
Return class name.
Implements GModelSpatial.
Definition at line 114 of file GModelSpatialComposite.hpp.
|
virtual |
Clear spatial composite model.
Implements GModelSpatial.
Definition at line 203 of file GModelSpatialComposite.cpp.
References free_members(), GModelSpatial::free_members(), init_members(), and GModelSpatial::init_members().
|
virtual |
Clone spatial composite model.
Implements GModelSpatial.
Definition at line 223 of file GModelSpatialComposite.cpp.
References GModelSpatialComposite().
|
inlinevirtual |
Return class code.
Returns the code GModelSpatialComposite of the class.
Implements GModelSpatial.
Definition at line 128 of file GModelSpatialComposite.hpp.
References GMODEL_SPATIAL_COMPOSITE.
const GModelSpatial * GModelSpatialComposite::component | ( | const int & | index | ) | const |
Returns pointer to spatial component element.
[in] | index | Index of spatial component [0,...,components()-1]. |
GException::out_of_range | Index is out of range. |
Returns a spatial component to the composite model
Definition at line 607 of file GModelSpatialComposite.cpp.
References G_COMPONENT_INDEX, and m_components.
Referenced by GResponse::irf_composite(), GCTAResponseIrf::nroi_composite(), and write().
const GModelSpatial * GModelSpatialComposite::component | ( | const std::string & | name | ) | const |
Returns pointer to specific spatial component.
[in] | name | Name of spatial component. |
GException::invalid_argument | Spatial model not found. |
Returns a spatial component of the composite model
Definition at line 631 of file GModelSpatialComposite.cpp.
References G_COMPONENT_NAME, m_components, and m_names.
|
inline |
Return number of model components.
Definition at line 158 of file GModelSpatialComposite.hpp.
References m_components.
Referenced by GResponse::irf_composite(), GCTAResponseIrf::nroi_composite(), and print().
|
virtual |
Checks where model contains specified sky direction.
[in] | dir | Sky direction. |
[in] | margin | Margin to be added to sky direction (degrees) |
Signals whether a sky direction is contained in one of the model components.
Implements GModelSpatial.
Definition at line 315 of file GModelSpatialComposite.cpp.
References m_components, and m_scales.
|
protected |
Copy class members.
[in] | model | Spatial composite model. |
Definition at line 798 of file GModelSpatialComposite.cpp.
References m_components, m_names, GModelSpatial::m_pars, m_scales, GModelSpatial::m_type, and scale().
Referenced by GModelSpatialComposite(), and operator=().
|
virtual |
Evaluate function.
[in] | photon | Incident photon. |
[in] | gradients | Compute gradients? |
Evaluates the spatial composite model by summing all model components, weighting by their scale and dividing the sum of all scales.
Implements GModelSpatial.
Definition at line 240 of file GModelSpatialComposite.cpp.
References m_components, m_scales, and sum_of_scales().
|
virtual |
Returns flux integrated in sky region.
[in] | region | Sky region. |
[in] | srcEng | Energy. |
[in] | srcTime | Time. |
Returns flux within a sky region.
Reimplemented from GModelSpatial.
Definition at line 710 of file GModelSpatialComposite.cpp.
References m_components, m_scales, and sum_of_scales().
|
protected |
Delete class members.
Definition at line 848 of file GModelSpatialComposite.cpp.
References m_components, and m_scales.
Referenced by clear(), operator=(), and ~GModelSpatialComposite().
|
protected |
Initialise class members.
Definition at line 777 of file GModelSpatialComposite.cpp.
References m_components, m_names, GModelSpatial::m_pars, m_scales, and GModelSpatial::m_type.
Referenced by clear(), GModelSpatialComposite(), and operator=().
|
virtual |
Returns MC sky direction.
[in] | energy | Photon energy. |
[in] | time | Photon arrival time. |
[in,out] | ran | Random number generator. |
Draws an arbitrary model component and an arbitrary direction from that component.
Implements GModelSpatial.
Definition at line 273 of file GModelSpatialComposite.cpp.
References m_components, m_scales, sum(), sum_of_scales(), and GRan::uniform().
|
inlinevirtual |
Return normalization of composite source for Monte Carlo simulations.
[in] | dir | Centre of simulation cone. |
[in] | radius | Radius of simulation cone (degrees). |
Returns unity.
Implements GModelSpatial.
Definition at line 145 of file GModelSpatialComposite.hpp.
|
virtual |
Assignment operator.
[in] | model | Spatial composite model. |
Definition at line 170 of file GModelSpatialComposite.cpp.
References copy_members(), free_members(), init_members(), and GModelSpatial::operator=().
Print composite spatial model information.
[in] | chatter | Chattiness. |
Implements GModelSpatial.
Definition at line 739 of file GModelSpatialComposite.cpp.
References components(), GModelSpatial::m_pars, gammalib::parformat(), SILENT, GModelSpatial::size(), and gammalib::str().
|
virtual |
Read model from XML element.
[in] | xml | XML element. |
Reads the spatial information from an XML element.
Implements GModelSpatial.
Definition at line 342 of file GModelSpatialComposite.cpp.
References GModelSpatialRegistry::alloc(), append(), GXmlElement::attribute(), GXmlNode::element(), GXmlNode::elements(), GOptimizerPar::fix(), GOptimizerPar::free(), GXmlElement::has_attribute(), GOptimizerPar::max(), GOptimizerPar::min(), GOptimizerPar::range(), GOptimizerPar::remove_max(), GOptimizerPar::remove_min(), scale(), gammalib::todouble(), gammalib::toint(), and GOptimizerPar::value().
Referenced by GModelSpatialComposite().
double GModelSpatialComposite::scale | ( | const int & | index | ) | const |
Returns scale of spatial component.
[in] | index | Index of spatial component [0,...,components()-1]. |
GException::out_of_range | Index is out of range. |
Returns the scale of a spatial component to the composite model
Definition at line 665 of file GModelSpatialComposite.cpp.
References G_COMPONENT_INDEX, and m_scales.
Referenced by append(), copy_members(), GResponse::irf_composite(), GCTAResponseIrf::nroi_composite(), and read().
|
protectedvirtual |
Set boundary sky region.
Implements GModelSpatial.
Definition at line 886 of file GModelSpatialComposite.cpp.
References GModelSpatial::m_region, and GModelSpatial::region().
double GModelSpatialComposite::sum_of_scales | ( | void | ) | const |
Returns sum of all model scales.
Definition at line 683 of file GModelSpatialComposite.cpp.
References m_scales, and sum().
Referenced by eval(), flux(), GResponse::irf_composite(), mc(), and GCTAResponseIrf::nroi_composite().
|
virtual |
Write model into XML element.
[in] | xml | XML element into which model information is written. |
Write the spatial information into an XML element.
Implements GModelSpatial.
Definition at line 424 of file GModelSpatialComposite.cpp.
References GXmlNode::append(), GXmlElement::attribute(), GModelSpatial::clone(), component(), GXmlNode::element(), GXmlNode::elements(), G_WRITE, GXmlElement::has_attribute(), m_components, m_names, m_scales, max(), min(), GOptimizerPar::name(), GModelSpatial::size(), gammalib::str(), GModelSpatial::type(), GModelSpatial::write(), and gammalib::xml_check_type().
|
protected |
Components.
Definition at line 102 of file GModelSpatialComposite.hpp.
Referenced by append(), component(), components(), contains(), copy_members(), eval(), flux(), free_members(), init_members(), mc(), and write().
|
protected |
Component names.
Definition at line 103 of file GModelSpatialComposite.hpp.
Referenced by append(), component(), copy_members(), init_members(), and write().
|
protected |
Component scales.
Definition at line 104 of file GModelSpatialComposite.hpp.
Referenced by append(), contains(), copy_members(), eval(), flux(), free_members(), init_members(), mc(), scale(), sum_of_scales(), and write().