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

Private Member Functions

void init_members (void)
 Initialise class members.
 
void copy_members (const GLATResponseTable &table)
 Copy class members.
 
void free_members (void)
 Delete class members.
 

Private Attributes

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

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

GLATResponseTable::GLATResponseTable ( void )

Void constructor.

Definition at line 63 of file GLATResponseTable.cpp.

References init_members().

Referenced by clone().

◆ GLATResponseTable() [2/2]

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

Destructor.

Definition at line 94 of file GLATResponseTable.cpp.

References free_members().

Member Function Documentation

◆ classname()

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.

◆ clear()

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 GLATAeff::init_members(), GLATEdisp::init_members(), GLATPsfBase::init_members(), and read().

◆ clone()

GLATResponseTable * GLATResponseTable::clone ( void ) const
virtual

Clone instance.

Implements GBase.

Definition at line 164 of file GLATResponseTable.cpp.

References GLATResponseTable().

◆ copy_members()

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

◆ costheta_hi()

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.

◆ costheta_lo()

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

◆ energies()

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

Return energies of 4 corners used for interpolation.

Definition at line 574 of file GLATResponseTable.cpp.

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

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

◆ energy()

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

◆ energy_hi()

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

◆ energy_lo()

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

◆ free_members()

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

◆ index()

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, index(), m_ctheta_num, and m_energy_num.

Referenced by index(), and GLATPsfV3::normalize_psf().

◆ indices()

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

◆ init_members()

void GLATResponseTable::init_members ( void )
private

◆ interpolate() [1/2]

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()(), GLATAeff::operator()(), and GLATPsfV1::psf().

◆ interpolate() [2/2]

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, set(), and size().

◆ ncostheta()

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 GLATAeff::ncostheta(), GLATEdisp::ncostheta(), GLATPsfBase::ncostheta(), GLATPsfV3::normalize_psf(), and print().

◆ nenergies()

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 GLATAeff::nenergies(), GLATEdisp::nenergies(), GLATPsfBase::nenergies(), GLATPsfV3::normalize_psf(), and print().

◆ operator=()

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

◆ print()

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

◆ read()

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(), and GFitsTableCol::real().

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

◆ set()

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(), interpolate(), and GLATPsfV3::psf().

◆ size()

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 interpolate(), GLATPsfV1::read(), GLATPsfV3::read(), GLATAeff::read_aeff(), GLATEdisp::read_edisp(), GLATPsfV1::write(), GLATPsfV3::write(), GLATAeff::write_aeff(), and GLATEdisp::write_edisp().

◆ weights()

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, m_wgt4, and weights().

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

◆ write()

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

◆ m_ctheta

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

◆ m_ctheta_hi

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

◆ m_ctheta_lo

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

◆ m_ctheta_num

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

◆ m_energy

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

◆ m_energy_hi

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

◆ m_energy_lo

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

◆ m_energy_num

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

◆ m_inx1

int GLATResponseTable::m_inx1
private

Index 1.

Definition at line 105 of file GLATResponseTable.hpp.

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

◆ m_inx2

int GLATResponseTable::m_inx2
private

Index 2.

Definition at line 106 of file GLATResponseTable.hpp.

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

◆ m_inx3

int GLATResponseTable::m_inx3
private

Index 3.

Definition at line 107 of file GLATResponseTable.hpp.

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

◆ m_inx4

int GLATResponseTable::m_inx4
private

Index 4.

Definition at line 108 of file GLATResponseTable.hpp.

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

◆ m_last_ctheta

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

◆ m_last_energy

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

◆ m_logE

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

◆ m_wgt1

double GLATResponseTable::m_wgt1
private

Weighting factor 1.

Definition at line 109 of file GLATResponseTable.hpp.

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

◆ m_wgt2

double GLATResponseTable::m_wgt2
private

Weighting factor 2.

Definition at line 110 of file GLATResponseTable.hpp.

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

◆ m_wgt3

double GLATResponseTable::m_wgt3
private

Weighting factor 3.

Definition at line 111 of file GLATResponseTable.hpp.

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

◆ m_wgt4

double GLATResponseTable::m_wgt4
private

Weighting factor 4.

Definition at line 112 of file GLATResponseTable.hpp.

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


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