GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GArf Class Reference

Auxiliary Response File class. More...

#include <GArf.hpp>

Inheritance diagram for GArf:
GBase

Public Member Functions

 GArf (void)
 Void constructor. More...
 
 GArf (const GFilename &filename)
 File constructor. More...
 
 GArf (const GEbounds &ebds)
 Energy boundary constructor. More...
 
 GArf (const GArf &arf)
 Copy constructor. More...
 
virtual ~GArf (void)
 Destructor. More...
 
GArfoperator= (const GArf &arf)
 Assignment operator. More...
 
GArfoperator+= (const GArf &arf)
 Add Auxiliary Response File. More...
 
GArfoperator-= (const GArf &arf)
 Subtract Auxiliary Response File. More...
 
GArfoperator*= (const double &scale)
 Scale Auxiliary Response File values. More...
 
GArfoperator/= (const double &scale)
 Divide Auxiliary Response File values. More...
 
double & operator[] (const int &index)
 Return content of spectral bin. More...
 
const double & operator[] (const int &index) const
 Return content of spectral bin (const version) More...
 
double & operator() (const int &index, const int &col)
 Return content of additional columns. More...
 
const double & operator() (const int &index, const int &col) const
 Return content of additional columns (const version) More...
 
std::vector< double > & operator[] (const std::string &colname)
 Return additional vector column. More...
 
const std::vector< double > & operator[] (const std::string &colname) const
 Return additional vector column (const version) More...
 
double operator() (const std::string &colname, const GEnergy &energy) const
 Return vector column content as function of energy. More...
 
void clear (void)
 Clear object. More...
 
GArfclone (void) const
 Clone object. More...
 
std::string classname (void) const
 Return class name. More...
 
int size (void) const
 Return number of spectral bins. More...
 
int columns (void) const
 Return number of additional columns. More...
 
double & at (const int &index)
 Return content of spectral bin. More...
 
const double & at (const int &index) const
 Return content of spectral bin (const version) More...
 
double & at (const int &index, const int &col)
 Return content of additional columns. More...
 
const double & at (const int &index, const int &col) const
 Return content of additional columns (const version) More...
 
void append (const std::string &name, const std::vector< double > &column)
 Append additional column to spectrum. More...
 
const GEboundsebounds (void) const
 Return energy boundaries. More...
 
void load (const GFilename &filename)
 Load Auxiliary Response File. More...
 
void save (const GFilename &filename, const bool &clobber=false) const
 Save Auxiliary Response File. More...
 
void read (const GFits &fits)
 Read Auxiliary Response File. More...
 
void read (const GFitsTable &table)
 Read Auxiliary Response File. More...
 
void write (GFits &fits) const
 Write Auxiliary Response 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 Auxiliary Response 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 GArf &pha)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void set_logetrue (void)
 Set true energy node array. More...
 
int column_index (const std::string &colname) const
 Returns index of additional vector column. More...
 

Protected Attributes

GFilename m_filename
 Filename of origin. More...
 
GEbounds m_ebounds
 Energy boundaries. More...
 
GNodeArray m_logetrue
 Log10 energies in TeV. More...
 
std::vector< double > m_specresp
 Spectral response. More...
 
std::vector< std::string > m_colnames
 Additional column names. More...
 
std::vector< std::vector
< double > > 
m_coldata
 Additional column data. More...
 
GFitsHeader m_header
 FITS header cards. More...
 

Friends

GArf operator+ (const GArf &a, const GArf &b)
 Auxiliary Response File addition operator friend. More...
 
GArf operator- (const GArf &a, const GArf &b)
 Auxiliary Response File subtraction operator friend. More...
 
GArf operator* (const GArf &arf, const double &scale)
 Auxiliary Response File scaling operator friend. More...
 
GArf operator* (const double &scale, const GArf &arf)
 Auxiliary Response File scaling operator friend. More...
 
GArf operator/ (const GArf &arf, const double &scale)
 Auxiliary Response File vision operator friend. More...
 

Detailed Description

Auxiliary Response File class.

Definition at line 54 of file GArf.hpp.

Constructor & Destructor Documentation

GArf::GArf ( void  )

Void constructor.

Definition at line 66 of file GArf.cpp.

References init_members().

Referenced by clone().

GArf::GArf ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenameFile name.

Definition at line 81 of file GArf.cpp.

References init_members(), and load().

GArf::GArf ( const GEbounds ebds)
explicit

Energy boundary constructor.

Parameters
[in]ebdsEnergy boundaries.

Definition at line 99 of file GArf.cpp.

References init_members(), m_ebounds, m_specresp, set_logetrue(), and GEbounds::size().

GArf::GArf ( const GArf arf)

Copy constructor.

Parameters
[in]arfAuxiliary Response File.

Definition at line 123 of file GArf.cpp.

References copy_members(), and init_members().

GArf::~GArf ( void  )
virtual

Destructor.

Definition at line 139 of file GArf.cpp.

References free_members().

Member Function Documentation

void GArf::append ( const std::string &  name,
const std::vector< double > &  column 
)

Append additional column to spectrum.

Parameters
[in]nameAdditional column name.
[in]columnAdditional column data.

Definition at line 522 of file GArf.cpp.

References G_APPEND, m_coldata, m_colnames, size(), and gammalib::str().

Referenced by read().

double & GArf::at ( const int &  index)

Return content of spectral bin.

Parameters
[in]indexSpectral bin index [0,...,size()[.
Exceptions
GException::out_of_rangeSpectral bin index is out of range.

Returns reference to content of spectral bin with specified index.

Definition at line 428 of file GArf.cpp.

References G_AT1, m_specresp, and size().

const double & GArf::at ( const int &  index) const

Return content of spectral bin (const version)

Parameters
[in]indexSpectral bin index [0,...,size()[.
Exceptions
GException::out_of_rangeSpectral bin index is out of range.
  • Returns reference to content of spectral bin with specified index.

Definition at line 451 of file GArf.cpp.

References G_AT1, m_specresp, and size().

double & GArf::at ( const int &  index,
const int &  col 
)

Return content of additional columns.

Parameters
[in]indexBin index [0,...,size()-1].
[in]colColumns index [0,...,columns()-1].
Exceptions
GException::out_of_rangeSpectral bin or column index is out of range.

Returns reference to content of additional columns.

Definition at line 475 of file GArf.cpp.

References columns(), G_AT2, m_coldata, and size().

const double & GArf::at ( const int &  index,
const int &  col 
) const

Return content of additional columns (const version)

Parameters
[in]indexBin index [0,...,size()-1].
[in]colColumns index [0,...,columns()-1].
Exceptions
GException::out_of_rangeSpectral bin or column index is out of range.

Returns reference to content of additional columns.

Definition at line 501 of file GArf.cpp.

References columns(), G_AT2, m_coldata, and size().

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

Return class name.

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

Implements GBase.

Definition at line 137 of file GArf.hpp.

void GArf::clear ( void  )
virtual

Clear object.

Reset object to a clean initial state.

Implements GBase.

Definition at line 395 of file GArf.cpp.

References free_members(), and init_members().

Referenced by GCTAOnOffObservation::init_members(), load(), and read().

GArf * GArf::clone ( void  ) const
virtual

Clone object.

Returns
Pointer to Auxiliary Response File.

Implements GBase.

Definition at line 411 of file GArf.cpp.

References GArf().

int GArf::column_index ( const std::string &  colname) const
protected

Returns index of additional vector column.

Parameters
[in]colnameVector column name.
Returns
Vector column index.

Returns index of additional vector column. Returns -1 if the vector column has not found.

Definition at line 958 of file GArf.cpp.

References columns(), and m_colnames.

Referenced by operator()(), and operator[]().

int GArf::columns ( void  ) const
inline

Return number of additional columns.

Returns
Number of additional columns.

Returns the number of additional columns.

Definition at line 223 of file GArf.hpp.

References m_colnames.

Referenced by at(), column_index(), and write().

void GArf::copy_members ( const GArf arf)
protected

Copy class members.

Parameters
[in]arfAuxiliary Response File.

Definition at line 890 of file GArf.cpp.

References m_coldata, m_colnames, m_ebounds, m_filename, m_header, m_logetrue, and m_specresp.

Referenced by GArf(), and operator=().

const GEbounds & GArf::ebounds ( void  ) const
inline

Return energy boundaries.

Returns
Energy boundaries for all spectral bins.

Returns the energy boundaries for all spectral bins.

Definition at line 237 of file GArf.hpp.

References m_ebounds.

Referenced by GCTAOnOffObservation::arf_stacked(), GCTAOnOffObservation::check_consistency(), GCTAOnOffObservation::compute_arf(), GCTAOnOffObservation::compute_arf_cut(), GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::N_gamma(), operator+=(), and operator-=().

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

Return file name.

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

Returns the file name from which the ARF information has been read or into which ARF information has been saved. The returned string will be empty if no load() or save() method has been called before.

Definition at line 254 of file GArf.hpp.

References m_filename.

Referenced by GCTAOnOffObservation::write().

void GArf::free_members ( void  )
protected

Delete class members.

Definition at line 909 of file GArf.cpp.

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

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

Return FITS header.

Returns
FITS header or ARF file.

Definition at line 266 of file GArf.hpp.

References m_header.

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

void GArf::header ( const GFitsHeader header)
inline

Set FITS header.

Parameters
[in]headerFITS header.

Definition at line 278 of file GArf.hpp.

References header(), and m_header.

void GArf::init_members ( void  )
protected

Initialise class members.

Definition at line 869 of file GArf.cpp.

References GFitsHeader::clear(), GNodeArray::clear(), GEbounds::clear(), GFilename::clear(), m_coldata, m_colnames, m_ebounds, m_filename, m_header, m_logetrue, and m_specresp.

Referenced by clear(), GArf(), and operator=().

void GArf::load ( const GFilename filename)

Load Auxiliary Response File.

Parameters
[in]filenameFile name.

Loads the Auxiliary Response File from the SPECRESP extension of the FITS file.

Definition at line 552 of file GArf.cpp.

References clear(), m_filename, read(), and GFilename::url().

Referenced by GArf(), and GCTAOnOffObservation::read().

double & GArf::operator() ( const int &  index,
const int &  col 
)
inline

Return content of additional columns.

Parameters
[in]indexBin index [0,...,size()-1].
[in]colColumns index [0,...,columns()-1].

Returns reference to content of additional columns.

Definition at line 180 of file GArf.hpp.

References m_coldata.

const double & GArf::operator() ( const int &  index,
const int &  col 
) const
inline

Return content of additional columns (const version)

Parameters
[in]indexBin index [0,...,size()-1].
[in]colColumns index [0,...,columns()-1].

Returns reference to content of additional columns.

Definition at line 195 of file GArf.hpp.

References m_coldata.

double GArf::operator() ( const std::string &  colname,
const GEnergy energy 
) const

Return vector column content as function of energy.

Parameters
[in]colnameVector column name.
[in]energyEnergy.
Returns
Vector column content.

Returns content of additional vector column as function of energy.

Definition at line 348 of file GArf.cpp.

References column_index(), exp(), G_OPERATOR2, GNodeArray::inx_left(), GNodeArray::inx_right(), log(), GEnergy::log10TeV(), m_coldata, m_logetrue, GNodeArray::set_value(), GNodeArray::wgt_left(), and GNodeArray::wgt_right().

GArf & GArf::operator*= ( const double &  scale)

Scale Auxiliary Response File values.

Parameters
[in]scaleScale factor.
Returns
Scaled Auxiliary Response File.

Multiplies the values of the Auxiliary Response File with a scale factor.

Definition at line 257 of file GArf.cpp.

References m_specresp, and size().

GArf & GArf::operator+= ( const GArf arf)

Add Auxiliary Response File.

Parameters
[in]arfAuxiliary Response File.
Returns
Sum of Auxiliary Response Files.
Exceptions
GException::invalid_valueIncompatible Auxiliary Response Files.

Adds the ARF values of an Auxiliary Response File to the current values.

The operator only works if the provide Auxiliary Response File has the same energy binning than the current Auxiliary Response File.

Definition at line 196 of file GArf.cpp.

References ebounds(), G_OPERATOR_PLUS, m_specresp, and size().

GArf & GArf::operator-= ( const GArf arf)

Subtract Auxiliary Response File.

Parameters
[in]arfAuxiliary Response File.
Returns
Difference of Auxiliary Response File.
Exceptions
GException::invalid_valueIncompatible Auxiliary Response Files.

Subtracts the ARF values of an Auxiliary Response File from the current values.

The operator only works if the provide Auxiliary Response File has the same energy binning than the current Auxiliary Response File.

Definition at line 230 of file GArf.cpp.

References ebounds(), G_OPERATOR_MINUS, m_specresp, and size().

GArf & GArf::operator/= ( const double &  scale)

Divide Auxiliary Response File values.

Parameters
[in]scaleDivision factor.
Returns
Divided Auxiliary Response File.

Divides the values of the Auxiliary Response File by a division factor.

Definition at line 277 of file GArf.cpp.

References m_specresp, and size().

GArf & GArf::operator= ( const GArf arf)

Assignment operator.

Parameters
[in]arfAuxiliary Response File.
Returns
Auxiliary Response File.

Definition at line 161 of file GArf.cpp.

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

double & GArf::operator[] ( const int &  index)
inline

Return content of spectral bin.

Parameters
[in]indexBin index [0,...,size()-1].

Returns reference to content of spectral bin with specified index.

Definition at line 151 of file GArf.hpp.

References m_specresp.

const double & GArf::operator[] ( const int &  index) const
inline

Return content of spectral bin (const version)

Parameters
[in]indexBin index [0,...,size()-1].

Returns reference to content of spectral bin with specified index.

Definition at line 165 of file GArf.hpp.

References m_specresp.

std::vector< double > & GArf::operator[] ( const std::string &  colname)

Return additional vector column.

Parameters
[in]colnameVector column name.
Returns
Vector column.

Returns reference to additional vector column.

Definition at line 297 of file GArf.cpp.

References column_index(), G_OPERATOR, and m_coldata.

const std::vector< double > & GArf::operator[] ( const std::string &  colname) const

Return additional vector column (const version)

Parameters
[in]colnameVector column name.
Returns
Vector column.

Returns reference to additional vector column.

Definition at line 322 of file GArf.cpp.

References column_index(), G_OPERATOR, and m_coldata.

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

Print Auxiliary Response File.

Parameters
[in]chatterChattiness.
Returns
String containing Auxiliary Response File information.

Implements GBase.

Definition at line 834 of file GArf.cpp.

References GEbounds::emax(), GEbounds::emin(), m_ebounds, gammalib::parformat(), GEnergy::print(), SILENT, GEbounds::size(), and gammalib::str().

Referenced by GCTAOnOffObservation::print().

void GArf::read ( const GFits fits)

Read Auxiliary Response File.

Parameters
[in]fitsFITS file.

Loads the Auxiliary Response File from the SPECRESP extension of the FITS file.

Definition at line 617 of file GArf.cpp.

References clear(), gammalib::extname_arf, and GFits::table().

Referenced by load().

void GArf::read ( const GFitsTable table)

Read Auxiliary Response File.

Parameters
[in]tableARF FITS table.

Reads the Auxiliary Response File from a FITS table. The true energy boundaries are expected in the ENERG_LO and ENERG_HI columns, the response information is expected in the SPECRESP column.

The method will analyze the unit of the SPECRESP column, and if either m**2, m^2 or m2 are encountered, multiply the values of the column by \(10^4\) to convert the response into units of \(cm^2\). Units of the ENERG_LO and ENERG_HI columns are also interpreted for conversion.

See http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html#tth_sEc4 for details about the Auxiliary Response File format.

Definition at line 651 of file GArf.cpp.

References GEbounds::append(), append(), clear(), GFitsHDU::header(), m_ebounds, m_header, m_specresp, GFitsTable::ncols(), GFitsTableCol::nrows(), GFitsTableCol::real(), set_logetrue(), gammalib::strip_whitespace(), gammalib::tolower(), and GFitsTableCol::unit().

void GArf::save ( const GFilename filename,
const bool &  clobber = false 
) const

Save Auxiliary Response File.

Parameters
[in]filenameFile name.
[in]clobberOverwrite existing file?

Saves the Auxiliary Response 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 the SPECRESP binary FITS table into the FITS file that contains the values of the Auxiliary Response File.

Definition at line 589 of file GArf.cpp.

References m_filename, GFits::saveto(), GFilename::url(), and write().

void GArf::set_logetrue ( void  )
protected

Set true energy node array.

Definition at line 919 of file GArf.cpp.

References GNodeArray::append(), GNodeArray::clear(), GEbounds::elogmean(), GEnergy::log10TeV(), m_ebounds, m_logetrue, GNodeArray::reserve(), and GEbounds::size().

Referenced by GArf(), and read().

int GArf::size ( void  ) const
inline

Return number of spectral bins.

Returns
Number of spectral bins.

Returns the number of spectral bins.

Definition at line 209 of file GArf.hpp.

References m_specresp.

Referenced by append(), at(), GCTAOnOffObservation::N_gamma(), operator*=(), operator+=(), operator-=(), operator/=(), and write().

void GArf::write ( GFits fits) const

Write Auxiliary Response File.

Parameters
[in]fitsFITS file.

Writes the Auxiliary Response File into the SPECRESP extension of the FITS file. An existing extension with the same name will be removed from the FITS file before writing.

The method writes the boundaries of the true energy bins into the ENERG_LO and ENERG_HI columns, response information will be written into the SPECRESP column.

See http://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/docs/memos/cal_gen_92_002/cal_gen_92_002.html#tth_sEc4 for details about the Auxiliary Response File format.

Definition at line 740 of file GArf.cpp.

References GFitsTable::append(), GFits::append(), GFitsHDU::card(), columns(), GFitsTable::contains(), GFits::contains(), GEbounds::emax(), GEbounds::emin(), GFitsHDU::extname(), gammalib::extname_arf, GEnergy::keV(), m_coldata, m_colnames, m_ebounds, m_header, m_specresp, GFits::remove(), GFitsHeader::size(), size(), and GFitsTableCol::unit().

Referenced by save().

Friends And Related Function Documentation

GArf operator* ( const GArf arf,
const double &  scale 
)
friend

Auxiliary Response File scaling operator friend.

Parameters
[in]arfAuxiliary Response File.
[in]scaleScale factor.
Returns
Scaled Auxiliary Response File.

Definition at line 325 of file GArf.hpp.

GArf operator* ( const double &  scale,
const GArf arf 
)
friend

Auxiliary Response File scaling operator friend.

Parameters
[in]scaleScale factor.
[in]arfAuxiliary Response File.
Returns
Scaled Auxiliary Response File.

Definition at line 341 of file GArf.hpp.

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

Auxiliary Response File addition operator friend.

Parameters
[in]aFirst Auxiliary Response File.
[in]bSecond Auxiliary Response File.
Returns
Sum of Auxiliary Response Files.

Definition at line 293 of file GArf.hpp.

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

Auxiliary Response File subtraction operator friend.

Parameters
[in]aFirst Auxiliary Response File.
[in]bSecond Auxiliary Response File.
Returns
Difference of Auxiliary Response Files.

Definition at line 309 of file GArf.hpp.

GArf operator/ ( const GArf arf,
const double &  scale 
)
friend

Auxiliary Response File vision operator friend.

Parameters
[in]arfAuxiliary Response File.
[in]scaleDivision factor.
Returns
Divided Auxiliary Response File.

Definition at line 357 of file GArf.hpp.

Member Data Documentation

std::vector<std::vector<double> > GArf::m_coldata
protected

Additional column data.

Definition at line 126 of file GArf.hpp.

Referenced by append(), at(), copy_members(), init_members(), operator()(), operator[](), and write().

std::vector<std::string> GArf::m_colnames
protected

Additional column names.

Definition at line 125 of file GArf.hpp.

Referenced by append(), column_index(), columns(), copy_members(), init_members(), and write().

GEbounds GArf::m_ebounds
protected

Energy boundaries.

Definition at line 122 of file GArf.hpp.

Referenced by copy_members(), ebounds(), GArf(), init_members(), print(), read(), set_logetrue(), and write().

GFilename GArf::m_filename
mutableprotected

Filename of origin.

Definition at line 121 of file GArf.hpp.

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

GFitsHeader GArf::m_header
protected

FITS header cards.

Definition at line 127 of file GArf.hpp.

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

GNodeArray GArf::m_logetrue
protected

Log10 energies in TeV.

Definition at line 123 of file GArf.hpp.

Referenced by copy_members(), init_members(), operator()(), and set_logetrue().

std::vector<double> GArf::m_specresp
protected

Spectral response.

Definition at line 124 of file GArf.hpp.

Referenced by at(), copy_members(), GArf(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), operator[](), read(), size(), and write().


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