GammaLib
2.0.0
|
CTA point spread function class with a King profile. More...
#include <GCTAPsfKing.hpp>
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... | |
GCTAPsfKing & | operator= (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... | |
GCTAPsfKing * | 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 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... | |
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.
GCTAPsfKing::GCTAPsfKing | ( | void | ) |
Void constructor.
Constructs empty point spread function.
Definition at line 71 of file GCTAPsfKing.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 88 of file GCTAPsfKing.cpp.
References init_members(), and load().
GCTAPsfKing::GCTAPsfKing | ( | const GCTAPsfKing & | psf | ) |
Copy constructor.
[in] | psf | Point 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().
|
virtual |
Destructor.
Destructs point spread function.
Definition at line 127 of file GCTAPsfKing.cpp.
References free_members().
|
inlinevirtual |
Return class name.
Implements GCTAPsf.
Definition at line 145 of file GCTAPsfKing.hpp.
|
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().
|
virtual |
Clone point spread functions.
Returns a pointer to a deep copy of the point spread function.
Implements GCTAPsf.
Definition at line 266 of file GCTAPsfKing.cpp.
References GCTAPsfKing().
|
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 %. 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().
|
private |
Copy class members.
[in] | psf | Point 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=().
|
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. |
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().
|
inlinevirtual |
Return filename.
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().
|
private |
Delete class members.
Definition at line 710 of file GCTAPsfKing.cpp.
Referenced by clear(), operator=(), and ~GCTAPsfKing().
|
private |
Initialise class members.
Definition at line 658 of file GCTAPsfKing.cpp.
References GCTAResponseTable::clear(), GFilename::clear(), 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 clear(), GCTAPsfKing(), 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_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().
|
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 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().
|
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. 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.
[in] | psf | 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=().
Print point spread function information.
[in] | chatter | Chattiness. |
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().
|
private |
Return maximum size of PSF (radians)
[in] | logE | Log10 of the true photon energy (TeV). |
[in] | theta | Offset angle in camera system (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.
[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 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.
[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 416 of file GCTAPsfKing.cpp.
References GFitsHDU::extname(), GFilename::extname(), gammalib::extname_cta_psfking, GFits::remove(), table(), GFilename::url(), and write().
|
inline |
|
inline |
Assign response table.
[in] | table | Response table. |
Definition at line 181 of file GCTAPsfKing.hpp.
|
private |
Update PSF parameter cache.
[in] | logE | Log10 of the true photon energy (TeV). |
[in] | theta | Offset 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.
[in] | table | FITS binary table. |
Writes point spread function into a FITS binary table
.
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().
|
private |
Name of Aeff response file.
Definition at line 121 of file GCTAPsfKing.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and print().
|
private |
Energy index.
Definition at line 123 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), print(), read(), and update().
|
private |
Gamma.
Definition at line 125 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), read(), and update().
|
private |
Sigma.
Definition at line 126 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), read(), update(), and write().
|
private |
Theta index.
Definition at line 124 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), print(), and read().
|
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().
|
mutableprivate |
Cache energy.
Definition at line 129 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), and update().
|
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().
|
mutableprivate |
Maximum PSF radius.
Definition at line 135 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), mc(), operator()(), and update().
|
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().
|
mutableprivate |
King profile sigma squared.
Definition at line 133 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), and update().
|
mutableprivate |
Cache offset angle.
Definition at line 130 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), and update().
|
private |
PSF response table.
Definition at line 122 of file GCTAPsfKing.hpp.
Referenced by copy_members(), init_members(), print(), read(), table(), update(), and write().