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

Interface class for multi-wavelength observations. More...

#include <GMWLObservation.hpp>

Inheritance diagram for GMWLObservation:
GObservation GBase

Public Member Functions

 GMWLObservation (void)
 Void constructor. More...
 
 GMWLObservation (const GFilename &filename)
 File constructor. More...
 
 GMWLObservation (const GMWLObservation &obs)
 Copy constructor. More...
 
virtual ~GMWLObservation (void)
 Destructor. More...
 
virtual GMWLObservationoperator= (const GMWLObservation &obs)
 Assignment operator. More...
 
virtual void clear (void)
 Clear instance. More...
 
virtual GMWLObservationclone (void) const
 Clone instance. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual void response (const GResponse &rsp)
 Set response function. More...
 
virtual const GMWLResponseresponse (void) const
 Return response. 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 multi-wavelength information. More...
 
void load (const GFilename &filename)
 Load observation. More...
 
const GFilenamefilename (void) const
 Return filename. More...
 
void filename (const GFilename &filename)
 Set filename. 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 *gradient, GMatrixSparse *curvature, double *npred) const
 Compute likelihood function. More...
 
virtual double model (const GModels &models, const GEvent &event, GVector *gradient=NULL) const
 Return model value and (optionally) gradient. More...
 
virtual int nobserved (void) const
 Return total number of observed events. More...
 
virtual double npred (const GModels &models, GVector *gradient=NULL) const
 Return total number (and optionally gradient) 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 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...
 
bool has_events (void) const
 Signal if observation has events. 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...
 
- 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 GMWLObservation &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 *gradient, 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 *gradient, 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 *gradient, GMatrixSparse *curvature, double *npred) const
 Evaluate log-likelihood function for Gaussian statistic and binned analysis (version with working arrays) 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
 Filename. More...
 
GMWLResponse m_response
 Response function. 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...
 

Detailed Description

Interface class for multi-wavelength observations.

This class implements a multi-wavelength observation. A multi-wavelength observation contains spectral points obtained with an unspecified instrument. The spectral points are given in physical units.

Definition at line 51 of file GMWLObservation.hpp.

Constructor & Destructor Documentation

GMWLObservation::GMWLObservation ( void  )

Void constructor.

Creates instance of an undefined observation.

Definition at line 66 of file GMWLObservation.cpp.

References init_members().

Referenced by clone().

GMWLObservation::GMWLObservation ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenameFile name.

Creates instance from file.

Definition at line 83 of file GMWLObservation.cpp.

References init_members(), and load().

GMWLObservation::GMWLObservation ( const GMWLObservation obs)

Copy constructor.

Parameters
[in]obsObservation.

Creates instance by copying an existing observation.

Definition at line 103 of file GMWLObservation.cpp.

References copy_members(), and init_members().

GMWLObservation::~GMWLObservation ( void  )
virtual

Destructor.

Destroy instance.

Definition at line 121 of file GMWLObservation.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GObservation.

Definition at line 101 of file GMWLObservation.hpp.

void GMWLObservation::clear ( void  )
virtual

Clear instance.

This method properly resets the instance to an initial state.

Implements GObservation.

Definition at line 179 of file GMWLObservation.cpp.

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

Referenced by load(), and read().

GMWLObservation * GMWLObservation::clone ( void  ) const
virtual

Clone instance.

Implements GObservation.

Definition at line 197 of file GMWLObservation.cpp.

References GMWLObservation().

void GMWLObservation::copy_members ( const GMWLObservation obs)
protected

Copy class members.

Parameters
[in]obsObservation to be copied

Definition at line 402 of file GMWLObservation.cpp.

References m_filename, m_instrument, and m_response.

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

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

Return deadtime correction factor.

Returns
Deadtime correction factor (always 1).

Implements GObservation.

Definition at line 161 of file GMWLObservation.hpp.

const GFilename & GMWLObservation::filename ( void  ) const
inline

Return filename.

Returns
Filename.

Definition at line 173 of file GMWLObservation.hpp.

References m_filename.

Referenced by filename(), load(), and read().

void GMWLObservation::filename ( const GFilename filename)
inline

Set filename.

Parameters
[in]filenameFilename.

Definition at line 185 of file GMWLObservation.hpp.

References filename(), and m_filename.

void GMWLObservation::free_members ( void  )
protected

Delete class members.

Definition at line 417 of file GMWLObservation.cpp.

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

void GMWLObservation::init_members ( void  )
protected

Initialise class members.

The instrument name is set here to "MWL" so that the registry has an instrument type with that name. This may be later overwritten by a specific instrument.

Definition at line 382 of file GMWLObservation.cpp.

References GMWLResponse::clear(), GFilename::clear(), m_filename, m_instrument, m_response, and GObservation::m_statistic.

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

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

Return instrument name.

Returns
Instrument name.

Implements GObservation.

Definition at line 125 of file GMWLObservation.hpp.

Referenced by print().

double GMWLObservation::livetime ( void  ) const
inlinevirtual

Return livetime.

Returns
Livetime (always 1).

Implements GObservation.

Definition at line 149 of file GMWLObservation.hpp.

void GMWLObservation::load ( const GFilename filename)

Load observation.

Parameters
[in]filenameFile name.

Definition at line 309 of file GMWLObservation.cpp.

References clear(), filename(), GObservation::id(), GMWLSpectrum::instrument(), GMWLSpectrum::load(), GObservation::m_events, m_filename, m_instrument, and GObservation::name().

Referenced by GMWLObservation(), and read().

double GMWLObservation::ontime ( void  ) const
inlinevirtual

Return ontime.

Returns
Ontime (always 1).

Implements GObservation.

Definition at line 137 of file GMWLObservation.hpp.

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

Assignment operator.

Parameters
[in]obsObservation.

Copies observation into the instance.

Definition at line 144 of file GMWLObservation.cpp.

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

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

Print multi-wavelength information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing multi-wavelength information.

Implements GObservation.

Definition at line 338 of file GMWLObservation.cpp.

References EXPLICIT, instrument(), GObservation::m_events, GObservation::name(), gammalib::parformat(), GEvents::print(), SILENT, and GObservation::statistic().

void GMWLObservation::read ( const GXmlElement xml)
virtual

Read observation from XML element.

Parameters
[in]xmlXML element.

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

<observation name="..." id="..." instrument="MWL">
  <parameter name="Instrument" value="..."/>
  <parameter name="Data" file="..."/>
</observation>

The extno and extname attributes of the data parameter are optional, and can be used to indicate the extension number or name from which the multi-wavelength data should be loaded. If both are given, the extension number will take precedence and the extension name is ignored.

Implements GObservation.

Definition at line 248 of file GMWLObservation.cpp.

References clear(), filename(), G_READ, load(), m_instrument, gammalib::xml_file_expand(), and gammalib::xml_get_attr().

void GMWLObservation::response ( const GResponse rsp)
virtual

Set response function.

Parameters
[in]rspResponse function.
Exceptions
GMWLException::bad_response_typeSpecified response in not of type GMWLResponse.

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

Implements GObservation.

Definition at line 214 of file GMWLObservation.cpp.

References G_RESPONSE, and m_response.

const GMWLResponse * GMWLObservation::response ( void  ) const
inlinevirtual

Return response.

Returns
Response.

Implements GObservation.

Definition at line 113 of file GMWLObservation.hpp.

References m_response.

void GMWLObservation::write ( GXmlElement xml) const
virtual

Write observation into XML element.

Parameters
[in]xmlXML element.
Exceptions
GException::xml_invalid_parnumInvalid number of parameters found in XML element.
GException::xml_invalid_parnamesInvalid parameter names found in XML element.

Writes information for a multi-wavelength observation into an XML element. The format of the XML element is

<observation name="..." id="..." instrument="MWL">
  <parameter name="Instrument" value="..."/>
  <parameter name="Data" file="..."/>
</observation>

Implements GObservation.

Definition at line 286 of file GMWLObservation.cpp.

References GXmlElement::attribute(), G_WRITE, m_filename, m_instrument, gammalib::xml_file_reduce(), and gammalib::xml_need_par().

Member Data Documentation

GFilename GMWLObservation::m_filename
protected

Filename.

Definition at line 90 of file GMWLObservation.hpp.

Referenced by copy_members(), filename(), init_members(), load(), and write().

std::string GMWLObservation::m_instrument
protected

Instrument name.

Definition at line 89 of file GMWLObservation.hpp.

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

GMWLResponse GMWLObservation::m_response
protected

Response function.

Definition at line 91 of file GMWLObservation.hpp.

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


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