GammaLib
2.1.0.dev
|
Redistribution Matrix File class. More...
#include <GRmf.hpp>
Public Member Functions | |
GRmf (void) | |
Void constructor. More... | |
GRmf (const GFilename &filename) | |
File constructor. More... | |
GRmf (const GEbounds &etrue, const GEbounds &emeasured) | |
Energy boundary constructor. More... | |
GRmf (const GRmf &rmf) | |
Copy constructor. More... | |
virtual | ~GRmf (void) |
Destructor. More... | |
GRmf & | operator= (const GRmf &rmf) |
Assignment operator. More... | |
GRmf & | operator+= (const GRmf &rmf) |
Add Redistribution Matrix File. More... | |
GRmf & | operator-= (const GRmf &rmf) |
Subtract Redistribution Matrix File. More... | |
GRmf & | operator*= (const double &scale) |
Scale Redistribution Matrix File values. More... | |
GRmf & | operator/= (const double &scale) |
Divide Redistribution Matrix File values. More... | |
double & | operator() (const int &itrue, const int &imeasured) |
Return content of redistribution matrix bin. More... | |
const double & | operator() (const int &itrue, const int &imeasured) const |
Return content of redistribution matrix bin (const version) More... | |
void | clear (void) |
Clear object. More... | |
GRmf * | clone (void) const |
Clone object. More... | |
std::string | classname (void) const |
Return class name. More... | |
int | size (void) const |
Return number of redistribution matrix bins. More... | |
int | ntrue (void) const |
Return number of true energy bins in redistribution matrix. More... | |
int | nmeasured (void) const |
Return number of measured energy bins in redistribution matrix. More... | |
int | itruemax (void) const |
Return true energy index of maximum value of the redistribution matrix. More... | |
int | imeasmax (void) const |
Return measured energy index of maximum value of the redistribution matrix. More... | |
double & | at (const int &itrue, const int &imeasured) |
Return content of redistribution matrix bin. More... | |
const double & | at (const int &itrue, const int &imeasured) const |
Return content of redistribution matrix bin (const version) More... | |
const GEbounds & | etrue (void) const |
Return true energy boundaries. More... | |
const GEbounds & | emeasured (void) const |
Return measured energy boundaries. More... | |
GEbounds | etrue (const GEnergy &emeasured) const |
Return true energy boundaries for specified measured energy. More... | |
GEbounds | emeasured (const GEnergy &etrue) const |
Return measured energy boundaries for specified true energy. More... | |
const GMatrixSparse & | matrix (void) const |
Return redistribution matrix. More... | |
void | load (const GFilename &filename) |
Load Redistribution Matrix File. More... | |
void | save (const GFilename &filename, const bool &clobber=false, const std::string &unit="keV") const |
Save Redistribution Matrix File. More... | |
void | read (const GFits &fits) |
Read Redistribution Matrix File. More... | |
void | read (const GFitsTable &table) |
Read Redistribution Matrix File. More... | |
void | write (GFits &fits, const std::string &unit="keV") const |
Write Redistribution Matrix File. More... | |
const GFilename & | filename (void) const |
Return file name. More... | |
const GFitsHeader & | header (void) const |
Return FITS header. More... | |
void | header (const GFitsHeader &header) |
Set FITS header. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print Redistribution Matrix File. 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 GRmf &rmf) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
GFilename | m_filename |
Filename of origin. More... | |
GEbounds | m_ebds_true |
True energy boundaries. More... | |
GEbounds | m_ebds_measured |
Measured energy boundaries. More... | |
GMatrixSparse | m_matrix |
Sparse redistribution matrix. More... | |
int | m_imeasmax |
Index of measured maximum. More... | |
int | m_itruemax |
Index of true maximum. More... | |
GFitsHeader | m_header |
FITS header cards. More... | |
Friends | |
GRmf | operator+ (const GRmf &a, const GRmf &b) |
Redistribution Matrix File addition operator friend. More... | |
GRmf | operator- (const GRmf &a, const GRmf &b) |
Redistribution Matrix File subtraction operator friend. More... | |
GRmf | operator* (const GRmf &rmf, const double &scale) |
Redistribution Matrix File scaling operator friend. More... | |
GRmf | operator* (const double &scale, const GRmf &rmf) |
Redistribution Matrix File scaling operator friend. More... | |
GRmf | operator/ (const GRmf &rmf, const double &scale) |
Redistribution Matrix File vision operator friend. More... | |
Redistribution Matrix File class.
Matrix rows are true energy, columns are channels
GRmf::GRmf | ( | void | ) |
Void constructor.
Definition at line 62 of file GRmf.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | File name. |
Definition at line 77 of file GRmf.cpp.
References init_members(), and load().
Energy boundary constructor.
[in] | etrue | True energy boundaries. |
[in] | emeasured | Measured energy boundaries. |
Definition at line 96 of file GRmf.cpp.
References emeasured(), etrue(), init_members(), m_ebds_measured, m_ebds_true, m_matrix, and GEbounds::size().
GRmf::GRmf | ( | const GRmf & | rmf | ) |
Copy constructor.
[in] | rmf | Redistribution Matrix File. |
Definition at line 118 of file GRmf.cpp.
References copy_members(), and init_members().
|
virtual |
double & GRmf::at | ( | const int & | itrue, |
const int & | imeasured | ||
) |
Return content of redistribution matrix bin.
[in] | itrue | True energy index [0,...,ntrue()[. |
[in] | imeasured | Measured energy index [0,...,nmeasured()[. |
GException::out_of_range | True or measured energy index is out of range. |
Returns reference to content of redistribution matrix bin bin with true energy index itrue
and measured energy index imeasured
.
Definition at line 350 of file GRmf.cpp.
References G_AT, m_matrix, nmeasured(), and ntrue().
const double & GRmf::at | ( | const int & | itrue, |
const int & | imeasured | ||
) | const |
Return content of redistribution matrix bin (const version)
[in] | itrue | True energy index [0,...,ntrue()[. |
[in] | imeasured | Measured energy index [0,...,nmeasured()[. |
GException::out_of_range | True or measured energy index is out of range. |
Returns reference to content of redistribution matrix bin bin with true energy index itrue
and measured energy index imeasured
.
Definition at line 380 of file GRmf.cpp.
References G_AT, m_matrix, nmeasured(), and ntrue().
|
inlinevirtual |
|
virtual |
Clear object.
Reset object to a clean initial state.
Implements GBase.
Definition at line 315 of file GRmf.cpp.
References free_members(), and init_members().
Referenced by GCTAEdispRmf::init_members(), GCTAOnOffObservation::init_members(), load(), and read().
|
virtual |
|
protected |
Copy class members.
[in] | rmf | Redistribution Matrix File. |
Definition at line 928 of file GRmf.cpp.
References m_ebds_measured, m_ebds_true, m_filename, m_header, m_imeasmax, m_itruemax, and m_matrix.
Referenced by GRmf(), and operator=().
|
inline |
Return measured energy boundaries.
Returns the measured energy boundaries for redistribution matrix.
Definition at line 265 of file GRmf.hpp.
References m_ebds_measured.
Referenced by GCTAOnOffObservation::apply_ebounds(), GCTAOnOffObservation::check_consistency(), GCTAOnOffObservation::compute_alpha(), GCTAEdispRmf::compute_ereco_bounds(), GCTAEdispRmf::compute_etrue_bounds(), GCTAOnOffObservation::compute_rmf(), GCTAEdispRmf::etrue_bounds(), GCTAOnOffObservation::GCTAOnOffObservation(), GRmf(), operator+=(), operator-=(), GCTAEdispRmf::print(), GCTAOnOffObservation::rmf_stacked(), GCTAEdispRmf::set_cache(), and GCTAEdispRmf::set_matrix().
Return measured energy boundaries for specified true energy.
[in] | etrue | True energy. |
Returns the measured energy boundaries for the specified true energy etrue
. If the RMF is not covering the specified true energy, an empty energy boundary object is returned.
Definition at line 460 of file GRmf.cpp.
References GMatrixBase::columns(), GEbounds::emax(), GEbounds::emin(), GEbounds::index(), m_ebds_measured, m_ebds_true, and m_matrix.
|
inline |
Return true energy boundaries.
Returns the true energy boundaries for redistribution matrix.
Definition at line 251 of file GRmf.hpp.
References m_ebds_true.
Referenced by GCTAOnOffObservation::apply_ebounds(), GCTAOnOffObservation::check_consistency(), GCTAEdispRmf::compute_ereco_bounds(), GCTAOnOffObservation::compute_rmf(), GCTAEdispRmf::ereco_bounds(), GCTAOnOffObservation::GCTAOnOffObservation(), GRmf(), operator+=(), operator-=(), GCTAEdispRmf::print(), GCTAOnOffObservation::rmf_stacked(), GCTAEdispRmf::set_cache(), and GCTAEdispRmf::set_matrix().
Return true energy boundaries for specified measured energy.
[in] | emeasured | Measured energy. |
Returns the true energy boundaries for the specified measured energy emeasured
. If the RMF is not covering the specified measured energy, an empty energy boundary object is returned.
Definition at line 408 of file GRmf.cpp.
References GEbounds::emax(), GEbounds::emin(), GEbounds::index(), m_ebds_measured, m_ebds_true, m_matrix, and GMatrixBase::rows().
|
inline |
Return file name.
Returns the file name from which the RMF information has been read or into which RMF information has been saved. The returned string will be empty if no load() or save() method has been called before.
Definition at line 294 of file GRmf.hpp.
References m_filename.
Referenced by GCTAOnOffObservation::write().
|
protected |
Delete class members.
Definition at line 947 of file GRmf.cpp.
Referenced by clear(), operator=(), and ~GRmf().
|
inline |
Return FITS header.
Definition at line 306 of file GRmf.hpp.
References m_header.
Referenced by header(), and GCTAOnOffObservation::set().
|
inline |
|
inline |
Return measured energy index of maximum value of the redistribution matrix.
Returns the measured energy index of maximum value of the redistribution matrix.
Definition at line 237 of file GRmf.hpp.
References m_imeasmax.
|
protected |
Initialise class members.
Definition at line 907 of file GRmf.cpp.
References GFitsHeader::clear(), GFilename::clear(), GEbounds::clear(), GMatrixSparse::clear(), m_ebds_measured, m_ebds_true, m_filename, m_header, m_imeasmax, m_itruemax, and m_matrix.
Referenced by clear(), GRmf(), and operator=().
|
inline |
Return true energy index of maximum value of the redistribution matrix.
Returns the true energy index of maximum value of the redistribution matrix.
Definition at line 223 of file GRmf.hpp.
References m_itruemax.
void GRmf::load | ( | const GFilename & | filename | ) |
Load Redistribution Matrix File.
[in] | filename | File name. |
Loads the Redistribution Matrix File from the MATRIX
extension of the FITS file and the reconstructed energy boundaries from the EBOUNDS
extension.
Definition at line 510 of file GRmf.cpp.
References clear(), m_filename, read(), and GFilename::url().
Referenced by GRmf(), GCTAEdispRmf::load(), and GCTAOnOffObservation::read().
|
inline |
|
inline |
Return number of measured energy bins in redistribution matrix.
Returns the number of measured energy bins in redistribution matrix.
Definition at line 207 of file GRmf.hpp.
References GMatrixBase::columns(), and m_matrix.
Referenced by at(), GCTAEdispRmf::compute_etrue_bounds(), GCTAOnOffObservation::GCTAOnOffObservation(), operator*=(), operator+=(), operator-=(), operator/=(), GCTAEdispRmf::set_cache(), GCTAEdispRmf::set_matrix(), and write().
|
inline |
Return number of true energy bins in redistribution matrix.
Returns the number of true energy bins in redistribution matrix.
Definition at line 193 of file GRmf.hpp.
References m_matrix, and GMatrixBase::rows().
Referenced by at(), GCTAEdispRmf::compute_ereco_bounds(), GCTAOnOffObservation::GCTAOnOffObservation(), operator*=(), operator+=(), operator-=(), operator/=(), GCTAEdispRmf::set_cache(), GCTAEdispRmf::set_matrix(), and write().
|
inline |
Return content of redistribution matrix bin.
[in] | itrue | True energy index [0,...,ntrue()-1]. |
[in] | imeasured | Measured energy index [0,...,nmeasured()-1]. |
Returns reference to content of redistribution matrix bin bin with true energy index itrue
and measured energy index imeasured
.
Definition at line 149 of file GRmf.hpp.
References m_matrix.
|
inline |
Return content of redistribution matrix bin (const version)
[in] | itrue | True energy index [0,...,ntrue()-1]. |
[in] | imeasured | Measured energy index [0,...,nmeasured()-1]. |
Returns reference to content of redistribution matrix bin bin with true energy index itrue
and measured energy index imeasured
.
Definition at line 165 of file GRmf.hpp.
References m_matrix.
GRmf & GRmf::operator*= | ( | const double & | scale | ) |
Scale Redistribution Matrix File values.
[in] | scale | Scale factor. |
Multiplies the values of the Redistribution Matrix File with a scale factor.
Definition at line 268 of file GRmf.cpp.
References m_matrix, nmeasured(), and ntrue().
Add Redistribution Matrix File.
[in] | rmf | Redistribution Matrix File. |
GException::invalid_value | Incompatible Redistribution Matrix Files. |
Adds the RMF values of an Redistribution Matrix File to the current values.
The operator only works if the provide Redistribution Matrix File has the same energy binning than the current Redistribution Matrix File.
Definition at line 192 of file GRmf.cpp.
References emeasured(), etrue(), G_OPERATOR_PLUS, m_matrix, nmeasured(), and ntrue().
Subtract Redistribution Matrix File.
[in] | rmf | Redistribution Matrix File. |
GException::invalid_value | Incompatible Redistribution Matrix Files. |
Subtracts the RMF values of an Redistribution Matrix File from the current values.
The operator only works if the provide Redistribution Matrix File has the same energy binning than the current Redistribution Matrix File.
Definition at line 233 of file GRmf.cpp.
References emeasured(), etrue(), G_OPERATOR_MINUS, m_matrix, nmeasured(), and ntrue().
GRmf & GRmf::operator/= | ( | const double & | scale | ) |
Divide Redistribution Matrix File values.
[in] | scale | Division factor. |
Divides the values of the Redistribution Matrix File by a division factor.
Definition at line 290 of file GRmf.cpp.
References m_matrix, nmeasured(), and ntrue().
Assignment operator.
[in] | rmf | Redistribution Matrix File. |
Definition at line 156 of file GRmf.cpp.
References copy_members(), free_members(), and init_members().
Print Redistribution Matrix File.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 866 of file GRmf.cpp.
References GEbounds::emax(), GEbounds::emin(), m_ebds_measured, m_ebds_true, gammalib::parformat(), GEnergy::print(), SILENT, GEbounds::size(), and gammalib::str().
Referenced by GCTAOnOffObservation::print().
void GRmf::read | ( | const GFits & | fits | ) |
Read Redistribution Matrix File.
[in] | fits | File file. |
Reads the Redistribution Matrix File from the MATRIX
extension of the FITS file and the reconstructed energy boundaries from the EBOUNDS
extension.
Definition at line 582 of file GRmf.cpp.
References clear(), gammalib::extname_ebounds, gammalib::extname_rmf, m_ebds_measured, GEbounds::read(), and GFits::table().
Referenced by load().
void GRmf::read | ( | const GFitsTable & | table | ) |
Read Redistribution Matrix File.
[in] | table | RMF FITS table. |
Reads the Redistribution Matrix File from a FITS table. The true energy bins are expected in the ENERG_LO
and ENERG_HI
columns. Information for matrix compression are stored in the N_GRP
, F_CHAN
and N_CHAN
columns, and the matrix elements are stored in the MATRIX
column.
The method automatically decompresses the Redistribution Matrix File and stores the matrix elements in a spare matrix.
See http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html#tth_sEc3 for details about the Redistribution Matrix File file format.
Definition at line 621 of file GRmf.cpp.
References GEbounds::append(), GEbounds::clear(), GFitsHDU::header(), GFitsTableCol::integer(), m_ebds_measured, m_ebds_true, m_header, m_imeasmax, m_itruemax, m_matrix, matrix(), max(), GFitsTableCol::nrows(), GFitsTableCol::real(), GEbounds::size(), and GFitsTableCol::unit().
void GRmf::save | ( | const GFilename & | filename, |
const bool & | clobber = false , |
||
const std::string & | unit = "keV" |
||
) | const |
Save Redistribution Matrix File.
[in] | filename | File name. |
[in] | clobber | Overwrite existing file? |
[in] | unit | Energy unit. |
Saves the Redistribution Matrix File into a FITS file. If a file with the given filename
does not yet exist it will be created. If the file exists it can be overwritten if the clobber
flag is set to true
. Otherwise an exception is thrown.
The method will save two binary FITS tables into the FITS file: a MATRIX
extension that contains the Redistribution Matrix File elements, and an EBOUNDS
extension that contains the measured energy boundaries for all matrix. The unit
argument specifies the unit of the true energies that will be saved in the MATRIX
extension.
Definition at line 551 of file GRmf.cpp.
References m_filename, GFits::saveto(), GFilename::url(), and write().
|
inline |
Return number of redistribution matrix bins.
Returns the number of redistribution matrix bins.
Definition at line 179 of file GRmf.hpp.
References GMatrixBase::columns(), m_matrix, and GMatrixBase::rows().
void GRmf::write | ( | GFits & | fits, |
const std::string & | unit = "keV" |
||
) | const |
Write Redistribution Matrix File.
[in] | fits | FITS file. |
[in] | unit | Energy unit. |
Writes the Redistribution Matrix File into MATRIX
and EBOUNDS
extensions of the FITS file. Extensions with these names will be removed from the FITS file before writing.
The true energy bins are written into the ENERG_LO
and ENERG_HI
columns. The units of the energies in these columns is specified by the unit
argument. Information for matrix compression are stored in the N_GRP
, F_CHAN
and N_CHAN
columns, and the matrix elements are written into the MATRIX
column.
The measured energy bins are written into the EBOUNDS
extension.
See http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html#tth_sEc3 for details about the Redistribution Matrix File file format.
Definition at line 710 of file GRmf.cpp.
References GFitsTable::append(), GFits::append(), GFitsHDU::card(), GFitsTable::contains(), GFits::contains(), GEbounds::emax(), GEbounds::emin(), GFitsHDU::extname(), gammalib::extname_ebounds, gammalib::extname_rmf, m_ebds_measured, m_ebds_true, m_header, m_matrix, matrix(), nmeasured(), ntrue(), GFits::remove(), GFitsHeader::size(), GFitsTableCol::unit(), and GEbounds::write().
Referenced by save().
|
protected |
Measured energy boundaries.
Definition at line 119 of file GRmf.hpp.
Referenced by copy_members(), emeasured(), etrue(), GRmf(), init_members(), print(), read(), and write().
|
protected |
True energy boundaries.
Definition at line 118 of file GRmf.hpp.
Referenced by copy_members(), emeasured(), etrue(), GRmf(), init_members(), print(), read(), and write().
|
mutableprotected |
Filename of origin.
Definition at line 117 of file GRmf.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and save().
|
protected |
FITS header cards.
Definition at line 123 of file GRmf.hpp.
Referenced by copy_members(), header(), init_members(), read(), and write().
|
protected |
Index of measured maximum.
Definition at line 121 of file GRmf.hpp.
Referenced by copy_members(), imeasmax(), init_members(), and read().
|
protected |
Index of true maximum.
Definition at line 122 of file GRmf.hpp.
Referenced by copy_members(), init_members(), itruemax(), and read().
|
protected |
Sparse redistribution matrix.
Definition at line 120 of file GRmf.hpp.
Referenced by at(), copy_members(), emeasured(), etrue(), GRmf(), init_members(), matrix(), nmeasured(), ntrue(), operator()(), operator*=(), operator+=(), operator-=(), operator/=(), read(), size(), and write().