GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTABackgroundPerfTable Class Reference

CTA performance table background class. More...

#include <GCTABackgroundPerfTable.hpp>

Inheritance diagram for GCTABackgroundPerfTable:
GCTABackground GBase

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...
 
GCTABackgroundPerfTableoperator= (const GCTABackgroundPerfTable &bgd)
 Assignment operator. More...
 
void clear (void)
 Clear background. More...
 
GCTABackgroundPerfTableclone (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 GModelSpectralNodesspectrum (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...
 
GCTABackgroundoperator= (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...
 

Detailed Description

CTA performance table background class.

Definition at line 47 of file GCTABackgroundPerfTable.hpp.

Constructor & Destructor Documentation

GCTABackgroundPerfTable::GCTABackgroundPerfTable ( void  )

Void constructor.

Definition at line 63 of file GCTABackgroundPerfTable.cpp.

References init_members().

Referenced by clone().

GCTABackgroundPerfTable::GCTABackgroundPerfTable ( const GFilename filename)
explicit

File constructor.

Parameters
[in]filenamePerformance 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.

Parameters
[in]bgdBackground.

Definition at line 100 of file GCTABackgroundPerfTable.cpp.

References copy_members(), and init_members().

GCTABackgroundPerfTable::~GCTABackgroundPerfTable ( void  )
virtual

Destructor.

Definition at line 117 of file GCTABackgroundPerfTable.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GCTABackground.

Definition at line 127 of file GCTABackgroundPerfTable.hpp.

void GCTABackgroundPerfTable::clear ( void  )
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().

GCTABackgroundPerfTable * GCTABackgroundPerfTable::clone ( void  ) const
virtual

Clone background.

Returns
Pointer to deep copy of background.

Implements GCTABackground.

Definition at line 230 of file GCTABackgroundPerfTable.cpp.

References GCTABackgroundPerfTable().

void GCTABackgroundPerfTable::copy_members ( const GCTABackgroundPerfTable bgd)
private

Copy class members.

Parameters
[in]bgdBackground.

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=().

GFilename GCTABackgroundPerfTable::filename ( void  ) const
inlinevirtual

Return filename.

Returns
Returns filename from which the background was loaded.

Implements GCTABackground.

Definition at line 139 of file GCTABackgroundPerfTable.hpp.

References m_filename.

Referenced by load().

void GCTABackgroundPerfTable::free_members ( void  )
private

Delete class members.

Definition at line 574 of file GCTABackgroundPerfTable.cpp.

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

void GCTABackgroundPerfTable::init_mc_cache ( void  ) const
private

Initialise Monte Carlo cache.

Todo:

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().

void GCTABackgroundPerfTable::init_members ( void  )
private
void GCTABackgroundPerfTable::load ( const GFilename filename)
virtual

Load background from performance table.

Parameters
[in]filenamePerformance table file name.
Exceptions
GException::file_open_errorFile 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().

GCTAInstDir GCTABackgroundPerfTable::mc ( const GEnergy energy,
const GTime time,
GRan ran 
) const
virtual

Returns MC instrument direction.

Parameters
[in]energyPhoton energy.
[in]timePhoton arrival time.
[in,out]ranRandom number generator.
Returns
CTA instrument direction.

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().

double GCTABackgroundPerfTable::operator() ( const double &  logE,
const double &  detx,
const double &  dety 
) const
virtual

Return background rate in units of events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\).

Parameters
[in]logELog10 of the true photon energy (TeV).
[in]detxTangential coordinate in nominal system (rad).
[in]detyTangential coordinate in nominal system (rad).
Returns
Background rate (events MeV \(^{-1}\) s \(^{-1}\) sr \(^{-1}\)).

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.

Parameters
[in]bgdBackground.
Returns
Background.

Definition at line 139 of file GCTABackgroundPerfTable.cpp.

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

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

Print background information.

Parameters
[in]chatterChattiness.
Returns
String containing background information.

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().

double GCTABackgroundPerfTable::rate ( const double &  logE) const
private

Return background rate for a given energy (events/s/MeV/sr)

Parameters
[in]logELog10 of the true photon energy (TeV).
Returns
Background rate (events/s/MeV/sr)

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().

double GCTABackgroundPerfTable::rate_ebin ( const GCTAInstDir dir,
const GEnergy emin,
const GEnergy emax 
) const
virtual

Returns background rate integrated over energy interval in units of events s \(^{-1}\) sr \(^{-1}\).

Parameters
[in]dirInstrument direction.
[in]eminMinimum energy of energy interval.
[in]emaxMaximum energy of energy interval.
Returns
Integrated background count rate (events s \(^{-1}\) sr \(^{-1}\)).

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().

void GCTABackgroundPerfTable::sigma ( const double &  sigma)
inline

Set sigma for offset angle dependence.

Parameters
[in]sigmaSigma 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().

const double & GCTABackgroundPerfTable::sigma ( void  ) const
inline

Return sigma for offset angle dependence.

Returns
Sigma for offset angle dependence.

Definition at line 181 of file GCTABackgroundPerfTable.hpp.

References m_sigma.

Referenced by mc(), sigma(), and solidangle().

int GCTABackgroundPerfTable::size ( void  ) const
inline

Return number of node energies in response.

Returns
Number of node energies.

Definition at line 152 of file GCTABackgroundPerfTable.hpp.

References m_energy, and GEnergies::size().

Referenced by init_mc_cache(), print(), rate(), and rate_ebin().

double GCTABackgroundPerfTable::solidangle ( void  ) const
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().

const GModelSpectralNodes & GCTABackgroundPerfTable::spectrum ( void  ) const
inlinevirtual

Get response cube spectrum.

Returns
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().

Member Data Documentation

std::vector<double> GCTABackgroundPerfTable::m_background
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().

GEnergies GCTABackgroundPerfTable::m_energy
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().

GFilename GCTABackgroundPerfTable::m_filename
private

Name of background response file.

Definition at line 109 of file GCTABackgroundPerfTable.hpp.

Referenced by copy_members(), filename(), init_members(), load(), and print().

GNodeArray GCTABackgroundPerfTable::m_log10_energy
private

log10(E) nodes for background interpolation

Definition at line 111 of file GCTABackgroundPerfTable.hpp.

Referenced by copy_members(), init_members(), load(), and rate().

std::vector<double> GCTABackgroundPerfTable::m_log_background
private

log(background rate)

Definition at line 113 of file GCTABackgroundPerfTable.hpp.

Referenced by copy_members(), init_members(), load(), and rate().

GModelSpectralNodes GCTABackgroundPerfTable::m_mc_spectrum
mutableprivate

Background spectrum.

Definition at line 117 of file GCTABackgroundPerfTable.hpp.

Referenced by copy_members(), init_mc_cache(), init_members(), and spectrum().

double GCTABackgroundPerfTable::m_sigma
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().


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