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

CTA point spread function class with a King profile. More...

#include <GCTAPsfKing.hpp>

Inheritance diagram for GCTAPsfKing:
GCTAPsf GBase

Public Member Functions

 GCTAPsfKing (void)
 Void constructor. More...
 
 GCTAPsfKing (const GFilename &filename)
 File constructor. More...
 
 GCTAPsfKing (const GCTAPsfKing &psf)
 Copy constructor. More...
 
virtual ~GCTAPsfKing (void)
 Destructor. More...
 
GCTAPsfKingoperator= (const GCTAPsfKing &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...
 
GCTAPsfKingclone (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 GCTAPsfKing &psf)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
void update (const double &logE, const double &theta) const
 Update PSF parameter cache. More...
 
double r_max (const double &logE, const double &theta) const
 Return maximum size of PSF (radians) 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_gamma
 Gamma. More...
 
int m_inx_sigma
 Sigma. More...
 
double m_par_logE
 Cache energy. More...
 
double m_par_theta
 Cache offset angle. More...
 
double m_par_norm
 King profile normalization. More...
 
double m_par_sigma
 King profile sigma (radians) More...
 
double m_par_sigma2
 King profile sigma squared. More...
 
double m_par_gamma
 King profile gamma parameter. More...
 
double m_par_rmax
 Maximum PSF radius. 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 class with a King profile.

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 GCTAPsfKing.hpp.

Constructor & Destructor Documentation

GCTAPsfKing::GCTAPsfKing ( void  )

Void constructor.

Constructs empty point spread function.

Definition at line 71 of file GCTAPsfKing.cpp.

References init_members().

Referenced by clone().

GCTAPsfKing::GCTAPsfKing ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenamePSF FITS file.

Constructs point spread function from a FITS file.

Definition at line 88 of file GCTAPsfKing.cpp.

References init_members(), and load().

GCTAPsfKing::GCTAPsfKing ( const GCTAPsfKing psf)

Copy constructor.

Parameters
[in]psfPoint spread function.

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

Definition at line 109 of file GCTAPsfKing.cpp.

References copy_members(), and init_members().

GCTAPsfKing::~GCTAPsfKing ( void  )
virtual

Destructor.

Destructs point spread function.

Definition at line 127 of file GCTAPsfKing.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GCTAPsf.

Definition at line 145 of file GCTAPsfKing.hpp.

void GCTAPsfKing::clear ( void  )
virtual

Clear point spread function.

Clears point spread function.

Implements GCTAPsf.

Definition at line 244 of file GCTAPsfKing.cpp.

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

GCTAPsfKing * GCTAPsfKing::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 266 of file GCTAPsfKing.cpp.

References GCTAPsfKing().

double GCTAPsfKing::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 %. If the King profile parameters are invalid the method returns zero.

Implements GCTAPsf.

Definition at line 559 of file GCTAPsfKing.cpp.

References G_CONTAINMENT_RADIUS, m_par_gamma, m_par_norm, m_par_sigma, pow(), sqrt(), gammalib::str(), and update().

void GCTAPsfKing::copy_members ( const GCTAPsfKing psf)
private

Copy class members.

Parameters
[in]psfPoint spread function.

Definition at line 685 of file GCTAPsfKing.cpp.

References m_filename, m_inx_energy, m_inx_gamma, m_inx_sigma, m_inx_theta, m_par_gamma, m_par_logE, m_par_norm, m_par_rmax, m_par_sigma, m_par_sigma2, m_par_theta, and m_psf.

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

double GCTAPsfKing::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.

Determine the radius beyond which the PSF becomes negligible. This radius is set by this method to where the containment fraction become 99.9%. If the King profile parameters are invalid the method returns zero.

Implements GCTAPsf.

Definition at line 517 of file GCTAPsfKing.cpp.

References m_par_norm, r_max(), and update().

GFilename GCTAPsfKing::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 159 of file GCTAPsfKing.hpp.

References m_filename.

Referenced by load().

void GCTAPsfKing::free_members ( void  )
private

Delete class members.

Definition at line 710 of file GCTAPsfKing.cpp.

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

void GCTAPsfKing::init_members ( void  )
private
void GCTAPsfKing::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_KING.

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

Implements GCTAPsf.

Definition at line 372 of file GCTAPsfKing.cpp.

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

Referenced by GCTAPsfKing().

double GCTAPsfKing::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 angle for the King Profile. If the King profile parameters are invalid the method returns a zero offset angle.

Implements GCTAPsf.

Definition at line 464 of file GCTAPsfKing.cpp.

References m_par_gamma, m_par_norm, m_par_rmax, m_par_sigma, pow(), sqrt(), GRan::uniform(), and update().

double GCTAPsfKing::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. If the King profile parameters are invalid the method returns zero.

Implements GCTAPsf.

Definition at line 191 of file GCTAPsfKing.cpp.

References m_par_gamma, m_par_norm, m_par_rmax, m_par_sigma, pow(), and update().

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

Assignment operator.

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

Assigns point spread function.

Definition at line 151 of file GCTAPsfKing.cpp.

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

std::string GCTAPsfKing::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 602 of file GCTAPsfKing.cpp.

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

double GCTAPsfKing::r_max ( const double &  logE,
const double &  theta 
) const
private

Return maximum size of PSF (radians)

Parameters
[in]logELog10 of the true photon energy (TeV).
[in]thetaOffset angle in camera system (radians).
Returns
Maximum size of point spread function (radians).

Determine the radius beyond which the PSF becomes negligible. This radius is set by this method to where the containment fraction become 99.9%.

This method requires the m_par_gamma and m_par_sigma to be set to valid values. In case that the parameters lead to an infinite result the method will return a maximum size of zero.

Definition at line 813 of file GCTAPsfKing.cpp.

References gammalib::is_infinite(), m_par_gamma, m_par_sigma, pow(), and sqrt().

Referenced by delta_max(), and update().

void GCTAPsfKing::read ( const GFitsTable table)

Read point spread function from FITS table.

Parameters
[in]tableFITS table.
Exceptions
GException::invalid_valueResponse table is not two-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
GAMMA    - Gamma
SIGMA    - Sigma

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

Definition at line 293 of file GCTAPsfKing.cpp.

References GCTAResponseTable::axes(), GCTAResponseTable::axis(), GCTAResponseTable::axis_log10(), GCTAResponseTable::axis_radians(), GCTAResponseTable::clear(), gammalib::deg2rad, G_READ, m_inx_energy, m_inx_gamma, m_inx_sigma, m_inx_theta, m_psf, GCTAResponseTable::read(), GCTAResponseTable::scale(), gammalib::str(), and GCTAResponseTable::table().

Referenced by load().

void GCTAPsfKing::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 416 of file GCTAPsfKing.cpp.

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

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

Return response table.

Returns
Response table.

Definition at line 170 of file GCTAPsfKing.hpp.

References m_psf.

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

void GCTAPsfKing::table ( const GCTAResponseTable table)
inline

Assign response table.

Parameters
[in]tableResponse table.

Definition at line 181 of file GCTAPsfKing.hpp.

References m_psf, and table().

void GCTAPsfKing::update ( const double &  logE,
const double &  theta 
) const
private

Update PSF parameter cache.

Parameters
[in]logELog10 of the true photon energy (TeV).
[in]thetaOffset angle.

This method updates the PSF parameter cache. As the performance table PSF only depends on energy, the only parameter on which the cache values depend is the energy. If the PSF parameters are invalid the m_par_norm member will be set to zero. Valid PSF parameters are \(\gamma > 1\) and \(\sigma > 0\).

Definition at line 729 of file GCTAPsfKing.cpp.

References gammalib::deg2rad, m_inx_energy, m_inx_gamma, m_inx_sigma, m_par_gamma, m_par_logE, m_par_norm, m_par_rmax, m_par_sigma, m_par_sigma2, m_par_theta, m_psf, norm(), pow(), r_max(), and gammalib::twopi.

Referenced by containment_radius(), delta_max(), mc(), and operator()().

void GCTAPsfKing::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 340 of file GCTAPsfKing.cpp.

References m_inx_sigma, m_psf, gammalib::rad2deg, GCTAResponseTable::scale(), GCTAResponseTable::tables(), and GCTAResponseTable::write().

Referenced by save().

Member Data Documentation

GFilename GCTAPsfKing::m_filename
private

Name of Aeff response file.

Definition at line 121 of file GCTAPsfKing.hpp.

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

int GCTAPsfKing::m_inx_energy
private

Energy index.

Definition at line 123 of file GCTAPsfKing.hpp.

Referenced by copy_members(), init_members(), print(), read(), and update().

int GCTAPsfKing::m_inx_gamma
private

Gamma.

Definition at line 125 of file GCTAPsfKing.hpp.

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

int GCTAPsfKing::m_inx_sigma
private

Sigma.

Definition at line 126 of file GCTAPsfKing.hpp.

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

int GCTAPsfKing::m_inx_theta
private

Theta index.

Definition at line 124 of file GCTAPsfKing.hpp.

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

double GCTAPsfKing::m_par_gamma
mutableprivate

King profile gamma parameter.

Definition at line 134 of file GCTAPsfKing.hpp.

Referenced by containment_radius(), copy_members(), init_members(), mc(), operator()(), r_max(), and update().

double GCTAPsfKing::m_par_logE
mutableprivate

Cache energy.

Definition at line 129 of file GCTAPsfKing.hpp.

Referenced by copy_members(), init_members(), and update().

double GCTAPsfKing::m_par_norm
mutableprivate

King profile normalization.

Definition at line 131 of file GCTAPsfKing.hpp.

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

double GCTAPsfKing::m_par_rmax
mutableprivate

Maximum PSF radius.

Definition at line 135 of file GCTAPsfKing.hpp.

Referenced by copy_members(), init_members(), mc(), operator()(), and update().

double GCTAPsfKing::m_par_sigma
mutableprivate

King profile sigma (radians)

Definition at line 132 of file GCTAPsfKing.hpp.

Referenced by containment_radius(), copy_members(), init_members(), mc(), operator()(), r_max(), and update().

double GCTAPsfKing::m_par_sigma2
mutableprivate

King profile sigma squared.

Definition at line 133 of file GCTAPsfKing.hpp.

Referenced by copy_members(), init_members(), and update().

double GCTAPsfKing::m_par_theta
mutableprivate

Cache offset angle.

Definition at line 130 of file GCTAPsfKing.hpp.

Referenced by copy_members(), init_members(), and update().

GCTAResponseTable GCTAPsfKing::m_psf
private

PSF response table.

Definition at line 122 of file GCTAPsfKing.hpp.

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


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