110 if (
this != &cache) {
163 for (GResponseCacheName::const_iterator it_name =
m_cache.begin();
164 it_name !=
m_cache.end(); ++it_name) {
165 for (GResponseCacheEnergy::const_iterator it_energy =
166 it_name->second.begin();
167 it_energy != it_name->second.end(); ++it_energy) {
168 size += it_energy->second.size();
190 for (GResponseCacheName::const_iterator it_name =
m_cache.begin();
191 it_name !=
m_cache.end(); ++it_name) {
192 for (GResponseCacheEnergy::const_iterator it_energy =
193 it_name->second.begin();
194 it_energy != it_name->second.end(); ++it_energy) {
195 nenergies += it_energy->second.size();
221 u_int64_t energy =
hash(ereco, etrue);
224 m_cache[name][energy][0] = value;
250 u_int64_t energy =
hash(ereco, etrue);
251 u_int64_t instdir = dir.
hash();
254 m_cache[name][energy][instdir] = value;
285 u_int64_t energy =
hash(ereco, etrue);
286 u_int64_t instdir = 0;
289 GResponseCacheName::const_iterator it_name =
m_cache.find(name);
290 if (it_name !=
m_cache.end()) {
293 GResponseCacheEnergy::const_iterator it_energy =
294 it_name->second.find(energy);
295 if (it_energy != it_name->second.end()) {
298 GResponseCacheDir::const_iterator it_dir =
299 it_energy->second.find(instdir);
300 if (it_dir != it_energy->second.end()) {
303 *value = it_dir->second;
342 u_int64_t energy =
hash(ereco, etrue);
343 u_int64_t instdir = dir.
hash();
346 GResponseCacheName::const_iterator it_name =
m_cache.find(name);
347 if (it_name !=
m_cache.end()) {
350 GResponseCacheEnergy::const_iterator it_energy =
351 it_name->second.find(energy);
352 if (it_energy != it_name->second.end()) {
355 GResponseCacheDir::const_iterator it_dir =
356 it_energy->second.find(instdir);
357 if (it_dir != it_energy->second.end()) {
360 *value = it_dir->second;
399 result.append(
"=== GResponseCache ===");
406 for (GResponseCacheName::const_iterator it_name =
m_cache.begin();
407 it_name !=
m_cache.end(); ++it_name) {
415 for (GResponseCacheEnergy::const_iterator it_energy =
416 it_name->second.begin();
417 it_energy != it_name->second.end(); ++it_energy) {
419 for (GResponseCacheDir::const_iterator it_dir =
420 it_energy->second.begin();
421 it_dir != it_energy->second.end(); ++it_dir) {
502 static float buffer[2];
505 buffer[0] = float(ereco.
MeV());
506 buffer[1] = float(etrue.
MeV());
509 u_int64_t
hash; std::memcpy(&hash, &buffer,
sizeof hash);
Abstract instrument direction base class definition.
void free_members(void)
Delete class members.
void init_members(void)
Initialise class members.
GResponseCache & operator=(const GResponseCache &cache)
Assignment operator.
GResponseCache(void)
Void constructor.
double MeV(void) const
Return energy in MeV.
void copy_members(const GResponseCache &cache)
Copy class members.
int size(void) const
Return number of elements in cache.
u_int64_t hash(const GEnergy &ereco, const GEnergy &etrue) const
Encode reconstructued and true energy into hash value.
Abstract instrument direction base class.
Response cache class definition.
virtual ~GResponseCache(void)
Destructor.
virtual u_int64_t hash(void) const =0
GResponseCacheName m_cache
int nenergies(void) const
Return number of energies in cache.
GResponseCache * clone(void) const
Clone response cache.
void clear(void)
Clear response cache.
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.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void set(const std::string &name, const GEnergy &ereco, const GEnergy &etrue, const double &value)
Set cache value.
std::string print(const GChatter &chatter=NORMAL) const
Print response cache.
Class that handles energies in a unit independent way.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.