CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes
DTConfigPluginHandler Class Reference

#include <DTConfigPluginHandler.h>

Inheritance diagram for DTConfigPluginHandler:
DTConfigAbstractHandler

Public Member Functions

virtual int get (const edm::EventSetup &context, int cfgId, const DTKeyedConfig *&obj)
 get content More...
 
virtual int get (const DTKeyedConfigListRcd &keyRecord, int cfgId, const DTKeyedConfig *&obj)
 
virtual void getData (const edm::EventSetup &context, int cfgId, std::vector< std::string > &list)
 
virtual void getData (const DTKeyedConfigListRcd &keyRecord, int cfgId, std::vector< std::string > &list)
 
void purge ()
 purge db copy More...
 
virtual ~DTConfigPluginHandler ()
 
- Public Member Functions inherited from DTConfigAbstractHandler
virtual ~DTConfigAbstractHandler ()
 

Static Public Member Functions

static void build ()
 build static object More...
 
- Static Public Member Functions inherited from DTConfigAbstractHandler
static DTConfigAbstractHandlergetInstance ()
 get static object More...
 

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 DTConfigPluginHandleroperator= (const DTConfigPluginHandler &x)
 

Private Attributes

std::map< int, counted_brickbrickMap
 
int cachedBrickNumber
 
int cachedByteNumber
 
int cachedStringNumber
 

Additional Inherited Members

- Protected Member Functions inherited from DTConfigAbstractHandler
 DTConfigAbstractHandler ()
 
- Static Protected Attributes inherited from DTConfigAbstractHandler
static DTConfigAbstractHandlerinstance = 0
 

Detailed Description

Description: Class to hold configuration identifier for chambers

Date:
2011/06/06 17:24:05
Revision:
1.3
Author
Paolo Ronchese INFN Padova

Definition at line 34 of file DTConfigPluginHandler.h.

Member Typedef Documentation

typedef std::pair<int,const DTKeyedConfig*> DTConfigPluginHandler::counted_brick
private

Definition at line 71 of file DTConfigPluginHandler.h.

Constructor & Destructor Documentation

DTConfigPluginHandler::~DTConfigPluginHandler ( )
virtual

Destructor

Definition at line 61 of file DTConfigPluginHandler.cc.

References purge().

61  {
62  purge();
63 }
void purge()
purge db copy
DTConfigPluginHandler::DTConfigPluginHandler ( )
private

Constructor

Definition at line 45 of file DTConfigPluginHandler.cc.

Referenced by build().

45  :
46  cachedBrickNumber( 0 ),
47  cachedStringNumber( 0 ),
48  cachedByteNumber( 0 ) {
49 // std::cout << "===============================" << std::endl;
50 // std::cout << "= =" << std::endl;
51 // std::cout << "= new DTConfigPluginHandler =" << std::endl;
52 // std::cout << "= =" << std::endl;
53 // std::cout << "===============================" << std::endl;
54 // if ( instance == 0 ) instance = this;
55 }
DTConfigPluginHandler::DTConfigPluginHandler ( const DTConfigPluginHandler x)
private

Member Function Documentation

void DTConfigPluginHandler::build ( )
static

build static object

Operations

Definition at line 69 of file DTConfigPluginHandler.cc.

References DTConfigPluginHandler(), and DTConfigAbstractHandler::instance.

Referenced by DTConfigHandlerFactory::DTConfigHandlerFactory().

69  {
70  if ( instance == 0 ) instance = new DTConfigPluginHandler;
71 }
static DTConfigAbstractHandler * instance
int DTConfigPluginHandler::get ( const edm::EventSetup context,
int  cfgId,
const DTKeyedConfig *&  obj 
)
virtual
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, cppFunctionSkipper::exception, cond::KeyList::get(), edm::eventsetup::EventSetupRecord::get(), DTKeyedConfig::getId(), cond::KeyList::load(), maxBrickNumber, maxByteNumber, maxStringNumber, edm::ESHandle< class >::product(), and findQualityFiles::size.

Referenced by Options.Options::__getitem__(), betterConfigParser.BetterConfigParser::__updateDict(), betterConfigParser.BetterConfigParser::getCompares(), betterConfigParser.BetterConfigParser::getGeneral(), and betterConfigParser.BetterConfigParser::getResultingSection().

81  {
82 
83  bool cacheFound = false;
84  int cacheAge = 999999999;
85  std::map<int,counted_brick>::iterator cache_iter = brickMap.begin();
86  std::map<int,counted_brick>::iterator cache_icfg = brickMap.find( cfgId );
87  std::map<int,counted_brick>::iterator cache_iend = brickMap.end();
88  if ( cache_icfg != cache_iend ) {
89  std::pair<const int,counted_brick>& entry = *cache_icfg;
90  counted_brick& cBrick = entry.second;
91  cacheAge = cBrick.first;
92  obj = cBrick.second;
93  cacheFound = true;
94  }
95 
96  std::map<int,const DTKeyedConfig*> ageMap;
97  if ( cacheFound ) {
98  if ( !cacheAge ) return 0;
99  while ( cache_iter != cache_iend ) {
100  std::pair<const int,counted_brick>& entry = *cache_iter++;
101  counted_brick& cBrick = entry.second;
102  int& brickAge = cBrick.first;
103  if ( brickAge < cacheAge ) brickAge++;
104  if ( entry.first == cfgId ) brickAge = 0;
105  }
106  return 0;
107  }
108  else {
109  while ( cache_iter != cache_iend ) {
110  std::pair<const int,counted_brick>& entry = *cache_iter++;
111  counted_brick& cBrick = entry.second;
112  ageMap.insert( std::pair<int,const DTKeyedConfig*>(
113  ++cBrick.first, entry.second.second ) );
114  }
115  }
116 
117 // get dummy brick list
119  keyRecord.get( klh );
120  cond::KeyList const & kl= *klh.product();
121  cond::KeyList* keyList = const_cast<cond::KeyList*>( &kl );
122  if ( keyList == 0 ) return 999;
123 
124  std::vector<unsigned long long> checkedKeys;
125  const DTKeyedConfig* kBrick = 0;
126  checkedKeys.push_back( cfgId );
127  bool brickFound = false;
128  try {
129  keyList->load( checkedKeys );
130  kBrick = keyList->get<DTKeyedConfig>( 0 );
131  if ( kBrick != 0 ) brickFound = ( kBrick->getId() == cfgId );
132  }
133  catch ( std::exception const & e ) {
134  }
135  if ( brickFound ) {
136  counted_brick cBrick( 0, obj = new DTKeyedConfig( *kBrick ) );
137  brickMap.insert( std::pair<int,counted_brick>( cfgId, cBrick ) );
138  DTKeyedConfig::data_iterator d_iter = kBrick->dataBegin();
139  DTKeyedConfig::data_iterator d_iend = kBrick->dataEnd();
141  cachedStringNumber += ( d_iend - d_iter );
142  while ( d_iter != d_iend ) cachedByteNumber += ( *d_iter++ ).size();
143  }
144  std::map<int,const DTKeyedConfig*>::reverse_iterator iter = ageMap.rbegin();
145  while ( ( cachedBrickNumber > maxBrickNumber ) ||
148  const DTKeyedConfig* oldestBrick = iter->second;
149  int oldestId = oldestBrick->getId();
151  DTKeyedConfig::data_iterator d_iter = oldestBrick->dataBegin();
152  DTKeyedConfig::data_iterator d_iend = oldestBrick->dataEnd();
153  cachedStringNumber -= ( d_iend - d_iter );
154  while ( d_iter != d_iend ) cachedByteNumber -= ( *d_iter++ ).size();
155  brickMap.erase( oldestId );
156  delete iter->second;
157  iter++;
158  }
159 
160  return 999;
161 
162 }
std::map< int, counted_brick > brickMap
void load(std::vector< unsigned long long > const &keys)
Definition: KeyList.cc:10
std::pair< int, const DTKeyedConfig * > counted_brick
data_iterator dataBegin() const
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
void get(HolderT &iHolder) const
T const * get(int n) const
Definition: KeyList.h:39
T const * product() const
Definition: ESHandle.h:62
int getId() const
std::vector< std::string >::const_iterator data_iterator
Definition: DTKeyedConfig.h:56
tuple size
Write out results.
data_iterator dataEnd() const
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 ShapeTools.ShapeBuilder::doCombinedDataset(), and getData().

166  {
167  getData( context.get<DTKeyedConfigListRcd>(), cfgId, list );
168  return;
169 }
virtual void getData(const edm::EventSetup &context, int cfgId, std::vector< std::string > &list)
const T & get() const
Definition: EventSetup.h:55
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
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.

Referenced by ShapeTools.ShapeBuilder::doCombinedDataset().

174  {
175  const DTKeyedConfig* obj = 0;
176  get( keyRecord, cfgId, obj );
177  if ( obj == 0 ) return;
178  DTKeyedConfig::data_iterator d_iter = obj->dataBegin();
179  DTKeyedConfig::data_iterator d_iend = obj->dataEnd();
180  while ( d_iter != d_iend ) list.push_back( *d_iter++ );
181  DTKeyedConfig::link_iterator l_iter = obj->linkBegin();
182  DTKeyedConfig::link_iterator l_iend = obj->linkEnd();
183  while ( l_iter != l_iend ) getData( keyRecord, *l_iter++, list );
184  return;
185 }
data_iterator dataBegin() const
link_iterator linkBegin() const
link_iterator linkEnd() const
std::vector< int >::const_iterator link_iterator
Definition: DTKeyedConfig.h:57
virtual void getData(const edm::EventSetup &context, int cfgId, std::vector< std::string > &list)
std::vector< std::string >::const_iterator data_iterator
Definition: DTKeyedConfig.h:56
data_iterator dataEnd() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
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().

188  {
189  std::cout << "DTConfigPluginHandler::purge "
190  << this << " "
191  << cachedBrickNumber << " "
192  << cachedStringNumber << " "
193  << cachedByteNumber << std::endl;
194  std::map<int,counted_brick>::const_iterator iter = brickMap.begin();
195  std::map<int,counted_brick>::const_iterator iend = brickMap.end();
196  while ( iter != iend ) {
197  delete iter->second.second;
198  iter++;
199  }
200  brickMap.clear();
201  cachedBrickNumber = 0;
202  cachedStringNumber = 0;
203  cachedByteNumber = 0;
204  return;
205 }
std::map< int, counted_brick > brickMap
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

std::map<int,counted_brick> DTConfigPluginHandler::brickMap
private

Definition at line 72 of file DTConfigPluginHandler.h.

Referenced by get(), and purge().

int DTConfigPluginHandler::cachedBrickNumber
private

Definition at line 73 of file DTConfigPluginHandler.h.

Referenced by get(), and purge().

int DTConfigPluginHandler::cachedByteNumber
private

Definition at line 75 of file DTConfigPluginHandler.h.

Referenced by get(), and purge().

int DTConfigPluginHandler::cachedStringNumber
private

Definition at line 74 of file DTConfigPluginHandler.h.

Referenced by get(), and purge().

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().