GammaLib
2.0.0
|
CTA point spread function table class. More...
#include <GCTAPsfTable.hpp>
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... | |
GCTAPsfTable & | operator= (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... | |
GCTAPsfTable * | 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 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 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... | |
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.
GCTAPsfTable::GCTAPsfTable | ( | void | ) |
Void constructor.
Constructs empty point spread function.
Definition at line 68 of file GCTAPsfTable.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | PSF 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.
[in] | psf | Point 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().
|
virtual |
Destructor.
Destructs point spread function.
Definition at line 124 of file GCTAPsfTable.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GCTAPsf.
Definition at line 135 of file GCTAPsfTable.hpp.
|
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().
|
virtual |
Clone point spread functions.
Returns a pointer to a deep copy of the point spread function.
Implements GCTAPsf.
Definition at line 260 of file GCTAPsfTable.cpp.
References GCTAPsfTable().
|
virtual |
Return the radius that contains a fraction of the events (radians)
[in] | fraction | of events (0.0-1.0) |
[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. |
GException::invalid_argument | Invalid 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.
|
private |
Copy class members.
[in] | psf | Point 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=().
|
virtual |
Return maximum size of PSF (radians)
[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. |
Returns the maximum PSF radius.
Implements GCTAPsf.
Definition at line 513 of file GCTAPsfTable.cpp.
References m_delta_max.
|
private |
Return element index.
[in] | ieng | Energy index [0,...,neng-1] |
[in] | itheta | Offset angle index [0,...,ntheta-1] |
[in] | idelta | Delta 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().
|
inlinevirtual |
Return filename.
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().
|
private |
Delete class members.
Definition at line 709 of file GCTAPsfTable.cpp.
Referenced by clear(), operator=(), and ~GCTAPsfTable().
|
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=().
|
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_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().
|
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 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().
|
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). |
[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. 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.
[in] | psf | 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=().
|
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().
Print point spread function information.
[in] | chatter | Chattiness. |
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.
[in] | table | FITS table. |
GException::invalid_value | Response 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.
[in] | filename | FITS file name. |
[in] | clobber | Overwrite 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().
|
inline |
|
inline |
Assign response table.
[in] | table | Response table. |
Definition at line 171 of file GCTAPsfTable.hpp.
void GCTAPsfTable::write | ( | GFitsBinTable & | table | ) | const |
Write point spread function into FITS table.
[in] | table | FITS binary table. |
Writes point spread function into a FITS binary table
.
Definition at line 338 of file GCTAPsfTable.cpp.
References m_psf, and GCTAResponseTable::write().
Referenced by save().
|
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().
|
private |
Name of Aeff response file.
Definition at line 118 of file GCTAPsfTable.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and print().
|
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().
|
private |
Energy index.
Definition at line 120 of file GCTAPsfTable.hpp.
Referenced by copy_members(), element(), init_members(), operator()(), precompute(), print(), and read().
|
private |
PSF histogram.
Definition at line 123 of file GCTAPsfTable.hpp.
Referenced by copy_members(), init_members(), operator()(), precompute(), and read().
|
private |
Theta index.
Definition at line 121 of file GCTAPsfTable.hpp.
Referenced by copy_members(), element(), init_members(), operator()(), precompute(), print(), and read().
|
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().
|
private |
Maximum PSF value.
Definition at line 125 of file GCTAPsfTable.hpp.
Referenced by copy_members(), init_members(), mc(), and precompute().