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

Fermi/LAT observation class. More...

#include <GLATObservation.hpp>

Inheritance diagram for GLATObservation:
GObservation GBase

Public Member Functions

 GLATObservation (void)
 Void constructor. More...
 
 GLATObservation (const GXmlElement &xml)
 XML constructor. More...
 
 GLATObservation (const GLATObservation &obs)
 Copy constructor. More...
 
virtual ~GLATObservation (void)
 Destructor. More...
 
GLATObservationoperator= (const GLATObservation &obs)
 Assignment operator. More...
 
virtual void clear (void)
 Clear Fermi/LAT observation. More...
 
virtual GLATObservationclone (void) const
 Clone Fermi/LAT observation. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual void response (const GResponse &rsp)
 Set response function. More...
 
virtual const GLATResponseresponse (void) const
 Return Fermi/LAT response function. More...
 
virtual std::string instrument (void) const
 Return instrument name. 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 observation from XML element. More...
 
virtual void write (GXmlElement &xml) const
 Write observation into XML element. More...
 
virtual std::string print (const GChatter &chatter=NORMAL) const
 Print LAT observation information. More...
 
void load_unbinned (const std::string &ft1name, const std::string &ft2name, const std::string &ltcube_name)
 Load data for unbinned analysis. More...
 
void load_binned (const std::string &cntmap_name, const std::string &expmap_name, const std::string &ltcube_name)
 Load data for binned analysis. More...
 
void response (const std::string &irfname)
 Set response function. More...
 
const GLATLtCubeltcube (void) const
 Return Fermi/LAT livetime cube. 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 GLATObservation &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_ft1file
 FT1 filename. More...
 
std::string m_ft2file
 FT2 filename. More...
 
std::string m_ltfile
 Lifetime cube filename. More...
 
std::string m_cntfile
 Counts map filename. More...
 
std::string m_expfile
 Exposure map filename. More...
 
GLATResponse m_response
 Instrument response functions. More...
 
GLATLtCubem_ltcube
 Pointer to livetime cube. 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

Fermi/LAT observation class.

This class implements a Fermi/LAT observation.

Definition at line 49 of file GLATObservation.hpp.

Constructor & Destructor Documentation

GLATObservation::GLATObservation ( void  )

Void constructor.

Definition at line 67 of file GLATObservation.cpp.

References init_members().

Referenced by clone().

GLATObservation::GLATObservation ( const GXmlElement xml)
explicit

XML constructor.

Parameters
[in]xmlXML element.

Constructs a LAT observation from the information that is found in an XML element.

Definition at line 85 of file GLATObservation.cpp.

References init_members(), and read().

GLATObservation::GLATObservation ( const GLATObservation obs)

Copy constructor.

Parameters
[in]obsLAT observation.

Definition at line 103 of file GLATObservation.cpp.

References copy_members(), and init_members().

GLATObservation::~GLATObservation ( void  )
virtual

Destructor.

Definition at line 119 of file GLATObservation.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GObservation.

Definition at line 108 of file GLATObservation.hpp.

void GLATObservation::clear ( void  )
virtual

Clear Fermi/LAT observation.

Implements GObservation.

Definition at line 174 of file GLATObservation.cpp.

References free_members(), GObservation::free_members(), init_members(), and GObservation::init_members().

Referenced by read().

GLATObservation * GLATObservation::clone ( void  ) const
virtual

Clone Fermi/LAT observation.

Returns
Pointer to deep copy of Fermi/LAT observation.

Implements GObservation.

Definition at line 194 of file GLATObservation.cpp.

References GLATObservation().

void GLATObservation::copy_members ( const GLATObservation obs)
protected

Copy class members.

Parameters
[in]obsLAT observation.

Definition at line 719 of file GLATObservation.cpp.

References GLATLtCube::clone(), m_cntfile, m_expfile, m_ft1file, m_ft2file, m_ltcube, m_ltfile, and m_response.

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

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

Return deadtime correction factor.

Returns
Deadtime correction factor

Implements GObservation.

Definition at line 185 of file GLATObservation.hpp.

void GLATObservation::free_members ( void  )
protected

Delete class members.

Definition at line 740 of file GLATObservation.cpp.

References m_ltcube.

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

void GLATObservation::init_members ( void  )
protected

Initialise class members.

Definition at line 698 of file GLATObservation.cpp.

References GLATResponse::clear(), m_cntfile, m_expfile, m_ft1file, m_ft2file, m_ltcube, m_ltfile, and m_response.

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

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

Return instrument name.

Returns
Instrument name ("LAT")

Implements GObservation.

Definition at line 146 of file GLATObservation.hpp.

Referenced by print().

double GLATObservation::livetime ( void  ) const
inlinevirtual

Return livetime.

Returns
Livetime

Implements GObservation.

Definition at line 172 of file GLATObservation.hpp.

Referenced by print().

void GLATObservation::load_binned ( const std::string &  cntmap_name,
const std::string &  expmap_name,
const std::string &  ltcube_name 
)

Load data for binned analysis.

Parameters
[in]cntmap_nameCounts map or Source map FITS filename
[in]expmap_nameBinned explosure map FITS filename
[in]ltcube_nameLivetime cube FITS filename
Todo:
So far nothing is done with the expmap file. Approriate loading needs to be implemented.

Definition at line 653 of file GLATObservation.cpp.

References GObservation::events(), GLATEventCube::load(), GLATLtCube::load(), m_cntfile, GObservation::m_events, m_expfile, m_ltcube, and m_ltfile.

Referenced by read().

void GLATObservation::load_unbinned ( const std::string &  ft1name,
const std::string &  ft2name,
const std::string &  ltcube_name 
)

Load data for unbinned analysis.

Parameters
[in]ft1nameFT1 FITS filename.
[in]ft2nameFT2 FITS filename.
[in]ltcube_nameLivetime cube FITS filename
Todo:
So far nothing is done with the ft2 file and the ltcube file. Loading of the relevant information needs to be implemented.

Definition at line 599 of file GLATObservation.cpp.

References GFits::close(), GObservation::events(), GLATLtCube::load(), GObservation::m_events, m_ft1file, m_ft2file, m_ltcube, m_ltfile, and GLATEventList::read().

Referenced by read().

const GLATLtCube * GLATObservation::ltcube ( void  ) const
inline

Return Fermi/LAT livetime cube.

Returns
Fermi/LAT livetime cube

Definition at line 133 of file GLATObservation.hpp.

References m_ltcube.

Referenced by GLATMeanPsf::set().

double GLATObservation::ontime ( void  ) const
inlinevirtual

Return ontime.

Returns
Ontime

Implements GObservation.

Definition at line 159 of file GLATObservation.hpp.

Referenced by print().

GLATObservation & GLATObservation::operator= ( const GLATObservation obs)

Assignment operator.

Parameters
[in]obsFermi/LAT observation.
Returns
Fermi/LAT observation.

Definition at line 141 of file GLATObservation.cpp.

References copy_members(), free_members(), init_members(), and GObservation::operator=().

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

Print LAT observation information.

Parameters
[in]chatterChattiness.
Returns
String containing LAT observation information.

Implements GObservation.

Definition at line 538 of file GLATObservation.cpp.

References instrument(), livetime(), GObservation::m_events, m_ltcube, m_response, GObservation::name(), ontime(), gammalib::parformat(), GLATResponse::print(), GLATLtCube::print(), GEvents::print(), gammalib::reduce(), SILENT, GObservation::statistic(), and gammalib::str().

void GLATObservation::read ( const GXmlElement xml)
virtual

Read observation from XML element.

Parameters
[in]xmlXML element.
Exceptions
GException::invalid_valueInvalid parameter names found in XML element.

Reads information for a LAT observation from an XML element. The expected format of the XML element is

<observation name="..." id="..." instrument="LAT">
  <parameter name="FT1" file="..."/>
  <parameter name="FT2" file="..."/>
  <parameter name="LiveTimeCube" file="..."/>
  <parameter name="IRF" file="..."/>
</observation>

for an unbinned observation and

<observation name="..." id="..." instrument="LAT">
  <parameter name="CountsMap" file="..."/>
  <parameter name="ExposureMap" file="..."/>
  <parameter name="LiveTimeCube" file="..."/>
  <parameter name="IRF" value="..."/>
</observation>

for a binned observation.

Implements GObservation.

Definition at line 292 of file GLATObservation.cpp.

References GXmlElement::attribute(), clear(), GXmlNode::element(), GXmlNode::elements(), G_READ, load_binned(), load_unbinned(), response(), gammalib::xml_check_parnum(), and gammalib::xml_file_expand().

Referenced by GLATObservation().

void GLATObservation::response ( const GResponse rsp)
virtual

Set response function.

Parameters
[in]rspResponse function.
Exceptions
GException::invalid_argumentResponse rsp in not a LAT response.

Sets the response function for the observation. The argument has to be of type GLATResponse, otherwise an exception is thrown.

Implements GObservation.

Definition at line 211 of file GLATObservation.cpp.

References G_RESPONSE, m_response, and GObservation::name().

Referenced by GLATMeanPsf::set().

const GLATResponse * GLATObservation::response ( void  ) const
inlinevirtual

Return Fermi/LAT response function.

Returns
Fermi/LAT response function

Implements GObservation.

Definition at line 120 of file GLATObservation.hpp.

References m_response.

Referenced by read().

void GLATObservation::response ( const std::string &  irfname)

Set response function.

Parameters
[in]irfnameName of instrument response function.

Set the LAT response function using the IRF name and the path to the calibration database. The IRF name has to be one of

 name (is equivalent to front+back)
 name::front
 name::back
 name::psf(0-3)
 name::edisp(0-3)

where name is the response name (for example "P8R2_SOURCE_V6"). Note that the name is case sensitive, but the event typ is not case sensitive.

Definition at line 250 of file GLATObservation.cpp.

References GLATResponse::clear(), GLATResponse::load(), and m_response.

void GLATObservation::write ( GXmlElement xml) const
virtual

Write observation into XML element.

Parameters
[in]xmlXML element.
Exceptions
GException::invalid_valueNo events allocated or invalid parameter names found in XML element..
GException::runtime_errorNon-LAT events encountered.

Writes information for a LAT observation into an XML element. The expected format of the XML element is

<observation name="..." id="..." instrument="LAT">
  <parameter name="FT1" file="..."/>
  <parameter name="FT2" file="..."/>
  <parameter name="LiveTimeCube" file="..."/>
  <parameter name="IRF" file="..."/>
</observation>

for an unbinned observation and

<observation name="..." id="..." instrument="LAT">
  <parameter name="CountsMap" file="..."/>
  <parameter name="ExposureMap" file="..."/>
  <parameter name="LiveTimeCube" file="..."/>
  <parameter name="IRF" value="..."/>
</observation>

for a binned observation.

Todo:
We should create a special exception that informs that there is neither a valid LAT event list nor a valid LAT counts map in this observations.

Implements GObservation.

Definition at line 429 of file GLATObservation.cpp.

References GXmlNode::append(), GXmlElement::attribute(), GXmlNode::element(), GXmlNode::elements(), G_WRITE, m_cntfile, GObservation::m_events, m_expfile, m_ft1file, m_ft2file, m_ltfile, m_response, GObservation::name(), GLATResponse::rspname(), gammalib::xml_check_parnum(), and gammalib::xml_file_reduce().

Member Data Documentation

std::string GLATObservation::m_cntfile
protected

Counts map filename.

Definition at line 95 of file GLATObservation.hpp.

Referenced by copy_members(), init_members(), load_binned(), and write().

std::string GLATObservation::m_expfile
protected

Exposure map filename.

Definition at line 96 of file GLATObservation.hpp.

Referenced by copy_members(), init_members(), load_binned(), and write().

std::string GLATObservation::m_ft1file
protected

FT1 filename.

Definition at line 92 of file GLATObservation.hpp.

Referenced by copy_members(), init_members(), load_unbinned(), and write().

std::string GLATObservation::m_ft2file
protected

FT2 filename.

Definition at line 93 of file GLATObservation.hpp.

Referenced by copy_members(), init_members(), load_unbinned(), and write().

GLATLtCube* GLATObservation::m_ltcube
protected

Pointer to livetime cube.

Definition at line 98 of file GLATObservation.hpp.

Referenced by copy_members(), free_members(), init_members(), load_binned(), load_unbinned(), ltcube(), and print().

std::string GLATObservation::m_ltfile
protected

Lifetime cube filename.

Definition at line 94 of file GLATObservation.hpp.

Referenced by copy_members(), init_members(), load_binned(), load_unbinned(), and write().

GLATResponse GLATObservation::m_response
protected

Instrument response functions.

Definition at line 97 of file GLATObservation.hpp.

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


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