GammaLib
2.1.0.dev
|
Response cache class. More...
#include <GResponseCache.hpp>
Public Member Functions | |
GResponseCache (void) | |
Void constructor. More... | |
GResponseCache (const GResponseCache &cache) | |
Copy constructor. More... | |
virtual | ~GResponseCache (void) |
Destructor. More... | |
GResponseCache & | operator= (const GResponseCache &cache) |
Assignment operator. More... | |
void | clear (void) |
Clear response cache. More... | |
GResponseCache * | clone (void) const |
Clone response cache. More... | |
std::string | classname (void) const |
Return class name. More... | |
bool | is_empty (void) const |
Checks whether the cache is empty. More... | |
int | size (void) const |
Return number of elements in cache. More... | |
int | nenergies (void) const |
Return number of energies in cache. 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 GInstDir &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 GInstDir &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 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 GResponseCache &cache) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
u_int64_t | hash (const GEnergy &ereco, const GEnergy &etrue) const |
Encode reconstructued and true energy into hash value. More... | |
Protected Attributes | |
GResponseCacheName | m_cache |
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 60 of file GResponseCache.hpp.
GResponseCache::GResponseCache | ( | void | ) |
Void constructor.
Definition at line 54 of file GResponseCache.cpp.
References init_members().
Referenced by clone().
GResponseCache::GResponseCache | ( | const GResponseCache & | cache | ) |
Copy constructor.
[in] | cache | Response cache. |
Definition at line 69 of file GResponseCache.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 117 of file GResponseCache.hpp.
|
virtual |
Clear response cache.
Implements GBase.
Definition at line 137 of file GResponseCache.cpp.
References free_members(), and init_members().
Referenced by GResponse::init_members().
|
virtual |
Clone response cache.
Implements GBase.
Definition at line 378 of file GResponseCache.cpp.
References GResponseCache().
bool GResponseCache::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 276 of file GResponseCache.cpp.
References hash(), and m_cache.
Referenced by contains(), GCTAResponseCube::irf_spatial(), GResponse::irf_spatial(), and GCTAResponseIrf::nroi().
bool GResponseCache::contains | ( | const std::string & | name, |
const GInstDir & | 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 | Instrument 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 332 of file GResponseCache.cpp.
References contains(), GInstDir::hash(), hash(), and m_cache.
|
protected |
Copy class members.
[in] | cache | Response cache. |
Definition at line 465 of file GResponseCache.cpp.
References m_cache.
Referenced by GResponseCache(), and operator=().
|
protected |
Delete class members.
Definition at line 478 of file GResponseCache.cpp.
Referenced by clear(), operator=(), and ~GResponseCache().
Encode reconstructued and true energy into hash value.
[in] | ereco | Reconstructed energy. |
[in] | etrue | True energy. |
Encodes the reconstructued and true energy in a 64 Bit unsigned integer value. The energy are converted into single precision floating point values and mapped on a 64 Bit unsigned integer value. This provides unique hash values for all instruments up to the precision of floating point singles.
Definition at line 498 of file GResponseCache.cpp.
References GEnergy::MeV().
Referenced by contains(), and set().
|
protected |
Initialise class members.
Definition at line 450 of file GResponseCache.cpp.
References m_cache.
Referenced by clear(), GResponseCache(), and operator=().
|
inline |
Checks whether the cache is empty.
Checks whether the response cache is empty.
Definition at line 131 of file GResponseCache.hpp.
References m_cache.
int GResponseCache::nenergies | ( | void | ) | const |
Return number of energies in cache.
Returns the number of energies in the response cache.
Definition at line 184 of file GResponseCache.cpp.
References m_cache.
Referenced by print().
GResponseCache & GResponseCache::operator= | ( | const GResponseCache & | cache | ) |
Assignment operator.
[in] | cache | Response cache. |
Definition at line 107 of file GResponseCache.cpp.
References copy_members(), free_members(), and init_members().
Print response cache.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 390 of file GResponseCache.cpp.
References m_cache, nenergies(), gammalib::parformat(), SILENT, size(), and gammalib::str().
Referenced by GCTAResponseIrf::print(), and GCTAResponseCube::print().
|
inline |
Remove cache for source.
[in] | name | Source name. |
Remove cache for source with name
.
Definition at line 145 of file GResponseCache.hpp.
References m_cache.
Referenced by GResponse::remove_response_cache().
void GResponseCache::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 215 of file GResponseCache.cpp.
References hash(), and m_cache.
Referenced by GCTAResponseCube::irf_spatial(), GResponse::irf_spatial(), and GCTAResponseIrf::nroi().
void GResponseCache::set | ( | const std::string & | name, |
const GInstDir & | 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 243 of file GResponseCache.cpp.
References GInstDir::hash(), hash(), and m_cache.
int GResponseCache::size | ( | void | ) | const |
Return number of elements in cache.
Returns the number of elements in the response cache.
Definition at line 157 of file GResponseCache.cpp.
References m_cache.
Referenced by print().
|
protected |
Definition at line 107 of file GResponseCache.hpp.
Referenced by contains(), copy_members(), init_members(), is_empty(), nenergies(), print(), remove(), set(), and size().