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

COMPTEL DRM model class. More...

#include <GCOMModelDRM.hpp>

Inheritance diagram for GCOMModelDRM:
GModelData GModel GBase

Public Member Functions

 GCOMModelDRM (void)
 Void constructor. More...
 
 GCOMModelDRM (const GXmlElement &xml)
 XML constructor. More...
 
 GCOMModelDRM (const GCOMModelDRM &model)
 Copy constructor. More...
 
virtual ~GCOMModelDRM (void)
 Destructor. More...
 
virtual GCOMModelDRMoperator= (const GCOMModelDRM &model)
 Assignment operator. More...
 
virtual void clear (void)
 Clear instance. More...
 
virtual GCOMModelDRMclone (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
 Evaluate function. More...
 
virtual double npred (const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
 Return spatially integrated DRM model. More...
 
virtual GCOMEventCubemc (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...
 
- 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...
 
virtual GVector eval (const GObservation &obs, GMatrixSparse *gradients=NULL) const
 Return model values and gradients. 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...
 
const GModelAssociationsassociations (void) const
 Return model associations. More...
 
void associations (const GModelAssociations &associations)
 Set model associations. More...
 
const bool & has_eval_indices (void) const
 Signals that parameter indices updated by eval() method were set. More...
 
const std::vector< int > & eval_indices (void) const
 Return vector of parameter indices updated by eval() method. 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 GCOMModelDRM &model)
 Copy class members. More...
 
void free_members (void)
 Delete class members. 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

GModelPar m_norm
 Normalisation. More...
 
GCOMDri m_drm
 Model. More...
 
GFilename m_filename
 Name of DRM FITS file. 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...
 
GModelAssociations m_associations
 Model associations. 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...
 
bool m_has_eval_inx
 
std::vector< int > m_eval_inx
 

Detailed Description

COMPTEL DRM model class.

This class implements a COMPTEL data space model. The model has a normalization parameters.

Definition at line 49 of file GCOMModelDRM.hpp.

Constructor & Destructor Documentation

GCOMModelDRM::GCOMModelDRM ( void  )

Void constructor.

Constructs an empty COMPTEL DRM model.

Definition at line 70 of file GCOMModelDRM.cpp.

References init_members().

Referenced by clone().

GCOMModelDRM::GCOMModelDRM ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs a COMPTEL DRM model from the information that is found in an XML element. Please refer to the method GCOMModelDRM::read to learn more about the information that is expected in the XML element.

Definition at line 89 of file GCOMModelDRM.cpp.

References init_members(), and read().

GCOMModelDRM::GCOMModelDRM ( const GCOMModelDRM model)

Copy constructor.

Parameters
[in]modelCOMPTEL DRM model.

Constructs a COMPTEL DRM 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 111 of file GCOMModelDRM.cpp.

References copy_members(), and init_members().

GCOMModelDRM::~GCOMModelDRM ( void  )
virtual

Destructor.

Destroys a COMPTEL DRM model.

Definition at line 129 of file GCOMModelDRM.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GModelData.

Definition at line 96 of file GCOMModelDRM.hpp.

void GCOMModelDRM::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 192 of file GCOMModelDRM.cpp.

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

GCOMModelDRM * GCOMModelDRM::clone ( void  ) const
virtual

Clone instance.

Returns
Pointer to deep copy of COMPTEL DRM model.

Clone a COMPTEL DRM model. Cloning performs a deep copy of the information, so the original object can be destroyed after cloning without any loss of information.

Implements GModelData.

Definition at line 218 of file GCOMModelDRM.cpp.

References GCOMModelDRM().

void GCOMModelDRM::copy_members ( const GCOMModelDRM model)
protected

Copy class members.

Parameters
[in]modelModel.

Definition at line 546 of file GCOMModelDRM.cpp.

References m_drm, m_filename, m_norm, and GModel::m_pars.

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

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

Evaluate function.

Parameters
[in]eventObserved event.
[in]obsObservation.
[in]gradientsCompute gradients?
Returns
Background model value.
Exceptions
GException::invalid_argumentObservation is not a COMPTEL observation. Event is not a COMPTEL event bin.

Evaluates the COMPTEL DRM model.

Implements GModelData.

Definition at line 238 of file GCOMModelDRM.cpp.

References GOptimizerPar::factor_gradient(), G_EVAL, GCOMEventBin::index(), GOptimizerPar::is_free(), gammalib::is_infinite(), gammalib::is_notanumber(), m_drm, m_norm, GCOMDri::map(), GModel::name(), GSkyMap::pixels(), GOptimizerPar::scale(), GCOMEventBin::size(), GModel::size(), and GOptimizerPar::value().

void GCOMModelDRM::free_members ( void  )
protected

Delete class members.

Definition at line 565 of file GCOMModelDRM.cpp.

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

bool GCOMModelDRM::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. By definition, a DRM model is always temporally constant.

Implements GModelData.

Definition at line 125 of file GCOMModelDRM.hpp.

GCOMEventCube * GCOMModelDRM::mc ( const GObservation obs,
GRan ran 
) const
virtual

Return simulated list of events.

Parameters
[in]obsObservation.
[in]ranRandom number generator.
Returns
COMPTEL event cube.
Exceptions
GException::feature_not_implementedMethod is not implemented.

Draws a sample of events from the COMPTEL DRM model using a Monte Carlo simulation.

Todo:
Implement method.

Implements GModelData.

Definition at line 360 of file GCOMModelDRM.cpp.

References G_MC.

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

Return spatially integrated DRM model.

Parameters
[in]obsEngMeasured event energy.
[in]obsTimeMeasured event time.
[in]obsObservation.
Returns
Spatially integrated DRM model.
Exceptions
GException::feature_not_implementedMethod is not implemented.

Spatially integrates the DRM model for a given measured event energy and event time.

Todo:
Implement method.

Implements GModelData.

Definition at line 329 of file GCOMModelDRM.cpp.

References G_NRED.

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

Assignment operator.

Parameters
[in]modelCOMPTEL DRM model.
Returns
COMPTEL DRM model

Assigns the information from a COMPTEL DRM 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 156 of file GCOMModelDRM.cpp.

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

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

Print model information.

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

Implements GModelData.

Definition at line 477 of file GCOMModelDRM.cpp.

References m_filename, GModel::m_pars, gammalib::parformat(), GModel::print_attributes(), SILENT, GModel::size(), and gammalib::str().

void GCOMModelDRM::read ( const GXmlElement xml)
virtual

Read model from XML element.

Parameters
[in]xmlXML element.

Read the COMPTEL DRM model from an XML element.

The model has the following XML file syntax:

<source name="Model" type="DRM" file="drm.fits" instrument="COM">
  <parameter name="Normalization" ../>
</source>

Implements GModelData.

Definition at line 387 of file GCOMModelDRM.cpp.

References GXmlElement::attribute(), G_READ, GCOMDri::load(), m_drm, m_filename, m_norm, GOptimizerPar::name(), norm(), GModelPar::read(), GModel::read_attributes(), gammalib::xml_check_parnum(), gammalib::xml_file_expand(), and gammalib::xml_get_par().

Referenced by GCOMModelDRM().

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

Return model type.

Returns
Model type.

Returns the type of the model. The type for a DRM model is "DRM".

Implements GModelData.

Definition at line 110 of file GCOMModelDRM.hpp.

Referenced by write().

void GCOMModelDRM::write ( GXmlElement xml) const
virtual

Write model into XML element.

Parameters
[in]xmlXML element.

Write the COMPTEL DRM model into an XML element.

The model has the following XML file syntax:

<source name="Model" type="DRM" file="drm.fits" instrument="COM">
  <parameter name="Normalization" ../>
</source>

Implements GModelData.

Definition at line 425 of file GCOMModelDRM.cpp.

References GXmlNode::append(), GXmlElement::attribute(), GXmlNode::element(), GXmlNode::elements(), G_WRITE, GModel::instruments(), m_filename, m_norm, GModel::name(), GOptimizerPar::name(), norm(), type(), GModelPar::write(), GModel::write_attributes(), gammalib::xml_check_type(), gammalib::xml_file_reduce(), and gammalib::xml_need_par().

Member Data Documentation

GCOMDri GCOMModelDRM::m_drm
protected

Model.

Definition at line 85 of file GCOMModelDRM.hpp.

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

GFilename GCOMModelDRM::m_filename
protected

Name of DRM FITS file.

Definition at line 86 of file GCOMModelDRM.hpp.

Referenced by copy_members(), init_members(), print(), read(), and write().

GModelPar GCOMModelDRM::m_norm
protected

Normalisation.

Definition at line 84 of file GCOMModelDRM.hpp.

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


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