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

Pulse Height Analyzer class. More...

#include <GPha.hpp>

Inheritance diagram for GPha:
GBase

Public Member Functions

 GPha (void)
 Void constructor. More...
 
 GPha (const GFilename &filename)
 File constructor. More...
 
 GPha (const GEbounds &ebds)
 Energy boundary constructor. More...
 
 GPha (const int &bins)
 Energy bins constructor. More...
 
 GPha (const GPha &pha)
 Copy constructor. More...
 
virtual ~GPha (void)
 Destructor. More...
 
GPhaoperator= (const GPha &pha)
 Assignment operator. More...
 
GPhaoperator+= (const GPha &pha)
 Add spectrum. More...
 
GPhaoperator-= (const GPha &pha)
 Subtract spectrum. More...
 
GPhaoperator*= (const double &scale)
 Scale spectrum values. More...
 
GPhaoperator/= (const double &scale)
 Divide spectrum 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...
 
void clear (void)
 Clear object. More...
 
GPhaclone (void) const
 Clone object. More...
 
std::string classname (void) const
 Return class name. More...
 
int size (void) const
 Return number of bins in spectrum. 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...
 
double counts (void) const
 Number of counts in spectrum. More...
 
GNdarray counts_spectrum (void) const
 Get number of counts in spectrum as GNdarray. More...
 
void areascal (const int &index, const double &areascal)
 Set area scaling factor. More...
 
const double & areascal (const int &index) const
 Return area scaling factor. More...
 
void backscal (const int &index, const double &backscal)
 Set background scaling factor. More...
 
const double & backscal (const int &index) const
 Return background scaling factor. More...
 
GNdarray backscal_spectrum (void) const
 Get background scaling factors as GNdarray. More...
 
const double & underflow (void) const
 Return number of underflow counts. More...
 
const double & overflow (void) const
 Return number of overflow counts. More...
 
const double & outflow (void) const
 Return number of outflow counts. More...
 
void exposure (const double &exposure)
 Set exposure time. More...
 
const double & exposure (void) const
 Return exposure time. More...
 
void emin_obs (const GEnergy &emin_obs)
 Set minimum energy of observations. More...
 
const GEnergyemin_obs (void) const
 Return minimum energy of observations. More...
 
void emax_obs (const GEnergy &emax_obs)
 Set maximum energy of observations. More...
 
const GEnergyemax_obs (void) const
 Return maximum energy of observations. More...
 
void backfile (const std::string &backfile)
 Set background file name. More...
 
const std::string & backfile (void) const
 Return background file name. More...
 
void corrfile (const std::string &corrfile)
 Set correction file name. More...
 
const std::string & corrfile (void) const
 Return correction file name. More...
 
void respfile (const std::string &respfile)
 Set Redistribution Matrix File name. More...
 
const std::string & respfile (void) const
 Return Redistribution Matrix File name. More...
 
void ancrfile (const std::string &ancrfile)
 Set Ancilliary Response File name. More...
 
const std::string & ancrfile (void) const
 Return Ancilliary Response File name. More...
 
void fill (const GEnergy &energy, const double &value=1.0)
 Fill spectrum with a value. More...
 
void load (const GFilename &filename)
 Load Pulse Height Analyzer spectrum. More...
 
void save (const GFilename &filename, const bool &clobber=false) const
 Save Pulse Height Analyzer spectrum. More...
 
void read (const GFits &fits)
 Read Pulse Height Analyzer spectrum. More...
 
void read (const GFitsTable &table)
 Read Pulse Height Analyzer spectrum. More...
 
void write (GFits &fits) const
 Write Pulse Height Analyzer spectrum. 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 Pulse Height Analyzer spectrum. 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 GPha &pha)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void alloc (const int &size)
 Allocate spectrum. 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...
 
std::vector< double > m_counts
 Counts data. More...
 
std::vector< double > m_areascal
 Area scaling. More...
 
std::vector< double > m_backscal
 Background scaling. More...
 
std::vector< std::string > m_colnames
 Additional column names. More...
 
std::vector< std::vector
< double > > 
m_coldata
 Additional column data. More...
 
GEnergy m_emin_obs
 Minimum energy of observation. More...
 
GEnergy m_emax_obs
 Minimum energy of observation. More...
 
double m_underflow
 Number of underflowing events. More...
 
double m_overflow
 Number of overflowing events. More...
 
double m_outflow
 Number of outflowing events. More...
 
double m_exposure
 Deadtime corr. exp. time (sec) More...
 
GEbounds m_ebounds
 Energy boundaries. More...
 
std::string m_backfile
 Background file. More...
 
std::string m_corrfile
 Correction file. More...
 
std::string m_respfile
 RMF file. More...
 
std::string m_ancrfile
 ARF file. More...
 
GFitsHeader m_header
 FITS header cards. More...
 

Friends

GPha operator+ (const GPha &a, const GPha &b)
 Spectrum addition operator friend. More...
 
GPha operator- (const GPha &a, const GPha &b)
 Spectrum subtraction operator friend. More...
 
GPha operator* (const GPha &pha, const double &scale)
 Spectrum scaling operator friend. More...
 
GPha operator* (const double &scale, const GPha &pha)
 Spectrum scaling operator friend. More...
 
GPha operator/ (const GPha &pha, const double &scale)
 Spectrum division operator friend. More...
 

Detailed Description

Pulse Height Analyzer class.

This class implements a Pulse Height Analyzer (PHA) spectrum that is used as data container for an XSPEC analysis. A PHA spectrum is a vector that provides the number of measured counts as function of the channel number.

As an extension to the PHA format, the GPha class may also store the energy boundaries for all PHA channels. If defined, the energy boundaries will be written as a EBOUNDS extension to the same file where the PHA spectrum resides. Upon loading, GPha will also load the energy boundaries from an EBOUNDS extension if they are present.

Definition at line 64 of file GPha.hpp.

Constructor & Destructor Documentation

GPha::GPha ( void  )

Void constructor.

Definition at line 71 of file GPha.cpp.

References init_members().

Referenced by clone().

GPha::GPha ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenameFile name.

Definition at line 86 of file GPha.cpp.

References init_members(), and load().

GPha::GPha ( const GEbounds ebds)
explicit

Energy boundary constructor.

Parameters
[in]ebdsEnergy boundaries.

Definition at line 104 of file GPha.cpp.

References alloc(), init_members(), m_ebounds, and GEbounds::size().

GPha::GPha ( const int &  bins)
explicit

Energy bins constructor.

Parameters
[in]binsNumber of energy bins.

Definition at line 125 of file GPha.cpp.

References alloc(), and init_members().

GPha::GPha ( const GPha pha)

Copy constructor.

Parameters
[in]phaPulse Height Analyzer spectrum.

Definition at line 143 of file GPha.cpp.

References copy_members(), and init_members().

GPha::~GPha ( void  )
virtual

Destructor.

Definition at line 159 of file GPha.cpp.

References free_members().

Member Function Documentation

void GPha::alloc ( const int &  size)
protected

Allocate spectrum.

Parameters
[in]sizeSize of spectrum.

Allocates memory for a spectrum of given size and sets number of counts to zero and area and background scaling factors to one.

Definition at line 1303 of file GPha.cpp.

References m_areascal, m_backscal, m_counts, m_exposure, m_outflow, m_overflow, and m_underflow.

Referenced by GPha(), and read().

void GPha::ancrfile ( const std::string &  ancrfile)
inline

Set Ancilliary Response File name.

Parameters
[in]ancrfileAncilliary Response File name.

Set the Ancilliary Response File name.

Definition at line 514 of file GPha.hpp.

References ancrfile(), and m_ancrfile.

const std::string & GPha::ancrfile ( void  ) const
inline

Return Ancilliary Response File name.

Returns
Ancilliary Response File name.

Returns the Ancilliary Response File name.

Definition at line 529 of file GPha.hpp.

References m_ancrfile.

Referenced by ancrfile(), read(), and write().

void GPha::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 574 of file GPha.cpp.

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

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

void GPha::areascal ( const int &  index,
const double &  areascal 
)

Set area scaling factor.

Parameters
[in]indexBin index [0,...,size()-1].
[in]areascalArea scaling factor.
Exceptions
GException::out_of_rangeSpectral bin index is out of range.

Set area scaling for spectral bin with specified index.

Definition at line 607 of file GPha.cpp.

References G_AREASCAL_SET, m_areascal, and size().

const double & GPha::areascal ( const int &  index) const

Return area scaling factor.

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

Returns reference to area scaling for spectral bin with specified index.

Definition at line 634 of file GPha.cpp.

References G_AREASCAL_GET, m_areascal, and size().

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

Return content of spectral bin.

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

Returns reference to content of spectral bin with specified index.

Definition at line 482 of file GPha.cpp.

References G_AT1, m_counts, and size().

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

Return content of spectral bin (const version)

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

Returns reference to content of spectral bin with specified index.

Definition at line 504 of file GPha.cpp.

References G_AT1, m_counts, and size().

double & GPha::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 527 of file GPha.cpp.

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

const double & GPha::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 553 of file GPha.cpp.

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

void GPha::backfile ( const std::string &  backfile)
inline

Set background file name.

Parameters
[in]backfileBackground file name.

Set the background file name.

Definition at line 427 of file GPha.hpp.

References backfile(), and m_backfile.

const std::string & GPha::backfile ( void  ) const
inline

Return background file name.

Returns
Background file name.

Returns the background file name.

Definition at line 442 of file GPha.hpp.

References m_backfile.

Referenced by backfile(), read(), and write().

void GPha::backscal ( const int &  index,
const double &  backscal 
)

Set background scaling factor.

Parameters
[in]indexBin index [0,...,size()-1].
[in]backscalBackground scaling factor.
Exceptions
GException::out_of_rangeSpectral bin index is out of range.

Set background scaling for spectral bin with specified index.

Definition at line 658 of file GPha.cpp.

References G_BACKSCAL_SET, m_backscal, and size().

Referenced by GCTAOnOffObservation::compute_alpha(), GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::likelihood_cstat(), GCTAOnOffObservation::likelihood_wstat(), and GCTAOnOffObservation::model_background().

const double & GPha::backscal ( const int &  index) const

Return background scaling factor.

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

Returns reference to background scaling for spectral bin with specified index.

Definition at line 685 of file GPha.cpp.

References G_BACKSCAL_GET, m_backscal, and size().

GNdarray GPha::backscal_spectrum ( void  ) const

Get background scaling factors as GNdarray.

Returns
GNdarray of background scaling factors.

Returns the background scaling factors as GNdarray.

Definition at line 747 of file GPha.cpp.

References m_backscal, and size().

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

Return class name.

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

Implements GBase.

Definition at line 182 of file GPha.hpp.

void GPha::clear ( void  )
virtual

Clear object.

Reset object to a clean initial state.

Implements GBase.

Definition at line 447 of file GPha.cpp.

References free_members(), and init_members().

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

GPha * GPha::clone ( void  ) const
virtual

Clone object.

Returns
Pulse Height Analyzer spectrum.

Implements GBase.

Definition at line 465 of file GPha.cpp.

References GPha().

int GPha::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 1330 of file GPha.cpp.

References columns(), and m_colnames.

Referenced by operator[]().

int GPha::columns ( void  ) const
inline

Return number of additional columns.

Returns
Number of additional columns.

Returns the number of additional columns.

Definition at line 268 of file GPha.hpp.

References m_colnames.

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

void GPha::copy_members ( const GPha pha)
protected

Copy class members.

Parameters
[in]phaPulse Height Analyzer spectrum.

Definition at line 1258 of file GPha.cpp.

References m_ancrfile, m_areascal, m_backfile, m_backscal, m_coldata, m_colnames, m_corrfile, m_counts, m_ebounds, m_emax_obs, m_emin_obs, m_exposure, m_filename, m_header, m_outflow, m_overflow, m_respfile, and m_underflow.

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

void GPha::corrfile ( const std::string &  corrfile)
inline

Set correction file name.

Parameters
[in]corrfileCorrection file name.

Set the correction file name.

Definition at line 456 of file GPha.hpp.

References corrfile(), and m_corrfile.

const std::string & GPha::corrfile ( void  ) const
inline

Return correction file name.

Returns
Correction file name.

Returns the correction file name.

Definition at line 471 of file GPha.hpp.

References m_corrfile.

Referenced by corrfile(), read(), and write().

double GPha::counts ( void  ) const

Number of counts in spectrum.

Returns the number of counts in the spectrum.

Definition at line 703 of file GPha.cpp.

References m_counts.

Referenced by counts_spectrum(), GCTAOnOffObservation::nobserved(), and print().

GNdarray GPha::counts_spectrum ( void  ) const

Get number of counts in spectrum as GNdarray.

Returns
GNdarray of number of counts in spectrum.

Returns the number of counts in the spectrum as GNdarray.

Definition at line 724 of file GPha.cpp.

References counts(), m_counts, and size().

const GEbounds & GPha::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 282 of file GPha.hpp.

References m_ebounds.

Referenced by GCTAOnOffObservation::check_consistency(), GCTAOnOffObservation::compute_bgd(), GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::model_background(), GCTAOnOffObservation::model_gamma(), GCTAOnOffObservation::N_bgd(), operator+=(), operator-=(), and read().

void GPha::emax_obs ( const GEnergy emax_obs)
inline

Set maximum energy of observations.

Parameters
[in]emax_obsMaximum energy of observation.

Set the maximum energy of the observation.

Definition at line 398 of file GPha.hpp.

References emax_obs(), and m_emax_obs.

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

const GEnergy & GPha::emax_obs ( void  ) const
inline

Return maximum energy of observations.

Returns
Maximum energy of observation.

Returns the maximum energy of the observation.

Definition at line 413 of file GPha.hpp.

References m_emax_obs.

Referenced by emax_obs().

void GPha::emin_obs ( const GEnergy emin_obs)
inline

Set minimum energy of observations.

Parameters
[in]emin_obsMinimum energy of observation.

Set the minimum energy of the observation.

Definition at line 369 of file GPha.hpp.

References emin_obs(), and m_emin_obs.

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

const GEnergy & GPha::emin_obs ( void  ) const
inline

Return minimum energy of observations.

Returns
Minimum energy of observation.

Returns the minimum energy of the observation.

Definition at line 384 of file GPha.hpp.

References m_emin_obs.

Referenced by emin_obs().

void GPha::exposure ( const double &  exposure)
inline

Set exposure time.

Parameters
[in]exposureExposure time (seconds).

Set the exposure time in seconds.

Definition at line 340 of file GPha.hpp.

References exposure(), and m_exposure.

Referenced by GCTAOnOffObservation::GCTAOnOffObservation(), GCTAOnOffObservation::N_bgd(), GCTAOnOffObservation::N_gamma(), GCTAOnOffObservation::set(), and GCTAOnOffObservation::set_exposure().

const double & GPha::exposure ( void  ) const
inline

Return exposure time.

Returns
Exposure time (seconds).

Returns the exposure time in seconds.

Definition at line 355 of file GPha.hpp.

References m_exposure.

Referenced by exposure(), and print().

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

Return file name.

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

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

Definition at line 546 of file GPha.hpp.

References m_filename.

Referenced by GCTAOnOffObservation::write().

void GPha::fill ( const GEnergy energy,
const double &  value = 1.0 
)

Fill spectrum with a value.

Parameters
[in]energyEnergy.
[in]valueFill value (defaults to 1.0).

Fills the specified value at a given energy in the spectrum.

Definition at line 771 of file GPha.cpp.

References GEbounds::emax(), GEbounds::emin(), GEbounds::index(), m_counts, m_ebounds, m_outflow, m_overflow, and m_underflow.

Referenced by GCTAOnOffObservation::model_background(), GCTAOnOffObservation::model_gamma(), and GCTAOnOffObservation::set().

void GPha::free_members ( void  )
protected

Delete class members.

Definition at line 1288 of file GPha.cpp.

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

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

Return FITS header.

Returns
FITS header or PHA file.

Definition at line 558 of file GPha.hpp.

References m_header.

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

void GPha::header ( const GFitsHeader header)
inline

Set FITS header.

Parameters
[in]headerFITS header.

Definition at line 570 of file GPha.hpp.

References header(), and m_header.

void GPha::load ( const GFilename filename)

Load Pulse Height Analyzer spectrum.

Parameters
[in]filenameFile name.

Loads the Pulse Height Analyzer spectrum from a FITS file.

Definition at line 806 of file GPha.cpp.

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

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

double & GPha::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 225 of file GPha.hpp.

References m_coldata.

const double & GPha::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 240 of file GPha.hpp.

References m_coldata.

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

Scale spectrum values.

Parameters
[in]scaleScale factor.
Returns
Scaled Pulse Height Analyzer spectrum.

Multiplies the counts of a spectrum with a scale factor. The exposure time and area and background scale factors are not altered.

Definition at line 343 of file GPha.cpp.

References m_counts, m_outflow, m_overflow, m_underflow, and size().

GPha & GPha::operator+= ( const GPha pha)

Add spectrum.

Parameters
[in]phaPulse Height Analyzer spectrum.
Returns
Sum of Pulse Height Analyzer spectra.
Exceptions
GException::invalid_valueIncompatible spectrum.

Adds the counts of a spectrum to the counts of the current spectrum. The operator also adds the exposure times of the spectrum to the current exposure time. The area scaling factor \(\alpha\) is recomputed for each spectral bin using

\[ \alpha = \frac{N_1 + N_2}{\frac{N_1}{\alpha_1} + \frac{N_2}{\alpha_2}} \]

where \(N_1\) and \(N_2\) are the number of events in the bin for spectrum 1 and 2, respectively, and \(\alpha_1\) and \(\alpha_2\) are the corresponding area scaling factors.

The background scaling factor is not altered.

The operator only works if the provide specturm has the same energy binning than the current spectrum.

Definition at line 231 of file GPha.cpp.

References ebounds(), G_OPERATOR_PLUS, m_areascal, m_counts, m_exposure, m_outflow, m_overflow, m_underflow, and size().

GPha & GPha::operator-= ( const GPha pha)

Subtract spectrum.

Parameters
[in]phaPulse Height Analyzer spectrum.
Returns
Difference of Pulse Height Analyzer spectra.
Exceptions
GException::invalid_valueIncompatible spectrum.

Subtracts the counts of a spectrum from the counts of the current spectrum. The operator also subtracts the exposure times of the spectrum from the current exposure time. The area scaling factor \(\alpha\) is recomputed for each spectral bin using

\[ \alpha = \frac{N_1 - N_2}{\frac{N_1}{\alpha_1} - \frac{N_2}{\alpha_2}} \]

where \(N_1\) and \(N_2\) are the number of events in the bin for spectrum 1 and 2, respectively, and \(\alpha_1\) and \(\alpha_2\) are the corresponding area scaling factors.

The background scaling factor is not altered.

The operator only works if the provide specturm has the same energy binning than the current spectrum.

Definition at line 297 of file GPha.cpp.

References ebounds(), G_OPERATOR_MINUS, m_areascal, m_counts, m_exposure, m_outflow, m_overflow, m_underflow, and size().

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

Divide spectrum values.

Parameters
[in]scaleDivision factor.
Returns
Divided Pulse Height Analyzer spectrum.

Divides the counts of a spectrum by a scale factor. The exposure time and the area and background scale factors are not altered.

Definition at line 369 of file GPha.cpp.

References m_counts, m_outflow, m_overflow, m_underflow, and size().

GPha & GPha::operator= ( const GPha pha)

Assignment operator.

Parameters
[in]phaPulse Height Analyzer spectrum.
Returns
Pulse Height Analyzer spectrum.

Definition at line 181 of file GPha.cpp.

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

double & GPha::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 196 of file GPha.hpp.

References m_counts.

const double & GPha::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 210 of file GPha.hpp.

References m_counts.

std::vector< double > & GPha::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 394 of file GPha.cpp.

References column_index(), G_OPERATOR, and m_coldata.

const std::vector< double > & GPha::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 419 of file GPha.cpp.

References column_index(), G_OPERATOR, and m_coldata.

const double & GPha::outflow ( void  ) const
inline

Return number of outflow counts.

Returns
Number of counts with energies between energy bins.

Returns the number of counts with energies between energy bins.

Definition at line 326 of file GPha.hpp.

References m_outflow.

const double & GPha::overflow ( void  ) const
inline

Return number of overflow counts.

Returns
Number of counts with energies larger than the last energy bin.

Returns the number of counts with energies larger than the last energy bin.

Definition at line 312 of file GPha.hpp.

References m_overflow.

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

Print Pulse Height Analyzer spectrum.

Parameters
[in]chatterChattiness.
Returns
String containing Pulse Height Analyzer spectrum information.

Implements GBase.

Definition at line 1163 of file GPha.cpp.

References counts(), GEbounds::emax(), GEbounds::emin(), exposure(), m_ebounds, m_emax_obs, m_emin_obs, m_outflow, m_overflow, m_underflow, gammalib::parformat(), GEnergy::print(), SILENT, GEbounds::size(), size(), and gammalib::str().

Referenced by GCTAOnOffObservation::print().

void GPha::read ( const GFits fits)

Read Pulse Height Analyzer spectrum.

Parameters
[in]fitsFile file.

Reads the Pulse Height Analyzer spectrum from the SPECTRUM extension of the FITS file. If the file contains also an EBOUNDS extension the energy boundaries of all Pulse Height Analyzer channels are also loaded.

Definition at line 874 of file GPha.cpp.

References clear(), GFits::contains(), ebounds(), gammalib::extname_ebounds, gammalib::extname_pha, m_ebounds, GEbounds::read(), and GFits::table().

Referenced by load().

void GPha::read ( const GFitsTable table)

Read Pulse Height Analyzer spectrum.

Parameters
[in]tableFITS table.
Exceptions
GException::invalid_valueMismatch between PHA file and energy boundaries.

Reads the Pulse Height Analyzer spectrum from a FITS table. The channel values are expected in the COUNTS column of the table. All other columns are ignored.

See https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node5.html for details about the Pulse Height Analyzer spectrum format.

Definition at line 917 of file GPha.cpp.

References alloc(), ancrfile(), append(), backfile(), clear(), corrfile(), G_READ, GFitsHDU::has_card(), GFitsHDU::header(), m_ancrfile, m_areascal, m_backfile, m_backscal, m_corrfile, m_counts, m_ebounds, m_emax_obs, m_emin_obs, m_exposure, m_header, m_outflow, m_overflow, m_respfile, m_underflow, GEnergy::MeV(), GFitsTable::ncols(), GFitsTableCol::nrows(), GFitsTableCol::real(), GFitsHDU::real(), respfile(), GEbounds::size(), gammalib::str(), GFitsHDU::string(), and gammalib::tolower().

void GPha::respfile ( const std::string &  respfile)
inline

Set Redistribution Matrix File name.

Parameters
[in]respfileRedistribution Matrix File name.

Set the Redistribution Matrix File name.

Definition at line 485 of file GPha.hpp.

References m_respfile, and respfile().

const std::string & GPha::respfile ( void  ) const
inline

Return Redistribution Matrix File name.

Returns
Redistribution Matrix File name.

Returns the Redistribution Matrix File name.

Definition at line 500 of file GPha.hpp.

References m_respfile.

Referenced by read(), respfile(), and write().

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

Save Pulse Height Analyzer spectrum.

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

Saves the Pulse Height Analyzer spectrum and energy boundaries 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 SPECTRUM extension that contains the channel values of the Pulse Height Analyzer spectrum and an EBOUNDS extension that contains the energy boundaries for all channels.

Definition at line 845 of file GPha.cpp.

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

const double & GPha::underflow ( void  ) const
inline

Return number of underflow counts.

Returns
Number of counts with energies lower than the first energy bin.

Returns the number of counts with energies lower than the first energy bin.

Definition at line 297 of file GPha.hpp.

References m_underflow.

void GPha::write ( GFits fits) const

Write Pulse Height Analyzer spectrum.

Parameters
[in]fitsFITS file.

Writes the Pulse Height Analyzer spectrum into SPECTRUM and EBOUNDS extensions of the FITS file. Extensions with these names will be removed from the FITS file before writing.

The columns CHANNEL, COUNTS, STAT_ERR, SYS_ERR, QUALITY, GROUPING, AREASCAL, and BACKSCAL will be written into the SPECTRUM extension, but only the CHANNEL and COUNTS columns will be filled with values. Note that the channels start from 1 in the Pulse Height Analyzer spectrum.

See https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node5.html for details about the PHA file format.

Definition at line 1035 of file GPha.cpp.

References abs(), ancrfile(), GFitsTable::append(), GFits::append(), backfile(), GFitsHDU::card(), columns(), GFits::contains(), corrfile(), GFitsHDU::extname(), gammalib::extname_ebounds, gammalib::extname_pha, GFitsHDU::has_card(), m_ancrfile, m_areascal, m_backfile, m_backscal, m_coldata, m_colnames, m_corrfile, m_counts, m_ebounds, m_emax_obs, m_emin_obs, m_exposure, m_header, m_outflow, m_overflow, m_respfile, m_underflow, GEnergy::MeV(), GFits::remove(), respfile(), GFitsHeader::size(), GEbounds::size(), size(), sqrt(), and GEbounds::write().

Referenced by save().

Friends And Related Function Documentation

GPha operator* ( const GPha pha,
const double &  scale 
)
friend

Spectrum scaling operator friend.

Parameters
[in]phaPulse Height Analyzer spectrum.
[in]scaleScale factor.
Returns
Scaled Pulse Height Analyzer spectrum.

Definition at line 617 of file GPha.hpp.

GPha operator* ( const double &  scale,
const GPha pha 
)
friend

Spectrum scaling operator friend.

Parameters
[in]scaleScale factor.
[in]phaPulse Height Analyzer spectrum.
Returns
Scaled Pulse Height Analyzer spectrum.

Definition at line 633 of file GPha.hpp.

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

Spectrum addition operator friend.

Parameters
[in]aFirst Pulse Height Analyzer spectrum.
[in]bSecond Pulse Height Analyzer spectrum.
Returns
Sum of Pulse Height Analyzer spectra.

Definition at line 585 of file GPha.hpp.

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

Spectrum subtraction operator friend.

Parameters
[in]aFirst Pulse Height Analyzer spectrum.
[in]bSecond Pulse Height Analyzer spectrum.
Returns
Difference of Pulse Height Analyzer spectra.

Definition at line 601 of file GPha.hpp.

GPha operator/ ( const GPha pha,
const double &  scale 
)
friend

Spectrum division operator friend.

Parameters
[in]phaPulse Height Analyzer spectrum.
[in]scaleDivision factor.
Returns
Divided Pulse Height Analyzer spectrum.

Definition at line 649 of file GPha.hpp.

Member Data Documentation

std::string GPha::m_ancrfile
protected

ARF file.

Definition at line 171 of file GPha.hpp.

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

std::vector<double> GPha::m_areascal
protected

Area scaling.

Definition at line 157 of file GPha.hpp.

Referenced by alloc(), areascal(), copy_members(), init_members(), operator+=(), operator-=(), read(), and write().

std::string GPha::m_backfile
protected

Background file.

Definition at line 168 of file GPha.hpp.

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

std::vector<double> GPha::m_backscal
protected

Background scaling.

Definition at line 158 of file GPha.hpp.

Referenced by alloc(), backscal(), backscal_spectrum(), copy_members(), init_members(), read(), and write().

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

Additional column data.

Definition at line 160 of file GPha.hpp.

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

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

Additional column names.

Definition at line 159 of file GPha.hpp.

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

std::string GPha::m_corrfile
protected

Correction file.

Definition at line 169 of file GPha.hpp.

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

std::vector<double> GPha::m_counts
protected
GEbounds GPha::m_ebounds
protected

Energy boundaries.

Definition at line 167 of file GPha.hpp.

Referenced by copy_members(), ebounds(), fill(), GPha(), init_members(), print(), read(), and write().

GEnergy GPha::m_emax_obs
protected

Minimum energy of observation.

Definition at line 162 of file GPha.hpp.

Referenced by copy_members(), emax_obs(), init_members(), print(), read(), and write().

GEnergy GPha::m_emin_obs
protected

Minimum energy of observation.

Definition at line 161 of file GPha.hpp.

Referenced by copy_members(), emin_obs(), init_members(), print(), read(), and write().

double GPha::m_exposure
protected

Deadtime corr. exp. time (sec)

Definition at line 166 of file GPha.hpp.

Referenced by alloc(), copy_members(), exposure(), init_members(), operator+=(), operator-=(), read(), and write().

GFilename GPha::m_filename
mutableprotected

Filename of origin.

Definition at line 155 of file GPha.hpp.

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

GFitsHeader GPha::m_header
protected

FITS header cards.

Definition at line 172 of file GPha.hpp.

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

double GPha::m_outflow
protected

Number of outflowing events.

Definition at line 165 of file GPha.hpp.

Referenced by alloc(), copy_members(), fill(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), outflow(), print(), read(), and write().

double GPha::m_overflow
protected

Number of overflowing events.

Definition at line 164 of file GPha.hpp.

Referenced by alloc(), copy_members(), fill(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), overflow(), print(), read(), and write().

std::string GPha::m_respfile
protected

RMF file.

Definition at line 170 of file GPha.hpp.

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

double GPha::m_underflow
protected

Number of underflowing events.

Definition at line 163 of file GPha.hpp.

Referenced by alloc(), copy_members(), fill(), init_members(), operator*=(), operator+=(), operator-=(), operator/=(), print(), read(), underflow(), and write().


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