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

Fermi/LAT point spread function version 3 class. More...

#include <GLATPsfV3.hpp>

Inheritance diagram for GLATPsfV3:
GLATPsfBase GBase

Classes

class  base_integrand
 

Public Member Functions

 GLATPsfV3 (void)
 Void constructor. More...
 
 GLATPsfV3 (const GLATPsfV3 &psf)
 Copy constructor. More...
 
virtual ~GLATPsfV3 (void)
 Destructor. More...
 
GLATPsfV3operator= (const GLATPsfV3 &psf)
 Assignment operator. More...
 
void clear (void)
 Clear point spread function. More...
 
GLATPsfV3clone (void) const
 Clone point spread function. More...
 
std::string classname (void) const
 Return class name. More...
 
void read (const GFitsTable &table)
 Read point spread function from FITS table. More...
 
void write (GFits &file) const
 Write point spread function into FITS file. More...
 
double psf (const double &offset, const double &logE, const double &ctheta)
 Return point spread function value. More...
 
int version (void) const
 Return point spread function version number. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print point spread function. More...
 
- Public Member Functions inherited from GLATPsfBase
 GLATPsfBase (void)
 Void constructor. More...
 
 GLATPsfBase (const GLATPsfBase &psf)
 Copy constructor. More...
 
virtual ~GLATPsfBase (void)
 Destructor. More...
 
GLATPsfBaseoperator= (const GLATPsfBase &psf)
 Assignment operator. More...
 
void read_scale (const GFitsTable &hdu)
 Read PSF scale factors from FITS table. More...
 
void write_scale (GFits &file) const
 Write PSF scale factors. More...
 
int size (void) const
 Return number of bins in point spread function. More...
 
int nenergies (void) const
 Return number of energies in point spread function. More...
 
int ncostheta (void) const
 Return number of cosine theta bins in point spread function. More...
 
const double & costhetamin (void) const
 Return cosine theta minimum. More...
 
void costhetamin (const double &ctheta)
 Set minimum cos(theta) angle for point spread function. More...
 
bool has_phi (void) const
 Signal that point spread function has Phi dependence. More...
 
const bool & front (void) const
 Signal that point spread function is for front section. More...
 
void front (const bool &front)
 Set if point spread function is for front section. More...
 
const double & scale_par1 (void) const
 Return first scaling parameter. More...
 
const double & scale_par2 (void) const
 Return second scaling parameter. More...
 
const double & scale_index (void) const
 Return scaling index. 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 GLATPsfV3 &psf)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
double eval_psf (const double &offset, const double &energy, const int &index)
 Evaluate PSF for a specific set of parameters. More...
 
double integrate_psf (const double &energy, const int &index)
 Integrates PSF for a specific set of parameters. More...
 
void normalize_psf (void)
 Normalize PSF for all parameters. More...
 

Static Private Member Functions

static double base_fct (const double &u, const double &gamma)
 Return point spread base function value. More...
 
static double base_int (const double &u, const double &gamma)
 Return approximation of point spread base function integral. More...
 

Private Attributes

std::vector< double > m_ncore
 PSF ncore parameter. More...
 
std::vector< double > m_ntail
 PSF ntail parameter. More...
 
std::vector< double > m_score
 PSF score parameter. More...
 
std::vector< double > m_stail
 PSF stail parameter. More...
 
std::vector< double > m_gcore
 PSF gcore parameter. More...
 
std::vector< double > m_gtail
 PSF gtail parameter. More...
 

Additional Inherited Members

- Protected Member Functions inherited from GLATPsfBase
void init_members (void)
 Initialise class members. More...
 
void copy_members (const GLATPsfBase &psf)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
double scale_factor (const double &energy) const
 Return scale factor for energy (in MeV) More...
 
- Protected Attributes inherited from GLATPsfBase
bool m_front
 PSF is for front section? More...
 
GLATResponseTable m_rpsf_bins
 PSF energy and cos theta binning. More...
 
double m_scale_par1
 PSF scaling parameter 1. More...
 
double m_scale_par2
 PSF scaling parameter 2. More...
 
double m_scale_index
 PSF scaling index. More...
 
double m_min_ctheta
 Minimum valid cos(theta) More...
 

Detailed Description

Fermi/LAT point spread function version 3 class.

Version 3 of the Fermi/LAT PSF is the sum of two King model functions. In contrast to version 2, this class interpolates the distributions rather than the parameters.

This class has been inspired by code from the Fermi/LAT ScienceTools. For comparison check the file irfs/latResponse/src/Psf3.h

Definition at line 51 of file GLATPsfV3.hpp.

Constructor & Destructor Documentation

GLATPsfV3::GLATPsfV3 ( void  )

Void constructor.

Definition at line 61 of file GLATPsfV3.cpp.

References init_members().

Referenced by clone().

GLATPsfV3::GLATPsfV3 ( const GLATPsfV3 psf)

Copy constructor.

Parameters
[in]psfPoint spread function.

Definition at line 76 of file GLATPsfV3.cpp.

References copy_members(), and init_members().

GLATPsfV3::~GLATPsfV3 ( void  )
virtual

Destructor.

Definition at line 92 of file GLATPsfV3.cpp.

References free_members().

Member Function Documentation

double GLATPsfV3::base_fct ( const double &  u,
const double &  gamma 
)
staticprivate

Return point spread base function value.

Parameters
[in]uFunction argument.
[in]gammaIndex.

The version 3 PSF base function is given by

\[\left(1 - \frac{1}{\Gamma} \right) \left(1 + \frac{u}{\Gamma} \right)^{-\Gamma}\]

Definition at line 507 of file GLATPsfV3.cpp.

References pow().

Referenced by GLATPsfV3::base_integrand::eval(), and eval_psf().

double GLATPsfV3::base_int ( const double &  u,
const double &  gamma 
)
staticprivate

Return approximation of point spread base function integral.

Parameters
[in]uFunction argument.
[in]gammaIndex.

The version 3 PSF base function integral is approximated by

\[1 - \left(1 + \frac{u}{\Gamma} \right)^{1-\Gamma}\]

which is valid for small angles \(u\). For larger angles a numerical integration of the base function has to be performed.

Todo:
Verify that 1+u/gamma is not negative

Definition at line 534 of file GLATPsfV3.cpp.

References pow().

Referenced by integrate_psf().

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

Return class name.

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

Implements GLATPsfBase.

Definition at line 130 of file GLATPsfV3.hpp.

void GLATPsfV3::clear ( void  )
virtual

Clear point spread function.

Implements GLATPsfBase.

Definition at line 147 of file GLATPsfV3.cpp.

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

GLATPsfV3 * GLATPsfV3::clone ( void  ) const
virtual

Clone point spread function.

Returns
Pointer to deep copy of point spread function

Implements GLATPsfBase.

Definition at line 167 of file GLATPsfV3.cpp.

References GLATPsfV3().

void GLATPsfV3::copy_members ( const GLATPsfV3 psf)
private

Copy class members.

Parameters
[in]psfPoint spread function.

Definition at line 472 of file GLATPsfV3.cpp.

References m_gcore, m_gtail, m_ncore, m_ntail, m_score, and m_stail.

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

double GLATPsfV3::eval_psf ( const double &  offset,
const double &  energy,
const int &  index 
)
private

Evaluate PSF for a specific set of parameters.

Parameters
[in]offsetOffset angle (radians).
[in]energyEnergy (MeV).
[in]indexParameter array index.

Evaluates PSF as function of offset angle and energy for a specific set of PSF parameters. The parameter set that is used is specified by the index parameter. The energy parameter only serves to scale the score and stail parameters of the PSF.

This method is inspired from the Fermi/LAT Science Tools method Psf3::evaluate.

Definition at line 559 of file GLATPsfV3.cpp.

References base_fct(), m_gcore, m_gtail, m_ncore, m_ntail, m_score, m_stail, psf(), and GLATPsfBase::scale_factor().

Referenced by psf().

void GLATPsfV3::free_members ( void  )
private

Delete class members.

Definition at line 490 of file GLATPsfV3.cpp.

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

void GLATPsfV3::init_members ( void  )
private

Initialise class members.

Definition at line 452 of file GLATPsfV3.cpp.

References m_gcore, m_gtail, m_ncore, m_ntail, m_score, and m_stail.

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

double GLATPsfV3::integrate_psf ( const double &  energy,
const int &  index 
)
private

Integrates PSF for a specific set of parameters.

Parameters
[in]energyEnergy (MeV).
[in]indexParameter array index.

Integrates PSF for a specific set of parameters.

Compile option G_APPROXIMATE_PSF_INTEGRAL: If defined, a numerical PSF integral is only performed for energies < 120 MeV, while for larger energies the small angle approximation is used. In not defined, a numerical PSF integral is performed for all energies. This option is kept for comparison with the Fermi/LAT ScienceTools who select the integration method based on the true photon energy. As the normalization is only performed once upon loading of the PSF, CPU time is not really an issue here, and we can afford the more precise numerical integration. Note that the uncertainties of the approximation at energies near to 120 MeV reaches 0.1%.

Todo:
Implement gcore and gtail checking

Definition at line 609 of file GLATPsfV3.cpp.

References base_int(), m_gcore, m_gtail, m_ncore, m_ntail, m_score, m_stail, gammalib::pihalf, psf(), GIntegral::romberg(), GLATPsfBase::scale_factor(), and gammalib::twopi.

Referenced by normalize_psf().

void GLATPsfV3::normalize_psf ( void  )
private

Normalize PSF for all parameters.

Makes sure that PSF is normalized for all parameters. We assure this by looping over all parameter nodes, integrating the PSF for each set of parameters, and dividing the NCORE parameter by the integral.

Compile option G_CHECK_PSF_NORM: If defined, checks that the PSF is normalized correctly.

Definition at line 679 of file GLATPsfV3.cpp.

References GLATResponseTable::costheta_lo(), GLATResponseTable::energy(), GLATResponseTable::index(), integrate_psf(), m_gcore, m_gtail, m_ncore, m_ntail, GLATPsfBase::m_rpsf_bins, m_score, m_stail, GLATResponseTable::ncostheta(), GLATResponseTable::nenergies(), norm(), gammalib::pihalf, GIntegral::romberg(), GLATPsfBase::scale_factor(), sum(), and gammalib::twopi.

Referenced by read().

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

Assignment operator.

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

Definition at line 114 of file GLATPsfV3.cpp.

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

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

Print point spread function.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
String containing point spread function information.

Implements GLATPsfBase.

Definition at line 425 of file GLATPsfV3.cpp.

References SILENT.

double GLATPsfV3::psf ( const double &  offset,
const double &  logE,
const double &  ctheta 
)
virtual

Return point spread function value.

Parameters
[in]offsetOffset angle (deg).
[in]logELog10 of the true photon energy (MeV).
[in]cthetaCosine of zenith angle.

Evaluates point spread function by doing a bi-linear interpolation of PSF values obtained at the 4 corners that bound the specified energy and cos(theta) value.

This method is inspired by the Fermi/LAT Science Tools method Psf3::value.

Implements GLATPsfBase.

Definition at line 382 of file GLATPsfV3.cpp.

References gammalib::deg2rad, GLATResponseTable::energies(), eval_psf(), GLATResponseTable::indices(), GLATPsfBase::m_min_ctheta, GLATPsfBase::m_rpsf_bins, GLATResponseTable::set(), and GLATResponseTable::weights().

Referenced by eval_psf(), and integrate_psf().

void GLATPsfV3::read ( const GFitsTable table)
virtual

Read point spread function from FITS table.

Parameters
[in]tableFITS table.
Exceptions
GException::invalid_argumentInconsistent response table encountered

Reads point spread function information from FITS HDU. In addition to the energy and costheta binning information, 6 columns are expected: NCORE, NTAIL, SCORE, STAIL, GCORE, and GTAIL.

The method assures that NCORE is set properly for each energy and cos(theta) bin so that the integral over the PSF amount to unity. This normalization is done by the method normalize_psf.

Implements GLATPsfBase.

Definition at line 189 of file GLATPsfV3.cpp.

References GLATResponseTable::costheta_lo(), G_READ, m_gcore, m_gtail, GLATPsfBase::m_min_ctheta, m_ncore, m_ntail, GLATPsfBase::m_rpsf_bins, m_score, m_stail, normalize_psf(), GFitsTableCol::number(), GLATResponseTable::read(), GFitsTableCol::real(), GLATPsfBase::size(), GLATResponseTable::size(), and gammalib::str().

int GLATPsfV3::version ( void  ) const
inlinevirtual

Return point spread function version number.

Returns
Point spread function version number (3).

Implements GLATPsfBase.

Definition at line 142 of file GLATPsfV3.hpp.

void GLATPsfV3::write ( GFits file) const
virtual

Write point spread function into FITS file.

Parameters
[in]fileFITS file.

Writes the PSF into the extension "RPSF" of a FITS file. This method does not check if a "RPSF" extension exists so far, it simply adds one each time it is called.

Nothing is done if the PSF size is 0.

Todo:
Check if a RPSF extension exists already in FITS file

Implements GLATPsfBase.

Definition at line 308 of file GLATPsfV3.cpp.

References GFitsTable::append(), GFits::append(), GFitsHDU::card(), GFitsHDU::extname(), GLATPsfBase::front(), m_gcore, m_gtail, m_ncore, m_ntail, GLATPsfBase::m_rpsf_bins, m_score, m_stail, GLATPsfBase::size(), GLATResponseTable::size(), and GLATResponseTable::write().

Member Data Documentation

std::vector<double> GLATPsfV3::m_gcore
private

PSF gcore parameter.

Definition at line 119 of file GLATPsfV3.hpp.

Referenced by copy_members(), eval_psf(), init_members(), integrate_psf(), normalize_psf(), read(), and write().

std::vector<double> GLATPsfV3::m_gtail
private

PSF gtail parameter.

Definition at line 120 of file GLATPsfV3.hpp.

Referenced by copy_members(), eval_psf(), init_members(), integrate_psf(), normalize_psf(), read(), and write().

std::vector<double> GLATPsfV3::m_ncore
private

PSF ncore parameter.

Definition at line 115 of file GLATPsfV3.hpp.

Referenced by copy_members(), eval_psf(), init_members(), integrate_psf(), normalize_psf(), read(), and write().

std::vector<double> GLATPsfV3::m_ntail
private

PSF ntail parameter.

Definition at line 116 of file GLATPsfV3.hpp.

Referenced by copy_members(), eval_psf(), init_members(), integrate_psf(), normalize_psf(), read(), and write().

std::vector<double> GLATPsfV3::m_score
private

PSF score parameter.

Definition at line 117 of file GLATPsfV3.hpp.

Referenced by copy_members(), eval_psf(), init_members(), integrate_psf(), normalize_psf(), read(), and write().

std::vector<double> GLATPsfV3::m_stail
private

PSF stail parameter.

Definition at line 118 of file GLATPsfV3.hpp.

Referenced by copy_members(), eval_psf(), init_members(), integrate_psf(), normalize_psf(), read(), and write().


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