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

CTA 2D point spread function class. More...

#include <GCTAPsf2D.hpp>

Inheritance diagram for GCTAPsf2D:
GCTAPsf GBase

Public Member Functions

 GCTAPsf2D (void)
 Void constructor. More...
 
 GCTAPsf2D (const GFilename &filename)
 File constructor. More...
 
 GCTAPsf2D (const GCTAPsf2D &psf)
 Copy constructor. More...
 
virtual ~GCTAPsf2D (void)
 Destructor. More...
 
GCTAPsf2Doperator= (const GCTAPsf2D &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...
 
GCTAPsf2Dclone (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 binary 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 GCTAPsf2D &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...
 

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_sigma1
 1st Gaussian sigma More...
 
int m_inx_ampl2
 2nd Gaussian relative amplitude More...
 
int m_inx_sigma2
 2nd Gaussian sigma More...
 
int m_inx_ampl3
 3nd Gaussian relative amplitude More...
 
int m_inx_sigma3
 3nd Gaussian sigma More...
 
double m_par_logE
 Cache energy. More...
 
double m_par_theta
 Cache offset angle. More...
 
double m_norm
 Global normalization. More...
 
double m_norm2
 Gaussian 2 normalization. More...
 
double m_norm3
 Gaussian 3 normalization. More...
 
double m_sigma1
 Gaussian 1 sigma. More...
 
double m_sigma2
 Gaussian 2 sigma. More...
 
double m_sigma3
 Gaussian 3 sigma. More...
 
double m_width1
 Gaussian 1 width. More...
 
double m_width2
 Gaussian 2 width. More...
 
double m_width3
 Gaussian 3 width. 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 2D point spread function class.

This class implements the CTA point spread function response as function of energy and offset angle.

Definition at line 54 of file GCTAPsf2D.hpp.

Constructor & Destructor Documentation

GCTAPsf2D::GCTAPsf2D ( void  )

Void constructor.

Constructs empty point spread function.

Definition at line 68 of file GCTAPsf2D.cpp.

References init_members().

Referenced by clone().

GCTAPsf2D::GCTAPsf2D ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenameFITS file name.

Constructs point spread function from a FITS file.

Definition at line 85 of file GCTAPsf2D.cpp.

References init_members(), and load().

GCTAPsf2D::GCTAPsf2D ( const GCTAPsf2D 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 GCTAPsf2D.cpp.

References copy_members(), and init_members().

GCTAPsf2D::~GCTAPsf2D ( void  )
virtual

Destructor.

Destructs point spread function.

Definition at line 124 of file GCTAPsf2D.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GCTAPsf.

Definition at line 149 of file GCTAPsf2D.hpp.

void GCTAPsf2D::clear ( void  )
virtual

Clear point spread function.

Clears point spread function.

Implements GCTAPsf.

Definition at line 259 of file GCTAPsf2D.cpp.

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

GCTAPsf2D * GCTAPsf2D::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 281 of file GCTAPsf2D.cpp.

References GCTAPsf2D().

double GCTAPsf2D::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 < fraction < 1.0)
[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
Containment radius (radians).
Exceptions
GException::invalid_argumentInvalid fraction specified.

Uses the Newton-Raphson method to find which 'a' solves the equation:

\[ fraction = m\_norm * \left( e^{m\_width1 * a^2} + m\_norm2 * e^{m\_width2 * a^2} + m\_norm3 * e^{m\_width3 * a^2} \right) \]

Calculate the radius from the center that contains fraction of the events (fraction * 100. = Containment % ). Fraction must be

\[ 0.0 < fraction < 1.0 \]

Implements GCTAPsf.

Definition at line 586 of file GCTAPsf2D.cpp.

References abs(), delta_max(), exp(), G_CONTAINMENT_RADIUS, m_norm, m_norm2, m_norm3, m_width1, m_width2, m_width3, gammalib::pi, gammalib::str(), update(), and gammalib::warning().

void GCTAPsf2D::copy_members ( const GCTAPsf2D psf)
private

Copy class members.

Parameters
[in]psfPoint spread function.

Definition at line 779 of file GCTAPsf2D.cpp.

References m_filename, m_inx_ampl2, m_inx_ampl3, m_inx_energy, m_inx_sigma1, m_inx_sigma2, m_inx_sigma3, m_inx_theta, m_norm, m_norm2, m_norm3, m_par_logE, m_par_theta, m_psf, m_sigma1, m_sigma2, m_sigma3, m_width1, m_width2, and m_width3.

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

double GCTAPsf2D::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). 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.

Determine the radius beyond which the PSF becomes negligible. This radius is set by this method to \(5 \times \sigma\), where \(\sigma\) is the Gaussian width of the largest PSF component.

Implements GCTAPsf.

Definition at line 531 of file GCTAPsf2D.cpp.

References m_sigma1, m_sigma2, m_sigma3, and update().

Referenced by containment_radius().

GFilename GCTAPsf2D::filename ( void  ) const
inlinevirtual

Return filename.

Returns
Returns filename from which point spread function was loaded

Implements GCTAPsf.

Definition at line 161 of file GCTAPsf2D.hpp.

References m_filename.

Referenced by load().

void GCTAPsf2D::free_members ( void  )
private

Delete class members.

Definition at line 811 of file GCTAPsf2D.cpp.

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

void GCTAPsf2D::init_members ( void  )
private
void GCTAPsf2D::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_3GAUSS.

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

Implements GCTAPsf.

Definition at line 397 of file GCTAPsf2D.cpp.

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

Referenced by GCTAPsf2D().

double GCTAPsf2D::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 for a three component Gaussian PSF.

Implements GCTAPsf.

Definition at line 484 of file GCTAPsf2D.cpp.

References GRan::chisq2(), m_norm2, m_norm3, m_sigma1, m_sigma2, m_sigma3, sum(), GRan::uniform(), and update().

double GCTAPsf2D::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). Defaults to 0.0.
[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.

Implements GCTAPsf.

Definition at line 187 of file GCTAPsf2D.cpp.

References exp(), m_norm, m_norm2, m_norm3, m_width1, m_width2, m_width3, and update().

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

Assignment operator.

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

Assigns point spread function.

Definition at line 148 of file GCTAPsf2D.cpp.

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

std::string GCTAPsf2D::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 689 of file GCTAPsf2D.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().

void GCTAPsf2D::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
SIGMA_1  - 1st Gaussian sigma
AMPL_2   - 2nd Gaussian relative amplitude
SIGMA_2  - 2nd Gaussian sigma
AMPL_3   - 3rd Gaussian relative amplitude
SIGMA_3  - 3rd Gaussian 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 311 of file GCTAPsf2D.cpp.

References GCTAResponseTable::axes(), GCTAResponseTable::axis(), GCTAResponseTable::axis_log10(), GCTAResponseTable::axis_radians(), GCTAResponseTable::clear(), gammalib::deg2rad, G_READ, m_inx_ampl2, m_inx_ampl3, m_inx_energy, m_inx_sigma1, m_inx_sigma2, m_inx_sigma3, m_inx_theta, m_psf, GCTAResponseTable::read(), GCTAResponseTable::scale(), gammalib::str(), and GCTAResponseTable::table().

Referenced by load().

void GCTAPsf2D::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?

Save the point spread function into a FITS file.

If no extension name is provided, the point spread function will be saved into the POINT SPREAD FUNCTION extension.

Definition at line 437 of file GCTAPsf2D.cpp.

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

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

Return response table.

Returns
Response table.

Definition at line 172 of file GCTAPsf2D.hpp.

References m_psf.

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

void GCTAPsf2D::table ( const GCTAResponseTable table)
inline

Assign response table.

Parameters
[in]tableResponse table.

Definition at line 183 of file GCTAPsf2D.hpp.

References m_psf, and table().

void GCTAPsf2D::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 in camera system (rad).

This method updates the PSF parameter cache.

Definition at line 826 of file GCTAPsf2D.cpp.

References m_inx_ampl2, m_inx_ampl3, m_inx_energy, m_inx_sigma1, m_inx_sigma2, m_inx_sigma3, m_norm, m_norm2, m_norm3, m_par_logE, m_par_theta, m_psf, m_sigma1, m_sigma2, m_sigma3, m_width1, m_width2, m_width3, and gammalib::twopi.

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

void GCTAPsf2D::write ( GFitsBinTable table) const

Write point spread function into FITS binary table.

Parameters
[in]tableFITS binary table.

Writes point spread function into FITS binary table.

Todo:
Add necessary keywords.

Definition at line 363 of file GCTAPsf2D.cpp.

References m_inx_sigma1, m_inx_sigma2, m_inx_sigma3, m_psf, gammalib::rad2deg, GCTAResponseTable::scale(), GCTAResponseTable::tables(), and GCTAResponseTable::write().

Referenced by save().

Member Data Documentation

GFilename GCTAPsf2D::m_filename
private

Name of Aeff response file.

Definition at line 118 of file GCTAPsf2D.hpp.

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

int GCTAPsf2D::m_inx_ampl2
private

2nd Gaussian relative amplitude

Definition at line 123 of file GCTAPsf2D.hpp.

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

int GCTAPsf2D::m_inx_ampl3
private

3nd Gaussian relative amplitude

Definition at line 125 of file GCTAPsf2D.hpp.

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

int GCTAPsf2D::m_inx_energy
private

Energy index.

Definition at line 120 of file GCTAPsf2D.hpp.

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

int GCTAPsf2D::m_inx_sigma1
private

1st Gaussian sigma

Definition at line 122 of file GCTAPsf2D.hpp.

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

int GCTAPsf2D::m_inx_sigma2
private

2nd Gaussian sigma

Definition at line 124 of file GCTAPsf2D.hpp.

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

int GCTAPsf2D::m_inx_sigma3
private

3nd Gaussian sigma

Definition at line 126 of file GCTAPsf2D.hpp.

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

int GCTAPsf2D::m_inx_theta
private

Theta index.

Definition at line 121 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_norm
mutableprivate

Global normalization.

Definition at line 131 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_norm2
mutableprivate

Gaussian 2 normalization.

Definition at line 132 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_norm3
mutableprivate

Gaussian 3 normalization.

Definition at line 133 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_par_logE
mutableprivate

Cache energy.

Definition at line 129 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_par_theta
mutableprivate

Cache offset angle.

Definition at line 130 of file GCTAPsf2D.hpp.

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

GCTAResponseTable GCTAPsf2D::m_psf
private

PSF response table.

Definition at line 119 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_sigma1
mutableprivate

Gaussian 1 sigma.

Definition at line 134 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_sigma2
mutableprivate

Gaussian 2 sigma.

Definition at line 135 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_sigma3
mutableprivate

Gaussian 3 sigma.

Definition at line 136 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_width1
mutableprivate

Gaussian 1 width.

Definition at line 137 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_width2
mutableprivate

Gaussian 2 width.

Definition at line 138 of file GCTAPsf2D.hpp.

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

double GCTAPsf2D::m_width3
mutableprivate

Gaussian 3 width.

Definition at line 139 of file GCTAPsf2D.hpp.

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


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