GammaLib
2.0.0
|
Isotropic spatial model. More...
#include <GModelSpatialDiffuseConst.hpp>
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... | |
GModelSpatialDiffuseConst & | operator= (const GModelSpatialDiffuseConst &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear isotropic spatial model. More... | |
virtual GModelSpatialDiffuseConst * | clone (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 ®ion, 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 GModelSpatialDiffuse & | operator= (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 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 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... | |
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.
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.
[in] | dummy | Dummy flag. |
[in] | type | Model 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().
|
explicit |
XML constructor.
[in] | xml | XML 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().
|
explicit |
Value constructor.
[in] | value | Isotropic 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.
[in] | model | Isotropic 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().
|
virtual |
Destructor.
Destructs isotropic spatial model.
Definition at line 180 of file GModelSpatialDiffuseConst.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GModelSpatialDiffuse.
Definition at line 108 of file GModelSpatialDiffuseConst.hpp.
|
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().
|
virtual |
Clone 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().
|
inlinevirtual |
Signals whether model contains sky direction.
[in] | dir | Sky direction. |
[in] | margin | Margin to be added to sky direction (deg, default: 0.0). |
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.
|
protected |
Copy class members.
[in] | model | Isotropic 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=().
|
virtual |
Evaluate isotropic spatial model value.
[in] | photon | Incident photon. |
[in] | gradients | Compute gradients? |
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().
|
virtual |
Returns isotropic flux integrated in sky region.
[in] | region | Sky region. |
[in] | srcEng | Energy. |
[in] | srcTime | Time. |
Returns isotropic flux within a sky region. The flux \(F\) is computed using
\[F = \frac{{\tt value}}{4 \pi} \times \Omega\]
where
Reimplemented from GModelSpatial.
Definition at line 485 of file GModelSpatialDiffuseConst.cpp.
References gammalib::fourpi, m_value, norm(), GSkyRegion::solidangle(), and GOptimizerPar::value().
|
protected |
Delete class members.
Definition at line 593 of file GModelSpatialDiffuseConst.cpp.
Referenced by clear(), operator=(), and ~GModelSpatialDiffuseConst().
|
protected |
Initialise class members.
Definition at line 540 of file GModelSpatialDiffuseConst.cpp.
References GSkyDir::clear(), GOptimizerPar::clear(), GOptimizerPar::fix(), GOptimizerPar::gradient(), GOptimizerPar::has_grad(), m_mc_centre, m_mc_cos_radius, GModelSpatial::m_pars, GModelSpatial::m_type, m_value, GOptimizerPar::name(), GOptimizerPar::range(), GOptimizerPar::scale(), and GOptimizerPar::value().
Referenced by clear(), GModelSpatialDiffuseConst(), and operator=().
|
virtual |
Return MC sky direction.
[in] | energy | Photon energy. |
[in] | time | Photon arrival time. |
[in,out] | ran | Random number generator. |
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().
|
virtual |
Return normalization of constant diffuse source for Monte Carlo simulations.
[in] | dir | Centre of simulation cone. |
[in] | radius | Radius of simulation cone (deg). |
GException::invalid_argument | Radius 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.
[in] | model | 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=().
Print isotropic source model information.
[in] | chatter | Chattiness. |
Implements GModelSpatialDiffuse.
Definition at line 506 of file GModelSpatialDiffuseConst.cpp.
References GModelSpatial::m_pars, gammalib::parformat(), SILENT, GModelSpatial::size(), and gammalib::str().
|
virtual |
Read model from XML element.
[in] | xml | XML 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().
|
protectedvirtual |
Set boundary sky region.
Implements GModelSpatialDiffuse.
Definition at line 603 of file GModelSpatialDiffuseConst.cpp.
References GModelSpatial::m_region, and GModelSpatial::region().
|
inline |
Get model value.
Returns the value of the isotropic spatial model.
Definition at line 122 of file GModelSpatialDiffuseConst.hpp.
References m_value, and GOptimizerPar::value().
|
inline |
Set model value.
[in] | value | Model value. |
Set the value of the isotropic spatial model.
Definition at line 136 of file GModelSpatialDiffuseConst.hpp.
References m_value, and GOptimizerPar::value().
|
virtual |
Write model into XML element.
[in] | xml | XML 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().
|
mutableprotected |
Simulation cone centre.
Definition at line 97 of file GModelSpatialDiffuseConst.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_norm().
|
mutableprotected |
Cosine of sim. cone radius.
Definition at line 98 of file GModelSpatialDiffuseConst.hpp.
Referenced by copy_members(), init_members(), mc(), and mc_norm().
|
protected |
Value.
Definition at line 96 of file GModelSpatialDiffuseConst.hpp.
Referenced by copy_members(), eval(), flux(), GModelSpatialDiffuseConst(), init_members(), read(), value(), and write().