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

Redistribution Matrix File class. More...

#include <GRmf.hpp>

Inheritance diagram for GRmf:
GBase

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...
 
GRmfoperator= (const GRmf &rmf)
 Assignment operator. More...
 
GRmfoperator+= (const GRmf &rmf)
 Add Redistribution Matrix File. More...
 
GRmfoperator-= (const GRmf &rmf)
 Subtract Redistribution Matrix File. More...
 
GRmfoperator*= (const double &scale)
 Scale Redistribution Matrix File values. More...
 
GRmfoperator/= (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...
 
GRmfclone (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 GEboundsetrue (void) const
 Return true energy boundaries. More...
 
const GEboundsemeasured (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 GMatrixSparsematrix (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 GFilenamefilename (void) const
 Return file name. More...
 
const GFitsHeaderheader (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...
 

Detailed Description

Redistribution Matrix File class.

Matrix rows are true energy, columns are channels

Definition at line 55 of file GRmf.hpp.

Constructor & Destructor Documentation

GRmf::GRmf ( void  )

Void constructor.

Definition at line 62 of file GRmf.cpp.

References init_members().

Referenced by clone().

GRmf::GRmf ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenameFile name.

Definition at line 77 of file GRmf.cpp.

References init_members(), and load().

GRmf::GRmf ( const GEbounds etrue,
const GEbounds emeasured 
)

Energy boundary constructor.

Parameters
[in]etrueTrue energy boundaries.
[in]emeasuredMeasured 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.

Parameters
[in]rmfRedistribution Matrix File.

Definition at line 118 of file GRmf.cpp.

References copy_members(), and init_members().

GRmf::~GRmf ( void  )
virtual

Destructor.

Definition at line 134 of file GRmf.cpp.

References free_members().

Member Function Documentation

double & GRmf::at ( const int &  itrue,
const int &  imeasured 
)

Return content of redistribution matrix bin.

Parameters
[in]itrueTrue energy index [0,...,ntrue()[.
[in]imeasuredMeasured energy index [0,...,nmeasured()[.
Exceptions
GException::out_of_rangeTrue 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)

Parameters
[in]itrueTrue energy index [0,...,ntrue()[.
[in]imeasuredMeasured energy index [0,...,nmeasured()[.
Exceptions
GException::out_of_rangeTrue 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().

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

Return class name.

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

Implements GBase.

Definition at line 133 of file GRmf.hpp.

void GRmf::clear ( void  )
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().

GRmf * GRmf::clone ( void  ) const
virtual

Clone object.

Returns
Redistribution Matrix File.

Implements GBase.

Definition at line 331 of file GRmf.cpp.

References GRmf().

void GRmf::copy_members ( const GRmf rmf)
protected

Copy class members.

Parameters
[in]rmfRedistribution 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=().

GEbounds GRmf::emeasured ( const GEnergy etrue) const

Return measured energy boundaries for specified true energy.

Parameters
[in]etrueTrue energy.
Returns
Measured energy boundaries for specified 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.

const GEbounds & GRmf::etrue ( void  ) const
inline
GEbounds GRmf::etrue ( const GEnergy emeasured) const

Return true energy boundaries for specified measured energy.

Parameters
[in]emeasuredMeasured energy.
Returns
True energy boundaries for specified 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().

const GFilename & GRmf::filename ( void  ) const
inline

Return file name.

Returns
File name from which the RMF information has been read or into which RMF information has been saved.

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

void GRmf::free_members ( void  )
protected

Delete class members.

Definition at line 947 of file GRmf.cpp.

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

const GFitsHeader & GRmf::header ( void  ) const
inline

Return FITS header.

Returns
FITS header or RMF file.

Definition at line 306 of file GRmf.hpp.

References m_header.

Referenced by header(), and GCTAOnOffObservation::set().

void GRmf::header ( const GFitsHeader header)
inline

Set FITS header.

Parameters
[in]headerFITS header.

Definition at line 318 of file GRmf.hpp.

References header(), and m_header.

int GRmf::imeasmax ( void  ) const
inline

Return measured energy index of maximum value of the redistribution matrix.

Returns
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.

void GRmf::init_members ( void  )
protected
int GRmf::itruemax ( void  ) const
inline

Return true energy index of maximum value of the redistribution matrix.

Returns
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.

Parameters
[in]filenameFile 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().

const GMatrixSparse & GRmf::matrix ( void  ) const
inline

Return redistribution matrix.

Returns
Redistribution matrix.

Definition at line 277 of file GRmf.hpp.

References m_matrix.

Referenced by read(), and write().

int GRmf::nmeasured ( void  ) const
inline

Return number of measured energy bins in redistribution matrix.

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

int GRmf::ntrue ( void  ) const
inline

Return number of true energy bins in redistribution matrix.

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

double & GRmf::operator() ( const int &  itrue,
const int &  imeasured 
)
inline

Return content of redistribution matrix bin.

Parameters
[in]itrueTrue energy index [0,...,ntrue()-1].
[in]imeasuredMeasured 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.

const double & GRmf::operator() ( const int &  itrue,
const int &  imeasured 
) const
inline

Return content of redistribution matrix bin (const version)

Parameters
[in]itrueTrue energy index [0,...,ntrue()-1].
[in]imeasuredMeasured 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.

Parameters
[in]scaleScale factor.
Returns
Scaled Redistribution Matrix File.

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

GRmf & GRmf::operator+= ( const GRmf rmf)

Add Redistribution Matrix File.

Parameters
[in]rmfRedistribution Matrix File.
Returns
Sum of Redistribution Matrix File.
Exceptions
GException::invalid_valueIncompatible 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().

GRmf & GRmf::operator-= ( const GRmf rmf)

Subtract Redistribution Matrix File.

Parameters
[in]rmfRedistribution Matrix File.
Returns
Difference of Redistribution Matrix File.
Exceptions
GException::invalid_valueIncompatible 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.

Parameters
[in]scaleDivision factor.
Returns
Divided Redistribution Matrix File.

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

GRmf & GRmf::operator= ( const GRmf rmf)

Assignment operator.

Parameters
[in]rmfRedistribution Matrix File.
Returns
Redistribution Matrix File.

Definition at line 156 of file GRmf.cpp.

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

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

Print Redistribution Matrix File.

Parameters
[in]chatterChattiness.
Returns
String containing Redistribution Matrix File information.

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.

Parameters
[in]fitsFile 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.

Parameters
[in]tableRMF 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.

Parameters
[in]filenameFile name.
[in]clobberOverwrite existing file?
[in]unitEnergy 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().

int GRmf::size ( void  ) const
inline

Return number of redistribution matrix bins.

Returns
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.

Parameters
[in]fitsFITS file.
[in]unitEnergy 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().

Friends And Related Function Documentation

GRmf operator* ( const GRmf rmf,
const double &  scale 
)
friend

Redistribution Matrix File scaling operator friend.

Parameters
[in]rmfRedistribution Matrix File.
[in]scaleScale factor.
Returns
Scaled Redistribution Matrix File.

Definition at line 365 of file GRmf.hpp.

GRmf operator* ( const double &  scale,
const GRmf rmf 
)
friend

Redistribution Matrix File scaling operator friend.

Parameters
[in]scaleScale factor.
[in]rmfRedistribution Matrix File.
Returns
Scaled Redistribution Matrix File.

Definition at line 381 of file GRmf.hpp.

GRmf operator+ ( const GRmf a,
const GRmf b 
)
friend

Redistribution Matrix File addition operator friend.

Parameters
[in]aFirst Redistribution Matrix File.
[in]bSecond Redistribution Matrix File.
Returns
Sum of Redistribution Matrix Files.

Definition at line 333 of file GRmf.hpp.

GRmf operator- ( const GRmf a,
const GRmf b 
)
friend

Redistribution Matrix File subtraction operator friend.

Parameters
[in]aFirst Redistribution Matrix File.
[in]bSecond Redistribution Matrix File.
Returns
Difference of Redistribution Matrix Files.

Definition at line 349 of file GRmf.hpp.

GRmf operator/ ( const GRmf rmf,
const double &  scale 
)
friend

Redistribution Matrix File vision operator friend.

Parameters
[in]rmfRedistribution Matrix File.
[in]scaleDivision factor.
Returns
Divided Redistribution Matrix File.

Definition at line 397 of file GRmf.hpp.

Member Data Documentation

GEbounds GRmf::m_ebds_measured
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().

GEbounds GRmf::m_ebds_true
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().

GFilename GRmf::m_filename
mutableprotected

Filename of origin.

Definition at line 117 of file GRmf.hpp.

Referenced by copy_members(), filename(), init_members(), load(), and save().

GFitsHeader GRmf::m_header
protected

FITS header cards.

Definition at line 123 of file GRmf.hpp.

Referenced by copy_members(), header(), init_members(), read(), and write().

int GRmf::m_imeasmax
protected

Index of measured maximum.

Definition at line 121 of file GRmf.hpp.

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

int GRmf::m_itruemax
protected

Index of true maximum.

Definition at line 122 of file GRmf.hpp.

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

GMatrixSparse GRmf::m_matrix
protected

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