GammaLib
2.1.0.dev
|
INTEGRAL/SPI observation class. More...
#include <GSPIObservation.hpp>
Public Member Functions | |
GSPIObservation (void) | |
Void constructor. More... | |
GSPIObservation (const GXmlElement &xml) | |
XML constructor. More... | |
GSPIObservation (const GFilename &filename) | |
Observation Group constructor. More... | |
GSPIObservation (const GSPIObservation &obs) | |
Copy constructor. More... | |
virtual | ~GSPIObservation (void) |
Destructor. More... | |
virtual GSPIObservation & | operator= (const GSPIObservation &obs) |
Assignment operator. More... | |
virtual void | clear (void) |
Clear INTEGRAL/SPI observation. More... | |
virtual GSPIObservation * | clone (void) const |
Clone INTEGRAL/SPI observation. More... | |
virtual std::string | classname (void) const |
Return class name. More... | |
virtual void | response (const GResponse &rsp) |
Set INTEGRAL/SPI response function. More... | |
virtual const GSPIResponse * | response (void) const |
Return pointer to response function. More... | |
virtual std::string | instrument (void) const |
Return instrument. More... | |
virtual double | ontime (void) const |
Return ontime. More... | |
virtual double | livetime (void) const |
Return livetime. More... | |
virtual double | deadc (const GTime &time=GTime()) const |
Return deadtime correction factor. More... | |
virtual void | read (const GXmlElement &xml) |
Read INTEGRAL/SPI observation from XML element. More... | |
virtual void | write (GXmlElement &xml) const |
Write INTEGRAL/SPI observation into XML element. More... | |
virtual std::string | print (const GChatter &chatter=NORMAL) const |
Print observation information. More... | |
void | read (const GFits &fits) |
Read Observation Group from FITS file. More... | |
void | load (const GFilename &filename) |
Load Observation Group. More... | |
void | ontime (const double &ontime) |
Set ontime. More... | |
void | livetime (const double &livetime) |
Set livetime. More... | |
void | deadc (const double &deadc) |
Set deadtime correction factor. More... | |
Public Member Functions inherited from GObservation | |
GObservation (void) | |
Void constructor. More... | |
GObservation (const GObservation &obs) | |
Copy constructor. More... | |
virtual | ~GObservation (void) |
Destructor. More... | |
virtual GObservation & | operator= (const GObservation &obs) |
Assignment operator. More... | |
virtual GEvents * | events (void) |
Return events. More... | |
virtual const GEvents * | events (void) const |
Return events (const version) More... | |
virtual void | events (const GEvents &events) |
Set event container. More... | |
virtual double | likelihood (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
Compute likelihood function. More... | |
virtual double | model (const GModels &models, const GEvent &event, GVector *gradients=NULL) const |
Return model value and (optionally) gradients. More... | |
virtual GVector | model (const GModels &models, GMatrixSparse *gradients=NULL) const |
Return vector of model values and (optionally) gradients. More... | |
virtual int | nobserved (void) const |
Return total number of observed events. More... | |
virtual double | npred (const GModels &models, GVector *gradients=NULL) const |
Return total number (and optionally gradients) of predicted counts for all models. More... | |
virtual double | npred (const GModel &model) const |
Return total number of predicted counts for one model. More... | |
virtual double | model_grad (const GModel &model, const GModelPar &par, const GEvent &event) const |
Returns parameter gradient of model for a given event. More... | |
virtual GVector | model_grad (const GModel &model, const GModelPar &par) const |
Returns parameter gradients of model for all events. More... | |
virtual double | npred_grad (const GModel &model, const GModelPar &par) const |
Returns parameter gradient of Npred. More... | |
virtual void | remove_response_cache (const std::string &name) |
Response cache removal hook. More... | |
virtual const double & | grad_step_size (void) const |
Return gradient step size. More... | |
bool | has_events (void) const |
Signal if observation has events. More... | |
bool | has_gradient (const GModel &model, const GModelPar &par) const |
Check whether a model parameter has an analytical gradient. More... | |
void | name (const std::string &name) |
Set observation name. More... | |
void | id (const std::string &id) |
Set observation identifier. More... | |
void | statistic (const std::string &statistic) |
Set optimizer statistic. More... | |
const std::string & | name (void) const |
Return observation name. More... | |
const std::string & | id (void) const |
Return observation identifier. More... | |
const std::string & | statistic (void) const |
Return optimizer statistic. More... | |
void | computed_gradient (const GModel &model, const GModelPar &par) const |
Signals that an analytical gradient was computed for a model parameter. 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 GSPIObservation &obs) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Member Functions inherited from GObservation | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GObservation &obs) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
virtual double | likelihood_poisson_unbinned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
Evaluate log-likelihood function for Poisson statistic and unbinned analysis (version with working arrays) More... | |
virtual double | likelihood_poisson_binned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
Evaluate log-likelihood function for Poisson statistic and binned analysis (version with working arrays) More... | |
virtual double | likelihood_gaussian_binned (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const |
Evaluate log-likelihood function for Gaussian statistic and binned analysis (version with working arrays) More... | |
virtual bool | use_event_for_likelihood (const int &index) const |
Check whether bin should be used for likelihood analysis. More... | |
virtual double | npred_spec (const GModel &model, const GTime &obsTime) const |
Integrates spatially integrated Npred kernel spectrally. More... | |
Protected Attributes | |
std::string | m_instrument |
Instrument name. More... | |
GFilename | m_filename |
OG FITS filename. More... | |
GFilename | m_rsp_grpname |
Response group FITS filename (optional) More... | |
GFilename | m_rsp_filename |
Response FITS filename (optional) More... | |
GSPIResponse | m_response |
Response functions. More... | |
double | m_ontime |
Ontime (sec) More... | |
double | m_livetime |
Livetime (sec) More... | |
double | m_deadc |
Deadtime correction. More... | |
Protected Attributes inherited from GObservation | |
std::string | m_name |
Observation name. More... | |
std::string | m_id |
Observation identifier. More... | |
std::string | m_statistic |
Optimizer statistic. More... | |
GEvents * | m_events |
Pointer to event container. More... | |
double | m_grad_step_size |
Gradient step size. More... | |
std::vector< std::string > | m_pars_with_gradients |
INTEGRAL/SPI observation class.
The INTEGRAL/SPI observation class defines an observation.
Definition at line 54 of file GSPIObservation.hpp.
GSPIObservation::GSPIObservation | ( | void | ) |
Void constructor.
Creates an empty INTEGRAL/SPI observation.
Definition at line 66 of file GSPIObservation.cpp.
References init_members().
Referenced by clone().
|
explicit |
XML constructor.
[in] | xml | XML element. |
Constructs an INTEGRAL/SPI observation from the information that is found in the XML element.
Definition at line 84 of file GSPIObservation.cpp.
References init_members(), and read().
|
explicit |
Observation Group constructor.
[in] | filename | Observation Group FITS file name. |
Constructs an INTEGRAL/SPI observation from an Observation Group.
Definition at line 104 of file GSPIObservation.cpp.
References init_members(), and load().
GSPIObservation::GSPIObservation | ( | const GSPIObservation & | obs | ) |
Copy constructor.
[in] | obs | INTEGRAL/SPI observation. |
Creates INTEGRAL/SPI observation by copying from an existing INTEGRAL/SPI observation.
Definition at line 125 of file GSPIObservation.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GObservation.
Definition at line 112 of file GSPIObservation.hpp.
|
virtual |
Clear INTEGRAL/SPI observation.
Clears INTEGRAL/SPI observation by resetting all class members to an initial state. Any information that was present before will be lost.
Implements GObservation.
Definition at line 204 of file GSPIObservation.cpp.
References free_members(), GObservation::free_members(), init_members(), and GObservation::init_members().
Referenced by read().
|
virtual |
Clone INTEGRAL/SPI observation.
Implements GObservation.
Definition at line 224 of file GSPIObservation.cpp.
References GSPIObservation().
|
protected |
Copy class members.
[in] | obs | INTEGRAL/SPI observation. |
Definition at line 572 of file GSPIObservation.cpp.
References m_deadc, m_filename, m_instrument, m_livetime, m_ontime, m_response, m_rsp_filename, and m_rsp_grpname.
Referenced by GSPIObservation(), and operator=().
Return deadtime correction factor.
[in] | time | Time. |
Implements GObservation.
Definition at line 178 of file GSPIObservation.hpp.
References m_deadc.
Referenced by deadc().
|
inline |
Set deadtime correction factor.
[in] | deadc | Deadtime correction factor. |
Definition at line 217 of file GSPIObservation.hpp.
|
protected |
Delete class members.
Definition at line 592 of file GSPIObservation.cpp.
Referenced by clear(), operator=(), and ~GSPIObservation().
|
protected |
Initialise class members.
Definition at line 550 of file GSPIObservation.cpp.
References GSPIResponse::clear(), GFilename::clear(), m_deadc, m_filename, m_instrument, m_livetime, m_ontime, m_response, m_rsp_filename, and m_rsp_grpname.
Referenced by clear(), GSPIObservation(), and operator=().
|
inlinevirtual |
Return instrument.
Implements GObservation.
Definition at line 137 of file GSPIObservation.hpp.
References m_instrument.
Referenced by print().
|
inlinevirtual |
Return livetime.
Implements GObservation.
Definition at line 163 of file GSPIObservation.hpp.
References m_livetime.
Referenced by livetime(), and print().
|
inline |
Set livetime.
[in] | livetime | Livetime. |
Definition at line 204 of file GSPIObservation.hpp.
References livetime(), and m_livetime.
void GSPIObservation::load | ( | const GFilename & | filename | ) |
Load Observation Group.
[in] | filename | Observation Group FITS file name. |
Loads data from an Observation Group FITS file into an INTEGRAL/SPI observation.
Definition at line 459 of file GSPIObservation.cpp.
References GFits::close(), m_filename, and read().
Referenced by GSPIObservation(), and read().
|
inlinevirtual |
Return ontime.
Implements GObservation.
Definition at line 150 of file GSPIObservation.hpp.
References m_ontime.
|
inline |
|
virtual |
Assignment operator.
[in] | obs | INTEGRAL/SPI observation. |
Assign INTEGRAL/SPI observation to this object. The assignment performs a deep copy of all information, hence the original object from which the assignment was made can be destroyed after this operation without any loss of information.
Definition at line 168 of file GSPIObservation.cpp.
References copy_members(), free_members(), init_members(), and GObservation::operator=().
Print observation information.
[in] | chatter | Chattiness. |
Implements GObservation.
Definition at line 487 of file GSPIObservation.cpp.
References instrument(), GFilename::is_empty(), livetime(), m_deadc, GObservation::m_events, m_filename, m_response, m_rsp_filename, m_rsp_grpname, GObservation::name(), ontime(), gammalib::parformat(), GSPIResponse::print(), GEvents::print(), gammalib::reduce(), SILENT, GObservation::statistic(), gammalib::str(), and GFilename::url().
|
virtual |
Read INTEGRAL/SPI observation from XML element.
[in] | xml | XML element. |
Reads information for a INTEGRAL/SPI observation from an XML element. The expected format of the XML element is
<observation name="Crab" id="0044" instrument="SPI"> <parameter name="ObservationGroup" file="og_spi.fits"/> </observation>
In addition, a response group can be specified using
<observation name="Crab" id="0044" instrument="SPI"> <parameter name="ObservationGroup" file="og_spi.fits"/> <parameter name="ResponseGroup" file="spi_irf_grp.fits"/> </observation>
If a response group is found the file is loaded and the response is set. Optionally, an energy attribute can be specified in units of keV, leading to the setup of a line response
<observation name="Crab" id="0044" instrument="SPI"> <parameter name="ObservationGroup" file="og_spi.fits"/> <parameter name="ResponseGroup" file="spi_irf_grp.fits" energy="511"/> </observation>
Alternatively, a response file can be specified, which will be directly loaded in the SPI response class.
<observation name="Crab" id="0044" instrument="SPI"> <parameter name="ObservationGroup" file="og_spi.fits"/> <parameter name="ResponseFile" file="irf.fits"/> </observation>
Implements GObservation.
Definition at line 296 of file GSPIObservation.cpp.
References GXmlElement::attribute(), clear(), G_READ, GXmlElement::has_attribute(), load(), GSPIResponse::load(), m_filename, m_instrument, m_response, m_rsp_filename, m_rsp_grpname, GSPIResponse::rspname(), GSPIResponse::set(), gammalib::todouble(), gammalib::xml_file_expand(), gammalib::xml_get_attr(), gammalib::xml_get_par(), and gammalib::xml_has_par().
Referenced by GSPIObservation(), and load().
void GSPIObservation::read | ( | const GFits & | fits | ) |
Read Observation Group from FITS file.
[in] | fits | FITS file. |
Reads Observation Group from a FITS file.
Definition at line 426 of file GSPIObservation.cpp.
References GObservation::events(), GSPIEventCube::livetime(), m_deadc, GObservation::m_events, m_livetime, m_ontime, GSPIEventCube::ontime(), and GSPIEventCube::read().
|
virtual |
Set INTEGRAL/SPI response function.
[in] | rsp | INTEGRAL/SPI response function. |
GException::invalid_argument | Specified response is not a INTEGRAL/SPI response. |
Sets the response function for the observation.
Implements GObservation.
Definition at line 240 of file GSPIObservation.cpp.
References G_RESPONSE, m_response, and GObservation::name().
|
inlinevirtual |
Return pointer to response function.
Implements GObservation.
Definition at line 124 of file GSPIObservation.hpp.
References m_response.
|
virtual |
Write INTEGRAL/SPI observation into XML element.
[in] | xml | XML element. |
Writes information for a INTEGRAL/SPI observation into an XML element. In case that no response information is available the method writes the format
<observation name="Crab" id="0044" instrument="SPI"> <parameter name="ObservationGroup" file="og_spi.fits"/> </observation>
If a response group file is defined the method writes the format
<observation name="Crab" id="0044" instrument="SPI"> <parameter name="ObservationGroup" file="og_spi.fits"/> <parameter name="ResponseGroup" file="spi_irf_grp.fits" energy="511"/> </observation>
The energy attribute is optional, and is only written in case that the IRF is a line IRF.
Otherwise, if a response file is defined the method writes the format
<observation name="Crab" id="0044" instrument="SPI"> <parameter name="ObservationGroup" file="og_spi.fits"/> <parameter name="ResponseFile" file="irf.fits"/> </observation>
Implements GObservation.
Definition at line 388 of file GSPIObservation.cpp.
References GXmlElement::attribute(), GSPIResponse::energy_keV(), G_WRITE, GFilename::is_empty(), m_filename, m_response, m_rsp_filename, m_rsp_grpname, gammalib::str(), gammalib::xml_file_reduce(), and gammalib::xml_need_par().
|
protected |
Deadtime correction.
Definition at line 102 of file GSPIObservation.hpp.
Referenced by copy_members(), deadc(), init_members(), print(), and read().
|
protected |
OG FITS filename.
Definition at line 96 of file GSPIObservation.hpp.
Referenced by copy_members(), init_members(), load(), print(), read(), and write().
|
protected |
Instrument name.
Definition at line 95 of file GSPIObservation.hpp.
Referenced by copy_members(), init_members(), instrument(), and read().
|
protected |
Livetime (sec)
Definition at line 101 of file GSPIObservation.hpp.
Referenced by copy_members(), init_members(), livetime(), and read().
|
protected |
Ontime (sec)
Definition at line 100 of file GSPIObservation.hpp.
Referenced by copy_members(), init_members(), ontime(), and read().
|
protected |
Response functions.
Definition at line 99 of file GSPIObservation.hpp.
Referenced by copy_members(), init_members(), print(), read(), response(), and write().
|
protected |
Response FITS filename (optional)
Definition at line 98 of file GSPIObservation.hpp.
Referenced by copy_members(), init_members(), print(), read(), and write().
|
protected |
Response group FITS filename (optional)
Definition at line 97 of file GSPIObservation.hpp.
Referenced by copy_members(), init_members(), print(), read(), and write().