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

CTA point spread function table class. More...

#include <GCTAPsfTable.hpp>

Inheritance diagram for GCTAPsfTable:
GCTAPsf GBase

Public Member Functions

 GCTAPsfTable (void)
 Void constructor. More...
 
 GCTAPsfTable (const GFilename &filename)
 File constructor. More...
 
 GCTAPsfTable (const GCTAPsfTable &psf)
 Copy constructor. More...
 
virtual ~GCTAPsfTable (void)
 Destructor. More...
 
GCTAPsfTableoperator= (const GCTAPsfTable &psf)
 Assignment operator. More...
 
double operator() (const double &delta, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
 Return point spread function (in units of sr^-1) More...
 
void clear (void)
 Clear point spread function. More...
 
GCTAPsfTableclone (void) const
 Clone point spread functions. More...
 
std::string classname (void) const
 Return class name. More...
 
void load (const GFilename &filename)
 Load point spread function from FITS file. More...
 
GFilename filename (void) const
 Return filename. More...
 
double mc (GRan &ran, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
 Simulate PSF offset (radians) More...
 
double delta_max (const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
 Return maximum size of PSF (radians) More...
 
double containment_radius (const double &fraction, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const
 Return the radius that contains a fraction of the events (radians) More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print point spread function information. More...
 
const GCTAResponseTabletable (void) const
 Return response table. More...
 
void table (const GCTAResponseTable &table)
 Assign response table. More...
 
void read (const GFitsTable &table)
 Read point spread function from FITS table. More...
 
void write (GFitsBinTable &table) const
 Write point spread function into FITS table. More...
 
void save (const GFilename &filename, const bool &clobber=false) const
 Save point spread function table into FITS file. More...
 
- Public Member Functions inherited from GCTAPsf
 GCTAPsf (void)
 Void constructor. More...
 
 GCTAPsf (const GCTAPsf &psf)
 Copy constructor. More...
 
virtual ~GCTAPsf (void)
 Destructor. More...
 
GCTAPsfoperator= (const GCTAPsf &psf)
 Assignment operator. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Private Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GCTAPsfTable &psf)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void precompute (void)
 Performs precomputations for point spread function. More...
 
int element (const int &ieng, const int &itheta, const int &idelta)
 Return element index. More...
 

Private Attributes

GFilename m_filename
 Name of Aeff response file. More...
 
GCTAResponseTable m_psf
 PSF response table. More...
 
int m_inx_energy
 Energy index. More...
 
int m_inx_theta
 Theta index. More...
 
int m_inx_delta
 Delta index. More...
 
int m_inx_rpsf
 PSF histogram. More...
 
double m_delta_max
 Maximum delta angle (radians) More...
 
double m_psf_max
 Maximum PSF value. More...
 

Additional Inherited Members

- Protected Member Functions inherited from GCTAPsf
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GCTAPsf &psf)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Detailed Description

CTA point spread function table class.

This class implements the CTA point spread function response as function of energy as determined from a FITS table.

Definition at line 54 of file GCTAPsfTable.hpp.

Constructor & Destructor Documentation

GCTAPsfTable::GCTAPsfTable ( void  )

Void constructor.

Constructs empty point spread function.

Definition at line 68 of file GCTAPsfTable.cpp.

References init_members().

Referenced by clone().

GCTAPsfTable::GCTAPsfTable ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenamePSF FITS file.

Constructs point spread function from a FITS file.

Definition at line 85 of file GCTAPsfTable.cpp.

References init_members(), and load().

GCTAPsfTable::GCTAPsfTable ( const GCTAPsfTable psf)

Copy constructor.

Parameters
[in]psfPoint spread function.

Constructs point spread function by copying from another point spread function.

Definition at line 106 of file GCTAPsfTable.cpp.

References copy_members(), and init_members().

GCTAPsfTable::~GCTAPsfTable ( void  )
virtual

Destructor.

Destructs point spread function.

Definition at line 124 of file GCTAPsfTable.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GCTAPsf.

Definition at line 135 of file GCTAPsfTable.hpp.

void GCTAPsfTable::clear ( void  )
virtual

Clear point spread function.

Clears point spread function.

Implements GCTAPsf.

Definition at line 238 of file GCTAPsfTable.cpp.

References GCTAPsf::free_members(), free_members(), GCTAPsf::init_members(), and init_members().

GCTAPsfTable * GCTAPsfTable::clone ( void  ) const
virtual

Clone point spread functions.

Returns
Deep copy of point spread function.

Returns a pointer to a deep copy of the point spread function.

Implements GCTAPsf.

Definition at line 260 of file GCTAPsfTable.cpp.

References GCTAPsfTable().

double GCTAPsfTable::containment_radius ( const double &  fraction,
const double &  logE,
const double &  theta = 0.0,
const double &  phi = 0.0,
const double &  zenith = 0.0,
const double &  azimuth = 0.0,
const bool &  etrue = true 
) const
virtual

Return the radius that contains a fraction of the events (radians)

Parameters
[in]fractionof events (0.0-1.0)
[in]logELog10 of the true photon energy (TeV).
[in]thetaOffset angle in camera system (rad). Not used.
[in]phiAzimuth angle in camera system (rad). Not used.
[in]zenithZenith angle in Earth system (rad). Not used.
[in]azimuthAzimuth angle in Earth system (rad). Not used.
[in]etrueUse true energy (true/false). Not used.
Returns
Containment radius (radians).
Exceptions
GException::invalid_argumentInvalid fraction specified.

Calculate the radius from the center that contains 'fraction' percent of the events. fraction * 100. = Containment %.

Implements GCTAPsf.

Definition at line 543 of file GCTAPsfTable.cpp.

References GCTAResponseTable::axis_bins(), GCTAResponseTable::axis_hi(), GCTAResponseTable::axis_lo(), GCTAResponseTable::axis_nodes(), gammalib::deg2rad, G_CONTAINMENT_RADIUS, m_inx_delta, m_psf, operator()(), sin(), gammalib::str(), sum(), and gammalib::twopi.

void GCTAPsfTable::copy_members ( const GCTAPsfTable psf)
private

Copy class members.

Parameters
[in]psfPoint spread function.

Definition at line 689 of file GCTAPsfTable.cpp.

References m_delta_max, m_filename, m_inx_delta, m_inx_energy, m_inx_rpsf, m_inx_theta, m_psf, and m_psf_max.

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

double GCTAPsfTable::delta_max ( const double &  logE,
const double &  theta = 0.0,
const double &  phi = 0.0,
const double &  zenith = 0.0,
const double &  azimuth = 0.0,
const bool &  etrue = true 
) const
virtual

Return maximum size of PSF (radians)

Parameters
[in]logELog10 of the true photon energy (TeV).
[in]thetaOffset angle in camera system (rad).
[in]phiAzimuth angle in camera system (rad). Not used.
[in]zenithZenith angle in Earth system (rad). Not used.
[in]azimuthAzimuth angle in Earth system (rad). Not used.
[in]etrueUse true energy (true/false). Not used.

Returns the maximum PSF radius.

Implements GCTAPsf.

Definition at line 513 of file GCTAPsfTable.cpp.

References m_delta_max.

int GCTAPsfTable::element ( const int &  ieng,
const int &  itheta,
const int &  idelta 
)
private

Return element index.

Parameters
[in]iengEnergy index [0,...,neng-1]
[in]ithetaOffset angle index [0,...,ntheta-1]
[in]ideltaDelta angle index [0,...,ndelta-1]

Definition at line 812 of file GCTAPsfTable.cpp.

References GCTAResponseTable::axis_bins(), m_inx_delta, m_inx_energy, m_inx_theta, and m_psf.

Referenced by precompute().

GFilename GCTAPsfTable::filename ( void  ) const
inlinevirtual

Return filename.

Returns
Filename from which point spread function was loaded.

Returns filename from which point spread function was loaded.

Implements GCTAPsf.

Definition at line 149 of file GCTAPsfTable.hpp.

References m_filename.

Referenced by load().

void GCTAPsfTable::free_members ( void  )
private

Delete class members.

Definition at line 709 of file GCTAPsfTable.cpp.

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

void GCTAPsfTable::init_members ( void  )
private

Initialise class members.

Definition at line 667 of file GCTAPsfTable.cpp.

References GCTAResponseTable::clear(), GFilename::clear(), m_delta_max, m_filename, m_inx_delta, m_inx_energy, m_inx_rpsf, m_inx_theta, m_psf, and m_psf_max.

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

void GCTAPsfTable::load ( const GFilename filename)
virtual

Load point spread function from FITS file.

Parameters
[in]filenameFITS file name.

Loads the point spread function from a FITS file.

If no extension name is given the method scans the HDUCLASS keywords of all extensions and loads the background from the first extension for which HDUCLAS4=PSF_TABLE.

Otherwise, the background will be loaded from the POINT SPREAD FUNCTION extension.

Implements GCTAPsf.

Definition at line 365 of file GCTAPsfTable.cpp.

References GFits::close(), GFilename::extname(), gammalib::extname_cta_psftable, filename(), gammalib::gadf_hduclas4(), m_filename, read(), GFits::table(), and table().

Referenced by GCTAPsfTable().

double GCTAPsfTable::mc ( GRan ran,
const double &  logE,
const double &  theta = 0.0,
const double &  phi = 0.0,
const double &  zenith = 0.0,
const double &  azimuth = 0.0,
const bool &  etrue = true 
) const
virtual

Simulate PSF offset (radians)

Parameters
[in]ranRandom number generator.
[in]logELog10 of the true photon energy (TeV).
[in]thetaOffset angle in camera system (rad).
[in]phiAzimuth angle in camera system (rad). Not used.
[in]zenithZenith angle in Earth system (rad). Not used.
[in]azimuthAzimuth angle in Earth system (rad). Not used.
[in]etrueUse true energy (true/false). Not used.

Draws a random offset from the point spread function using a rejection method.

Implements GCTAPsf.

Definition at line 457 of file GCTAPsfTable.cpp.

References gammalib::acos(), cos(), m_delta_max, m_psf_max, operator()(), and GRan::uniform().

double GCTAPsfTable::operator() ( const double &  delta,
const double &  logE,
const double &  theta = 0.0,
const double &  phi = 0.0,
const double &  zenith = 0.0,
const double &  azimuth = 0.0,
const bool &  etrue = true 
) const
virtual

Return point spread function (in units of sr^-1)

Parameters
[in]deltaAngular separation between true and measured photon directions (rad).
[in]logELog10 of the true photon energy (TeV).
[in]thetaOffset angle in camera system (rad).
[in]phiAzimuth angle in camera system (rad). Not used.
[in]zenithZenith angle in Earth system (rad). Not used.
[in]azimuthAzimuth angle in Earth system (rad). Not used.
[in]etrueUse true energy (true/false). Not used.

Returns the point spread function for a given angular separation in units of sr^-1 for a given energy and offset angle. The PSF value will be determined by trilinear interpolation (and extrapolation) in the PSF histograms. If the interpolation or extrapolation would lead to negative PSF values, the value of zero is returned. A zero value is also returned if the delta angle is larger than the largest angle in the response table.

Implements GCTAPsf.

Definition at line 192 of file GCTAPsfTable.cpp.

References m_delta_max, m_inx_delta, m_inx_energy, m_inx_rpsf, m_inx_theta, and m_psf.

Referenced by containment_radius(), and mc().

GCTAPsfTable & GCTAPsfTable::operator= ( const GCTAPsfTable psf)

Assignment operator.

Parameters
[in]psfPoint spread function.
Returns
Point spread function.

Assigns point spread function.

Definition at line 148 of file GCTAPsfTable.cpp.

References copy_members(), free_members(), init_members(), and GCTAPsf::operator=().

void GCTAPsfTable::precompute ( void  )
private

Performs precomputations for point spread function.

Replaces any invalid PSF histogram by zeroes, normalises the PSF histograms to unity, and computes maximum PSF value and maximum delta value.

Definition at line 723 of file GCTAPsfTable.cpp.

References GCTAResponseTable::axis_bins(), GCTAResponseTable::axis_hi(), GCTAResponseTable::axis_lo(), GCTAResponseTable::axis_nodes(), gammalib::deg2rad, element(), GCTAResponseTable::elements(), gammalib::is_infinite(), gammalib::is_notanumber(), m_delta_max, m_inx_delta, m_inx_energy, m_inx_rpsf, m_inx_theta, m_psf, m_psf_max, sin(), sum(), and gammalib::twopi.

Referenced by read().

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

Print point spread function information.

Parameters
[in]chatterChattiness.
Returns
String containing point spread function information.

Implements GCTAPsf.

Definition at line 600 of file GCTAPsfTable.cpp.

References GCTAResponseTable::axes(), GCTAResponseTable::axis_bins(), GCTAResponseTable::axis_hi(), GCTAResponseTable::axis_lo(), m_filename, m_inx_delta, m_inx_energy, m_inx_theta, m_psf, gammalib::parformat(), SILENT, and gammalib::str().

void GCTAPsfTable::read ( const GFitsTable table)

Read point spread function from FITS table.

Parameters
[in]tableFITS table.
Exceptions
GException::invalid_valueResponse table is not three-dimensional.

Reads the point spread function form the FITS table. The following column names are mandatory:

ENERG_LO - Energy lower bin boundaries
ENERG_HI - Energy upper bin boundaries
THETA_LO - Offset angle lower bin boundaries
THETA_HI - Offset angle upper bin boundaries
RAD_LO   - Delta angle lower bin boundaries
RAD_HI   - Delta angle upper bin boundaries
RPSF     - PSF histogram

The data are stored in the m_psf member. The energy axis will be set to log10, the offset and delta angle axes to radians.

Definition at line 288 of file GCTAPsfTable.cpp.

References GCTAResponseTable::axes(), GCTAResponseTable::axis(), GCTAResponseTable::axis_log10(), GCTAResponseTable::axis_radians(), GCTAResponseTable::clear(), G_READ, m_inx_delta, m_inx_energy, m_inx_rpsf, m_inx_theta, m_psf, precompute(), GCTAResponseTable::read(), gammalib::str(), and GCTAResponseTable::table().

Referenced by load().

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

Save point spread function table into FITS file.

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

Saves point spread function into a FITS file. If a file with the given filename does not yet exist it will be created, otherwise the method opens the existing file. The method will create a (or replace an existing) point spread function extension. The extension name can be specified as part of the filename, or if no extension name is given, is assumed to be POINT SPREAD FUNCTION.

An existing file will only be modified if the clobber flag is set to true.

Definition at line 409 of file GCTAPsfTable.cpp.

References GFitsHDU::extname(), GFilename::extname(), gammalib::extname_cta_psftable, GFits::remove(), table(), GFilename::url(), and write().

const GCTAResponseTable & GCTAPsfTable::table ( void  ) const
inline

Return response table.

Returns
Response table.

Definition at line 160 of file GCTAPsfTable.hpp.

References m_psf.

Referenced by load(), save(), and table().

void GCTAPsfTable::table ( const GCTAResponseTable table)
inline

Assign response table.

Parameters
[in]tableResponse table.

Definition at line 171 of file GCTAPsfTable.hpp.

References m_psf, and table().

void GCTAPsfTable::write ( GFitsBinTable table) const

Write point spread function into FITS table.

Parameters
[in]tableFITS binary table.

Writes point spread function into a FITS binary table.

Todo:
Add keywords.

Definition at line 338 of file GCTAPsfTable.cpp.

References m_psf, and GCTAResponseTable::write().

Referenced by save().

Member Data Documentation

double GCTAPsfTable::m_delta_max
private

Maximum delta angle (radians)

Definition at line 124 of file GCTAPsfTable.hpp.

Referenced by copy_members(), delta_max(), init_members(), mc(), operator()(), and precompute().

GFilename GCTAPsfTable::m_filename
private

Name of Aeff response file.

Definition at line 118 of file GCTAPsfTable.hpp.

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

int GCTAPsfTable::m_inx_delta
private

Delta index.

Definition at line 122 of file GCTAPsfTable.hpp.

Referenced by containment_radius(), copy_members(), element(), init_members(), operator()(), precompute(), print(), and read().

int GCTAPsfTable::m_inx_energy
private

Energy index.

Definition at line 120 of file GCTAPsfTable.hpp.

Referenced by copy_members(), element(), init_members(), operator()(), precompute(), print(), and read().

int GCTAPsfTable::m_inx_rpsf
private

PSF histogram.

Definition at line 123 of file GCTAPsfTable.hpp.

Referenced by copy_members(), init_members(), operator()(), precompute(), and read().

int GCTAPsfTable::m_inx_theta
private

Theta index.

Definition at line 121 of file GCTAPsfTable.hpp.

Referenced by copy_members(), element(), init_members(), operator()(), precompute(), print(), and read().

GCTAResponseTable GCTAPsfTable::m_psf
private

PSF response table.

Definition at line 119 of file GCTAPsfTable.hpp.

Referenced by containment_radius(), copy_members(), element(), init_members(), operator()(), precompute(), print(), read(), table(), and write().

double GCTAPsfTable::m_psf_max
private

Maximum PSF value.

Definition at line 125 of file GCTAPsfTable.hpp.

Referenced by copy_members(), init_members(), mc(), and precompute().


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