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

INTEGRAL/SPI observation class. More...

#include <GSPIObservation.hpp>

Inheritance diagram for GSPIObservation:
GObservation GBase

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 GSPIObservationoperator= (const GSPIObservation &obs)
 Assignment operator. More...
 
virtual void clear (void)
 Clear INTEGRAL/SPI observation. More...
 
virtual GSPIObservationclone (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 GSPIResponseresponse (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 GObservationoperator= (const GObservation &obs)
 Assignment operator. More...
 
virtual GEventsevents (void)
 Return events. More...
 
virtual const GEventsevents (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...
 
GEventsm_events
 Pointer to event container. More...
 
double m_grad_step_size
 Gradient step size. More...
 
std::vector< std::string > m_pars_with_gradients
 

Detailed Description

INTEGRAL/SPI observation class.

The INTEGRAL/SPI observation class defines an observation.

Todo:
Complete the class description.

Definition at line 54 of file GSPIObservation.hpp.

Constructor & Destructor Documentation

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().

GSPIObservation::GSPIObservation ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML 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().

GSPIObservation::GSPIObservation ( const GFilename filename)
explicit

Observation Group constructor.

Parameters
[in]filenameObservation 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.

Parameters
[in]obsINTEGRAL/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().

GSPIObservation::~GSPIObservation ( void  )
virtual

Destructor.

Definition at line 141 of file GSPIObservation.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GObservation.

Definition at line 112 of file GSPIObservation.hpp.

void GSPIObservation::clear ( void  )
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().

GSPIObservation * GSPIObservation::clone ( void  ) const
virtual

Clone INTEGRAL/SPI observation.

Returns
Pointer to deep copy of INTEGRAL/SPI observation.

Implements GObservation.

Definition at line 224 of file GSPIObservation.cpp.

References GSPIObservation().

void GSPIObservation::copy_members ( const GSPIObservation obs)
protected

Copy class members.

Parameters
[in]obsINTEGRAL/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=().

double GSPIObservation::deadc ( const GTime time = GTime()) const
inlinevirtual

Return deadtime correction factor.

Parameters
[in]timeTime.
Returns
Deadtime correction factor.

Implements GObservation.

Definition at line 178 of file GSPIObservation.hpp.

References m_deadc.

Referenced by deadc().

void GSPIObservation::deadc ( const double &  deadc)
inline

Set deadtime correction factor.

Parameters
[in]deadcDeadtime correction factor.

Definition at line 217 of file GSPIObservation.hpp.

References deadc(), and m_deadc.

void GSPIObservation::free_members ( void  )
protected

Delete class members.

Definition at line 592 of file GSPIObservation.cpp.

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

void GSPIObservation::init_members ( void  )
protected
std::string GSPIObservation::instrument ( void  ) const
inlinevirtual

Return instrument.

Returns
Instrument name.

Implements GObservation.

Definition at line 137 of file GSPIObservation.hpp.

References m_instrument.

Referenced by print().

double GSPIObservation::livetime ( void  ) const
inlinevirtual

Return livetime.

Returns
Livetime (seconds).

Implements GObservation.

Definition at line 163 of file GSPIObservation.hpp.

References m_livetime.

Referenced by livetime(), and print().

void GSPIObservation::livetime ( const double &  livetime)
inline

Set livetime.

Parameters
[in]livetimeLivetime.

Definition at line 204 of file GSPIObservation.hpp.

References livetime(), and m_livetime.

void GSPIObservation::load ( const GFilename filename)

Load Observation Group.

Parameters
[in]filenameObservation 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().

double GSPIObservation::ontime ( void  ) const
inlinevirtual

Return ontime.

Returns
Ontime (seconds).

Implements GObservation.

Definition at line 150 of file GSPIObservation.hpp.

References m_ontime.

Referenced by ontime(), and print().

void GSPIObservation::ontime ( const double &  ontime)
inline

Set ontime.

Parameters
[in]ontimeOntime.

Definition at line 191 of file GSPIObservation.hpp.

References m_ontime, and ontime().

GSPIObservation & GSPIObservation::operator= ( const GSPIObservation obs)
virtual

Assignment operator.

Parameters
[in]obsINTEGRAL/SPI observation.
Returns
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=().

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

Print observation information.

Parameters
[in]chatterChattiness.
Returns
String containing INTEGRAL/SPI observation information.

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().

void GSPIObservation::read ( const GXmlElement xml)
virtual

Read INTEGRAL/SPI observation from XML element.

Parameters
[in]xmlXML 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.

Parameters
[in]fitsFITS 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().

void GSPIObservation::response ( const GResponse rsp)
virtual

Set INTEGRAL/SPI response function.

Parameters
[in]rspINTEGRAL/SPI response function.
Exceptions
GException::invalid_argumentSpecified 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().

const GSPIResponse * GSPIObservation::response ( void  ) const
inlinevirtual

Return pointer to response function.

Returns
Response function pointer.

Implements GObservation.

Definition at line 124 of file GSPIObservation.hpp.

References m_response.

void GSPIObservation::write ( GXmlElement xml) const
virtual

Write INTEGRAL/SPI observation into XML element.

Parameters
[in]xmlXML 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().

Member Data Documentation

double GSPIObservation::m_deadc
protected

Deadtime correction.

Definition at line 102 of file GSPIObservation.hpp.

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

GFilename GSPIObservation::m_filename
protected

OG FITS filename.

Definition at line 96 of file GSPIObservation.hpp.

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

std::string GSPIObservation::m_instrument
protected

Instrument name.

Definition at line 95 of file GSPIObservation.hpp.

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

double GSPIObservation::m_livetime
protected

Livetime (sec)

Definition at line 101 of file GSPIObservation.hpp.

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

double GSPIObservation::m_ontime
protected

Ontime (sec)

Definition at line 100 of file GSPIObservation.hpp.

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

GSPIResponse GSPIObservation::m_response
protected

Response functions.

Definition at line 99 of file GSPIObservation.hpp.

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

GFilename GSPIObservation::m_rsp_filename
protected

Response FITS filename (optional)

Definition at line 98 of file GSPIObservation.hpp.

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

GFilename GSPIObservation::m_rsp_grpname
protected

Response group FITS filename (optional)

Definition at line 97 of file GSPIObservation.hpp.

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


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