GammaLib
2.1.0.dev
|
Response vector cache class. More...
#include <GResponseVectorCache.hpp>
Public Member Functions | |
GResponseVectorCache (void) | |
Void constructor. More... | |
GResponseVectorCache (const GResponseVectorCache &cache) | |
Copy constructor. More... | |
virtual | ~GResponseVectorCache (void) |
Destructor. More... | |
GResponseVectorCache & | operator= (const GResponseVectorCache &cache) |
Assignment operator. More... | |
void | clear (void) |
Clear response vector cache. More... | |
GResponseVectorCache * | 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 |
Returns size of vector chache. More... | |
void | set (const std::string &cache_id, const GVector &vector) |
Set cache value. More... | |
void | remove (const std::string &cache_id) |
Remove cache. More... | |
bool | contains (const std::string &cache_id, GVector *irfs=NULL) const |
Check if cache contains a value for specific parameters. More... | |
void | load (const GFilename &filename) |
Load response vector cache from FITS file. More... | |
void | save (const GFilename &filename, const bool &clobber=false) const |
Save the response vector cache into FITS file. More... | |
void | read (const GFitsTable &table) |
Read response vector cache from FITS table. 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 GResponseVectorCache &cache) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
int | find_cache (const std::string &cache_id) const |
Find cache. More... | |
Protected Attributes | |
std::vector< std::string > | m_cache_ids |
std::vector< int > | m_cache_entries |
std::vector< double * > | m_cache_values |
std::vector< int * > | m_cache_indices |
Response vector cache class.
The class implements a vector 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 54 of file GResponseVectorCache.hpp.
GResponseVectorCache::GResponseVectorCache | ( | void | ) |
Void constructor.
Definition at line 61 of file GResponseVectorCache.cpp.
References init_members().
Referenced by clone().
GResponseVectorCache::GResponseVectorCache | ( | const GResponseVectorCache & | cache | ) |
Copy constructor.
[in] | cache | Response vector cache. |
Definition at line 76 of file GResponseVectorCache.cpp.
References copy_members(), and init_members().
|
virtual |
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 103 of file GResponseVectorCache.hpp.
|
virtual |
Clear response vector cache.
Implements GBase.
Definition at line 144 of file GResponseVectorCache.cpp.
References free_members(), and init_members().
Referenced by GResponse::init_members().
|
virtual |
Clone response cache.
Implements GBase.
Definition at line 162 of file GResponseVectorCache.cpp.
References GResponseVectorCache().
bool GResponseVectorCache::contains | ( | const std::string & | cache_id, |
GVector * | vector = NULL |
||
) | const |
Check if cache contains a value for specific parameters.
[in] | cache_id | Cache identifier. |
[in,out] | vector | Pointer to cached vector (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 302 of file GResponseVectorCache.cpp.
References find_cache(), m_cache_entries, m_cache_indices, m_cache_values, and GVector::size().
Referenced by GResponse::irf_spatial().
|
protected |
Copy class members.
[in] | cache | Response cache. |
Definition at line 588 of file GResponseVectorCache.cpp.
References m_cache_entries, m_cache_ids, m_cache_indices, m_cache_values, and size().
Referenced by GResponseVectorCache(), and operator=().
|
protected |
Find cache.
[in] | cache_id | Cache identifier. |
Find cache for a given cache_id
. If no cache was found the method returns -1.
Definition at line 642 of file GResponseVectorCache.cpp.
References m_cache_ids.
Referenced by contains(), remove(), and set().
|
protected |
Delete class members.
Definition at line 618 of file GResponseVectorCache.cpp.
References m_cache_indices, m_cache_values, and size().
Referenced by clear(), load(), operator=(), and ~GResponseVectorCache().
|
protected |
Initialise class members.
Definition at line 570 of file GResponseVectorCache.cpp.
References m_cache_entries, m_cache_ids, m_cache_indices, and m_cache_values.
Referenced by clear(), GResponseVectorCache(), load(), and operator=().
|
inline |
Checks whether the cache is empty.
Checks whether the response cache is empty.
Definition at line 117 of file GResponseVectorCache.hpp.
References m_cache_ids.
void GResponseVectorCache::load | ( | const GFilename & | filename | ) |
Load response vector cache from FITS file.
[in] | filename | FITS file name. |
Loads the response vector cache from a FITS file. All binary tables in the FITS file are assumed to be response vector cache entries.
Definition at line 362 of file GResponseVectorCache.cpp.
References GFits::close(), free_members(), GFitsHDU::HT_BIN_TABLE, init_members(), read(), GFits::size(), and GFits::table().
Referenced by GCOMResponse::load_cache().
GResponseVectorCache & GResponseVectorCache::operator= | ( | const GResponseVectorCache & | cache | ) |
Assignment operator.
[in] | cache | Response vector cache. |
Definition at line 114 of file GResponseVectorCache.cpp.
References copy_members(), free_members(), and init_members().
Print response cache.
[in] | chatter | Chattiness. |
Implements GBase.
Definition at line 532 of file GResponseVectorCache.cpp.
References m_cache_entries, m_cache_ids, gammalib::parformat(), SILENT, size(), and gammalib::str().
void GResponseVectorCache::read | ( | const GFitsTable & | table | ) |
Read response vector cache from FITS table.
[in] | table | FITS table. |
Reads response vector cache from a FITS table. There is one cache entry in a FITS table, with the table extension name specifying the cache identifier. Only tables containing the "HDUCLAS2" keyword set to "VECTOR_CACHE" will be considered by the method, all other tables will be simply skipped.
Definition at line 483 of file GResponseVectorCache.cpp.
References GFitsHDU::extname(), GFitsHDU::has_card(), GFitsTableCol::integer(), m_cache_entries, m_cache_ids, m_cache_indices, m_cache_values, GFitsTable::nrows(), GFitsTableCol::real(), and GFitsHDU::string().
Referenced by load().
void GResponseVectorCache::remove | ( | const std::string & | cache_id | ) |
Remove cache.
[in] | cache_id | Cache identifier. |
Remove cache for a given cache_id
.
Definition at line 264 of file GResponseVectorCache.cpp.
References find_cache(), m_cache_entries, m_cache_ids, m_cache_indices, and m_cache_values.
Referenced by GResponse::remove_response_cache().
void GResponseVectorCache::save | ( | const GFilename & | filename, |
const bool & | clobber = false |
||
) | const |
Save the response vector cache into FITS file.
[in] | filename | FITS file name. |
[in] | clobber | Overwrite an response vector cache file? |
Saves the response vector cache into a FITS file. If a file with the given filename
does not yet exist it will be created, otherwise the method opens the existing file. The response vector cache can only be appended to an existing file if the clobber
flag is set to "true" (otherwise an exception is thrown).
The method will append all cache entries as binary FITS tables to the FITS file. The table extension names are defined by the cache identifiers. All cache entries with identifiers exceeding 80 characters will be skipped to avoid truncation of cache identifiers.
Definition at line 408 of file GResponseVectorCache.cpp.
References GFitsTable::append(), GFitsHDU::card(), GFitsHDU::extname(), m_cache_entries, m_cache_ids, m_cache_indices, m_cache_values, size(), and GFilename::url().
Referenced by GCOMResponse::save_cache().
void GResponseVectorCache::set | ( | const std::string & | cache_id, |
const GVector & | vector | ||
) |
Set cache value.
[in] | cache_id | Cache identifier. |
[in] | vector | Cache vector. |
Set cache vector for a given cache_id
.
Definition at line 176 of file GResponseVectorCache.cpp.
References find_cache(), m_cache_entries, m_cache_ids, m_cache_indices, m_cache_values, GVector::non_zeros(), and GVector::size().
Referenced by GResponse::irf_spatial().
|
inline |
Returns size of vector chache.
Returns the number of vectors that are stored in the vector cache.
Definition at line 131 of file GResponseVectorCache.hpp.
References m_cache_ids.
Referenced by copy_members(), free_members(), print(), and save().
|
protected |
Definition at line 91 of file GResponseVectorCache.hpp.
Referenced by contains(), copy_members(), init_members(), print(), read(), remove(), save(), and set().
|
protected |
Definition at line 90 of file GResponseVectorCache.hpp.
Referenced by copy_members(), find_cache(), init_members(), is_empty(), print(), read(), remove(), save(), set(), and size().
|
protected |
Definition at line 93 of file GResponseVectorCache.hpp.
Referenced by contains(), copy_members(), free_members(), init_members(), read(), remove(), save(), and set().
|
protected |
Definition at line 92 of file GResponseVectorCache.hpp.
Referenced by contains(), copy_members(), free_members(), init_members(), read(), remove(), save(), and set().