GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAResponseCache Class Reference

CTA response cache class. More...

#include <GCTAResponseCache.hpp>

Inheritance diagram for GCTAResponseCache:
GBase

Public Member Functions

 GCTAResponseCache (void)
 Void constructor. More...
 
 GCTAResponseCache (const GCTAResponseCache &cache)
 Copy constructor. More...
 
virtual ~GCTAResponseCache (void)
 Destructor. More...
 
GCTAResponseCacheoperator= (const GCTAResponseCache &cache)
 Assignment operator. More...
 
void clear (void)
 Clear CTA response cache. More...
 
GCTAResponseCacheclone (void) const
 Clone CTA response cache. More...
 
std::string classname (void) const
 Return class name. More...
 
int size (void) const
 Return number of elements in cache. More...
 
bool is_empty (void) const
 Checks whether the cache is empty. More...
 
void set (const std::string &name, const GEnergy &ereco, const GEnergy &etrue, const double &value)
 Set cache value. More...
 
void set (const std::string &name, const GCTAInstDir &dir, const GEnergy &ereco, const GEnergy &etrue, const double &value)
 Set cache value. More...
 
void remove (const std::string &name)
 Remove cache for source. More...
 
bool contains (const std::string &name, const GEnergy &ereco, const GEnergy &etrue, double *value=NULL) const
 Check if cache contains a value for specific parameters. More...
 
bool contains (const std::string &name, const GCTAInstDir &dir, const GEnergy &ereco, const GEnergy &etrue, double *value=NULL) const
 Check if cache contains a value for specific parameters. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print CTA response cache. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GCTAResponseCache &cache)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
double encode (const GEnergy &ereco, const GEnergy &etrue) const
 Encode reconstructued and true energy. More...
 
double encode (const GCTAInstDir &dir, const GEnergy &ereco, const GEnergy &etrue) const
 Encode instrument direction, reconstructued and true energy. More...
 

Protected Attributes

GCTAResponseCacheName m_cache
 

Detailed Description

CTA response cache class.

The class implements a cache for the Instrument Response Function values so that the values do not need to be recomputed each time but can be fetched from the cache.

Definition at line 55 of file GCTAResponseCache.hpp.

Constructor & Destructor Documentation

GCTAResponseCache::GCTAResponseCache ( void  )

Void constructor.

Definition at line 53 of file GCTAResponseCache.cpp.

References init_members().

Referenced by clone().

GCTAResponseCache::GCTAResponseCache ( const GCTAResponseCache cache)

Copy constructor.

Parameters
[in]cacheCTA response cache.

Definition at line 68 of file GCTAResponseCache.cpp.

References copy_members(), and init_members().

GCTAResponseCache::~GCTAResponseCache ( void  )
virtual

Destructor.

Definition at line 84 of file GCTAResponseCache.cpp.

References free_members().

Member Function Documentation

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

Return class name.

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

Implements GBase.

Definition at line 115 of file GCTAResponseCache.hpp.

void GCTAResponseCache::clear ( void  )
virtual

Clear CTA response cache.

Implements GBase.

Definition at line 136 of file GCTAResponseCache.cpp.

References free_members(), and init_members().

Referenced by GCTAResponse::init_members().

GCTAResponseCache * GCTAResponseCache::clone ( void  ) const
virtual

Clone CTA response cache.

Returns
Pointer to deep copy of CTA response cache.

Implements GBase.

Definition at line 329 of file GCTAResponseCache.cpp.

References GCTAResponseCache().

bool GCTAResponseCache::contains ( const std::string &  name,
const GEnergy ereco,
const GEnergy etrue,
double *  value = NULL 
) const

Check if cache contains a value for specific parameters.

Parameters
[in]nameCache name.
[in]erecoReconstructed energy.
[in]etrueTrue energy.
[out]valuePointer to cached value (only if found).
Returns
True if cached value was found, otherwise false.

Check if the cache contains a value for a given name, reconstructed energy ereco, and true energy etrue.

If the value pointer argument is not NULL, the method will return the cached value through this argument in case that the value exists.

Definition at line 243 of file GCTAResponseCache.cpp.

References encode(), and m_cache.

Referenced by contains(), GCTAResponse::irf(), and GCTAResponseIrf::nroi().

bool GCTAResponseCache::contains ( const std::string &  name,
const GCTAInstDir dir,
const GEnergy ereco,
const GEnergy etrue,
double *  value = NULL 
) const

Check if cache contains a value for specific parameters.

Parameters
[in]nameCache name.
[in]dirSky direction.
[in]erecoReconstructed energy.
[in]etrueTrue energy.
[out]valuePointer to cached value (only if found).
Returns
True if cached value was found, otherwise false.

Check if the cache contains a value for a given name, instrument direction dir,reconstructed energy ereco, and true energy etrue.

If the value pointer argument is not NULL, the method will return the cached value through this argument in case that the value exists.

Definition at line 291 of file GCTAResponseCache.cpp.

References contains(), encode(), and m_cache.

void GCTAResponseCache::copy_members ( const GCTAResponseCache cache)
protected

Copy class members.

Parameters
[in]cacheCTA response cache.

Definition at line 405 of file GCTAResponseCache.cpp.

References m_cache.

Referenced by GCTAResponseCache(), and operator=().

double GCTAResponseCache::encode ( const GEnergy ereco,
const GEnergy etrue 
) const
protected

Encode reconstructued and true energy.

Parameters
[in]erecoReconstructed energy.
[in]etrueTrue energy.
Returns
Encoded reconstructued and true energy

Encodes the reconstructued and true energy in a single double precision value. The encoding is done using the following formula:

\[ {\\ encode} = E_{\rm reco} \times 10^2 + E_{\rm true} \]

where

  • \(E_{\rm reco}\) is the reconstructued energy in TeV, and
  • \(E_{\rm true}\) is the true energy in TeV.

Definition at line 443 of file GCTAResponseCache.cpp.

References GEnergy::TeV().

Referenced by contains(), and set().

double GCTAResponseCache::encode ( const GCTAInstDir dir,
const GEnergy ereco,
const GEnergy etrue 
) const
protected

Encode instrument direction, reconstructued and true energy.

Parameters
[in]dirInstrument direction.
[in]erecoReconstructed energy.
[in]etrueTrue energy.
Returns
Encoded instrument direction, reconstructued and true energy

Encodes the instrument direction, reconstructued and true energy in a single double precision value. The encoding is done using the following formula:

\[ {\\ encode} = \alpha \times 10^8 + \delta \times 10^5 + E_{\rm reco} \times 10^2 + E_{\rm true} \]

where

  • \(\alpha\) is the Right Ascension of the instrument direction in degrees,
  • \(\delta\) is the Declination of the instrument direction in degrees,
  • \(E_{\rm reco}\) is the reconstructued energy in TeV, and
  • \(E_{\rm true}\) is the true energy in TeV.

Definition at line 478 of file GCTAResponseCache.cpp.

References GCTAInstDir::dir(), and GEnergy::TeV().

void GCTAResponseCache::free_members ( void  )
protected

Delete class members.

Definition at line 418 of file GCTAResponseCache.cpp.

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

void GCTAResponseCache::init_members ( void  )
protected

Initialise class members.

Definition at line 390 of file GCTAResponseCache.cpp.

References m_cache.

Referenced by clear(), GCTAResponseCache(), and operator=().

bool GCTAResponseCache::is_empty ( void  ) const
inline

Checks whether the cache is empty.

Returns
True if cache is empty, false otherwise.

Checks whether the response cache is empty.

Definition at line 129 of file GCTAResponseCache.hpp.

References m_cache.

GCTAResponseCache & GCTAResponseCache::operator= ( const GCTAResponseCache cache)

Assignment operator.

Parameters
[in]cacheCTA response cache.
Returns
CTA response cache.

Definition at line 106 of file GCTAResponseCache.cpp.

References copy_members(), free_members(), and init_members().

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

Print CTA response cache.

Parameters
[in]chatterChattiness.
Returns
String containing CTA response cache information.
Todo:
Implement method.

Implements GBase.

Definition at line 343 of file GCTAResponseCache.cpp.

References m_cache, gammalib::parformat(), SILENT, size(), and gammalib::str().

Referenced by GCTAResponseCube::print(), and GCTAResponseIrf::print().

void GCTAResponseCache::remove ( const std::string &  name)
inline

Remove cache for source.

Parameters
[in]nameSource name.

Remove cache for source with name.

Definition at line 143 of file GCTAResponseCache.hpp.

References m_cache.

Referenced by GCTAResponse::remove_response_cache().

void GCTAResponseCache::set ( const std::string &  name,
const GEnergy ereco,
const GEnergy etrue,
const double &  value 
)

Set cache value.

Parameters
[in]nameCache name.
[in]erecoReconstructed energy.
[in]etrueTrue energy.
[in]valueCache value.

Set cache value for a given name, reconstructed energy ereco, and true energy etrue.

Definition at line 183 of file GCTAResponseCache.cpp.

References encode(), and m_cache.

Referenced by GCTAResponse::irf(), and GCTAResponseIrf::nroi().

void GCTAResponseCache::set ( const std::string &  name,
const GCTAInstDir dir,
const GEnergy ereco,
const GEnergy etrue,
const double &  value 
)

Set cache value.

Parameters
[in]nameCache name.
[in]dirInstrument direction.
[in]erecoReconstructed energy.
[in]etrueTrue energy.
[in]valueCache value.

Set cache value for a given name, instrument direction dir, reconstructed energy ereco, and true energy etrue.

Definition at line 211 of file GCTAResponseCache.cpp.

References encode(), and m_cache.

int GCTAResponseCache::size ( void  ) const

Return number of elements in cache.

Returns
Number of elements in cache

Returns the number of elements in the response cache.

Definition at line 156 of file GCTAResponseCache.cpp.

References m_cache.

Referenced by print().

Member Data Documentation

GCTAResponseCacheName GCTAResponseCache::m_cache
protected

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