GammaLib
2.1.0.dev
|
CTA performance table background class. More...
#include <GCTABackgroundPerfTable.hpp>
Classes | |
class | integrand |
Public Member Functions | |
GCTABackgroundPerfTable (void) | |
Void constructor. More... | |
GCTABackgroundPerfTable (const GFilename &filename) | |
File constructor. More... | |
GCTABackgroundPerfTable (const GCTABackgroundPerfTable &bgd) | |
Copy constructor. More... | |
virtual | ~GCTABackgroundPerfTable (void) |
Destructor. More... | |
virtual double | operator() (const double &logE, const double &detx, const double &dety) const |
Return background rate in units of events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\). More... | |
GCTABackgroundPerfTable & | operator= (const GCTABackgroundPerfTable &bgd) |
Assignment operator. More... | |
void | clear (void) |
Clear background. More... | |
GCTABackgroundPerfTable * | clone (void) const |
Clone background. More... | |
std::string | classname (void) const |
Return class name. More... | |
void | load (const GFilename &filename) |
Load background from performance table. More... | |
GFilename | filename (void) const |
Return filename. More... | |
GCTAInstDir | mc (const GEnergy &energy, const GTime &time, GRan &ran) const |
Returns MC instrument direction. More... | |
const GModelSpectralNodes & | spectrum (void) const |
Get response cube spectrum. More... | |
double | rate_ebin (const GCTAInstDir &dir, const GEnergy &emin, const GEnergy &emax) const |
Returns background rate integrated over energy interval in units of events s \(^{-1}\) sr \(^{-1}\). More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print background information. More... | |
int | size (void) const |
Return number of node energies in response. More... | |
void | sigma (const double &sigma) |
Set sigma for offset angle dependence. More... | |
const double & | sigma (void) const |
Return sigma for offset angle dependence. More... | |
Public Member Functions inherited from GCTABackground | |
GCTABackground (void) | |
Void constructor. More... | |
GCTABackground (const GCTABackground &bgd) | |
Copy constructor. More... | |
virtual | ~GCTABackground (void) |
Destructor. More... | |
GCTABackground & | operator= (const GCTABackground &bgd) |
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 GCTABackgroundPerfTable &bgd) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
double | solidangle (void) const |
Returns integral over radial model (in steradians) More... | |
void | init_mc_cache (void) const |
Initialise Monte Carlo cache. More... | |
double | rate (const double &logE) const |
Return background rate for a given energy (events/s/MeV/sr) More... | |
Private Attributes | |
GFilename | m_filename |
Name of background response file. More... | |
GEnergies | m_energy |
Vector of energies. More... | |
GNodeArray | m_log10_energy |
log10(E) nodes for background interpolation More... | |
std::vector< double > | m_background |
Background rate. More... | |
std::vector< double > | m_log_background |
log(background rate) More... | |
double | m_sigma |
Sigma for offset angle computation (0=none) More... | |
GModelSpectralNodes | m_mc_spectrum |
Background spectrum. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from GCTABackground | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GCTABackground &bgd) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
CTA performance table background class.
Definition at line 47 of file GCTABackgroundPerfTable.hpp.
GCTABackgroundPerfTable::GCTABackgroundPerfTable | ( | void | ) |
Void constructor.
Definition at line 63 of file GCTABackgroundPerfTable.cpp.
References init_members().
Referenced by clone().
|
explicit |
File constructor.
[in] | filename | Performance table file name. |
Construct instance by loading the background information from a performance table.
Definition at line 81 of file GCTABackgroundPerfTable.cpp.
References init_members(), and load().
GCTABackgroundPerfTable::GCTABackgroundPerfTable | ( | const GCTABackgroundPerfTable & | bgd | ) |
Copy constructor.
[in] | bgd | Background. |
Definition at line 100 of file GCTABackgroundPerfTable.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GCTABackground.
Definition at line 127 of file GCTABackgroundPerfTable.hpp.
|
virtual |
Clear background.
This method properly resets the background to an initial state.
Implements GCTABackground.
Definition at line 210 of file GCTABackgroundPerfTable.cpp.
References GCTABackground::free_members(), free_members(), GCTABackground::init_members(), and init_members().
|
virtual |
Clone background.
Implements GCTABackground.
Definition at line 230 of file GCTABackgroundPerfTable.cpp.
References GCTABackgroundPerfTable().
|
private |
Copy class members.
[in] | bgd | Background. |
Definition at line 553 of file GCTABackgroundPerfTable.cpp.
References m_background, m_energy, m_filename, m_log10_energy, m_log_background, m_mc_spectrum, and m_sigma.
Referenced by GCTABackgroundPerfTable(), and operator=().
|
inlinevirtual |
Return filename.
Implements GCTABackground.
Definition at line 139 of file GCTABackgroundPerfTable.hpp.
References m_filename.
Referenced by load().
|
private |
Delete class members.
Definition at line 574 of file GCTABackgroundPerfTable.cpp.
Referenced by clear(), operator=(), and ~GCTABackgroundPerfTable().
|
private |
Initialise Monte Carlo cache.
Verify assumption made about the solid angles of the response table elements.
Add optional sampling on a finer spatial grid.
Definition at line 629 of file GCTABackgroundPerfTable.cpp.
References GModelSpectralNodes::append(), GModelSpectralNodes::clear(), m_background, m_energy, m_mc_spectrum, size(), and solidangle().
Referenced by spectrum().
|
private |
Initialise class members.
Definition at line 530 of file GCTABackgroundPerfTable.cpp.
References GNodeArray::clear(), GEnergies::clear(), GFilename::clear(), GModelSpectralNodes::clear(), m_background, m_energy, m_filename, m_log10_energy, m_log_background, m_mc_spectrum, and m_sigma.
Referenced by clear(), GCTABackgroundPerfTable(), and operator=().
|
virtual |
Load background from performance table.
[in] | filename | Performance table file name. |
GException::file_open_error | File could not be opened for read access. |
Loads the background information from a performance table.
Implements GCTABackground.
Definition at line 246 of file GCTABackgroundPerfTable.cpp.
References GNodeArray::append(), GEnergies::append(), GNodeArray::clear(), GEnergies::clear(), cos(), gammalib::deg2rad, filename(), G_LOAD, log(), GEnergy::log10TeV(), m_background, m_energy, m_filename, m_log10_energy, m_log_background, pow(), solidangle(), gammalib::split(), gammalib::strip_whitespace(), gammalib::todouble(), gammalib::twopi, and GFilename::url().
Referenced by GCTABackgroundPerfTable().
|
virtual |
Returns MC instrument direction.
[in] | energy | Photon energy. |
[in] | time | Photon arrival time. |
[in,out] | ran | Random number generator. |
Implements GCTABackground.
Definition at line 334 of file GCTABackgroundPerfTable.cpp.
References cos(), gammalib::deg2rad, GCTAInstDir::detx(), GCTAInstDir::dety(), exp(), sigma(), sin(), sqrt(), gammalib::twopi, and GRan::uniform().
|
virtual |
Return background rate in units of events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\).
[in] | logE | Log10 of the true photon energy (TeV). |
[in] | detx | Tangential coordinate in nominal system (rad). |
[in] | dety | Tangential coordinate in nominal system (rad). |
Returns the background rate for a given energy and detector coordinates. The rate is given per ontime. The method assures that the background rate never becomes negative.
If the performance table contains less than 2 nodes an empty value is returned.
Implements GCTABackground.
Definition at line 179 of file GCTABackgroundPerfTable.cpp.
References exp(), m_sigma, gammalib::rad2deg, rate(), and sqrt().
GCTABackgroundPerfTable & GCTABackgroundPerfTable::operator= | ( | const GCTABackgroundPerfTable & | bgd | ) |
Assignment operator.
[in] | bgd | Background. |
Definition at line 139 of file GCTABackgroundPerfTable.cpp.
References copy_members(), free_members(), init_members(), and GCTABackground::operator=().
Print background information.
[in] | chatter | Chattiness. |
Implements GCTABackground.
Definition at line 478 of file GCTABackgroundPerfTable.cpp.
References GEnergies::append(), m_energy, m_filename, m_sigma, gammalib::parformat(), SILENT, size(), and gammalib::str().
|
private |
Return background rate for a given energy (events/s/MeV/sr)
[in] | logE | Log10 of the true photon energy (TeV). |
Definition at line 661 of file GCTABackgroundPerfTable.cpp.
References exp(), GNodeArray::interpolate(), m_background, m_log10_energy, m_log_background, and size().
Referenced by operator()(), and rate_ebin().
|
virtual |
Returns background rate integrated over energy interval in units of events s \(^{-1}\) sr \(^{-1}\).
[in] | dir | Instrument direction. |
[in] | emin | Minimum energy of energy interval. |
[in] | emax | Maximum energy of energy interval. |
Returns the background count rate for a given instrument direction that is integrated over a specified energy interval. The rate is given per ontime.
If the energy interval is not positive, a zero background rate is returned.
Implements GCTABackground.
Definition at line 399 of file GCTABackgroundPerfTable.cpp.
References exp(), GEnergy::log10TeV(), m_background, m_energy, m_sigma, GEnergy::MeV(), gammalib::plaw_integral(), gammalib::rad2deg, rate(), size(), and GCTAInstDir::theta().
|
inline |
Set sigma for offset angle dependence.
[in] | sigma | Sigma for offset angle dependence. |
Sets the sigma parameter for the offset angle dependence of the effective area. If sigma
is 0, no offset angle dependency will be assumed. By default, sigma
= 3.
Definition at line 168 of file GCTABackgroundPerfTable.hpp.
References m_sigma, and sigma().
Referenced by GCTAResponseIrf::read().
|
inline |
Return sigma for offset angle dependence.
Definition at line 181 of file GCTABackgroundPerfTable.hpp.
References m_sigma.
Referenced by mc(), sigma(), and solidangle().
|
inline |
Return number of node energies in response.
Definition at line 152 of file GCTABackgroundPerfTable.hpp.
References m_energy, and GEnergies::size().
Referenced by init_mc_cache(), print(), rate(), and rate_ebin().
|
private |
Returns integral over radial model (in steradians)
Computes
\[\Omega = 2 \pi \int_0^{\pi} \sin \theta f(\theta) d\theta\]
where
\[f(\theta) = \exp \left(-\frac{1}{2} \left( \frac{\theta^2}{\sigma} \right)^2 \right)\]
\(\theta\) is the offset angle (in degrees), and \(\sigma\) is the Gaussian width (in degrees \(^2\)).
The integration is performed numerically, and the upper integration bound \(\pi\) is set to \(\sqrt(10 \sigma)\) to reduce inaccuracies in the numerical integration.
Definition at line 598 of file GCTABackgroundPerfTable.cpp.
References gammalib::deg2rad, gammalib::pi, GIntegral::romberg(), sigma(), sqrt(), and gammalib::twopi.
Referenced by init_mc_cache(), and load().
|
inlinevirtual |
Get response cube spectrum.
Returns the response cube spectrum.
Implements GCTABackground.
Definition at line 195 of file GCTABackgroundPerfTable.hpp.
References init_mc_cache(), m_mc_spectrum, and GModelSpectralNodes::nodes().
|
private |
Background rate.
Definition at line 112 of file GCTABackgroundPerfTable.hpp.
Referenced by copy_members(), init_mc_cache(), init_members(), load(), rate(), and rate_ebin().
|
private |
Vector of energies.
Definition at line 110 of file GCTABackgroundPerfTable.hpp.
Referenced by copy_members(), init_mc_cache(), init_members(), load(), print(), rate_ebin(), and size().
|
private |
Name of background response file.
Definition at line 109 of file GCTABackgroundPerfTable.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and print().
|
private |
log10(E) nodes for background interpolation
Definition at line 111 of file GCTABackgroundPerfTable.hpp.
Referenced by copy_members(), init_members(), load(), and rate().
|
private |
log(background rate)
Definition at line 113 of file GCTABackgroundPerfTable.hpp.
Referenced by copy_members(), init_members(), load(), and rate().
|
mutableprivate |
Background spectrum.
Definition at line 117 of file GCTABackgroundPerfTable.hpp.
Referenced by copy_members(), init_mc_cache(), init_members(), and spectrum().
|
private |
Sigma for offset angle computation (0=none)
Definition at line 114 of file GCTABackgroundPerfTable.hpp.
Referenced by copy_members(), init_members(), operator()(), print(), rate_ebin(), and sigma().