GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
GSPIObservation Class Reference

INTEGRAL/SPI observation class. More...

#include <GSPIObservation.hpp>

Inheritance diagram for GSPIObservation:
GObservation GBase

Public Member Functions

 GSPIObservation (void)
 Void constructor.
 
 GSPIObservation (const GXmlElement &xml)
 XML constructor.
 
 GSPIObservation (const GFilename &filename)
 Observation Group constructor.
 
 GSPIObservation (const GSPIObservation &obs)
 Copy constructor.
 
virtual ~GSPIObservation (void)
 Destructor.
 
virtual GSPIObservationoperator= (const GSPIObservation &obs)
 Assignment operator.
 
virtual void clear (void)
 Clear INTEGRAL/SPI observation.
 
virtual GSPIObservationclone (void) const
 Clone INTEGRAL/SPI observation.
 
virtual std::string classname (void) const
 Return class name.
 
virtual void response (const GResponse &rsp)
 Set INTEGRAL/SPI response function.
 
virtual const GSPIResponseresponse (void) const
 Return pointer to response function.
 
virtual std::string instrument (void) const
 Return instrument.
 
virtual double ontime (void) const
 Return ontime.
 
virtual double livetime (void) const
 Return livetime.
 
virtual double deadc (const GTime &time=GTime()) const
 Return deadtime correction factor.
 
virtual void read (const GXmlElement &xml)
 Read INTEGRAL/SPI observation from XML element.
 
virtual void write (GXmlElement &xml) const
 Write INTEGRAL/SPI observation into XML element.
 
virtual std::string print (const GChatter &chatter=NORMAL) const
 Print observation information.
 
virtual double grad_step_size (const GModelPar &par) const
 Return gradient step size for a given model parameter.
 
void read (const GFits &fits)
 Read Observation Group from FITS file.
 
void load (const GFilename &filename)
 Load Observation Group.
 
void ontime (const double &ontime)
 Set ontime.
 
void livetime (const double &livetime)
 Set livetime.
 
void deadc (const double &deadc)
 Set deadtime correction factor.
 
- Public Member Functions inherited from GObservation
 GObservation (void)
 Void constructor.
 
 GObservation (const GObservation &obs)
 Copy constructor.
 
virtual ~GObservation (void)
 Destructor.
 
virtual GObservationoperator= (const GObservation &obs)
 Assignment operator.
 
virtual GEventsevents (void)
 Return events.
 
virtual const GEventsevents (void) const
 Return events (const version)
 
virtual void events (const GEvents &events)
 Set event container.
 
virtual double likelihood (const GModels &models, GVector *gradients, GMatrixSparse *curvature, double *npred) const
 Compute likelihood function.
 
virtual double model (const GModels &models, const GEvent &event, GVector *gradients=NULL) const
 Return model value and (optionally) gradients.
 
virtual GVector model (const GModels &models, GMatrixSparse *gradients=NULL) const
 Return vector of model values and (optionally) gradients.
 
virtual double nobserved (void) const
 Return total number of observed events.
 
virtual double npred (const GModels &models, GVector *gradients=NULL) const
 Return total number (and optionally gradients) of predicted counts for all models.
 
virtual double npred (const GModel &model) const
 Return total number of predicted counts for one model.
 
virtual double model_grad (const GModel &model, const GModelPar &par, const GEvent &event) const
 Returns parameter gradient of model for a given event.
 
virtual GVector model_grad (const GModel &model, const GModelPar &par) const
 Returns parameter gradients of model for all events.
 
virtual double npred_grad (const GModel &model, const GModelPar &par) const
 Returns parameter gradient of Npred.
 
virtual void remove_response_cache (const std::string &name)
 Remove response cache for specific model.
 
bool has_events (void) const
 Signal if observation has events.
 
bool has_gradient (const GModel &model, const GModelPar &par) const
 Check whether a model parameter has an analytical gradient.
 
void name (const std::string &name)
 Set observation name.
 
void id (const std::string &id)
 Set observation identifier.
 
void statistic (const std::string &statistic)
 Set optimizer statistic.
 
const std::string & name (void) const
 Return observation name.
 
const std::string & id (void) const
 Return observation identifier.
 
const std::string & statistic (void) const
 Return optimizer statistic.
 
void computed_gradient (const GModel &model, const GModelPar &par) const
 Signals that an analytical gradient was computed for a model parameter.
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor.
 

Protected Member Functions

void init_members (void)
 Initialise class members.
 
void copy_members (const GSPIObservation &obs)
 Copy class members.
 
void free_members (void)
 Delete class members.
 
- Protected Member Functions inherited from GObservation
void init_members (void)
 Initialise class members.
 
void copy_members (const GObservation &obs)
 Copy class members.
 
void free_members (void)
 Delete class members.
 
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)
 
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)
 
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)
 
virtual bool use_event_for_likelihood (const int &index) const
 Check whether bin should be used for likelihood analysis.
 
virtual double npred_spec (const GModel &model, const GTime &obsTime) const
 Integrates spatially integrated Npred kernel spectrally.
 

Protected Attributes

std::string m_instrument
 Instrument name.
 
GFilename m_filename
 OG FITS filename.
 
GFilename m_rsp_grpname
 Response group FITS filename (optional)
 
GFilename m_rsp_filename
 Response FITS filename (optional)
 
GSPIResponse m_response
 Response functions.
 
double m_ontime
 Ontime (sec)
 
double m_livetime
 Livetime (sec)
 
double m_deadc
 Deadtime correction.
 
- Protected Attributes inherited from GObservation
std::string m_name
 Observation name.
 
std::string m_id
 Observation identifier.
 
std::string m_statistic
 Optimizer statistic.
 
GEventsm_events
 Pointer to event container.
 
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() [1/4]

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() [2/4]

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() [3/4]

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() [4/4]

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::~GSPIObservation ( void )
virtual

Destructor.

Definition at line 141 of file GSPIObservation.cpp.

References free_members().

Member Function Documentation

◆ classname()

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

Return class name.

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

Implements GObservation.

Definition at line 115 of file GSPIObservation.hpp.

◆ clear()

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 GObservation::free_members(), free_members(), GObservation::init_members(), and init_members().

Referenced by read().

◆ clone()

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

◆ copy_members()

void GSPIObservation::copy_members ( const GSPIObservation & obs)
protected

Copy class members.

Parameters
[in]obsINTEGRAL/SPI observation.

Definition at line 610 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=().

◆ deadc() [1/2]

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

Set deadtime correction factor.

Parameters
[in]deadcDeadtime correction factor.

Definition at line 220 of file GSPIObservation.hpp.

References deadc(), and m_deadc.

◆ deadc() [2/2]

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 181 of file GSPIObservation.hpp.

References m_deadc.

Referenced by deadc().

◆ free_members()

void GSPIObservation::free_members ( void )
protected

Delete class members.

Definition at line 630 of file GSPIObservation.cpp.

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

◆ grad_step_size()

double GSPIObservation::grad_step_size ( const GModelPar & par) const
virtual

Return gradient step size for a given model parameter.

Parameters
[in]parModel parameter
Returns
Gradient step size

Returns the step size that is used for numerical gradient computation for a given model parameter par.

Following a detailed analysis (see https://gitlab.in2p3.fr/gammalib/gammalib/-/issues/13) the step size is set to 0.002 for all parameters except of position angles (PA) which will have a step size of 0.02. At these step sizes numerical computation of parameter gradients is no longer perturbed by numerical noise.

Reimplemented from GObservation.

Definition at line 507 of file GSPIObservation.cpp.

References GOptimizerPar::name().

◆ init_members()

void GSPIObservation::init_members ( void )
protected

Initialise class members.

Initialises all members of a SPI observations.

Definition at line 588 of file GSPIObservation.cpp.

References GFilename::clear(), GSPIResponse::clear(), m_deadc, m_filename, m_instrument, m_livetime, m_ontime, m_response, m_rsp_filename, and m_rsp_grpname.

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

◆ instrument()

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

Return instrument.

Returns
Instrument name.

Implements GObservation.

Definition at line 140 of file GSPIObservation.hpp.

References m_instrument.

Referenced by print().

◆ livetime() [1/2]

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

Set livetime.

Parameters
[in]livetimeLivetime.

Definition at line 207 of file GSPIObservation.hpp.

References livetime(), and m_livetime.

◆ livetime() [2/2]

double GSPIObservation::livetime ( void ) const
inlinevirtual

Return livetime.

Returns
Livetime (seconds).

Implements GObservation.

Definition at line 166 of file GSPIObservation.hpp.

References m_livetime.

Referenced by livetime(), and print().

◆ load()

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 469 of file GSPIObservation.cpp.

References GFits::close(), m_filename, and read().

Referenced by GSPIObservation(), and read().

◆ ontime() [1/2]

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

Set ontime.

Parameters
[in]ontimeOntime.

Definition at line 194 of file GSPIObservation.hpp.

References m_ontime, and ontime().

◆ ontime() [2/2]

double GSPIObservation::ontime ( void ) const
inlinevirtual

Return ontime.

Returns
Ontime (seconds).

Implements GObservation.

Definition at line 153 of file GSPIObservation.hpp.

References m_ontime.

Referenced by ontime(), and print().

◆ operator=()

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

◆ print()

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 523 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(), GEvents::print(), GSPIResponse::print(), gammalib::reduce(), SILENT, GObservation::statistic(), gammalib::str(), and GFilename::url().

◆ read() [1/2]

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 436 of file GSPIObservation.cpp.

References GObservation::events(), m_deadc, GObservation::m_events, m_livetime, m_ontime, and GEvents::read().

◆ read() [2/2]

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

◆ response() [1/2]

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

◆ response() [2/2]

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

Return pointer to response function.

Returns
Response function pointer.

Implements GObservation.

Definition at line 127 of file GSPIObservation.hpp.

References m_response.

◆ write()

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, GSPIResponse::rspname(), gammalib::str(), gammalib::xml_file_reduce(), and gammalib::xml_need_par().

Member Data Documentation

◆ m_deadc

double GSPIObservation::m_deadc
protected

Deadtime correction.

Definition at line 105 of file GSPIObservation.hpp.

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

◆ m_filename

GFilename GSPIObservation::m_filename
protected

OG FITS filename.

Definition at line 99 of file GSPIObservation.hpp.

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

◆ m_instrument

std::string GSPIObservation::m_instrument
protected

Instrument name.

Definition at line 98 of file GSPIObservation.hpp.

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

◆ m_livetime

double GSPIObservation::m_livetime
protected

Livetime (sec)

Definition at line 104 of file GSPIObservation.hpp.

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

◆ m_ontime

double GSPIObservation::m_ontime
protected

Ontime (sec)

Definition at line 103 of file GSPIObservation.hpp.

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

◆ m_response

GSPIResponse GSPIObservation::m_response
protected

Response functions.

Definition at line 102 of file GSPIObservation.hpp.

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

◆ m_rsp_filename

GFilename GSPIObservation::m_rsp_filename
protected

Response FITS filename (optional)

Definition at line 101 of file GSPIObservation.hpp.

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

◆ m_rsp_grpname

GFilename GSPIObservation::m_rsp_grpname
protected

Response group FITS filename (optional)

Definition at line 100 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: