GammaLib
2.1.0.dev
|
CTA 2D point spread function class. More...
#include <GCTAPsf2D.hpp>
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... | |
GCTAPsf2D & | operator= (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... | |
GCTAPsf2D * | clone (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 GCTAResponseTable & | table (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... | |
GCTAPsf & | operator= (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... | |
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.
GCTAPsf2D::GCTAPsf2D | ( | void | ) |
Void constructor.
Constructs empty point spread function.
Definition at line 68 of file GCTAPsf2D.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | FITS 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.
[in] | psf | Point 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().
|
virtual |
Destructor.
Destructs point spread function.
Definition at line 124 of file GCTAPsf2D.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GCTAPsf.
Definition at line 149 of file GCTAPsf2D.hpp.
|
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().
|
virtual |
Clone point spread functions.
Returns a pointer to a deep copy of the point spread function.
Implements GCTAPsf.
Definition at line 281 of file GCTAPsf2D.cpp.
References GCTAPsf2D().
|
virtual |
Return the radius that contains a fraction of the events (radians)
[in] | fraction | of events (0.0 < fraction < 1.0) |
[in] | logE | Log10 of the true photon energy (TeV). |
[in] | theta | Offset angle in camera system (rad). |
[in] | phi | Azimuth angle in camera system (rad). Not used. |
[in] | zenith | Zenith angle in Earth system (rad). Not used. |
[in] | azimuth | Azimuth angle in Earth system (rad). Not used. |
[in] | etrue | Use true energy (true/false). Not used. |
GException::invalid_argument | Invalid 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().
|
private |
Copy class members.
[in] | psf | Point 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=().
|
virtual |
Return maximum size of PSF (radians)
[in] | logE | Log10 of the true photon energy (TeV). |
[in] | theta | Offset angle in camera system (rad). Not used. |
[in] | phi | Azimuth angle in camera system (rad). Not used. |
[in] | zenith | Zenith angle in Earth system (rad). Not used. |
[in] | azimuth | Azimuth angle in Earth system (rad). Not used. |
[in] | etrue | Use 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().
|
inlinevirtual |
Return filename.
Implements GCTAPsf.
Definition at line 161 of file GCTAPsf2D.hpp.
References m_filename.
Referenced by load().
|
private |
Delete class members.
Definition at line 811 of file GCTAPsf2D.cpp.
Referenced by clear(), operator=(), and ~GCTAPsf2D().
|
private |
Initialise class members.
Definition at line 745 of file GCTAPsf2D.cpp.
References GCTAResponseTable::clear(), GFilename::clear(), 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 clear(), GCTAPsf2D(), and operator=().
|
virtual |
Load point spread function from FITS file.
[in] | filename | FITS 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().
|
virtual |
Simulate PSF offset (radians)
[in] | ran | Random number generator. |
[in] | logE | Log10 of the true photon energy (TeV). |
[in] | theta | Offset angle in camera system (rad). |
[in] | phi | Azimuth angle in camera system (rad). Not used. |
[in] | zenith | Zenith angle in Earth system (rad). Not used. |
[in] | azimuth | Azimuth angle in Earth system (rad). Not used. |
[in] | etrue | Use 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().
|
virtual |
Return point spread function (in units of sr^-1)
[in] | delta | Angular separation between true and measured photon directions (rad). |
[in] | logE | Log10 of the true photon energy (TeV). |
[in] | theta | Offset angle in camera system (rad). Defaults to 0.0. |
[in] | phi | Azimuth angle in camera system (rad). Not used. |
[in] | zenith | Zenith angle in Earth system (rad). Not used. |
[in] | azimuth | Azimuth angle in Earth system (rad). Not used. |
[in] | etrue | Use 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().
Assignment operator.
[in] | psf | 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=().
Print point spread function information.
[in] | chatter | Chattiness. |
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.
[in] | table | FITS table. |
GException::invalid_value | Response 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.
[in] | filename | FITS file name. |
[in] | clobber | Overwrite 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().
|
inline |
|
inline |
Assign response table.
[in] | table | Response table. |
Definition at line 183 of file GCTAPsf2D.hpp.
|
private |
Update PSF parameter cache.
[in] | logE | Log10 of the true photon energy (TeV). |
[in] | theta | Offset 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.
[in] | table | FITS binary table. |
Writes point spread function into FITS binary table
.
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().
|
private |
Name of Aeff response file.
Definition at line 118 of file GCTAPsf2D.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and print().
|
private |
2nd Gaussian relative amplitude
Definition at line 123 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), read(), and update().
|
private |
3nd Gaussian relative amplitude
Definition at line 125 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), read(), and update().
|
private |
Energy index.
Definition at line 120 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), print(), read(), and update().
|
private |
1st Gaussian sigma
Definition at line 122 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), read(), update(), and write().
|
private |
2nd Gaussian sigma
Definition at line 124 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), read(), update(), and write().
|
private |
3nd Gaussian sigma
Definition at line 126 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), read(), update(), and write().
|
private |
Theta index.
Definition at line 121 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), print(), and read().
|
mutableprivate |
Global normalization.
Definition at line 131 of file GCTAPsf2D.hpp.
Referenced by containment_radius(), copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Gaussian 2 normalization.
Definition at line 132 of file GCTAPsf2D.hpp.
Referenced by containment_radius(), copy_members(), init_members(), mc(), operator()(), and update().
|
mutableprivate |
Gaussian 3 normalization.
Definition at line 133 of file GCTAPsf2D.hpp.
Referenced by containment_radius(), copy_members(), init_members(), mc(), operator()(), and update().
|
mutableprivate |
Cache energy.
Definition at line 129 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprivate |
Cache offset angle.
Definition at line 130 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), and update().
|
private |
PSF response table.
Definition at line 119 of file GCTAPsf2D.hpp.
Referenced by copy_members(), init_members(), print(), read(), table(), update(), and write().
|
mutableprivate |
Gaussian 1 sigma.
Definition at line 134 of file GCTAPsf2D.hpp.
Referenced by copy_members(), delta_max(), init_members(), mc(), and update().
|
mutableprivate |
Gaussian 2 sigma.
Definition at line 135 of file GCTAPsf2D.hpp.
Referenced by copy_members(), delta_max(), init_members(), mc(), and update().
|
mutableprivate |
Gaussian 3 sigma.
Definition at line 136 of file GCTAPsf2D.hpp.
Referenced by copy_members(), delta_max(), init_members(), mc(), and update().
|
mutableprivate |
Gaussian 1 width.
Definition at line 137 of file GCTAPsf2D.hpp.
Referenced by containment_radius(), copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Gaussian 2 width.
Definition at line 138 of file GCTAPsf2D.hpp.
Referenced by containment_radius(), copy_members(), init_members(), operator()(), and update().
|
mutableprivate |
Gaussian 3 width.
Definition at line 139 of file GCTAPsf2D.hpp.
Referenced by containment_radius(), copy_members(), init_members(), operator()(), and update().