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

Radial acceptance model class. More...

#include <GCTAModelRadialAcceptance.hpp>

Inheritance diagram for GCTAModelRadialAcceptance:
GModelData GModel GBase

Classes

class  roi_kern
 

Public Member Functions

 GCTAModelRadialAcceptance (void)
 Void constructor. More...
 
 GCTAModelRadialAcceptance (const GXmlElement &xml)
 XML constructor. More...
 
 GCTAModelRadialAcceptance (const GCTAModelRadial &radial, const GModelSpectral &spectral)
 Construct from radial and spectral components. More...
 
 GCTAModelRadialAcceptance (const GCTAModelRadial &radial, const GModelSpectral &spectral, const GModelTemporal &temporal)
 Construct from model components. More...
 
 GCTAModelRadialAcceptance (const GCTAModelRadialAcceptance &model)
 Copy constructor. More...
 
virtual ~GCTAModelRadialAcceptance (void)
 Destructor. More...
 
virtual GCTAModelRadialAcceptanceoperator= (const GCTAModelRadialAcceptance &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear instance. More...
 
virtual GCTAModelRadialAcceptanceclone (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 bool is_constant (void) const
 Signals if model is temporally constant. More...
 
virtual double eval (const GEvent &event, const GObservation &obs, const bool &gradients=false) const
 Return background rate in units of events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\). More...
 
virtual double npred (const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
 Return spatially integrated background rate in units of events MeV \(^{-1}\) s \(^{-1}\). More...
 
virtual GCTAEventListmc (const GObservation &obs, GRan &ran) const
 Return simulated list of events. 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 model information. More...
 
GCTAModelRadialradial (void) const
 Return radial model component. More...
 
GModelSpectralspectral (void) const
 Return spectral model component. More...
 
GModelTemporaltemporal (void) const
 Return temporal model component. More...
 
void radial (const GCTAModelRadial *radial)
 Set radial model component. More...
 
void spectral (const GModelSpectral *spectral)
 Set spectral model component. More...
 
void temporal (const GModelTemporal *temporal)
 Set temporal model component. More...
 
- Public Member Functions inherited from GModelData
 GModelData (void)
 Void constructor. More...
 
 GModelData (const GXmlElement &xml)
 XML constructor. More...
 
 GModelData (const GModelData &model)
 Copy constructor. More...
 
virtual ~GModelData (void)
 Destructor. More...
 
virtual GModelDataoperator= (const GModelData &model)
 Assignment operator. More...
 
- Public Member Functions inherited from GModel
 GModel (void)
 Void constructor. More...
 
 GModel (const GXmlElement &xml)
 XML constructor. More...
 
 GModel (const GModel &model)
 Copy constructor. More...
 
virtual ~GModel (void)
 Destructor. More...
 
virtual GModeloperator= (const GModel &model)
 Assignment operator. More...
 
virtual GModelParoperator[] (const int &index)
 Returns reference to model parameter by index. More...
 
virtual const GModelParoperator[] (const int &index) const
 Returns reference to model parameter by index (const version) More...
 
virtual GModelParoperator[] (const std::string &name)
 Returns reference to model parameter by name. More...
 
virtual const GModelParoperator[] (const std::string &name) const
 Returns reference to model parameter by name const version) More...
 
int size (void) const
 Return number of parameters in model. More...
 
int scales (void) const
 Return number of scale parameters in model. More...
 
GModelParat (const int &index)
 Returns reference to model parameter by index. More...
 
const GModelParat (const int &index) const
 Returns reference to model parameter by index (const version) More...
 
bool has_par (const std::string &name) const
 Checks if parameter name exists. More...
 
bool has_scales (void) const
 Signals that model has scales. More...
 
const std::string & name (void) const
 Return parameter name. More...
 
void name (const std::string &name)
 Set parameter name. More...
 
const double & ts (void) const
 Return Test Statistic value. More...
 
void ts (const double &ts)
 Set Test Statistic value. More...
 
const bool & tscalc (void) const
 Return Test Statistic computation flag. More...
 
void tscalc (const bool &tscalc)
 Set Test Statistic computation flag. More...
 
const bool & has_ts (void) const
 Signals that model has Test Statistics value. More...
 
std::string instruments (void) const
 Returns instruments to which model applies. More...
 
void instruments (const std::string &instruments)
 Set instruments to which model applies. More...
 
GModelParscale (const int &index)
 Returns reference to scale parameter by index. More...
 
const GModelParscale (const int &index) const
 Returns reference to scale parameter by index (const version) More...
 
GModelPar scale (const std::string &instrument) const
 Returns model scale factor for a given instrument. More...
 
void scale (const GModelPar &par)
 Set model scale factor for a given instrument. More...
 
std::string ids (void) const
 Returns observation identifiers to which model applies. More...
 
void ids (const std::string &ids)
 Set observation identifiers to which model applies. More...
 
bool is_valid (const std::string &instruments, const std::string &ids) const
 Verifies if model is valid for a given instrument and identifier. 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 GCTAModelRadialAcceptance &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void set_pointers (void)
 Set pointers. More...
 
bool valid_model (void) const
 Verifies if model has all components. More...
 
GCTAModelRadialxml_radial (const GXmlElement &radial) const
 Construct radial model from XML element. More...
 
GModelSpectralxml_spectral (const GXmlElement &spectral) const
 Return pointer to spectral model from XML element. More...
 
GModelTemporalxml_temporal (const GXmlElement &temporal) const
 Return pointer to temporal model from XML element. More...
 
- Protected Member Functions inherited from GModelData
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModelData &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
- Protected Member Functions inherited from GModel
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GModel &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void read_attributes (const GXmlElement &xml)
 Read model attributes. More...
 
void write_attributes (GXmlElement &xml) const
 Write model attributes. More...
 
std::string print_attributes (void) const
 Print model attributes. More...
 
void read_scales (const GXmlElement &xml)
 Read instrument scales from XML element. More...
 
void write_scales (GXmlElement &xml) const
 Write instrument scales into XML element. More...
 

Protected Attributes

GCTAModelRadialm_radial
 Radial model. More...
 
GModelSpectralm_spectral
 Spectral model. More...
 
GModelTemporalm_temporal
 Temporal model. More...
 
- Protected Attributes inherited from GModel
std::string m_name
 Model name. More...
 
std::vector< std::string > m_instruments
 Instruments to which model applies. More...
 
std::vector< GModelParm_scales
 Model instrument scale factors. More...
 
std::vector< std::string > m_ids
 Identifiers to which model applies. More...
 
std::vector< GModelPar * > m_pars
 Pointers to all model parameters. More...
 
bool m_has_ts
 Signals if TS is available. More...
 
bool m_has_tscalc
 Signals if tscalc attribute is available. More...
 
bool m_tscalc
 Signals if TS should be computed. More...
 
double m_ts
 Test Statistic of the model. More...
 

Detailed Description

Radial acceptance model class.

This class implements a radial acceptance model for CTA.

Definition at line 52 of file GCTAModelRadialAcceptance.hpp.

Constructor & Destructor Documentation

GCTAModelRadialAcceptance::GCTAModelRadialAcceptance ( void  )

Void constructor.

Constructs an empty CTA radial acceptance model.

Definition at line 84 of file GCTAModelRadialAcceptance.cpp.

References init_members().

Referenced by clone().

GCTAModelRadialAcceptance::GCTAModelRadialAcceptance ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs a CTA radial acceptance model from the information that is found in a XML element. Please refer to the read() method to learn about the expected structure of the XML element.

Definition at line 103 of file GCTAModelRadialAcceptance.cpp.

References init_members(), read(), and set_pointers().

GCTAModelRadialAcceptance::GCTAModelRadialAcceptance ( const GCTAModelRadial radial,
const GModelSpectral spectral 
)

Construct from radial and spectral components.

Parameters
[in]radialRadial CTA model component.
[in]spectralSpectral model component.

Constructs a CTA radial acceptance model from a radial and a spectral model component. The temporal component is assumed to be constant.

Definition at line 130 of file GCTAModelRadialAcceptance.cpp.

References GModelTemporalConst::clone(), GCTAModelRadial::clone(), GModelSpectral::clone(), init_members(), m_radial, m_spectral, m_temporal, set_pointers(), and temporal().

GCTAModelRadialAcceptance::GCTAModelRadialAcceptance ( const GCTAModelRadial radial,
const GModelSpectral spectral,
const GModelTemporal temporal 
)

Construct from model components.

Parameters
[in]radialRadial CTA model component.
[in]spectralSpectral model component.
[in]temporalTemporal model component.

Constructs a CTA radial acceptance model from a radial, a spectral and a temporal model component.

Definition at line 163 of file GCTAModelRadialAcceptance.cpp.

References GModelTemporal::clone(), GCTAModelRadial::clone(), GModelSpectral::clone(), init_members(), m_radial, m_spectral, m_temporal, and set_pointers().

GCTAModelRadialAcceptance::GCTAModelRadialAcceptance ( const GCTAModelRadialAcceptance model)

Copy constructor.

Parameters
[in]modelRadial acceptance model.

Constructs a CTA radial acceptance model by copying information from an existing model. Note that the copy is a deep copy, so the original object can be destroyed after the copy without any loss of information.

Definition at line 193 of file GCTAModelRadialAcceptance.cpp.

References copy_members(), init_members(), and set_pointers().

GCTAModelRadialAcceptance::~GCTAModelRadialAcceptance ( void  )
virtual

Destructor.

Destroys a CTA radial acceptance model.

Definition at line 215 of file GCTAModelRadialAcceptance.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GModelData.

Definition at line 137 of file GCTAModelRadialAcceptance.hpp.

void GCTAModelRadialAcceptance::clear ( void  )
virtual

Clear instance.

Resets the object to a clean initial state. All information that resided in the object will be lost.

Implements GModelData.

Definition at line 277 of file GCTAModelRadialAcceptance.cpp.

References GModelData::free_members(), free_members(), GModel::free_members(), GModelData::init_members(), init_members(), and GModel::init_members().

Referenced by read().

GCTAModelRadialAcceptance * GCTAModelRadialAcceptance::clone ( void  ) const
virtual

Clone instance.

Returns
Pointer to deep copy of CTA radial acceptance model.

Implements GModelData.

Definition at line 299 of file GCTAModelRadialAcceptance.cpp.

References GCTAModelRadialAcceptance().

void GCTAModelRadialAcceptance::copy_members ( const GCTAModelRadialAcceptance model)
protected

Copy class members.

Parameters
[in]modelModel.
Todo:
Document method.

Definition at line 864 of file GCTAModelRadialAcceptance.cpp.

References GModelTemporal::clone(), GCTAModelRadial::clone(), GModelSpectral::clone(), m_radial, m_spectral, m_temporal, and set_pointers().

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

double GCTAModelRadialAcceptance::eval ( const GEvent event,
const GObservation obs,
const bool &  gradients = false 
) const
virtual

Return background rate in units of events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\).

Parameters
[in]eventObserved event.
[in]obsObservation.
[in]gradientsCompute gradients?
Returns
Background rate (events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\)).

Evaluates tha CTA radial acceptance model which is a factorization of a spatial, spectral and temporal model component. The method returns a real rate, defined by the number of counts per MeV, steradian and ontime.

If the gradients flag is true the method will also set the parameter gradients of the model parameters.

Todo:

Add bookkeeping of last value and evaluate only if argument changed

Verify that CTA instrument direction pointer is valid, or better, add an offset method to GCTAPointing. Ideally, we should precompute all offset angles (for an event cube this may only be done easily if the pointing has been fixed; otherwise we need a structure similar to the Fermi/LAT livetime cube that provides the effective sky exposure as function of offset angle).

Implements GModelData.

Definition at line 411 of file GCTAModelRadialAcceptance.cpp.

References gammalib::cta_dir(), gammalib::cta_pnt(), GCTAPointing::dir(), GCTAInstDir::dir(), GEvent::energy(), GCTAModelRadial::eval(), GModelTemporal::eval(), GModelSpectral::eval(), G_EVAL, radial(), GModelTemporal::size(), GCTAModelSpatial::size(), GModelSpectral::size(), spectral(), temporal(), and GEvent::time().

void GCTAModelRadialAcceptance::free_members ( void  )
protected

Delete class members.

Todo:
Document method.

Definition at line 884 of file GCTAModelRadialAcceptance.cpp.

References m_radial, m_spectral, and m_temporal.

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

void GCTAModelRadialAcceptance::init_members ( void  )
protected

Initialise class members.

Todo:
Document method.

Definition at line 845 of file GCTAModelRadialAcceptance.cpp.

References m_radial, m_spectral, and m_temporal.

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

bool GCTAModelRadialAcceptance::is_constant ( void  ) const
inlinevirtual

Signals if model is temporally constant.

Returns
True if model is temporally constant, false otherwise.

Signals if the model is temporally constant. A temporally constant model is a model that has a temporal component of type "Constant".

Implements GModelData.

Definition at line 167 of file GCTAModelRadialAcceptance.hpp.

References m_temporal, and GModelTemporal::type().

GCTAEventList * GCTAModelRadialAcceptance::mc ( const GObservation obs,
GRan ran 
) const
virtual

Return simulated list of events.

Parameters
[in]obsObservation.
[in]ranRandom number generator.
Exceptions
GCTAException::no_pointingNo CTA pointing found in observation.

Draws a sample of events from the radial acceptance model using a Monte Carlo simulation. The pointing information, the energy boundaries and the good time interval for the sampling will be extracted from the observation argument that is passed to the method. The method also requires a random number generator of type GRan which is passed by reference, hence the state of the random number generator will be changed by the method.

Implements GModelData.

Definition at line 551 of file GCTAModelRadialAcceptance.cpp.

References GCTAEventList::append(), gammalib::cta_pnt(), GCTAEventAtom::dir(), GCTAPointing::dir(), GCTAInstDir::dir(), GEvents::ebounds(), GObservation::events(), GModelSpectral::flux(), G_MC, GEvents::gti(), m_temporal, GCTAModelRadial::mc(), GModelTemporal::mc(), GModelSpectral::mc(), GModel::name(), GCTAModelRadial::omega(), radial(), GCTAEventList::reserve(), GTimes::size(), GCTAPointing::skydir(), spectral(), and valid_model().

double GCTAModelRadialAcceptance::npred ( const GEnergy obsEng,
const GTime obsTime,
const GObservation obs 
) const
virtual

Return spatially integrated background rate in units of events MeV \(^{-1}\) s \(^{-1}\).

Parameters
[in]obsEngMeasured event energy.
[in]obsTimeMeasured event time.
[in]obsObservation.
Returns
Spatially integrated background rate (events MeV \(^{-1}\) s \(^{-1}\))
Exceptions
GException::no_listNo valid CTA event list found in observation
GCTAException::no_pointingNo valid CTA pointing found in observation

Spatially integrates the data model for a given measured event energy and event time. The method returns a real rate, defined as the number of counts per MeV and ontime.

Implements GModelData.

Definition at line 491 of file GCTAModelRadialAcceptance.cpp.

References gammalib::cta_event_list(), gammalib::cta_pnt(), gammalib::deg2rad, GCTAPointing::dir(), GModelTemporal::eval(), GModelSpectral::eval(), G_NPRED, radial(), GCTAEventList::roi(), GIntegral::romberg(), spectral(), temporal(), and valid_model().

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

Assignment operator.

Parameters
[in]modelRadial acceptance model.

Assigns the information from a CTA radial acceptance model to the actual object. Note that a deep copy of the information is performed, so the original object can be destroyed after the assignment without any loss of information.

Definition at line 241 of file GCTAModelRadialAcceptance.cpp.

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

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

Print model information.

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

Implements GModelData.

Definition at line 771 of file GCTAModelRadialAcceptance.cpp.

References gammalib::parformat(), GModel::print_attributes(), radial(), SILENT, GModelTemporal::size(), GCTAModelSpatial::size(), GModelSpectral::size(), GModel::size(), spectral(), gammalib::str(), temporal(), and type().

GCTAModelRadial * GCTAModelRadialAcceptance::radial ( void  ) const
inline

Return radial model component.

Returns
Pointer to radial model component.

Returns a pointer to the radial model component of the model. The pointer is of type GCTAModelRadial. Note that a NULL pointer may be returned if the model has no radial model component.

Definition at line 183 of file GCTAModelRadialAcceptance.hpp.

References m_radial.

Referenced by eval(), GCTAModelRadialAcceptance::roi_kern::eval(), mc(), npred(), print(), set_pointers(), valid_model(), and write().

void GCTAModelRadialAcceptance::radial ( const GCTAModelRadial radial)

Set radial model component.

Parameters
[in]radialPointer to radial model component.

Sets the radial model component of the model.

Definition at line 312 of file GCTAModelRadialAcceptance.cpp.

References GCTAModelRadial::clone(), m_radial, and set_pointers().

void GCTAModelRadialAcceptance::read ( const GXmlElement xml)
virtual

Read model from XML element.

Parameters
[in]xmlXML element.

The model is composed of a spectrum component ('spectral'), a radial component ('radialModel'), and, optionally, of a temporal component ('lightcurve'). If no temporal component is found a constant model is assumed.

Implements GModelData.

Definition at line 659 of file GCTAModelRadialAcceptance.cpp.

References clear(), GModelTemporalConst::clone(), GXmlNode::element(), m_radial, m_spectral, m_temporal, GModel::read_attributes(), set_pointers(), temporal(), xml_radial(), xml_spectral(), and xml_temporal().

Referenced by GCTAModelRadialAcceptance().

void GCTAModelRadialAcceptance::set_pointers ( void  )
protected

Set pointers.

Set pointers to all model parameters. The pointers are stored in a vector that is member of the GModelData base class.

Definition at line 907 of file GCTAModelRadialAcceptance.cpp.

References GModel::m_pars, radial(), GModelTemporal::size(), GCTAModelSpatial::size(), GModelSpectral::size(), spectral(), and temporal().

Referenced by copy_members(), GCTAModelRadialAcceptance(), radial(), read(), spectral(), and temporal().

GModelSpectral * GCTAModelRadialAcceptance::spectral ( void  ) const
inline

Return spectral model component.

Returns
Pointer to spectral model component.

Returns a pointer to the spectral model component of the model. The pointer is of type GModelSpectral. Note that a NULL pointer may be returned if the model has no spectral model component.

Definition at line 199 of file GCTAModelRadialAcceptance.hpp.

References m_spectral.

Referenced by gammalib::cta_model_spectral(), eval(), mc(), npred(), print(), set_pointers(), valid_model(), and write().

void GCTAModelRadialAcceptance::spectral ( const GModelSpectral spectral)

Set spectral model component.

Parameters
[in]spectralPointer to spectral model component.

Sets the spectral model component of the model.

Definition at line 339 of file GCTAModelRadialAcceptance.cpp.

References GModelSpectral::clone(), m_spectral, and set_pointers().

GModelTemporal * GCTAModelRadialAcceptance::temporal ( void  ) const
inline

Return temporal model component.

Returns
Pointer to temporal model component.

Returns a pointer to the temporal model component of the model. The pointer is of type GModelTemporal. Note that a NULL pointer may be returned if the model has no temporal model component.

Definition at line 215 of file GCTAModelRadialAcceptance.hpp.

References m_temporal.

Referenced by gammalib::cta_model_temporal(), eval(), GCTAModelRadialAcceptance(), npred(), print(), read(), set_pointers(), valid_model(), and write().

void GCTAModelRadialAcceptance::temporal ( const GModelTemporal temporal)

Set temporal model component.

Parameters
[in]temporalPointer to temporal model component.

Sets the temporal model component of the model.

Definition at line 366 of file GCTAModelRadialAcceptance.cpp.

References GModelTemporal::clone(), m_temporal, and set_pointers().

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

Return model type.

Returns
Model type.

Returns the type of the model. The type for a radial acceptance model is "RadialAcceptance".

Implements GModelData.

Definition at line 152 of file GCTAModelRadialAcceptance.hpp.

Referenced by print(), and xml_radial().

bool GCTAModelRadialAcceptance::valid_model ( void  ) const
protected

Verifies if model has all components.

Returns 'true' if models has a radial, a spectral and a temporal component. Otherwise returns 'false'.

Definition at line 949 of file GCTAModelRadialAcceptance.cpp.

References radial(), spectral(), and temporal().

Referenced by mc(), and npred().

void GCTAModelRadialAcceptance::write ( GXmlElement xml) const
virtual
GCTAModelRadial * GCTAModelRadialAcceptance::xml_radial ( const GXmlElement radial) const
protected

Construct radial model from XML element.

Parameters
[in]radialXML element containing radial model information.
Exceptions
GCTAException::model_invalid_radialInvalid radial model type encountered.

Returns pointer to a radial model that is defined in an XML element.

Definition at line 971 of file GCTAModelRadialAcceptance.cpp.

References GCTAModelRadialRegistry::alloc(), GXmlElement::attribute(), G_XML_RADIAL, GCTAModelRadial::read(), and type().

Referenced by read().

GModelSpectral * GCTAModelRadialAcceptance::xml_spectral ( const GXmlElement spectral) const
protected

Return pointer to spectral model from XML element.

Parameters
[in]spectralXML element.
Returns
Pointer to spectral model.

Returns pointer to spectral model that is defined in an XML element.

Definition at line 1003 of file GCTAModelRadialAcceptance.cpp.

References GModelSpectralRegistry::alloc().

Referenced by read().

GModelTemporal * GCTAModelRadialAcceptance::xml_temporal ( const GXmlElement temporal) const
protected

Return pointer to temporal model from XML element.

Parameters
[in]temporalXML element.
Returns
Pointer to temporal model.

Returns pointer to temporal model that is defined in an XML element.

Definition at line 1022 of file GCTAModelRadialAcceptance.cpp.

References GModelTemporalRegistry::alloc().

Referenced by read().

Member Data Documentation

GCTAModelRadial* GCTAModelRadialAcceptance::m_radial
protected
GModelSpectral* GCTAModelRadialAcceptance::m_spectral
protected
GModelTemporal* GCTAModelRadialAcceptance::m_temporal
protected

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