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

Interface for the Fermi LAT Response table class. More...

#include <GLATResponseTable.hpp>

Inheritance diagram for GLATResponseTable:
GBase

Public Member Functions

 GLATResponseTable (void)
 Void constructor. More...
 
 GLATResponseTable (const GLATResponseTable &table)
 Copy constructor. More...
 
virtual ~GLATResponseTable (void)
 Destructor. More...
 
GLATResponseTableoperator= (const GLATResponseTable &table)
 Assignment operator. More...
 
void clear (void)
 Clear instance. More...
 
GLATResponseTableclone (void) const
 Clone instance. More...
 
std::string classname (void) const
 Return class name. More...
 
void read (const GFitsTable &hdu)
 Read response table from FITS table HDU. More...
 
void write (GFitsTable &hdu) const
 Write response table into FITS table. More...
 
int index (const int &ie, const int &ic) const
 Return table index. More...
 
double energy (const int &ie) const
 Return mean energy of bin (units: MeV) More...
 
void set (const double &logE, const double &ctheta)
 Set indices and weighting for bi-linear interpolation of 2D array. More...
 
double interpolate (const double &logE, const double &ctheta, const std::vector< double > &array)
 Perform bi-linear interpolation of 2D array. More...
 
double interpolate (const double &logE, const double &ctheta, const std::vector< double > &array, const int &offset, const int &size)
 Perform bi-linear interpolation of 3D array. More...
 
int size (void) const
 Return number of bins in response table. More...
 
const int & nenergies (void) const
 Return number of energies in response table. More...
 
const int & ncostheta (void) const
 Return number of cosine theta bins in response table. More...
 
double energy_lo (const int &inx) const
 Return lower bin energy (units: MeV) More...
 
double energy_hi (const int &inx) const
 Return upper bin energy (units: MeV) More...
 
double costheta_lo (const int &inx) const
 Return lower bin cos theta [. More...
 
double costheta_hi (const int &inx) const
 Return upper bin cos theta. More...
 
std::vector< int > indices (void) const
 Return indices of 4 corners used for interpolation. More...
 
std::vector< double > energies (void) const
 Return energies of 4 corners used for interpolation. More...
 
std::vector< double > weights (void) const
 Return weights of 4 corners used for interpolation. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print response table information. 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 GLATResponseTable &table)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Private Attributes

int m_energy_num
 Number of energy bins in table. More...
 
int m_ctheta_num
 Number of cos theta bins in table. More...
 
double * m_energy_lo
 Energy bins lower boundary (MeV) More...
 
double * m_energy_hi
 Energy bins upper boundary (MeV) More...
 
double * m_ctheta_lo
 cos(theta) bins lower boundary More...
 
double * m_ctheta_hi
 cos(theta) bins upper boundary More...
 
std::vector< double > m_energy
 Energy nodes (MeV) More...
 
GNodeArray m_logE
 Energy nodes (log10 mean energy) More...
 
GNodeArray m_ctheta
 cos(theta) nodes More...
 
double m_last_energy
 Last requested energy for interpolation. More...
 
double m_last_ctheta
 Last requested cos(theta) for interpolation. More...
 
int m_inx1
 Index 1. More...
 
int m_inx2
 Index 2. More...
 
int m_inx3
 Index 3. More...
 
int m_inx4
 Index 4. More...
 
double m_wgt1
 Weighting factor 1. More...
 
double m_wgt2
 Weighting factor 2. More...
 
double m_wgt3
 Weighting factor 3. More...
 
double m_wgt4
 Weighting factor 4. More...
 

Detailed Description

Interface for the Fermi LAT Response table class.

A response table contains the binning information in energy and cos theta for the Fermi LAT response function. From this binning information, response values can be obtained using a bilinear interpolation in log10 of energy and in cos theta.

Definition at line 48 of file GLATResponseTable.hpp.

Constructor & Destructor Documentation

GLATResponseTable::GLATResponseTable ( void  )

Void constructor.

Definition at line 63 of file GLATResponseTable.cpp.

References init_members().

Referenced by clone().

GLATResponseTable::GLATResponseTable ( const GLATResponseTable table)

Copy constructor.

Parameters
tableResponse table.

Definition at line 78 of file GLATResponseTable.cpp.

References copy_members(), and init_members().

GLATResponseTable::~GLATResponseTable ( void  )
virtual

Destructor.

Definition at line 94 of file GLATResponseTable.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GBase.

Definition at line 122 of file GLATResponseTable.hpp.

void GLATResponseTable::clear ( void  )
virtual

Clear instance.

This method properly resets the object to an initial state.

Implements GBase.

Definition at line 148 of file GLATResponseTable.cpp.

References free_members(), and init_members().

Referenced by GLATPsfBase::init_members(), GLATEdisp::init_members(), GLATAeff::init_members(), and read().

GLATResponseTable * GLATResponseTable::clone ( void  ) const
virtual

Clone instance.

Implements GBase.

Definition at line 164 of file GLATResponseTable.cpp.

References GLATResponseTable().

void GLATResponseTable::copy_members ( const GLATResponseTable table)
private

Copy class members.

Parameters
[in]tableResponse table.

Definition at line 683 of file GLATResponseTable.cpp.

References m_ctheta, m_ctheta_hi, m_ctheta_lo, m_ctheta_num, m_energy, m_energy_hi, m_energy_lo, m_energy_num, m_inx1, m_inx2, m_inx3, m_inx4, m_last_ctheta, m_last_energy, m_logE, m_wgt1, m_wgt2, m_wgt3, and m_wgt4.

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

double GLATResponseTable::costheta_hi ( const int &  inx) const

Return upper bin cos theta.

Parameters
[in]inxIndex of cos theta bin (starting from 0)
Exceptions
GException::out_of_rangeCos theta bin index out of range

Definition at line 537 of file GLATResponseTable.cpp.

References G_COSTHETA_HI, m_ctheta_hi, and m_ctheta_num.

double GLATResponseTable::costheta_lo ( const int &  inx) const

Return lower bin cos theta [.

Parameters
[in]inxIndex of cos theta bin [0,...,m_ctheta_num[
Exceptions
GException::out_of_rangeCos theta bin index out of range

Definition at line 514 of file GLATResponseTable.cpp.

References G_COSTHETA_LO, m_ctheta_lo, and m_ctheta_num.

Referenced by GLATPsfV3::normalize_psf(), GLATPsfV1::read(), GLATPsfV3::read(), and GLATAeff::read_aeff().

std::vector< double > GLATResponseTable::energies ( void  ) const

Return energies of 4 corners used for interpolation.

Definition at line 574 of file GLATResponseTable.cpp.

References GNodeArray::inx_left(), GNodeArray::inx_right(), m_energy, m_energy_num, and m_logE.

Referenced by GLATPsfV3::psf().

double GLATResponseTable::energy ( const int &  ie) const

Return mean energy of bin (units: MeV)

Parameters
[in]ieIndex of energy bin [0,...,m_energy_num[
Exceptions
GException::out_of_rangeEnergy bin index out of range

The mean energy is actually computed from the logarithmic average of lower and upper boundaries: \(E=10^{0.5 \times (\log{E_{\rm min}} + \log{E_{\rm max}})}\) Note that this energy is stored in the m_energy array, hence to convert to MeV we simply have to the it to the power of 10.

Todo:
Store also linear energies to avoid conversion.

Definition at line 327 of file GLATResponseTable.cpp.

References G_ENERGY, m_energy, and m_energy_num.

Referenced by GLATPsfV3::normalize_psf().

double GLATResponseTable::energy_hi ( const int &  inx) const

Return upper bin energy (units: MeV)

Parameters
[in]inxIndex of energy bin [0,...,m_energy_num[
Exceptions
GException::out_of_rangeEnergy bin index out of range

Definition at line 491 of file GLATResponseTable.cpp.

References G_ENERGY_HI, m_energy_hi, and m_energy_num.

Referenced by read().

double GLATResponseTable::energy_lo ( const int &  inx) const

Return lower bin energy (units: MeV)

Parameters
[in]inxIndex of energy bin [0,...,m_energy_num[
Exceptions
GException::out_of_rangeEnergy bin index out of range

Definition at line 468 of file GLATResponseTable.cpp.

References G_ENERGY_LO, m_energy_lo, and m_energy_num.

Referenced by read().

void GLATResponseTable::free_members ( void  )
private

Delete class members.

Definition at line 730 of file GLATResponseTable.cpp.

References m_ctheta_hi, m_ctheta_lo, m_energy_hi, and m_energy_lo.

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

int GLATResponseTable::index ( const int &  ie,
const int &  ic 
) const

Return table index.

Parameters
[in]ieEnergy bin [0,...,m_energy_num[
[in]iccos theta bin [0,...,m_ctheta_num[
Exceptions
GException::out_of_rangeEnergy or cos theta bin index out of range

Computes table index from energy and cos theta bin indices.

Definition at line 289 of file GLATResponseTable.cpp.

References G_INDEX, m_ctheta_num, and m_energy_num.

Referenced by GLATPsfV3::normalize_psf().

std::vector< int > GLATResponseTable::indices ( void  ) const

Return indices of 4 corners used for interpolation.

Definition at line 555 of file GLATResponseTable.cpp.

References m_inx1, m_inx2, m_inx3, and m_inx4.

Referenced by GLATPsfV3::psf().

void GLATResponseTable::init_members ( void  )
private
double GLATResponseTable::interpolate ( const double &  logE,
const double &  ctheta,
const std::vector< double > &  array 
)

Perform bi-linear interpolation of 2D array.

Parameters
[in]logEBase 10 logarithm of the energy (MeV).
[in]cthetaCosine of zenith angle.
[in]arrayArray to be interpolated.

Bi-linear interpolation is performed in log10 of energy and in cos theta. The array is stored in a std::vector object with the logE axis varying more rapidely.

Definition at line 410 of file GLATResponseTable.cpp.

References m_inx1, m_inx2, m_inx3, m_inx4, m_wgt1, m_wgt2, m_wgt3, m_wgt4, and set().

Referenced by GLATAeff::operator()(), and GLATPsfV1::psf().

double GLATResponseTable::interpolate ( const double &  logE,
const double &  ctheta,
const std::vector< double > &  array,
const int &  offset,
const int &  size 
)

Perform bi-linear interpolation of 3D array.

Parameters
[in]logEBase 10 logarithm of the energy (MeV).
[in]cthetaCosine of zenith angle.
[in]arrayArray to be interpolated.
[in]offsetOffset if 3D array in 1st dimension.
[in]sizeSize of 3D array in 1st dimension.

Bi-linear interpolation is performed in log10 of energy and in cos theta. The array is stored in a std::vector object.

Definition at line 440 of file GLATResponseTable.cpp.

References m_inx1, m_inx2, m_inx3, m_inx4, m_wgt1, m_wgt2, m_wgt3, m_wgt4, and set().

const int & GLATResponseTable::ncostheta ( void  ) const
inline

Return number of cosine theta bins in response table.

Returns
Number of cosine theta bins in response table.

Definition at line 158 of file GLATResponseTable.hpp.

References m_ctheta_num.

Referenced by GLATPsfBase::ncostheta(), GLATEdisp::ncostheta(), GLATAeff::ncostheta(), GLATPsfV3::normalize_psf(), and print().

const int & GLATResponseTable::nenergies ( void  ) const
inline

Return number of energies in response table.

Returns
Number of energies in response table.

Definition at line 146 of file GLATResponseTable.hpp.

References m_energy_num.

Referenced by GLATPsfBase::nenergies(), GLATEdisp::nenergies(), GLATAeff::nenergies(), GLATPsfV3::normalize_psf(), and print().

GLATResponseTable & GLATResponseTable::operator= ( const GLATResponseTable table)

Assignment operator.

Parameters
tableResponse table.
Returns
Response table.

Definition at line 116 of file GLATResponseTable.cpp.

References copy_members(), free_members(), and init_members().

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

Print response table information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing response table information.

Implements GBase.

Definition at line 617 of file GLATResponseTable.cpp.

References ncostheta(), nenergies(), gammalib::parformat(), SILENT, and gammalib::str().

void GLATResponseTable::read ( const GFitsTable hdu)

Read response table from FITS table HDU.

Parameters
[in]hduResponse table HDU.

The response table definition is assumed to be stored in 4 vector columns with names ENERG_LO (energy bins lower boundary) ENERG_HI (energy bins upper boundary) CTHETA_LO (cos theta bins lower boundary) CTHETA_HI (cos theta bins upper boundary)

Definition at line 182 of file GLATResponseTable.cpp.

References clear(), energy_hi(), energy_lo(), log10(), m_ctheta, m_ctheta_hi, m_ctheta_lo, m_ctheta_num, m_energy, m_energy_hi, m_energy_lo, m_energy_num, m_logE, GNodeArray::nodes(), GFitsTableCol::number(), pow(), and GFitsTableCol::real().

Referenced by GLATPsfV1::read(), GLATPsfV3::read(), GLATAeff::read_aeff(), and GLATEdisp::read_edisp().

void GLATResponseTable::set ( const double &  logE,
const double &  ctheta 
)

Set indices and weighting for bi-linear interpolation of 2D array.

Parameters
[in]logEBase 10 logarithm of the energy (MeV).
[in]cthetaCosine of zenith angle.

Bi-linear interpolation is performed in log10 of energy and in cos theta.

Definition at line 355 of file GLATResponseTable.cpp.

References GNodeArray::inx_left(), GNodeArray::inx_right(), m_ctheta, m_energy_num, m_inx1, m_inx2, m_inx3, m_inx4, m_last_ctheta, m_last_energy, m_logE, m_wgt1, m_wgt2, m_wgt3, m_wgt4, GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().

Referenced by interpolate(), and GLATPsfV3::psf().

int GLATResponseTable::size ( void  ) const
inline

Return number of bins in response table.

Returns
Number of bins in response table.

Definition at line 134 of file GLATResponseTable.hpp.

References m_ctheta_num, and m_energy_num.

Referenced by GLATPsfV1::read(), GLATPsfV3::read(), GLATAeff::read_aeff(), GLATEdisp::read_edisp(), GLATPsfV1::write(), GLATPsfV3::write(), GLATAeff::write_aeff(), and GLATEdisp::write_edisp().

std::vector< double > GLATResponseTable::weights ( void  ) const

Return weights of 4 corners used for interpolation.

Definition at line 595 of file GLATResponseTable.cpp.

References m_wgt1, m_wgt2, m_wgt3, and m_wgt4.

Referenced by GLATPsfV3::psf().

void GLATResponseTable::write ( GFitsTable hdu) const

Write response table into FITS table.

Parameters
[in]hduFits table HDU.

Definition at line 249 of file GLATResponseTable.cpp.

References GFitsTable::append(), m_ctheta_hi, m_ctheta_lo, m_ctheta_num, m_energy_hi, m_energy_lo, and m_energy_num.

Referenced by GLATPsfV1::write(), GLATPsfV3::write(), GLATAeff::write_aeff(), and GLATEdisp::write_edisp().

Member Data Documentation

GNodeArray GLATResponseTable::m_ctheta
private

cos(theta) nodes

Definition at line 100 of file GLATResponseTable.hpp.

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

double* GLATResponseTable::m_ctheta_hi
private

cos(theta) bins upper boundary

Definition at line 97 of file GLATResponseTable.hpp.

Referenced by copy_members(), costheta_hi(), free_members(), init_members(), read(), and write().

double* GLATResponseTable::m_ctheta_lo
private

cos(theta) bins lower boundary

Definition at line 96 of file GLATResponseTable.hpp.

Referenced by copy_members(), costheta_lo(), free_members(), init_members(), read(), and write().

int GLATResponseTable::m_ctheta_num
private

Number of cos theta bins in table.

Definition at line 93 of file GLATResponseTable.hpp.

Referenced by copy_members(), costheta_hi(), costheta_lo(), index(), init_members(), ncostheta(), read(), size(), and write().

std::vector<double> GLATResponseTable::m_energy
private

Energy nodes (MeV)

Definition at line 98 of file GLATResponseTable.hpp.

Referenced by copy_members(), energies(), energy(), init_members(), and read().

double* GLATResponseTable::m_energy_hi
private

Energy bins upper boundary (MeV)

Definition at line 95 of file GLATResponseTable.hpp.

Referenced by copy_members(), energy_hi(), free_members(), init_members(), read(), and write().

double* GLATResponseTable::m_energy_lo
private

Energy bins lower boundary (MeV)

Definition at line 94 of file GLATResponseTable.hpp.

Referenced by copy_members(), energy_lo(), free_members(), init_members(), read(), and write().

int GLATResponseTable::m_energy_num
private

Number of energy bins in table.

Definition at line 92 of file GLATResponseTable.hpp.

Referenced by copy_members(), energies(), energy(), energy_hi(), energy_lo(), index(), init_members(), nenergies(), read(), set(), size(), and write().

int GLATResponseTable::m_inx1
private

Index 1.

Definition at line 105 of file GLATResponseTable.hpp.

Referenced by copy_members(), indices(), init_members(), interpolate(), and set().

int GLATResponseTable::m_inx2
private

Index 2.

Definition at line 106 of file GLATResponseTable.hpp.

Referenced by copy_members(), indices(), init_members(), interpolate(), and set().

int GLATResponseTable::m_inx3
private

Index 3.

Definition at line 107 of file GLATResponseTable.hpp.

Referenced by copy_members(), indices(), init_members(), interpolate(), and set().

int GLATResponseTable::m_inx4
private

Index 4.

Definition at line 108 of file GLATResponseTable.hpp.

Referenced by copy_members(), indices(), init_members(), interpolate(), and set().

double GLATResponseTable::m_last_ctheta
private

Last requested cos(theta) for interpolation.

Definition at line 104 of file GLATResponseTable.hpp.

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

double GLATResponseTable::m_last_energy
private

Last requested energy for interpolation.

Definition at line 103 of file GLATResponseTable.hpp.

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

GNodeArray GLATResponseTable::m_logE
private

Energy nodes (log10 mean energy)

Definition at line 99 of file GLATResponseTable.hpp.

Referenced by copy_members(), energies(), init_members(), read(), and set().

double GLATResponseTable::m_wgt1
private

Weighting factor 1.

Definition at line 109 of file GLATResponseTable.hpp.

Referenced by copy_members(), init_members(), interpolate(), set(), and weights().

double GLATResponseTable::m_wgt2
private

Weighting factor 2.

Definition at line 110 of file GLATResponseTable.hpp.

Referenced by copy_members(), init_members(), interpolate(), set(), and weights().

double GLATResponseTable::m_wgt3
private

Weighting factor 3.

Definition at line 111 of file GLATResponseTable.hpp.

Referenced by copy_members(), init_members(), interpolate(), set(), and weights().

double GLATResponseTable::m_wgt4
private

Weighting factor 4.

Definition at line 112 of file GLATResponseTable.hpp.

Referenced by copy_members(), init_members(), interpolate(), set(), and weights().


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