GammaLib
2.0.0
|
CTA cube background model class. More...
#include <GCTAModelCubeBackground.hpp>
Public Member Functions | |
GCTAModelCubeBackground (void) | |
Void constructor. More... | |
GCTAModelCubeBackground (const GXmlElement &xml) | |
XML constructor. More... | |
GCTAModelCubeBackground (const GModelSpectral &spectral) | |
Construct from spectral component. More... | |
GCTAModelCubeBackground (const GModelSpectral &spectral, const GModelTemporal &temporal) | |
Construct from model components. More... | |
GCTAModelCubeBackground (const GCTAModelCubeBackground &bgd) | |
Copy constructor. More... | |
virtual | ~GCTAModelCubeBackground (void) |
Destructor. More... | |
virtual GCTAModelCubeBackground & | operator= (const GCTAModelCubeBackground &model) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear CTA cube background model. More... | |
virtual GCTAModelCubeBackground * | clone (void) const |
Clone CTA cube background model. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual std::string | type (void) const |
Return data model type. More... | |
virtual bool | is_constant (void) const |
Signals if sky 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 GCTAEventList * | mc (const GObservation &obs, GRan &ran) const |
Return simulated list of events. More... | |
virtual void | read (const GXmlElement &xml) |
Read CTA cube background model from XML element. More... | |
virtual void | write (GXmlElement &xml) const |
Write CTA cube background model into XML element. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print CTA cube background model information. More... | |
GModelSpectral * | spectral (void) const |
Return spectral model component. More... | |
GModelTemporal * | temporal (void) const |
Return temporal 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 GModelData & | operator= (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 GModel & | operator= (const GModel &model) |
Assignment operator. More... | |
virtual GModelPar & | operator[] (const int &index) |
Returns reference to model parameter by index. More... | |
virtual const GModelPar & | operator[] (const int &index) const |
Returns reference to model parameter by index (const version) More... | |
virtual GModelPar & | operator[] (const std::string &name) |
Returns reference to model parameter by name. More... | |
virtual const GModelPar & | operator[] (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... | |
GModelPar & | at (const int &index) |
Returns reference to model parameter by index. More... | |
const GModelPar & | at (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... | |
GModelPar & | scale (const int &index) |
Returns reference to scale parameter by index. More... | |
const GModelPar & | scale (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 GModelAssociations & | associations (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 GCTAModelCubeBackground &bgd) |
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... | |
GModelSpectral * | xml_spectral (const GXmlElement &spectral) const |
Return pointer to spectral model from XML element. More... | |
GModelTemporal * | xml_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 | |
GModelSpectral * | m_spectral |
Spectral model. More... | |
GModelTemporal * | m_temporal |
Temporal model. More... | |
std::vector< std::string > | m_npred_names |
Model names. More... | |
std::vector< GEnergy > | m_npred_energies |
Model energy. More... | |
std::vector< GTime > | m_npred_times |
Model time. More... | |
std::vector< double > | m_npred_values |
Model values. 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< GModelPar > | m_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 |
CTA cube background model class.
This class implements a cube background model for CTA.
Definition at line 52 of file GCTAModelCubeBackground.hpp.
GCTAModelCubeBackground::GCTAModelCubeBackground | ( | void | ) |
Void constructor.
Definition at line 76 of file GCTAModelCubeBackground.cpp.
References init_members().
Referenced by clone().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Constructs a CTA cube background model from the information provided by an XML elements (see GCTAModelCubeBackground::read method).
Definition at line 94 of file GCTAModelCubeBackground.cpp.
References init_members(), read(), and set_pointers().
|
explicit |
Construct from spectral component.
[in] | spectral | Spectral model component. |
Constructs a CTA cube background model from a spectral
model component. The temporal component is assumed to be constant.
Definition at line 119 of file GCTAModelCubeBackground.cpp.
References GModelTemporalConst::clone(), GModelSpectral::clone(), init_members(), m_spectral, m_temporal, set_pointers(), and temporal().
GCTAModelCubeBackground::GCTAModelCubeBackground | ( | const GModelSpectral & | spectral, |
const GModelTemporal & | temporal | ||
) |
Construct from model components.
[in] | spectral | Spectral model component. |
[in] | temporal | Temporal model component. |
Constructs a CTA cube background model from a spectral
and a temporal
component.
Definition at line 149 of file GCTAModelCubeBackground.cpp.
References GModelTemporal::clone(), GModelSpectral::clone(), init_members(), m_spectral, m_temporal, and set_pointers().
GCTAModelCubeBackground::GCTAModelCubeBackground | ( | const GCTAModelCubeBackground & | bgd | ) |
Copy constructor.
[in] | bgd | CTA cube background model. |
Definition at line 173 of file GCTAModelCubeBackground.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GModelData.
Definition at line 118 of file GCTAModelCubeBackground.hpp.
|
virtual |
Clear CTA cube background model.
This method properly resets the CTA cube background model to an initial state.
Implements GModelData.
Definition at line 248 of file GCTAModelCubeBackground.cpp.
References GModelData::free_members(), free_members(), GModelData::init_members(), and init_members().
Referenced by read().
|
virtual |
Clone CTA cube background model.
Implements GModelData.
Definition at line 268 of file GCTAModelCubeBackground.cpp.
References GCTAModelCubeBackground().
|
protected |
Copy class members.
[in] | bgd | CTA background model. |
Definition at line 751 of file GCTAModelCubeBackground.cpp.
References GModelTemporal::clone(), GModelSpectral::clone(), m_npred_energies, m_npred_names, m_npred_times, m_npred_values, m_spectral, m_temporal, and set_pointers().
Referenced by GCTAModelCubeBackground(), and operator=().
|
virtual |
Return background rate in units of events MeV ^{-1} s ^{-1} sr ^{-1}.
[in] | event | Observed event. |
[in] | obs | Observation. |
[in] | gradients | Compute gradients? |
Evaluates the background model. The method returns a real rate, defined as 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.
Implements GModelData.
Definition at line 343 of file GCTAModelCubeBackground.cpp.
References GCTAResponseCube::background(), gammalib::cta_dir(), gammalib::cta_rsp_cube(), GEvent::energy(), GModelTemporal::eval(), GModelSpectral::eval(), G_EVAL, GModelTemporal::size(), GModelSpectral::size(), spectral(), temporal(), and GEvent::time().
|
protected |
Delete class members.
Definition at line 774 of file GCTAModelCubeBackground.cpp.
References m_spectral, and m_temporal.
Referenced by clear(), operator=(), and ~GCTAModelCubeBackground().
|
protected |
Initialise class members.
Definition at line 729 of file GCTAModelCubeBackground.cpp.
References m_npred_energies, m_npred_names, m_npred_times, m_npred_values, m_spectral, and m_temporal.
Referenced by clear(), GCTAModelCubeBackground(), and operator=().
|
inlinevirtual |
Signals if sky model is temporally constant.
Signals if the sky model is temporally constant. A temporally constant model is a model that has a temporal component of type "Constant".
Implements GModelData.
Definition at line 147 of file GCTAModelCubeBackground.hpp.
References m_temporal, and GModelTemporal::type().
|
virtual |
Return simulated list of events.
[in] | obs | Observation. |
[in] | ran | Random number generator. |
GException::feature_not_implemented | Specified observation is not a CTA observation. |
The simulation of an event list from a cube background model is not implemented, hence the method will always throw an exception.
Implements GModelData.
Definition at line 506 of file GCTAModelCubeBackground.cpp.
References G_MC.
|
virtual |
Return spatially integrated background rate in units of events MeV ^{-1} s ^{-1}.
[in] | obsEng | Measured event energy. |
[in] | obsTime | Measured event time. |
[in] | obs | Observation. |
Spatially integrates the cube background 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 410 of file GCTAModelCubeBackground.cpp.
References GCTAResponseCube::background(), gammalib::cta_rsp_cube(), GModelTemporal::eval(), GModelSpectral::eval(), G_NPRED, GObservation::id(), GObservation::instrument(), GCTACubeBackground::integral(), gammalib::is_infinite(), gammalib::is_notanumber(), GEnergy::log10TeV(), m_npred_energies, m_npred_names, m_npred_times, m_npred_values, spectral(), gammalib::str(), temporal(), valid_model(), and gammalib::warning().
|
virtual |
Assignment operator.
[in] | bgd | CTA cube background model. |
Definition at line 212 of file GCTAModelCubeBackground.cpp.
References copy_members(), free_members(), init_members(), and GModelData::operator=().
Print CTA cube background model information.
[in] | chatter | Chattiness. |
Implements GModelData.
Definition at line 669 of file GCTAModelCubeBackground.cpp.
References gammalib::parformat(), GModel::print_attributes(), SILENT, GModelTemporal::size(), GModelSpectral::size(), GModel::size(), spectral(), gammalib::str(), temporal(), and type().
|
virtual |
Read CTA cube background model from XML element.
[in] | xml | XML element. |
Set up CTA cube background model from the information provided by an XML element. The XML element is expected to have the following structure
<source name="..." type="..." instrument="..."> <spectrum type="..."> ... </spectrum> </source>
Optionally, a temporal model may be provided using the following syntax
<source name="..." type="..." instrument="..."> <spectrum type="..."> ... </spectrum> <temporal type="..."> ... </temporal> </source>
If no temporal component is found a constant model is assumed.
Implements GModelData.
Definition at line 547 of file GCTAModelCubeBackground.cpp.
References clear(), GModelTemporalConst::clone(), GXmlNode::element(), GXmlNode::elements(), m_spectral, m_temporal, GModel::read_attributes(), set_pointers(), spectral(), temporal(), xml_spectral(), and xml_temporal().
Referenced by GCTAModelCubeBackground().
|
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 795 of file GCTAModelCubeBackground.cpp.
References GModel::m_pars, GModelTemporal::size(), GModelSpectral::size(), spectral(), and temporal().
Referenced by copy_members(), GCTAModelCubeBackground(), read(), spectral(), and temporal().
|
inline |
Return 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 sky model has no spectral model component.
Definition at line 163 of file GCTAModelCubeBackground.hpp.
References m_spectral.
Referenced by gammalib::cta_model_spectral(), eval(), npred(), print(), read(), set_pointers(), valid_model(), and write().
void GCTAModelCubeBackground::spectral | ( | const GModelSpectral * | spectral | ) |
Set spectral model component.
[in] | spectral | Pointer to spectral model component. |
Sets the spectral model component of the model.
Definition at line 281 of file GCTAModelCubeBackground.cpp.
References GModelSpectral::clone(), m_spectral, and set_pointers().
|
inline |
Return 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 sky model has no temporal model component.
Definition at line 179 of file GCTAModelCubeBackground.hpp.
References m_temporal.
Referenced by gammalib::cta_model_temporal(), eval(), GCTAModelCubeBackground(), npred(), print(), read(), set_pointers(), valid_model(), and write().
void GCTAModelCubeBackground::temporal | ( | const GModelTemporal * | temporal | ) |
Set temporal model component.
[in] | temporal | Pointer to temporal model component. |
Sets the temporal model component of the model.
Definition at line 308 of file GCTAModelCubeBackground.cpp.
References GModelTemporal::clone(), m_temporal, and set_pointers().
|
inlinevirtual |
Return data model type.
Returns the type of the data model.
Implements GModelData.
Definition at line 132 of file GCTAModelCubeBackground.hpp.
Referenced by print().
|
protected |
Verifies if model has all components.
Returns 'true' if models has a spectral and a temporal component. Otherwise returns 'false'.
Definition at line 831 of file GCTAModelCubeBackground.cpp.
References spectral(), and temporal().
Referenced by npred().
|
virtual |
Write CTA cube background model into XML element.
[in] | xml | XML element. |
Write CTA cube background model information into an XML element. The XML element will have the following structure
<source name="..." type="..." instrument="..."> <spectrum type="..."> ... </spectrum> </source>
If the model contains a non-constant temporal model, the temporal component will also be written following the syntax
<source name="..." type="..." instrument="..."> <spectrum type="..."> ... </spectrum> <temporal type="..."> ... </temporal> </source>
If no temporal component is found a constant model is assumed.
Implements GModelData.
Definition at line 610 of file GCTAModelCubeBackground.cpp.
References GXmlNode::append(), GXmlElement::attribute(), GXmlNode::element(), GXmlNode::elements(), m_temporal, GModel::name(), spectral(), temporal(), GModelTemporal::type(), GModelTemporal::write(), GModelSpectral::write(), and GModel::write_attributes().
|
protected |
Return pointer to spectral model from XML element.
[in] | spectral | XML element. |
Returns pointer to spectral model that is defined in an XML element.
Definition at line 849 of file GCTAModelCubeBackground.cpp.
References GModelSpectralRegistry::alloc().
Referenced by read().
|
protected |
Return pointer to temporal model from XML element.
[in] | temporal | XML element. |
Returns pointer to temporal model that is defined in an XML element.
Definition at line 868 of file GCTAModelCubeBackground.cpp.
References GModelTemporalRegistry::alloc().
Referenced by read().
|
mutableprotected |
Model energy.
Definition at line 106 of file GCTAModelCubeBackground.hpp.
Referenced by copy_members(), init_members(), and npred().
|
mutableprotected |
Model names.
Definition at line 105 of file GCTAModelCubeBackground.hpp.
Referenced by copy_members(), init_members(), and npred().
|
mutableprotected |
Model time.
Definition at line 107 of file GCTAModelCubeBackground.hpp.
Referenced by copy_members(), init_members(), and npred().
|
mutableprotected |
Model values.
Definition at line 108 of file GCTAModelCubeBackground.hpp.
Referenced by copy_members(), init_members(), and npred().
|
protected |
Spectral model.
Definition at line 101 of file GCTAModelCubeBackground.hpp.
Referenced by copy_members(), free_members(), GCTAModelCubeBackground(), init_members(), read(), and spectral().
|
protected |
Temporal model.
Definition at line 102 of file GCTAModelCubeBackground.hpp.
Referenced by copy_members(), free_members(), GCTAModelCubeBackground(), init_members(), is_constant(), read(), temporal(), and write().