00001
00015 #include "Cache.h"
00016
00017 ClassImp(Cache)
00018
00019
00020 ostream & operator << (ostream & stream, const Cache & cache)
00021 {
00022 map<int, CacheBuffer *>::const_iterator buf_iter;
00023 for(buf_iter = cache.fCache.begin(); buf_iter != cache.fCache.end(); ++buf_iter) {
00024 stream << "**** " << Process::AsString( (Process::Process_t) buf_iter->first) << endl;
00025 stream << *(buf_iter->second);
00026 }
00027 stream << endl;
00028 return stream;
00029 }
00030
00031 Cache::Cache()
00032 {
00033 typedef map<int, CacheBuffer *>::value_type cache_pair;
00034
00035 fCache.insert( cache_pair( (int) Process::eIonization, new CacheBuffer ) );
00036 fCache.insert( cache_pair( (int) Process::eBremsstrahlung, new CacheBuffer ) );
00037 fCache.insert( cache_pair( (int) Process::ePairProduction, new CacheBuffer ) );
00038 fCache.insert( cache_pair( (int) Process::eNuclearInteraction, new CacheBuffer ) );
00039 }
00040
00041 Cache::Cache(unsigned int autoclear)
00042 {
00043 typedef map<int, CacheBuffer *>::value_type cache_pair;
00044
00045 fCache.insert(cache_pair((int) Process::eIonization, new CacheBuffer(autoclear)));
00046 fCache.insert(cache_pair((int) Process::eBremsstrahlung, new CacheBuffer(autoclear)));
00047 fCache.insert(cache_pair((int) Process::ePairProduction, new CacheBuffer(autoclear)));
00048 fCache.insert(cache_pair((int) Process::eNuclearInteraction, new CacheBuffer(autoclear)));
00049 }
00050
00051 Cache::~Cache()
00052 {
00053 map<int, CacheBuffer *>::iterator buf_iter;
00054 for(buf_iter = fCache.begin(); buf_iter != fCache.end(); ++buf_iter)
00055 delete buf_iter->second;
00056 fCache.clear();
00057 }
00058
00059 void Cache::AddToCache(Process::Process_t prs, double e, double de_dx)
00060 {
00061 map<int, CacheBuffer *>::iterator iter = fCache.find( (int) prs );
00062
00063 iter->second->AddToCache(e, de_dx);
00064 }
00065
00066 bool Cache::Retrieve(Process::Process_t prs, double e, double & de_dx) const
00067 {
00068 map<int, CacheBuffer *>::const_iterator iter = fCache.find( (int) prs );
00069
00070 return iter->second->Retrieve(e, de_dx);
00071 }
00072
00073 void Cache::ClearCache(void)
00074 {
00075 map<int, CacheBuffer *>::iterator buf_iter;
00076 for(buf_iter = fCache.begin(); buf_iter != fCache.end(); ++buf_iter)
00077 buf_iter->second->ClearCache();
00078 }
00079
00080 void Cache::Print(const Option_t *) const
00081 {
00082 cout << *this;
00083 }
00084
00085