GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpatialDiffuseConst Class Reference

Isotropic spatial model. More...

#include <GModelSpatialDiffuseConst.hpp>

Inheritance diagram for GModelSpatialDiffuseConst:
GModelSpatialDiffuse GModelSpatial GBase

Public Member Functions

 GModelSpatialDiffuseConst (void)
 Void constructor. More...
 
 GModelSpatialDiffuseConst (const bool &dummy, const std::string &type)
 Model type constructor. More...
 
 GModelSpatialDiffuseConst (const GXmlElement &xml)
 XML constructor. More...
 
 GModelSpatialDiffuseConst (const double &value)
 Value constructor. More...
 
 GModelSpatialDiffuseConst (const GModelSpatialDiffuseConst &model)
 Copy constructor. More...
 
virtual ~GModelSpatialDiffuseConst (void)
 Destructor. More...
 
GModelSpatialDiffuseConstoperator= (const GModelSpatialDiffuseConst &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear isotropic spatial model. More...
 
virtual GModelSpatialDiffuseConstclone (void) const
 Clone isotropic spatial model. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual double eval (const GPhoton &photon, const bool &gradients=false) const
 Evaluate isotropic spatial model value. More...
 
virtual GSkyDir mc (const GEnergy &energy, const GTime &time, GRan &ran) const
 Return MC sky direction. More...
 
virtual double mc_norm (const GSkyDir &dir, const double &radius) const
 Return normalization of constant diffuse source for Monte Carlo simulations. More...
 
virtual bool contains (const GSkyDir &dir, const double &margin=0.0) const
 Signals whether model contains 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 isotropic source model information. More...
 
virtual double flux (const GSkyRegion &region, const GEnergy &srcEng=GEnergy(), const GTime &srcTime=GTime()) const
 Returns isotropic flux integrated in sky region. More...
 
double value (void) const
 Get model value. More...
 
void value (const double &value)
 Set model value. More...
 
- Public Member Functions inherited from GModelSpatialDiffuse
 GModelSpatialDiffuse (void)
 Void constructor. More...
 
 GModelSpatialDiffuse (const GModelSpatialDiffuse &model)
 Copy constructor. More...
 
virtual ~GModelSpatialDiffuse (void)
 Destructor. More...
 
virtual GModelSpatialDiffuseoperator= (const GModelSpatialDiffuse &model)
 Assignment operator. More...
 
virtual GClassCode code (void) const
 Return class code. 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...
 
std::string type (void) const
 Return model type. More...
 
void type (const std::string &type)
 Set model type. 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...
 
const GSkyRegionregion (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 GModelSpatialDiffuseConst &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 GModelSpatialDiffuse
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelSpatialDiffuse &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. 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

GModelPar m_value
 Value. More...
 
GSkyDir m_mc_centre
 Simulation cone centre. More...
 
double m_mc_cos_radius
 Cosine of sim. cone radius. 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...
 

Detailed Description

Isotropic spatial model.

This class implements the spatial component of the factorised source model for an isotropic source. The model has a single parameter which is the normalization factor of the model.

Definition at line 48 of file GModelSpatialDiffuseConst.hpp.

Constructor & Destructor Documentation

GModelSpatialDiffuseConst::GModelSpatialDiffuseConst ( void  )

Void constructor.

Constructs empty isotropic spatial model.

Definition at line 70 of file GModelSpatialDiffuseConst.cpp.

References init_members().

Referenced by clone().

GModelSpatialDiffuseConst::GModelSpatialDiffuseConst ( const bool &  dummy,
const std::string &  type 
)

Model type constructor.

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

Constructs empty isotropic spatial model by specifying a model type.

Definition at line 89 of file GModelSpatialDiffuseConst.cpp.

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

GModelSpatialDiffuseConst::GModelSpatialDiffuseConst ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs isotropic spatial 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 113 of file GModelSpatialDiffuseConst.cpp.

References init_members(), and read().

GModelSpatialDiffuseConst::GModelSpatialDiffuseConst ( const double &  value)
explicit

Value constructor.

Parameters
[in]valueIsotropic intensity value ( \(sr^{-1}\)).

Constructs isotropic spatial model by assigning an intensity of value in units of \(sr^{-1}\) to the diffuse emission. This constructor explicitly sets the m_value member of the model.

Definition at line 136 of file GModelSpatialDiffuseConst.cpp.

References GModelSpatial::autoscale(), init_members(), m_value, and GOptimizerPar::value().

GModelSpatialDiffuseConst::GModelSpatialDiffuseConst ( const GModelSpatialDiffuseConst model)

Copy constructor.

Parameters
[in]modelIsotropic spatial model.

Constructs isotropic spatial model by copying another isotropic spatial model.

Definition at line 161 of file GModelSpatialDiffuseConst.cpp.

References copy_members(), and init_members().

GModelSpatialDiffuseConst::~GModelSpatialDiffuseConst ( void  )
virtual

Destructor.

Destructs isotropic spatial model.

Definition at line 180 of file GModelSpatialDiffuseConst.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GModelSpatialDiffuse.

Definition at line 108 of file GModelSpatialDiffuseConst.hpp.

void GModelSpatialDiffuseConst::clear ( void  )
virtual

Clear isotropic spatial model.

Clears the isotropic spatial model. This method is equivalent to creating an isotropic spatial model using the void constructor.

Implements GModelSpatialDiffuse.

Definition at line 240 of file GModelSpatialDiffuseConst.cpp.

References GModelSpatialDiffuse::free_members(), free_members(), GModelSpatial::free_members(), GModelSpatialDiffuse::init_members(), init_members(), and GModelSpatial::init_members().

GModelSpatialDiffuseConst * GModelSpatialDiffuseConst::clone ( void  ) const
virtual

Clone isotropic spatial model.

Returns
Pointer to deep copy of isotropic spatial model.

Returns a pointer to a deep copy of the isotropic spatial model.

Implements GModelSpatialDiffuse.

Definition at line 264 of file GModelSpatialDiffuseConst.cpp.

References GModelSpatialDiffuseConst().

bool GModelSpatialDiffuseConst::contains ( const GSkyDir dir,
const double &  margin = 0.0 
) const
inlinevirtual

Signals whether model contains sky direction.

Parameters
[in]dirSky direction.
[in]marginMargin to be added to sky direction (deg, default: 0.0).
Returns
True.

Signals whether a sky direction falls within the bounding circle of the diffuse model. As the constant model is defined on the entire sphere, the method returns always true.

Implements GModelSpatialDiffuse.

Definition at line 155 of file GModelSpatialDiffuseConst.hpp.

void GModelSpatialDiffuseConst::copy_members ( const GModelSpatialDiffuseConst model)
protected

Copy class members.

Parameters
[in]modelIsotropic spatial model.

Definition at line 573 of file GModelSpatialDiffuseConst.cpp.

References m_mc_centre, m_mc_cos_radius, GModelSpatial::m_pars, GModelSpatial::m_type, and m_value.

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

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

Evaluate isotropic spatial model value.

Parameters
[in]photonIncident photon.
[in]gradientsCompute gradients?
Returns
Model value ( \(sr^{-1}\)).

Evaluates the isotropic spatial model for a given photon, characterised by a sky direction, energy and arrival time \((\vec{p},E,t)\). By definition, the isotropic spatial model and gradient are independent of sky direction, energy and time. The model value is given by

\[ M_\mathrm{S}(\vec{p}|E,t) = \frac{v}{4\pi} \]

where \(v\) is the value() parameter, which is divided by the solid angle \(4\pi\) of the celestial sphere.

If the gradients flag is true the method will also evaluate the partial derivatives of the model. The value() gradient is given by

\[ \frac{\partial M_\mathrm{S}(\vec{p}|E,t)}{\partial v_v} = \frac{v_s}{4\pi} \]

where \(v=v_v v_s\) is the factorisation of the value() parameter into a value \(v_v\) and scale \(v_s\) term.

Implements GModelSpatialDiffuse.

Definition at line 301 of file GModelSpatialDiffuseConst.cpp.

References GOptimizerPar::factor_gradient(), gammalib::fourpi, GOptimizerPar::is_free(), m_value, norm(), GOptimizerPar::scale(), value(), and GOptimizerPar::value().

double GModelSpatialDiffuseConst::flux ( const GSkyRegion region,
const GEnergy srcEng = GEnergy(),
const GTime srcTime = GTime() 
) const
virtual

Returns isotropic flux integrated in sky region.

Parameters
[in]regionSky region.
[in]srcEngEnergy.
[in]srcTimeTime.
Returns
Flux (adimensional or ph/cm2/s).

Returns isotropic flux within a sky region. The flux \(F\) is computed using

\[F = \frac{{\tt value}}{4 \pi} \times \Omega\]

where

  • \({\tt value}\) is the normalisation factor returned by the value() method, and
  • \(\Omega\) is the solid angle of the sky region.

Reimplemented from GModelSpatial.

Definition at line 485 of file GModelSpatialDiffuseConst.cpp.

References gammalib::fourpi, m_value, norm(), GSkyRegion::solidangle(), and GOptimizerPar::value().

void GModelSpatialDiffuseConst::free_members ( void  )
protected

Delete class members.

Definition at line 593 of file GModelSpatialDiffuseConst.cpp.

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

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

Return MC sky direction.

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

Returns an arbitrary direction on the celestial sphere within a simulation cone region that has been defined by a previous call to the mc_norm() method (if no such call was made the entire sky will be assumed as the simulation cone). The sky direction is independent of event energy and arrival time.

Implements GModelSpatialDiffuse.

Definition at line 340 of file GModelSpatialDiffuseConst.cpp.

References gammalib::acos(), m_mc_centre, m_mc_cos_radius, gammalib::rad2deg, GSkyDir::rotate_deg(), and GRan::uniform().

double GModelSpatialDiffuseConst::mc_norm ( const GSkyDir dir,
const double &  radius 
) const
virtual

Return normalization of constant diffuse source for Monte Carlo simulations.

Parameters
[in]dirCentre of simulation cone.
[in]radiusRadius of simulation cone (deg).
Returns
Model normalization.
Exceptions
GException::invalid_argumentRadius of simulation cone not coprised in [0,180] degrees.

Returns the normalization of a constant diffuse source. The normalization is given by the product between the fraction \(f\) of the sky covered by the simulation cone

\[ f = \frac{2\pi \left( 1-\cos(r) \right)}{4\pi} \]

(where \(r\) is the radius of the simulation cone) and the model parameter value(). The normalization only depends of the radius of the simulation cone and is invariant to its centre.

Implements GModelSpatialDiffuse.

Definition at line 383 of file GModelSpatialDiffuseConst.cpp.

References cos(), gammalib::deg2rad, G_MC_NORM, m_mc_centre, m_mc_cos_radius, norm(), gammalib::str(), and value().

GModelSpatialDiffuseConst & GModelSpatialDiffuseConst::operator= ( const GModelSpatialDiffuseConst model)

Assignment operator.

Parameters
[in]modelIsotropic spatial model.
Returns
Isotropic spatial model.

Assigns an isotropic spatial model.

Definition at line 204 of file GModelSpatialDiffuseConst.cpp.

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

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

Print isotropic source model information.

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

Implements GModelSpatialDiffuse.

Definition at line 506 of file GModelSpatialDiffuseConst.cpp.

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

void GModelSpatialDiffuseConst::read ( const GXmlElement xml)
virtual

Read model from XML element.

Parameters
[in]xmlXML element.

Read the isotropic source model information from an XML element. The XML element is expected to have the following format:

<spatialModel type="DiffuseIsotropic">
  <parameter name="Value" scale="1" value="1" min="1"  max="1" free="0"/>
</spatialModel>

Implements GModelSpatialDiffuse.

Definition at line 422 of file GModelSpatialDiffuseConst.cpp.

References G_READ, m_value, GOptimizerPar::name(), GModelPar::read(), gammalib::xml_check_parnum(), and gammalib::xml_get_par().

Referenced by GModelSpatialDiffuseConst().

void GModelSpatialDiffuseConst::set_region ( void  ) const
protectedvirtual

Set boundary sky region.

Implements GModelSpatialDiffuse.

Definition at line 603 of file GModelSpatialDiffuseConst.cpp.

References GModelSpatial::m_region, and GModelSpatial::region().

double GModelSpatialDiffuseConst::value ( void  ) const
inline

Get model value.

Returns
Model value.

Returns the value of the isotropic spatial model.

Definition at line 122 of file GModelSpatialDiffuseConst.hpp.

References m_value, and GOptimizerPar::value().

Referenced by eval(), and mc_norm().

void GModelSpatialDiffuseConst::value ( const double &  value)
inline

Set model value.

Parameters
[in]valueModel value.

Set the value of the isotropic spatial model.

Definition at line 136 of file GModelSpatialDiffuseConst.hpp.

References m_value, and GOptimizerPar::value().

void GModelSpatialDiffuseConst::write ( GXmlElement xml) const
virtual

Write model into XML element.

Parameters
[in]xmlXML element.

Write the isotropic source model information into an XML element. The XML element will have the following format:

<spatialModel type="DiffuseIsotropic">
  <parameter name="Value" scale="1" value="1" min="1"  max="1" free="0"/>
</spatialModel>

Implements GModelSpatialDiffuse.

Definition at line 451 of file GModelSpatialDiffuseConst.cpp.

References G_WRITE, m_value, GOptimizerPar::name(), GModelSpatial::type(), GModelPar::write(), gammalib::xml_check_type(), and gammalib::xml_need_par().

Member Data Documentation

GSkyDir GModelSpatialDiffuseConst::m_mc_centre
mutableprotected

Simulation cone centre.

Definition at line 97 of file GModelSpatialDiffuseConst.hpp.

Referenced by copy_members(), init_members(), mc(), and mc_norm().

double GModelSpatialDiffuseConst::m_mc_cos_radius
mutableprotected

Cosine of sim. cone radius.

Definition at line 98 of file GModelSpatialDiffuseConst.hpp.

Referenced by copy_members(), init_members(), mc(), and mc_norm().

GModelPar GModelSpatialDiffuseConst::m_value
protected

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