#include <DTConfigPluginHandler.h>
Public Member Functions | |
virtual int | get (const edm::EventSetup &context, int cfgId, const DTKeyedConfig *&obj) |
get content | |
virtual int | get (const DTKeyedConfigListRcd &keyRecord, int cfgId, const DTKeyedConfig *&obj) |
virtual void | getData (const DTKeyedConfigListRcd &keyRecord, int cfgId, std::vector< std::string > &list) |
virtual void | getData (const edm::EventSetup &context, int cfgId, std::vector< std::string > &list) |
void | purge () |
purge db copy | |
virtual | ~DTConfigPluginHandler () |
Static Public Member Functions | |
static void | build () |
build static object | |
Static Public Attributes | |
static int | maxBrickNumber = 5000 |
static int | maxByteNumber = 10000000 |
static int | maxStringNumber = 100000 |
Private Types | |
typedef std::pair< int, const DTKeyedConfig * > | counted_brick |
Private Member Functions | |
DTConfigPluginHandler () | |
DTConfigPluginHandler (const DTConfigPluginHandler &x) | |
const DTConfigPluginHandler & | operator= (const DTConfigPluginHandler &x) |
Private Attributes | |
std::map< int, counted_brick > | brickMap |
int | cachedBrickNumber |
int | cachedByteNumber |
int | cachedStringNumber |
Description: Class to hold configuration identifier for chambers
Definition at line 34 of file DTConfigPluginHandler.h.
typedef std::pair<int,const DTKeyedConfig*> DTConfigPluginHandler::counted_brick [private] |
Definition at line 71 of file DTConfigPluginHandler.h.
DTConfigPluginHandler::~DTConfigPluginHandler | ( | ) | [virtual] |
DTConfigPluginHandler::DTConfigPluginHandler | ( | ) | [private] |
Constructor
Definition at line 45 of file DTConfigPluginHandler.cc.
Referenced by build().
: cachedBrickNumber( 0 ), cachedStringNumber( 0 ), cachedByteNumber( 0 ) { // std::cout << "===============================" << std::endl; // std::cout << "= =" << std::endl; // std::cout << "= new DTConfigPluginHandler =" << std::endl; // std::cout << "= =" << std::endl; // std::cout << "===============================" << std::endl; // if ( instance == 0 ) instance = this; }
DTConfigPluginHandler::DTConfigPluginHandler | ( | const DTConfigPluginHandler & | x | ) | [private] |
void DTConfigPluginHandler::build | ( | ) | [static] |
build static object
Operations
Definition at line 69 of file DTConfigPluginHandler.cc.
References DTConfigPluginHandler(), and DTConfigAbstractHandler::instance.
{ if ( instance == 0 ) instance = new DTConfigPluginHandler; }
int DTConfigPluginHandler::get | ( | const edm::EventSetup & | context, |
int | cfgId, | ||
const DTKeyedConfig *& | obj | ||
) | [virtual] |
get content
Reimplemented from DTConfigAbstractHandler.
Definition at line 74 of file DTConfigPluginHandler.cc.
References edm::EventSetup::get().
{ return get( context.get<DTKeyedConfigListRcd>(), cfgId, obj ); }
int DTConfigPluginHandler::get | ( | const DTKeyedConfigListRcd & | keyRecord, |
int | cfgId, | ||
const DTKeyedConfig *& | obj | ||
) | [virtual] |
Reimplemented from DTConfigAbstractHandler.
Definition at line 80 of file DTConfigPluginHandler.cc.
References brickMap, cachedBrickNumber, cachedByteNumber, cachedStringNumber, DTKeyedConfig::dataBegin(), DTKeyedConfig::dataEnd(), alignCSCRings::e, exception, cond::KeyList::get(), edm::eventsetup::EventSetupRecord::get(), DTKeyedConfig::getId(), cond::KeyList::load(), maxBrickNumber, maxByteNumber, maxStringNumber, edm::ESHandle< T >::product(), and findQualityFiles::size.
{ bool cacheFound = false; int cacheAge = 999999999; std::map<int,counted_brick>::iterator cache_iter = brickMap.begin(); std::map<int,counted_brick>::iterator cache_icfg = brickMap.find( cfgId ); std::map<int,counted_brick>::iterator cache_iend = brickMap.end(); if ( cache_icfg != cache_iend ) { std::pair<const int,counted_brick>& entry = *cache_icfg; counted_brick& cBrick = entry.second; cacheAge = cBrick.first; obj = cBrick.second; cacheFound = true; } std::map<int,const DTKeyedConfig*> ageMap; if ( cacheFound ) { if ( !cacheAge ) return 0; while ( cache_iter != cache_iend ) { std::pair<const int,counted_brick>& entry = *cache_iter++; counted_brick& cBrick = entry.second; int& brickAge = cBrick.first; if ( brickAge < cacheAge ) brickAge++; if ( entry.first == cfgId ) brickAge = 0; } return 0; } else { while ( cache_iter != cache_iend ) { std::pair<const int,counted_brick>& entry = *cache_iter++; counted_brick& cBrick = entry.second; ageMap.insert( std::pair<int,const DTKeyedConfig*>( ++cBrick.first, entry.second.second ) ); } } // get dummy brick list edm::ESHandle<cond::KeyList> klh; keyRecord.get( klh ); cond::KeyList const & kl= *klh.product(); cond::KeyList* keyList = const_cast<cond::KeyList*>( &kl ); if ( keyList == 0 ) return 999; std::vector<unsigned long long> checkedKeys; const DTKeyedConfig* kBrick = 0; checkedKeys.push_back( cfgId ); bool brickFound = false; try { keyList->load( checkedKeys ); kBrick = keyList->get<DTKeyedConfig>( 0 ); if ( kBrick != 0 ) brickFound = ( kBrick->getId() == cfgId ); } catch ( std::exception const & e ) { } if ( brickFound ) { counted_brick cBrick( 0, obj = new DTKeyedConfig( *kBrick ) ); brickMap.insert( std::pair<int,counted_brick>( cfgId, cBrick ) ); DTKeyedConfig::data_iterator d_iter = kBrick->dataBegin(); DTKeyedConfig::data_iterator d_iend = kBrick->dataEnd(); cachedBrickNumber++; cachedStringNumber += ( d_iend - d_iter ); while ( d_iter != d_iend ) cachedByteNumber += ( *d_iter++ ).size(); } std::map<int,const DTKeyedConfig*>::reverse_iterator iter = ageMap.rbegin(); while ( ( cachedBrickNumber > maxBrickNumber ) || ( cachedStringNumber > maxStringNumber ) || ( cachedByteNumber > maxByteNumber ) ) { const DTKeyedConfig* oldestBrick = iter->second; int oldestId = oldestBrick->getId(); cachedBrickNumber--; DTKeyedConfig::data_iterator d_iter = oldestBrick->dataBegin(); DTKeyedConfig::data_iterator d_iend = oldestBrick->dataEnd(); cachedStringNumber -= ( d_iend - d_iter ); while ( d_iter != d_iend ) cachedByteNumber -= ( *d_iter++ ).size(); brickMap.erase( oldestId ); delete iter->second; iter++; } return 999; }
void DTConfigPluginHandler::getData | ( | const DTKeyedConfigListRcd & | keyRecord, |
int | cfgId, | ||
std::vector< std::string > & | list | ||
) | [virtual] |
Reimplemented from DTConfigAbstractHandler.
Definition at line 172 of file DTConfigPluginHandler.cc.
References DTKeyedConfig::dataBegin(), DTKeyedConfig::dataEnd(), getData(), DTKeyedConfig::linkBegin(), DTKeyedConfig::linkEnd(), and getGTfromDQMFile::obj.
{ const DTKeyedConfig* obj = 0; get( keyRecord, cfgId, obj ); if ( obj == 0 ) return; DTKeyedConfig::data_iterator d_iter = obj->dataBegin(); DTKeyedConfig::data_iterator d_iend = obj->dataEnd(); while ( d_iter != d_iend ) list.push_back( *d_iter++ ); DTKeyedConfig::link_iterator l_iter = obj->linkBegin(); DTKeyedConfig::link_iterator l_iend = obj->linkEnd(); while ( l_iter != l_iend ) getData( keyRecord, *l_iter++, list ); return; }
void DTConfigPluginHandler::getData | ( | const edm::EventSetup & | context, |
int | cfgId, | ||
std::vector< std::string > & | list | ||
) | [virtual] |
Reimplemented from DTConfigAbstractHandler.
Definition at line 165 of file DTConfigPluginHandler.cc.
References edm::EventSetup::get().
Referenced by getData().
{ getData( context.get<DTKeyedConfigListRcd>(), cfgId, list ); return; }
const DTConfigPluginHandler& DTConfigPluginHandler::operator= | ( | const DTConfigPluginHandler & | x | ) | [private] |
void DTConfigPluginHandler::purge | ( | ) | [virtual] |
purge db copy
Reimplemented from DTConfigAbstractHandler.
Definition at line 188 of file DTConfigPluginHandler.cc.
References brickMap, cachedBrickNumber, cachedByteNumber, cachedStringNumber, and gather_cfg::cout.
Referenced by ~DTConfigPluginHandler().
{ std::cout << "DTConfigPluginHandler::purge " << this << " " << cachedBrickNumber << " " << cachedStringNumber << " " << cachedByteNumber << std::endl; std::map<int,counted_brick>::const_iterator iter = brickMap.begin(); std::map<int,counted_brick>::const_iterator iend = brickMap.end(); while ( iter != iend ) { delete iter->second.second; iter++; } brickMap.clear(); cachedBrickNumber = 0; cachedStringNumber = 0; cachedByteNumber = 0; return; }
std::map<int,counted_brick> DTConfigPluginHandler::brickMap [private] |
Definition at line 72 of file DTConfigPluginHandler.h.
int DTConfigPluginHandler::cachedBrickNumber [private] |
Definition at line 73 of file DTConfigPluginHandler.h.
int DTConfigPluginHandler::cachedByteNumber [private] |
Definition at line 75 of file DTConfigPluginHandler.h.
int DTConfigPluginHandler::cachedStringNumber [private] |
Definition at line 74 of file DTConfigPluginHandler.h.
int DTConfigPluginHandler::maxBrickNumber = 5000 [static] |
Definition at line 59 of file DTConfigPluginHandler.h.
Referenced by get().
int DTConfigPluginHandler::maxByteNumber = 10000000 [static] |
Definition at line 61 of file DTConfigPluginHandler.h.
Referenced by get().
int DTConfigPluginHandler::maxStringNumber = 100000 [static] |
Definition at line 60 of file DTConfigPluginHandler.h.
Referenced by get().