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

Fermi/LAT Response class. More...

#include <GLATResponse.hpp>

Inheritance diagram for GLATResponse:
GResponse GBase

Public Member Functions

 GLATResponse (void)
 Void constructor. More...
 
 GLATResponse (const GLATResponse &rsp)
 Copy constructor. More...
 
virtual ~GLATResponse (void)
 Destructor. More...
 
GLATResponseoperator= (const GLATResponse &rsp)
 Assignment operator. More...
 
virtual void clear (void)
 Clear response. More...
 
virtual GLATResponseclone (void) const
 Clone response. More...
 
virtual std::string classname (void) const
 Return class name. More...
 
virtual bool use_edisp (void) const
 Signal if response uses energy dispersion. More...
 
virtual bool use_tdisp (void) const
 Signal if response uses time dispersion. More...
 
virtual double irf (const GEvent &event, const GPhoton &photon, const GObservation &obs) const
 Return value of point source IRF. More...
 
virtual double nroi (const GModelSky &model, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
 Return integral of event probability for a given sky model over ROI. More...
 
virtual GEbounds ebounds (const GEnergy &obsEnergy) const
 Return true energy boundaries for a specific observed energy. More...
 
virtual std::string print (const GChatter &chatter=NORMAL) const
 Print Fermi-LAT response information. More...
 
virtual double irf_spatial (const GEvent &event, const GSource &source, const GObservation &obs) const
 Return value of model instrument response function. More...
 
int size (void) const
 Return number of event types. More...
 
const std::string & rspname (void) const
 Return response name. More...
 
void load (const std::string &rspname)
 Load Fermi LAT response from calibration database. More...
 
void save (const std::string &rspname) const
 Save Fermi LAT response in calibration database. More...
 
const bool & force_mean (void) const
 Signal if mean PSF should be used for response computation. More...
 
void force_mean (const bool &value)
 Set if mean PSF should be used for response computation. More...
 
GLATAeffaeff (const int &index) const
 Return pointer on effective area. More...
 
GLATPsfpsf (const int &index) const
 Return pointer on point spread function. More...
 
GLATEdispedisp (const int &index) const
 Return pointer on energy dispersion. More...
 
double irf_spatial_atom (const GLATEventAtom &event, const GSource &source, const GObservation &obs) const
 Return value of model IRF for event atom. More...
 
double irf_spatial_bin (const GLATEventBin &event, const GSource &source, const GObservation &obs) const
 Return value of model IRF for event bin. More...
 
- Public Member Functions inherited from GResponse
 GResponse (void)
 Void constructor. More...
 
 GResponse (const GResponse &rsp)
 Copy constructor. More...
 
virtual ~GResponse (void)
 Destructor. More...
 
virtual GResponseoperator= (const GResponse &rsp)
 Assignment operator. More...
 
virtual double convolve (const GModelSky &model, const GEvent &event, const GObservation &obs, const bool &grad=true) const
 Convolve sky model with the instrument response. More...
 
virtual GVector convolve (const GModelSky &model, const GObservation &obs, GMatrixSparse *gradients=NULL) const
 Convolve sky model with the instrument response. More...
 
virtual GVector irf_spatial (const GModelSky &model, const GObservation &obs, GMatrix *gradients=NULL) const
 Return instrument response vector integrated over the spatial model. More...
 
virtual void remove_response_cache (const std::string &name)
 Remove response cache for model. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Private Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GLATResponse &rsp)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
virtual double irf_ptsrc (const GEvent &event, const GSource &source, const GObservation &obs) const
 Return instrument response to point source. More...
 
virtual double irf_diffuse (const GEvent &event, const GSource &source, const GObservation &obs) const
 Return instrument response to diffuse source. More...
 

Private Attributes

std::string m_rspname
 Name of the instrument response. More...
 
bool m_force_mean
 Use mean PSF in any case. More...
 
std::vector< GLATAeff * > m_aeff
 Effective areas. More...
 
std::vector< GLATPsf * > m_psf
 Point spread functions. More...
 
std::vector< GLATEdisp * > m_edisp
 Energy dispersions. More...
 
std::vector< GLATMeanPsf * > m_ptsrc
 Mean PSFs for point sources. More...
 

Additional Inherited Members

- Protected Member Functions inherited from GResponse
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GResponse &rsp)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
double eval_prob (const GModelSky &model, const GEvent &event, const GEnergy &srcEng, const GTime &srcTime, const GObservation &obs, const bool &grad) const
 Convolve sky model with the instrument response. More...
 
GVector eval_probs (const GModelSky &model, const GObservation &obs, GMatrixSparse *gradients=NULL) const
 Convolve sky model with the instrument response. More...
 
int size_edisp_vector (const GModelSky &model, const GObservation &obs, const bool &grad) const
 Return size of vector for energy dispersion computation. More...
 
GEbounds ebounds_model (const GModelSky &model) const
 Return true energy intervals for sky model. More...
 
virtual double irf_radial (const GEvent &event, const GSource &source, const GObservation &obs) const
 Return instrument response to radial source. More...
 
virtual double irf_elliptical (const GEvent &event, const GSource &source, const GObservation &obs) const
 Return instrument response to elliptical source. More...
 
virtual double irf_composite (const GEvent &event, const GSource &source, const GObservation &obs) const
 Return instrument response to composite source. More...
 
virtual GVector irf_ptsrc (const GModelSky &model, const GObservation &obs, GMatrix *gradients=NULL) const
 Return instrument response to point source sky model. More...
 
virtual GVector irf_radial (const GModelSky &model, const GObservation &obs, GMatrix *gradients=NULL) const
 Return instrument response to radial source sky model. More...
 
virtual GVector irf_elliptical (const GModelSky &model, const GObservation &obs, GMatrix *gradients=NULL) const
 Return instrument response to ellipitical source sky model. More...
 
virtual GVector irf_diffuse (const GModelSky &model, const GObservation &obs, GMatrix *gradients=NULL) const
 Return instrument response to diffuse source sky model. More...
 
virtual GVector irf_composite (const GModelSky &model, const GObservation &obs, GMatrix *gradients=NULL) const
 Return instrument response to composite source sky model. More...
 
- Protected Attributes inherited from GResponse
bool m_use_irf_cache
 Control usage of irf cache. More...
 
bool m_use_nroi_cache
 Control usage of nroi cache. More...
 
int m_irf_radial_iter_theta
 Radial model integration theta iterations. More...
 
int m_irf_radial_iter_phi
 Radial model integration phi iterations. More...
 
int m_irf_elliptical_iter_theta
 Elliptical model integration theta iterations. More...
 
int m_irf_elliptical_iter_phi
 Elliptical model integration phi iterations. More...
 
double m_irf_diffuse_resolution
 Angular resolution for diffuse model. More...
 
GResponseCache m_irf_cache
 
GResponseCache m_nroi_cache
 
GResponseVectorCache m_irf_vector_cache
 

Detailed Description

Fermi/LAT Response class.

Definition at line 56 of file GLATResponse.hpp.

Constructor & Destructor Documentation

GLATResponse::GLATResponse ( void  )

Void constructor.

Definition at line 85 of file GLATResponse.cpp.

References init_members().

Referenced by clone().

GLATResponse::GLATResponse ( const GLATResponse rsp)

Copy constructor.

Parameters
[in]rspResponse.

Definition at line 100 of file GLATResponse.cpp.

References copy_members(), and init_members().

GLATResponse::~GLATResponse ( void  )
virtual

Destructor.

Definition at line 116 of file GLATResponse.cpp.

References free_members().

Member Function Documentation

GLATAeff * GLATResponse::aeff ( const int &  index) const

Return pointer on effective area.

Parameters
[in]indexResponse index [0,...,m_aeff.size()-1].

Definition at line 713 of file GLATResponse.cpp.

References G_AEFF, and m_aeff.

Referenced by load(), and GLATMeanPsf::set().

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

Return class name.

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

Implements GResponse.

Definition at line 137 of file GLATResponse.hpp.

void GLATResponse::clear ( void  )
virtual
GLATResponse * GLATResponse::clone ( void  ) const
virtual

Clone response.

Returns
Pointer to deep copy of response.

Implements GResponse.

Definition at line 191 of file GLATResponse.cpp.

References GLATResponse().

void GLATResponse::copy_members ( const GLATResponse rsp)
private

Copy class members.

Parameters
[in]rspResponse.

Definition at line 839 of file GLATResponse.cpp.

References m_aeff, m_edisp, m_force_mean, m_psf, m_ptsrc, and m_rspname.

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

GEbounds GLATResponse::ebounds ( const GEnergy obsEnergy) const
virtual

Return true energy boundaries for a specific observed energy.

Parameters
[in]obsEnergyObserved Energy.
Returns
True energy boundaries for given observed energy.
Exceptions
GException::feature_not_implementedMethod is not implemented.

Implements GResponse.

Definition at line 541 of file GLATResponse.cpp.

References G_EBOUNDS.

GLATEdisp * GLATResponse::edisp ( const int &  index) const

Return pointer on energy dispersion.

Parameters
[in]indexResponse index [0,...,m_edisp.size()-1].

Definition at line 753 of file GLATResponse.cpp.

References G_EDISP, and m_edisp.

Referenced by load().

const bool & GLATResponse::force_mean ( void  ) const
inline

Signal if mean PSF should be used for response computation.

Returns
True if mean PSF should be used for response computation.

Definition at line 199 of file GLATResponse.hpp.

References m_force_mean.

void GLATResponse::force_mean ( const bool &  value)
inline

Set if mean PSF should be used for response computation.

Parameters
[in]valueTrue if mean PSF should be used for response computation.

Definition at line 211 of file GLATResponse.hpp.

References m_force_mean.

void GLATResponse::free_members ( void  )
private

Delete class members.

Definition at line 877 of file GLATResponse.cpp.

References m_aeff, m_edisp, m_psf, and m_ptsrc.

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

void GLATResponse::init_members ( void  )
private

Initialise class members.

Definition at line 819 of file GLATResponse.cpp.

References m_aeff, m_edisp, m_force_mean, m_psf, m_ptsrc, and m_rspname.

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

double GLATResponse::irf ( const GEvent event,
const GPhoton photon,
const GObservation obs 
) const
virtual

Return value of point source IRF.

Parameters
[in]eventObserved event.
[in]photonIncident photon.
[in]obsObservation.
Exceptions
GException::invalid_argumentInstrument direction is not a valid LAT instrument direction.
Todo:
The IRF value is not divided by ontime of the event, but it is already time integrated.

Implements GResponse.

Definition at line 210 of file GLATResponse.cpp.

References GSkyDir::dec_deg(), GPhoton::dir(), GLATInstDir::dir(), GEvent::dir(), GPhoton::energy(), G_IRF, GEnergy::log10MeV(), m_ptsrc, GLATMeanPsf::name(), psf(), GSkyDir::ra_deg(), and gammalib::str().

Referenced by irf_diffuse(), irf_ptsrc(), and irf_spatial_atom().

double GLATResponse::irf_diffuse ( const GEvent event,
const GSource source,
const GObservation obs 
) const
privatevirtual

Return instrument response to diffuse source.

Parameters
[in]eventObserved event.
[in]sourceSource.
[in]obsObservation.
Returns
Instrument response to point source.

Returns the instrument response to a diffuse source.

Reimplemented from GResponse.

Definition at line 952 of file GLATResponse.cpp.

References irf(), irf_spatial_atom(), irf_spatial_bin(), and GEvent::is_atom().

double GLATResponse::irf_ptsrc ( const GEvent event,
const GSource source,
const GObservation obs 
) const
privatevirtual

Return instrument response to point source.

Parameters
[in]eventObserved event.
[in]sourceSource.
[in]obsObservation.
Returns
Instrument response to point source.

Returns the instrument response to a point source.

Reimplemented from GResponse.

Definition at line 922 of file GLATResponse.cpp.

References irf(), irf_spatial_atom(), irf_spatial_bin(), and GEvent::is_atom().

double GLATResponse::irf_spatial ( const GEvent event,
const GSource source,
const GObservation obs 
) const
virtual

Return value of model instrument response function.

Parameters
[in]eventEvent.
[in]sourceSource.
[in]obsObservation.

This method returns the response of the instrument to a specific source model. The method handles both event atoms and event bins.

Reimplemented from GResponse.

Definition at line 284 of file GLATResponse.cpp.

References irf_spatial_atom(), irf_spatial_bin(), and GEvent::is_atom().

double GLATResponse::irf_spatial_atom ( const GLATEventAtom event,
const GSource source,
const GObservation obs 
) const

Return value of model IRF for event atom.

Parameters
[in]eventEvent atom.
[in]sourceSource.
[in]obsObservations.
Exceptions
GException::feature_not_implementedMethod not yet implemented.
Todo:
Not yet implemented.

Definition at line 314 of file GLATResponse.cpp.

References G_IRF_ATOM, and irf().

Referenced by irf_diffuse(), irf_ptsrc(), and irf_spatial().

double GLATResponse::irf_spatial_bin ( const GLATEventBin event,
const GSource source,
const GObservation obs 
) const

Return value of model IRF for event bin.

Parameters
[in]eventEvent bin.
[in]sourceSource.
[in]obsObservation.
Exceptions
GException::invalid_valueDiffuse model not found.

This method first searches for a corresponding source map, and if found, computes the response from the source map. If no source map is present it checks if the source is a point source. If this is the case a mean PSF is allocated for the source and the response is computed from the mean PSF. Otherwise an GException::invalid_value exception is thrown.

Todo:

Extract event cube from observation. We do not need the cube pointer in the event anymore.

Implement more efficient method for response search (name search is not very rapid).

Instead of calling "offset = event.dir().dist_deg(srcDir)" we can precompute and store for each PSF the offsets. This should save quite some time since the distance computation is time consuming.

Definition at line 354 of file GLATResponse.cpp.

References GLATEventCube::diffname(), GLATEventCube::diffrsp(), GModelSpatialPointSource::dir(), GSkyDir::dist_deg(), GSource::energy(), GLATEventCube::enodes(), G_IRF_BIN, GNodeArray::inx_left(), GNodeArray::inx_right(), GEnergy::log10MeV(), m_force_mean, m_ptsrc, GEnergy::MeV(), GSource::model(), GSource::name(), GLATMeanPsf::name(), GLATEventCube::ndiffrsp(), GSkyMap::npix(), GLATEventBin::ontime(), GSkyMap::pixels(), psf(), GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().

Referenced by irf_diffuse(), irf_ptsrc(), and irf_spatial().

void GLATResponse::load ( const std::string &  rspname)

Load Fermi LAT response from calibration database.

Parameters
[in]rspnameResponse name.
Exceptions
GException::invalid_argumentInvalid response type encountered.

Loads the specified Fermi LAT response from the calibration database. The following response names are supported (case insensitive):

 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 575 of file GLATResponse.cpp.

References aeff(), clear(), edisp(), GCaldb::filename(), G_LOAD, m_aeff, m_edisp, m_psf, m_rspname, psf(), gammalib::split(), gammalib::strip_whitespace(), gammalib::tolower(), and gammalib::toupper().

Referenced by GLATObservation::response().

double GLATResponse::nroi ( const GModelSky model,
const GEnergy obsEng,
const GTime obsTime,
const GObservation obs 
) const
virtual

Return integral of event probability for a given sky model over ROI.

Parameters
[in]modelSky model.
[in]obsEngObserved photon energy.
[in]obsTimeObserved photon arrival time.
[in]obsObservation.
Returns
0
Exceptions
GException::feature_not_implementedMethod is not implemented.

Implements GResponse.

Definition at line 517 of file GLATResponse.cpp.

References G_NROI.

GLATResponse & GLATResponse::operator= ( const GLATResponse rsp)

Assignment operator.

Parameters
[in]rspResponse.
Returns
Response.

Definition at line 138 of file GLATResponse.cpp.

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

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

Print Fermi-LAT response information.

Parameters
[in]chatterChattiness.
Returns
String containing response information.

Implements GResponse.

Definition at line 774 of file GLATResponse.cpp.

References m_aeff, m_edisp, m_psf, m_ptsrc, m_rspname, gammalib::parformat(), gammalib::reduce(), SILENT, size(), and TERSE.

Referenced by GLATObservation::print().

GLATPsf * GLATResponse::psf ( const int &  index) const

Return pointer on point spread function.

Parameters
[in]indexResponse index [0,...,m_psf.size()-1].

Definition at line 733 of file GLATResponse.cpp.

References G_PSF, and m_psf.

Referenced by irf(), irf_spatial_bin(), load(), and GLATMeanPsf::set().

const std::string & GLATResponse::rspname ( void  ) const
inline

Return response name.

Returns
Response name.

Definition at line 187 of file GLATResponse.hpp.

References m_rspname.

Referenced by GLATObservation::write().

void GLATResponse::save ( const std::string &  rspname) const

Save Fermi LAT response in calibration database.

Parameters
[in]rspnameResponse name.
Todo:
Not yet implemented.

Definition at line 697 of file GLATResponse.cpp.

References G_SAVE.

int GLATResponse::size ( void  ) const
inline

Return number of event types.

Returns
Number of event types.

Returns the number of events types in this reponse.

Definition at line 175 of file GLATResponse.hpp.

References m_aeff.

Referenced by print(), and GLATMeanPsf::set().

bool GLATResponse::use_edisp ( void  ) const
inlinevirtual

Signal if response uses energy dispersion.

Returns
True if response uses energy dispersion.

Implements GResponse.

Definition at line 149 of file GLATResponse.hpp.

bool GLATResponse::use_tdisp ( void  ) const
inlinevirtual

Signal if response uses time dispersion.

Returns
True if response uses time dispersion.

Implements GResponse.

Definition at line 161 of file GLATResponse.hpp.

Member Data Documentation

std::vector<GLATAeff*> GLATResponse::m_aeff
private

Effective areas.

Definition at line 124 of file GLATResponse.hpp.

Referenced by aeff(), copy_members(), free_members(), init_members(), load(), print(), and size().

std::vector<GLATEdisp*> GLATResponse::m_edisp
private

Energy dispersions.

Definition at line 126 of file GLATResponse.hpp.

Referenced by copy_members(), edisp(), free_members(), init_members(), load(), and print().

bool GLATResponse::m_force_mean
private

Use mean PSF in any case.

Definition at line 123 of file GLATResponse.hpp.

Referenced by copy_members(), force_mean(), init_members(), and irf_spatial_bin().

std::vector<GLATPsf*> GLATResponse::m_psf
private

Point spread functions.

Definition at line 125 of file GLATResponse.hpp.

Referenced by copy_members(), free_members(), init_members(), load(), print(), and psf().

std::vector<GLATMeanPsf*> GLATResponse::m_ptsrc
private

Mean PSFs for point sources.

Definition at line 127 of file GLATResponse.hpp.

Referenced by copy_members(), free_members(), init_members(), irf(), irf_spatial_bin(), and print().

std::string GLATResponse::m_rspname
private

Name of the instrument response.

Definition at line 122 of file GLATResponse.hpp.

Referenced by copy_members(), init_members(), load(), print(), and rspname().


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