GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelData Class Referenceabstract

Abstract data model class. More...

#include <GModelData.hpp>

Inheritance diagram for GModelData:
GModel GBase GCOMModelDRBPhibarBins GCOMModelDRBPhibarNodes GCOMModelDRM GCTAModelAeffBackground GCTAModelBackground GCTAModelCubeBackground GCTAModelIrfBackground GCTAModelRadialAcceptance GCTAModelSkyCube GSPIModelDataSpace

Public Member Functions

 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 void clear (void)=0
 Clear object. More...
 
virtual GModelDataclone (void) const =0
 Clones object. More...
 
virtual std::string classname (void) const =0
 Return class name. More...
 
virtual std::string type (void) const =0
 
virtual bool is_constant (void) const =0
 
virtual double eval (const GEvent &event, const GObservation &obs, const bool &gradients=false) const =0
 
virtual double npred (const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const =0
 
virtual GEventsmc (const GObservation &obs, GRan &ran) const =0
 
virtual void read (const GXmlElement &xml)=0
 
virtual void write (GXmlElement &xml) const =0
 
virtual std::string print (const GChatter &chatter=NORMAL) const =0
 Print content of object. 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 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...
 

Additional Inherited Members

- 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

Abstract data model class.

This abstract base class implements a model of the event distribution in the instrument's data space.

Definition at line 55 of file GModelData.hpp.

Constructor & Destructor Documentation

GModelData::GModelData ( void  )

Void constructor.

Definition at line 57 of file GModelData.cpp.

References init_members().

GModelData::GModelData ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Definition at line 72 of file GModelData.cpp.

References init_members().

GModelData::GModelData ( const GModelData model)

Copy constructor.

Parameters
[in]modelData model.

Definition at line 87 of file GModelData.cpp.

References copy_members(), and init_members().

GModelData::~GModelData ( void  )
virtual

Destructor.

Definition at line 103 of file GModelData.cpp.

References free_members().

Member Function Documentation

virtual std::string GModelData::classname ( void  ) const
pure virtual

Return class name.

Returns
String containing the class name.

Returns the class name for non-abstract classes in a human readable way.

Implements GModel.

Implemented in GCTAModelSkyCube, GSPIModelDataSpace, GCTAModelBackground, GCTAModelRadialAcceptance, GCTAModelCubeBackground, GCOMModelDRBPhibarBins, GCOMModelDRBPhibarNodes, GCTAModelAeffBackground, GCOMModelDRM, and GCTAModelIrfBackground.

virtual void GModelData::clear ( void  )
pure virtual

Clear object.

Sets the object to a clean initial state. After calling the method the object will be in the same state as it were if an empty instance of the object would have been created.

Implements GModel.

Implemented in GCTAModelSkyCube, GSPIModelDataSpace, GCTAModelBackground, GCTAModelRadialAcceptance, GCTAModelCubeBackground, GCOMModelDRBPhibarBins, GCOMModelDRBPhibarNodes, GCTAModelAeffBackground, GCOMModelDRM, and GCTAModelIrfBackground.

virtual GModelData* GModelData::clone ( void  ) const
pure virtual

Clones object.

Returns
Pointer to deep copy of object.

Creates a deep copy of the object and returns a pointer to the object.

Implements GModel.

Implemented in GCTAModelSkyCube, GSPIModelDataSpace, GCTAModelBackground, GCTAModelRadialAcceptance, GCTAModelCubeBackground, GCOMModelDRBPhibarBins, GCOMModelDRBPhibarNodes, GCTAModelAeffBackground, GCOMModelDRM, and GCTAModelIrfBackground.

void GModelData::copy_members ( const GModelData model)
protected

Copy class members.

Parameters
[in]modelData model.

Definition at line 290 of file GModelData.cpp.

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

virtual double GModelData::eval ( const GEvent event,
const GObservation obs,
const bool &  gradients = false 
) const
pure virtual
GVector GModelData::eval ( const GObservation obs,
GMatrixSparse gradients = NULL 
) const
virtual

Return model values and gradients.

Parameters
[in]obsObservation.
[out]gradientsPointer to matrix of gradients.
Returns
Model values.

Evaluates the model values and parameter gradients for all events in an observation. Gradients are only returned if the gradients pointer is not NULL.

The matrix of gradients is a sparse matrix where the number of rows corresponds to the number of model parameters and the number of columns corresponds to the number of events. An exception is thrown if the dimension of the gradients matrix is not compatible with the model and the observations.

Implements GModel.

Definition at line 172 of file GModelData.cpp.

References GMatrixSparse::column(), GMatrixBase::columns(), GObservation::computed_gradient(), eval(), GObservation::events(), GOptimizerPar::factor_gradient(), G_EVAL, GOptimizerPar::has_grad(), GOptimizerPar::is_free(), GMatrixBase::rows(), GEvents::size(), GModel::size(), and gammalib::str().

virtual double GModelData::npred ( const GEnergy obsEng,
const GTime obsTime,
const GObservation obs 
) const
pure virtual
virtual std::string GModelData::print ( const GChatter chatter = NORMAL) const
pure virtual

Print content of object.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing the content of the object.

Formats the content in a standard way and puts this content in a C++ string that is returned.

Implements GModel.

Implemented in GCTAModelSkyCube, GSPIModelDataSpace, GCTAModelBackground, GCTAModelRadialAcceptance, GCTAModelCubeBackground, GCOMModelDRBPhibarBins, GCOMModelDRBPhibarNodes, GCTAModelAeffBackground, GCOMModelDRM, and GCTAModelIrfBackground.


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