GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialComposite Class Reference

Spatial composite model. More...

#include <GModelSpatialComposite.hpp>

Inheritance diagram for GModelSpatialComposite:
GModelSpatial GBase

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 GModelSpatialCompositeoperator= (const GModelSpatialComposite &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear spatial composite model. More...
 
virtual GModelSpatialCompositeclone (void) const
 Clone spatial composite model. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual std::string type (void) const
 Return model type. 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 GSkyRegionregion (void) const
 Return boundary sky region. 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...
 
void type (const std::string &type)
 Set model type. 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 GModelSpatialcomponent (const int &index) const
 Returns pointer to spatial component element. More...
 
const GModelSpatialcomponent (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 GModelSpatialoperator= (const GModelSpatial &model)
 Assignment operator. More...
 
virtual GModelParoperator[] (const int &index)
 Returns model parameter. More...
 
virtual const GModelParoperator[] (const int &index) const
 Returns model parameter (const version) More...
 
virtual GModelParoperator[] (const std::string &name)
 Returns model parameter. More...
 
virtual const GModelParoperator[] (const std::string &name) const
 Returns model parameter (const version) More...
 
GModelParat (const int &index)
 Returns model parameter. More...
 
const GModelParat (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...
 
double flux (const GSkyRegion *reg, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
 Returns model flux integrated in circular 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...
 
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::string m_type
 Model type. More...
 
std::vector< GModelSpatial * > m_components
 Components. More...
 
std::vector< std::string > m_names
 Component names. More...
 
std::vector< GModelPar * > m_scales
 Component scales. More...
 
GSkyRegionCircle m_region
 Bounding circle. More...
 
- Protected Attributes inherited from GModelSpatial
std::vector< GModelPar * > m_pars
 Parameter pointers. More...
 

Detailed Description

Spatial composite model.

This class implements the spatial model for a composition of spatial models.

Definition at line 47 of file GModelSpatialComposite.hpp.

Constructor & Destructor Documentation

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.

Parameters
[in]dummyDummy flag.
[in]typeModel type.

Constructs empty spatial composite model by specifying a model type.

Definition at line 88 of file GModelSpatialComposite.cpp.

References init_members(), m_type, and type().

GModelSpatialComposite::GModelSpatialComposite ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML 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.

Parameters
[in]modelSpatial composite model.

Definition at line 131 of file GModelSpatialComposite.cpp.

References copy_members(), and init_members().

GModelSpatialComposite::~GModelSpatialComposite ( void  )
virtual

Destructor.

Definition at line 148 of file GModelSpatialComposite.cpp.

References free_members().

Member Function Documentation

void GModelSpatialComposite::append ( const GModelSpatial component,
const std::string &  name = "",
const GModelPar par = GModelPar("", 1.0) 
)

Append spatial component.

Parameters
[in]componentSpatial model component to append.
[in]nameName of spatial model.
[in]parModel scaling parameter.

Appends a spatial component to the composite model

Definition at line 550 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().

std::string GModelSpatialComposite::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GModelSpatialComposite").

Implements GModelSpatial.

Definition at line 114 of file GModelSpatialComposite.hpp.

void GModelSpatialComposite::clear ( void  )
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().

GModelSpatialComposite * GModelSpatialComposite::clone ( void  ) const
virtual

Clone spatial composite model.

Returns
Pointer to deep copy of spatial composite model.

Implements GModelSpatial.

Definition at line 223 of file GModelSpatialComposite.cpp.

References GModelSpatialComposite().

GClassCode GModelSpatialComposite::code ( void  ) const
inlinevirtual

Return class code.

Returns
GModelSpatialComposite.

Returns the code GModelSpatialComposite of the class.

Implements GModelSpatial.

Definition at line 157 of file GModelSpatialComposite.hpp.

References GMODEL_SPATIAL_COMPOSITE.

const GModelSpatial * GModelSpatialComposite::component ( const int &  index) const

Returns pointer to spatial component element.

Parameters
[in]indexIndex of spatial component [0,...,components()-1].
Returns
Spatial model.
Exceptions
GException::out_of_rangeIndex is out of range.

Returns a spatial component to the composite model

Definition at line 622 of file GModelSpatialComposite.cpp.

References G_COMPONENT_INDEX, and m_components.

Referenced by GCTAResponse::irf_composite(), GCTAResponseIrf::nroi_composite(), and write().

const GModelSpatial * GModelSpatialComposite::component ( const std::string &  name) const

Returns pointer to specific spatial component.

Parameters
[in]nameName of spatial component.
Returns
Spatial model.
Exceptions
GException::invalid_argumentSpatial model not found.

Returns a spatial component of the composite model

Definition at line 646 of file GModelSpatialComposite.cpp.

References G_COMPONENT_NAME, m_components, and m_names.

int GModelSpatialComposite::components ( void  ) const
inline

Return number of model components.

Returns
Number of model components.

Definition at line 187 of file GModelSpatialComposite.hpp.

References m_components.

Referenced by GCTAResponse::irf_composite(), GCTAResponseIrf::nroi_composite(), and print().

bool GModelSpatialComposite::contains ( const GSkyDir dir,
const double &  margin = 0.0 
) const
virtual

Checks where model contains specified sky direction.

Parameters
[in]dirSky direction.
[in]marginMargin to be added to sky direction (degrees)
Returns
True if the model contains the sky direction.

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.

void GModelSpatialComposite::copy_members ( const GModelSpatialComposite model)
protected

Copy class members.

Parameters
[in]modelSpatial composite model.

Definition at line 781 of file GModelSpatialComposite.cpp.

References m_components, m_names, GModelSpatial::m_pars, m_region, m_scales, m_type, and scale().

Referenced by GModelSpatialComposite(), and operator=().

double GModelSpatialComposite::eval ( const GPhoton photon,
const bool &  gradients = false 
) const
virtual

Evaluate function.

Parameters
[in]photonIncident photon.
[in]gradientsCompute gradients?
Returns
Model value.

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().

void GModelSpatialComposite::free_members ( void  )
protected

Delete class members.

Definition at line 832 of file GModelSpatialComposite.cpp.

References m_components, and m_scales.

Referenced by clear(), operator=(), and ~GModelSpatialComposite().

void GModelSpatialComposite::init_members ( void  )
protected

Initialise class members.

Definition at line 759 of file GModelSpatialComposite.cpp.

References GSkyRegionCircle::clear(), m_components, m_names, GModelSpatial::m_pars, m_region, m_scales, and m_type.

Referenced by clear(), GModelSpatialComposite(), and operator=().

GSkyDir GModelSpatialComposite::mc ( const GEnergy energy,
const GTime time,
GRan ran 
) const
virtual

Returns MC sky direction.

Parameters
[in]energyPhoton energy.
[in]timePhoton arrival time.
[in,out]ranRandom number generator.
Returns
Sky direction.

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().

double GModelSpatialComposite::mc_norm ( const GSkyDir dir,
const double &  radius 
) const
inlinevirtual

Return normalization of composite source for Monte Carlo simulations.

Parameters
[in]dirCentre of simulation cone.
[in]radiusRadius of simulation cone (degrees).
Returns
Normalization.

Returns unity.

Implements GModelSpatial.

Definition at line 174 of file GModelSpatialComposite.hpp.

GModelSpatialComposite & GModelSpatialComposite::operator= ( const GModelSpatialComposite model)
virtual

Assignment operator.

Parameters
[in]modelSpatial composite model.
Returns
Spatial composite model.

Definition at line 170 of file GModelSpatialComposite.cpp.

References copy_members(), free_members(), init_members(), and GModelSpatial::operator=().

std::string GModelSpatialComposite::print ( const GChatter chatter = NORMAL) const
virtual

Print composite spatial model information.

Parameters
[in]chatterChattiness.
Returns
String containing composite spatial model information.

Implements GModelSpatial.

Definition at line 721 of file GModelSpatialComposite.cpp.

References components(), GModelSpatial::m_pars, gammalib::parformat(), SILENT, GModelSpatial::size(), and gammalib::str().

GSkyRegion * GModelSpatialComposite::region ( void  ) const
inlinevirtual

Return boundary sky region.

Returns
Boundary sky region.

Returns a sky region that fully encloses the point source.

Implements GModelSpatial.

Definition at line 201 of file GModelSpatialComposite.hpp.

References m_region, and set_region().

double GModelSpatialComposite::scale ( const int &  index) const

Returns scale of spatial component.

Parameters
[in]indexIndex of spatial component [0,...,components()-1].
Returns
Scale.
Exceptions
GException::out_of_rangeIndex is out of range.

Returns the scale of a spatial component to the composite model

Definition at line 680 of file GModelSpatialComposite.cpp.

References G_COMPONENT_INDEX, and m_scales.

Referenced by append(), copy_members(), GCTAResponse::irf_composite(), GCTAResponseIrf::nroi_composite(), and read().

void GModelSpatialComposite::set_region ( void  ) const
protected

Set boundary sky region.

Todo:
Implement computation of sky boundary region

Definition at line 870 of file GModelSpatialComposite.cpp.

References GSkyRegionCircle::centre(), m_region, and GSkyRegionCircle::radius().

Referenced by region().

double GModelSpatialComposite::sum_of_scales ( void  ) const

Returns sum of all model scales.

Returns
Sum of all model scales

Definition at line 698 of file GModelSpatialComposite.cpp.

References m_scales, and sum().

Referenced by eval(), GCTAResponse::irf_composite(), mc(), and GCTAResponseIrf::nroi_composite().

std::string GModelSpatialComposite::type ( void  ) const
inlinevirtual

Return model type.

Returns
Model type.

Returns the type of the spatial model.

Implements GModelSpatial.

Definition at line 128 of file GModelSpatialComposite.hpp.

References m_type.

Referenced by GModelSpatialComposite(), type(), and write().

void GModelSpatialComposite::type ( const std::string &  type)
inline

Set model type.

Parameters
[in]typeModel type.

Set the type of the spatial model.

Definition at line 142 of file GModelSpatialComposite.hpp.

References m_type, and type().

void GModelSpatialComposite::write ( GXmlElement xml) const
virtual

Write model into XML element.

Parameters
[in]xmlXML element into which model information is written.
Exceptions
GException::model_invalid_spatialExisting XML element is not of appropriate type
GException::model_invalid_parnumInvalid number of model parameters found in XML element.
GException::model_invalid_parnamesInvalid model parameter names found in XML element.

Write the spatial information into an XML element.

Implements GModelSpatial.

Definition at line 431 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(), type(), and GModelSpatial::write().

Member Data Documentation

std::vector<GModelSpatial*> GModelSpatialComposite::m_components
protected
std::vector<std::string> GModelSpatialComposite::m_names
protected

Component names.

Definition at line 102 of file GModelSpatialComposite.hpp.

Referenced by append(), component(), copy_members(), init_members(), and write().

GSkyRegionCircle GModelSpatialComposite::m_region
mutableprotected

Bounding circle.

Definition at line 104 of file GModelSpatialComposite.hpp.

Referenced by copy_members(), init_members(), region(), and set_region().

std::vector<GModelPar*> GModelSpatialComposite::m_scales
protected

Component scales.

Definition at line 103 of file GModelSpatialComposite.hpp.

Referenced by append(), contains(), copy_members(), eval(), free_members(), init_members(), mc(), scale(), sum_of_scales(), and write().

std::string GModelSpatialComposite::m_type
protected

Model type.

Definition at line 100 of file GModelSpatialComposite.hpp.

Referenced by copy_members(), GModelSpatialComposite(), init_members(), and type().


The documentation for this class was generated from the following files: