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

Radial Gaussian CTA model class. More...

#include <GCTAModelRadialGauss.hpp>

Inheritance diagram for GCTAModelRadialGauss:
GCTAModelRadial GCTAModelSpatial GBase

Classes

class  integrand
 

Public Member Functions

 GCTAModelRadialGauss (void)
 Void constructor. More...
 
 GCTAModelRadialGauss (const double &sigma)
 Constructor. More...
 
 GCTAModelRadialGauss (const GXmlElement &xml)
 XML constructor. More...
 
 GCTAModelRadialGauss (const GCTAModelRadialGauss &model)
 Copy constructor. More...
 
virtual ~GCTAModelRadialGauss (void)
 Destructor. More...
 
virtual GCTAModelRadialGaussoperator= (const GCTAModelRadialGauss &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear instance. More...
 
virtual GCTAModelRadialGaussclone (void) const
 Clone instance. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual std::string type (void) const
 Return model type. More...
 
virtual double eval (const double &offset, const bool &gradients=false) const
 Evaluate function. More...
 
virtual GCTAInstDir mc (GRan &ran) const
 Returns MC instrument direction. More...
 
virtual double mc_max_value (const GCTAObservation &obs) const
 Return maximum function value for Monte Carlo simulations. More...
 
virtual double omega (void) const
 Returns integral over radial model (in steradians) 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 point source information. More...
 
double sigma (void) const
 Return Gaussian width parameter. More...
 
void sigma (const double &sigma)
 Set Gaussian width parameter. More...
 
- Public Member Functions inherited from GCTAModelRadial
 GCTAModelRadial (void)
 Void constructor. More...
 
 GCTAModelRadial (const GCTAModelRadial &model)
 Copy constructor. More...
 
virtual ~GCTAModelRadial (void)
 Destructor. More...
 
virtual GCTAModelRadialoperator= (const GCTAModelRadial &model)
 Assignment operator. More...
 
virtual double eval (const GCTAInstDir &dir, const GEnergy &energy, const GTime &time, const bool &gradients=false) const
 Evaluate function. More...
 
virtual GCTAInstDir mc (const GEnergy &energy, const GTime &time, const GCTAObservation &obs, GRan &ran) const
 Returns MC instrument direction. More...
 
- Public Member Functions inherited from GCTAModelSpatial
 GCTAModelSpatial (void)
 Void constructor. More...
 
 GCTAModelSpatial (const GCTAModelSpatial &model)
 Copy constructor. More...
 
virtual ~GCTAModelSpatial (void)
 Destructor. More...
 
virtual GCTAModelSpatialoperator= (const GCTAModelSpatial &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 reference to model parameter. More...
 
virtual const GModelParoperator[] (const std::string &name) const
 Returns reference to model parameter (const version) More...
 
int size (void) const
 Return number of model parameters. More...
 
virtual double npred (const GEnergy &energy, const GTime &time, const GObservation &obs) const
 Return integral of spatial model component. 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 GCTAModelRadialGauss &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
- Protected Member Functions inherited from GCTAModelRadial
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GCTAModelRadial &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
- Protected Member Functions inherited from GCTAModelSpatial
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GCTAModelSpatial &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Protected Attributes

GModelPar m_sigma
 Width parameter (degrees^2) More...
 
- Protected Attributes inherited from GCTAModelSpatial
std::vector< GModelPar * > m_pars
 Parameter pointers. More...
 

Detailed Description

Radial Gaussian CTA model class.

This class implements the radial function

\[f(\theta) = \exp \left(-\frac{1}{2} \left( \frac{\theta^2}{\sigma} \right)^2 \right)\]

where \(\theta\) is the offset angle (in degrees), and \(\sigma\) is the width parameter (in degrees \(^2\)).

This function represents a Gaussian in \(\theta^2\).

Definition at line 58 of file GCTAModelRadialGauss.hpp.

Constructor & Destructor Documentation

GCTAModelRadialGauss::GCTAModelRadialGauss ( void  )

Void constructor.

Definition at line 71 of file GCTAModelRadialGauss.cpp.

References init_members().

Referenced by clone().

GCTAModelRadialGauss::GCTAModelRadialGauss ( const double &  sigma)
explicit

Constructor.

Parameters
[in]sigmaGaussian width (degrees \(^2\)).

Definition at line 86 of file GCTAModelRadialGauss.cpp.

References init_members(), and sigma().

GCTAModelRadialGauss::GCTAModelRadialGauss ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Creates instance of a radial Gaussian model by extracting information from an XML element. See GCTAModelRadialGauss::read() for more information about the expected structure of the XML element.

Definition at line 108 of file GCTAModelRadialGauss.cpp.

References init_members(), and read().

GCTAModelRadialGauss::GCTAModelRadialGauss ( const GCTAModelRadialGauss model)

Copy constructor.

Parameters
[in]modelRadial Gaussian model.

Definition at line 126 of file GCTAModelRadialGauss.cpp.

References copy_members(), and init_members().

GCTAModelRadialGauss::~GCTAModelRadialGauss ( void  )
virtual

Destructor.

Definition at line 143 of file GCTAModelRadialGauss.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GCTAModelRadial.

Definition at line 121 of file GCTAModelRadialGauss.hpp.

void GCTAModelRadialGauss::clear ( void  )
virtual
GCTAModelRadialGauss * GCTAModelRadialGauss::clone ( void  ) const
virtual

Clone instance.

Implements GCTAModelRadial.

Definition at line 215 of file GCTAModelRadialGauss.cpp.

References GCTAModelRadialGauss().

void GCTAModelRadialGauss::copy_members ( const GCTAModelRadialGauss model)
protected

Copy class members.

Parameters
[in]modelRadial Gaussian model.

Definition at line 526 of file GCTAModelRadialGauss.cpp.

References GCTAModelSpatial::m_pars, and m_sigma.

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

double GCTAModelRadialGauss::eval ( const double &  offset,
const bool &  gradients = false 
) const
virtual

Evaluate function.

Parameters
[in]offsetOffset angle (degrees).
[in]gradientsCompute gradients?
Returns
Function value

Evaluates the Gaussian model for a given offset. The Gaussian model is defined as

\[f(\theta) = \exp \left(-\frac{1}{2} \left( \frac{\theta^2}{\sigma} \right)^2 \right)\]

where \(\theta\) is the offset angle (in degrees), and \(\sigma\) is the Gaussian width (in degrees \(^2\)).

If the gradients flag is true the method will also compute the partial derivatives of the parameters. The partial derivative of the Gaussian width is given by

\[\frac{df}{d\sigma_v} = f(\theta) \frac{\theta^4}{\sigma^3} \sigma_s\]

where \(\sigma_v\) is the value part, \(\sigma_s\) is the scaling part, and \(\sigma = \sigma_v \sigma_s\).

Note that this method implements a function which is unity for \(\theta=0\).

Implements GCTAModelRadial.

Definition at line 248 of file GCTAModelRadialGauss.cpp.

References exp(), GOptimizerPar::factor_gradient(), gammalib::is_infinite(), gammalib::is_notanumber(), m_sigma, GOptimizerPar::scale(), and sigma().

void GCTAModelRadialGauss::free_members ( void  )
protected

Delete class members.

Definition at line 543 of file GCTAModelRadialGauss.cpp.

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

GCTAInstDir GCTAModelRadialGauss::mc ( GRan ran) const
virtual

Returns MC instrument direction.

Parameters
[in,out]ranRandom number generator.
Returns
CTA instrument direction.

Draws an arbitrary CTA instrument position from

\[f(\theta) = \sin(\theta) \exp \left(-\frac{1}{2}\frac{\theta^4}{\sigma^2} \right)\]

where \(\theta\) is the offset angle (in degrees), and \(\sigma\) is the Gaussian width (in degrees \(^2\)), using the rejection method.

Todo:
Method can be optimised by using a random deviate of sin instead of the uniform random deviate which leads to many unnecessary rejections.

Implements GCTAModelRadial.

Definition at line 301 of file GCTAModelRadialGauss.cpp.

References cos(), gammalib::deg2rad, exp(), sigma(), sin(), sqrt(), and GRan::uniform().

double GCTAModelRadialGauss::mc_max_value ( const GCTAObservation obs) const
virtual

Return maximum function value for Monte Carlo simulations.

Parameters
[in]obsCTA Observation.
Returns
Maximum function value for Monte Carlo simulations.

Implements GCTAModelRadial.

Definition at line 355 of file GCTAModelRadialGauss.cpp.

double GCTAModelRadialGauss::omega ( void  ) const
virtual

Returns integral over radial model (in steradians)

Computes

\[\Omega = 2 \pi \int_0^{\pi} \sin \theta f(\theta) d\theta\]

where

\[f(\theta) = \exp \left(-\frac{1}{2} \left( \frac{\theta^2}{\sigma} \right)^2 \right)\]

\(\theta\) is the offset angle (in degrees), and \(\sigma\) is the Gaussian width (in degrees \(^2\)).

The integration is performed numerically, and the upper integration bound \(\pi\) is set to \(\sqrt(10 \sigma)\) to reduce inaccuracies in the numerical integration.

Implements GCTAModelRadial.

Definition at line 379 of file GCTAModelRadialGauss.cpp.

References gammalib::deg2rad, gammalib::pi, GIntegral::romberg(), sigma(), sqrt(), and gammalib::twopi.

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

Assignment operator.

Parameters
[in]modelRadial Gaussian model.

Definition at line 164 of file GCTAModelRadialGauss.cpp.

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

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

Print point source information.

Parameters
[in]chatterChattiness.
Returns
String containing point source information.

Implements GCTAModelRadial.

Definition at line 465 of file GCTAModelRadialGauss.cpp.

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

void GCTAModelRadialGauss::read ( const GXmlElement xml)
virtual

Read model from XML element.

Parameters
[in]xmlXML element.

Read the Gaussian radial model information from an XML element in the following format

<radialModel type="...">
  <parameter name="Sigma"  scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
</radialModel>

Implements GCTAModelRadial.

Definition at line 415 of file GCTAModelRadialGauss.cpp.

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

Referenced by GCTAModelRadialGauss().

double GCTAModelRadialGauss::sigma ( void  ) const
inline

Return Gaussian width parameter.

Returns
Gaussian width parameter.

Definition at line 145 of file GCTAModelRadialGauss.hpp.

References m_sigma, and GOptimizerPar::value().

Referenced by eval(), GCTAModelRadialGauss(), mc(), omega(), read(), and write().

void GCTAModelRadialGauss::sigma ( const double &  sigma)
inline

Set Gaussian width parameter.

Parameters
[in]sigmaGaussian width parameter.

Definition at line 157 of file GCTAModelRadialGauss.hpp.

References m_sigma, and GOptimizerPar::value().

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

Return model type.

Returns
Model type "Gaussian".

Implements GCTAModelRadial.

Definition at line 133 of file GCTAModelRadialGauss.hpp.

Referenced by write().

void GCTAModelRadialGauss::write ( GXmlElement xml) const
virtual

Write model into XML element.

Parameters
[in]xmlXML element.

Write the Gaussian radial model information into an XML element in the following format

<radialModel type="...">
  <parameter name="Sigma"  scale="1.0" value="3.0" min="0.01" max="10.0" free="1"/>
</radialModel>

Implements GCTAModelRadial.

Definition at line 443 of file GCTAModelRadialGauss.cpp.

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

Member Data Documentation

GModelPar GCTAModelRadialGauss::m_sigma
protected

Width parameter (degrees^2)

Definition at line 111 of file GCTAModelRadialGauss.hpp.

Referenced by copy_members(), eval(), init_members(), read(), sigma(), and write().


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