GammaLib
1.7.0.dev
|
CTA response cache class. More...
#include <GCTAResponseCache.hpp>
Public Member Functions | |
GCTAResponseCache (void) | |
Void constructor. More... | |
GCTAResponseCache (const GCTAResponseCache &cache) | |
Copy constructor. More... | |
virtual | ~GCTAResponseCache (void) |
Destructor. More... | |
GCTAResponseCache & | operator= (const GCTAResponseCache &cache) |
Assignment operator. More... | |
void | clear (void) |
Clear CTA response cache. More... | |
GCTAResponseCache * | clone (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 |
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.
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.
[in] | cache | CTA response cache. |
Definition at line 68 of file GCTAResponseCache.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 115 of file GCTAResponseCache.hpp.
|
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().
|
virtual |
Clone 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.
[in] | name | Cache name. |
[in] | ereco | Reconstructed energy. |
[in] | etrue | True energy. |
[out] | value | Pointer to cached value (only if found). |
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.
[in] | name | Cache name. |
[in] | dir | Sky direction. |
[in] | ereco | Reconstructed energy. |
[in] | etrue | True energy. |
[out] | value | Pointer to cached value (only if found). |
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.
|
protected |
Copy class members.
[in] | cache | CTA response cache. |
Definition at line 405 of file GCTAResponseCache.cpp.
References m_cache.
Referenced by GCTAResponseCache(), and operator=().
Encode reconstructued and true energy.
[in] | ereco | Reconstructed energy. |
[in] | etrue | 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
Definition at line 443 of file GCTAResponseCache.cpp.
References GEnergy::TeV().
Referenced by contains(), and set().
|
protected |
Encode instrument direction, reconstructued and true energy.
[in] | dir | Instrument direction. |
[in] | ereco | Reconstructed energy. |
[in] | etrue | 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
Definition at line 478 of file GCTAResponseCache.cpp.
References GCTAInstDir::dir(), and GEnergy::TeV().
|
protected |
Delete class members.
Definition at line 418 of file GCTAResponseCache.cpp.
Referenced by clear(), operator=(), and ~GCTAResponseCache().
|
protected |
Initialise class members.
Definition at line 390 of file GCTAResponseCache.cpp.
References m_cache.
Referenced by clear(), GCTAResponseCache(), and operator=().
|
inline |
Checks whether the cache is empty.
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.
[in] | cache | CTA response cache. |
Definition at line 106 of file GCTAResponseCache.cpp.
References copy_members(), free_members(), and init_members().
Print CTA response cache.
[in] | chatter | Chattiness. |
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().
|
inline |
Remove cache for source.
[in] | name | Source 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.
[in] | name | Cache name. |
[in] | ereco | Reconstructed energy. |
[in] | etrue | True energy. |
[in] | value | Cache 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.
[in] | name | Cache name. |
[in] | dir | Instrument direction. |
[in] | ereco | Reconstructed energy. |
[in] | etrue | True energy. |
[in] | value | Cache 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.
int GCTAResponseCache::size | ( | void | ) | const |
Return 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().
|
protected |
Definition at line 105 of file GCTAResponseCache.hpp.
Referenced by contains(), copy_members(), init_members(), is_empty(), print(), remove(), set(), and size().