GammaLib
2.0.0
|
Interface for the Fermi LAT Response table class. More...
#include <GLATResponseTable.hpp>
Public Member Functions | |
GLATResponseTable (void) | |
Void constructor. More... | |
GLATResponseTable (const GLATResponseTable &table) | |
Copy constructor. More... | |
virtual | ~GLATResponseTable (void) |
Destructor. More... | |
GLATResponseTable & | operator= (const GLATResponseTable &table) |
Assignment operator. More... | |
void | clear (void) |
Clear instance. More... | |
GLATResponseTable * | clone (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... | |
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.
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.
table | Response table. |
Definition at line 78 of file GLATResponseTable.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 122 of file GLATResponseTable.hpp.
|
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().
|
virtual |
Clone instance.
Implements GBase.
Definition at line 164 of file GLATResponseTable.cpp.
References GLATResponseTable().
|
private |
Copy class members.
[in] | table | Response 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.
[in] | inx | Index of cos theta bin (starting from 0) |
GException::out_of_range | Cos 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 [.
[in] | inx | Index of cos theta bin [0,...,m_ctheta_num[ |
GException::out_of_range | Cos 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)
[in] | ie | Index of energy bin [0,...,m_energy_num[ |
GException::out_of_range | Energy 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.
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)
[in] | inx | Index of energy bin [0,...,m_energy_num[ |
GException::out_of_range | Energy 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)
[in] | inx | Index of energy bin [0,...,m_energy_num[ |
GException::out_of_range | Energy 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().
|
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.
[in] | ie | Energy bin [0,...,m_energy_num[ |
[in] | ic | cos theta bin [0,...,m_ctheta_num[ |
GException::out_of_range | Energy 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().
|
private |
Initialise class members.
Definition at line 650 of file GLATResponseTable.cpp.
References GNodeArray::clear(), 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 clear(), GLATResponseTable(), and operator=().
double GLATResponseTable::interpolate | ( | const double & | logE, |
const double & | ctheta, | ||
const std::vector< double > & | array | ||
) |
Perform bi-linear interpolation of 2D array.
[in] | logE | Base 10 logarithm of the energy (MeV). |
[in] | ctheta | Cosine of zenith angle. |
[in] | array | Array 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.
[in] | logE | Base 10 logarithm of the energy (MeV). |
[in] | ctheta | Cosine of zenith angle. |
[in] | array | Array to be interpolated. |
[in] | offset | Offset if 3D array in 1st dimension. |
[in] | size | Size 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().
|
inline |
Return 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().
|
inline |
Return 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.
table | Response table. |
Definition at line 116 of file GLATResponseTable.cpp.
References copy_members(), free_members(), and init_members().
Print response table information.
[in] | chatter | Chattiness (defaults to NORMAL). |
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.
[in] | hdu | Response 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.
[in] | logE | Base 10 logarithm of the energy (MeV). |
[in] | ctheta | Cosine 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().
|
inline |
Return 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.
[in] | hdu | Fits 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().
|
private |
cos(theta) nodes
Definition at line 100 of file GLATResponseTable.hpp.
Referenced by copy_members(), init_members(), read(), and set().
|
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().
|
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().
|
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().
|
private |
Energy nodes (MeV)
Definition at line 98 of file GLATResponseTable.hpp.
Referenced by copy_members(), energies(), energy(), init_members(), and read().
|
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().
|
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().
|
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().
|
private |
Index 1.
Definition at line 105 of file GLATResponseTable.hpp.
Referenced by copy_members(), indices(), init_members(), interpolate(), and set().
|
private |
Index 2.
Definition at line 106 of file GLATResponseTable.hpp.
Referenced by copy_members(), indices(), init_members(), interpolate(), and set().
|
private |
Index 3.
Definition at line 107 of file GLATResponseTable.hpp.
Referenced by copy_members(), indices(), init_members(), interpolate(), and set().
|
private |
Index 4.
Definition at line 108 of file GLATResponseTable.hpp.
Referenced by copy_members(), indices(), init_members(), interpolate(), and set().
|
private |
Last requested cos(theta) for interpolation.
Definition at line 104 of file GLATResponseTable.hpp.
Referenced by copy_members(), init_members(), and set().
|
private |
Last requested energy for interpolation.
Definition at line 103 of file GLATResponseTable.hpp.
Referenced by copy_members(), init_members(), and set().
|
private |
Energy nodes (log10 mean energy)
Definition at line 99 of file GLATResponseTable.hpp.
Referenced by copy_members(), energies(), init_members(), read(), and set().
|
private |
Weighting factor 1.
Definition at line 109 of file GLATResponseTable.hpp.
Referenced by copy_members(), init_members(), interpolate(), set(), and weights().
|
private |
Weighting factor 2.
Definition at line 110 of file GLATResponseTable.hpp.
Referenced by copy_members(), init_members(), interpolate(), set(), and weights().
|
private |
Weighting factor 3.
Definition at line 111 of file GLATResponseTable.hpp.
Referenced by copy_members(), init_members(), interpolate(), set(), and weights().
|
private |
Weighting factor 4.
Definition at line 112 of file GLATResponseTable.hpp.
Referenced by copy_members(), init_members(), interpolate(), set(), and weights().