42#define G_OPERATOR_PLUS "GRmf::operator+=(GRmf&)"
43#define G_OPERATOR_MINUS "GRmf::operator-=(GRmf&)"
44#define G_AT "GRmf::at(int&, int&)"
196 std::string msg =
"Incompatible true energy binning of "
197 "Redistribution Matrix File.";
201 std::string msg =
"Incompatible measured energy binning of "
202 "Redistribution Matrix File.";
207 for (
int itrue = 0; itrue <
ntrue(); ++itrue) {
208 for (
int imeasured = 0; imeasured <
nmeasured(); ++imeasured) {
237 std::string msg =
"Incompatible true energy binning of "
238 "Redistribution Matrix File.";
242 std::string msg =
"Incompatible measured energy binning of "
243 "Redistribution Matrix File.";
248 for (
int itrue = 0; itrue <
ntrue(); ++itrue) {
249 for (
int imeasured = 0; imeasured <
nmeasured(); ++imeasured) {
271 for (
int itrue = 0; itrue <
ntrue(); ++itrue) {
272 for (
int imeasured = 0; imeasured <
nmeasured(); ++imeasured) {
273 m_matrix(itrue, imeasured) *= scale;
293 for (
int itrue = 0; itrue <
ntrue(); ++itrue) {
294 for (
int imeasured = 0; imeasured <
nmeasured(); ++imeasured) {
295 m_matrix(itrue, imeasured) /= scale;
334 return new GRmf(*
this);
350double&
GRmf::at(
const int& itrue,
const int& imeasured)
353 if (itrue < 0 || itrue >=
ntrue()) {
358 if (imeasured < 0 || imeasured >=
nmeasured()) {
364 return (
m_matrix(itrue, imeasured));
380const double&
GRmf::at(
const int& itrue,
const int& imeasured)
const
383 if (itrue < 0 || itrue >=
ntrue()) {
388 if (imeasured < 0 || imeasured >=
nmeasured()) {
394 return (
m_matrix(itrue, imeasured));
437 if (row_start != -1 && row_stop != -1) {
473 int column_start = -1;
474 int column_stop = -1;
477 column_start = column;
483 column_stop = column;
489 if (column_start != -1 && column_stop != -1) {
553 const std::string& unit)
const
635 int rows = energy_lo->
nrows();
645 for (
int itrue = 0; itrue < rows; ++itrue) {
654 int ngroups = n_grp->
integer(itrue);
655 for (
int igroup = 0; igroup < ngroups; ++igroup) {
658 int imeasured = f_chan->
integer(itrue, igroup);
659 int nvalues = n_chan->
integer(itrue, igroup);
662 for (
int i = 0; i < nvalues; ++i, ++imeasured, ++icolumn) {
721 int length =
ntrue();
728 for (
int i = 0; i < length; i++) {
740 for (; ilast >= 0; --ilast) {
747 int num = ilast - ifirst + 1;
750 if (num > maxcolumns) {
768 for (
int itrue = 0; itrue < length; ++itrue) {
773 if (
m_matrix(itrue, ifirst) != 0.0) {
780 for (; ilast >= 0; --ilast) {
781 if (
m_matrix(itrue, ilast) != 0.0) {
787 int num = ilast - ifirst + 1;
799 f_chan(itrue) = ifirst;
803 for (
int i = 0; i < num; ++i, ++ifirst) {
810 energy_lo.
unit(unit);
811 energy_hi.
unit(unit);
825 hdu.
card(
"TELESCOP",
"unknown",
"Telescope");
826 hdu.
card(
"INSTRUME",
"unknown",
"Instrument");
827 hdu.
card(
"FILTER",
"none",
"Filter");
828 hdu.
card(
"CHANTYPE",
"PI",
"Channel type");
829 hdu.
card(
"DETCHANS",
nmeasured(),
"Total number of possible channels");
830 hdu.
card(
"HDUCLASS",
"OGIP",
"Format conforms to OGIP standard");
831 hdu.
card(
"HDUCLAS1",
"RESPONSE",
"Extension contains response data");
832 hdu.
card(
"HDUCLAS2",
"RSP_MATRIX",
"Extension contains a RMF");
833 hdu.
card(
"HDUVERS",
"1.3.0",
"Version of the file format");
834 hdu.
card(
"TLMIN4", 0,
"Minimum value allowed in column 4");
840 (
m_header[i].keyname() ==
"TELESCOP") ||
841 (
m_header[i].keyname() ==
"INSTRUME") ||
842 (
m_header[i].keyname() ==
"FILTER")) {
875 result.append(
"=== GRmf ===");
884 result.append(
" - ");
888 result.append(
" - ");
Exception handler interface definition.
FITS binary table class definition.
FITS table float column class interface definition.
FITS table short integer column class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
Mathematical function definitions.
XSPEC Redistribution Matrix File class definition.
double max(const GVector &vector)
Computes maximum vector element.
Energy boundaries container class.
int index(const GEnergy &eng) const
Returns energy bin index for a given energy.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
void read(const GFitsTable &table)
Read energy boundaries from FITS table.
void append(const GEnergy &emin, const GEnergy &emax)
Append energy interval.
int size(void) const
Return number of energy boundaries.
void clear(void)
Clear energy boundaries.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
void write(GFits &file, const std::string &extname=gammalib::extname_ebounds, const std::string &unit="keV") const
Write energy boundaries into FITS object.
Class that handles energies in a unit independent way.
std::string print(const GChatter &chatter=NORMAL) const
Print energy.
std::string url(void) const
Return Uniform Resource Locator (URL)
void clear(void)
Clear file name.
const GFitsHeader & header(void) const
Return extension header.
const std::string & extname(void) const
Return extension name.
GFitsHeaderCard & card(const int &cardno)
Return header card.
Abstract interface for FITS table column.
virtual int integer(const int &row, const int &inx=0) const =0
virtual double real(const int &row, const int &inx=0) const =0
void unit(const std::string &unit)
Set column unit.
void nrows(const int &nrows)
Set number of rows in column.
FITS table short integer column.
Abstract interface for FITS table.
bool contains(const std::string &colname) const
Checks the presence of a column in table.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
const int & rows(void) const
Return number of matrix rows.
const int & columns(void) const
Return number of matrix columns.
Sparse matrix class interface definition.
virtual void clear(void)
Clear matrix.
Redistribution Matrix File class.
void copy_members(const GRmf &rmf)
Copy class members.
const GMatrixSparse & matrix(void) const
Return redistribution matrix.
const GEbounds & etrue(void) const
Return true energy boundaries.
double & at(const int &itrue, const int &imeasured)
Return content of redistribution matrix bin.
GFilename m_filename
Filename of origin.
GEbounds m_ebds_true
True energy boundaries.
const GEbounds & emeasured(void) const
Return measured energy boundaries.
int m_itruemax
Index of true maximum.
std::string print(const GChatter &chatter=NORMAL) const
Print Redistribution Matrix File.
virtual ~GRmf(void)
Destructor.
const GFilename & filename(void) const
Return file name.
GRmf(void)
Void constructor.
void init_members(void)
Initialise class members.
void save(const GFilename &filename, const bool &clobber=false, const std::string &unit="keV") const
Save Redistribution Matrix File.
int nmeasured(void) const
Return number of measured energy bins in redistribution matrix.
void clear(void)
Clear object.
int ntrue(void) const
Return number of true energy bins in redistribution matrix.
GRmf & operator=(const GRmf &rmf)
Assignment operator.
GRmf * clone(void) const
Clone object.
GRmf & operator-=(const GRmf &rmf)
Subtract Redistribution Matrix File.
int m_imeasmax
Index of measured maximum.
GEbounds m_ebds_measured
Measured energy boundaries.
void write(GFits &fits, const std::string &unit="keV") const
Write Redistribution Matrix File.
void read(const GFits &fits)
Read Redistribution Matrix File.
void free_members(void)
Delete class members.
GFitsHeader m_header
FITS header cards.
GRmf & operator/=(const double &scale)
Divide Redistribution Matrix File values.
GRmf & operator*=(const double &scale)
Scale Redistribution Matrix File values.
GRmf & operator+=(const GRmf &rmf)
Add Redistribution Matrix File.
GMatrixSparse m_matrix
Sparse redistribution matrix.
void load(const GFilename &filename)
Load Redistribution Matrix File.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
const std::string extname_rmf
const std::string extname_ebounds
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.