CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CondDBESSource.cc
Go to the documentation of this file.
1 //
2 // Package: CondCore/ESSources
3 // Module: CondDBESSource
4 //
5 // Description: <one line class summary>
6 //
7 // Implementation:
8 // <Notes on implementation>
9 //
10 // Author: Zhen Xie
11 // Fixes and other changes: Giacomo Govi
12 //
13 #include "CondDBESSource.h"
14 
15 #include "boost/shared_ptr.hpp"
16 #include <boost/algorithm/string.hpp>
20 
23 
27 #include <exception>
28 
29 #include <iomanip>
30 
31 namespace {
32  /* utility ot build the name of the plugin corresponding to a given record
33  se ESSources
34  */
36  buildName( std::string const & iRecordName ) {
37  return iRecordName + std::string( "@NewProxy" );
38  }
39 
40  std::string joinRecordAndLabel( std::string const & iRecordName, std::string const & iLabelName ) {
41  return iRecordName + std::string( "@" ) + iLabelName;
42  }
43 
44  /* utility class to return a IOVs associated to a given "name"
45  This implementation return the IOV associated to a record...
46  It is essentialy a workaround to get the full IOV out of the tag colector
47  that is not accessible as hidden in the ESSource
48  FIXME: need to support label??
49  */
50  class CondGetterFromESSource : public cond::persistency::CondGetter {
51  public:
52  CondGetterFromESSource(CondDBESSource::ProxyMap const & ip) : m_proxies(ip){}
53  virtual ~CondGetterFromESSource(){}
54 
55  cond::persistency::IOVProxy get(std::string name) const override {
56  CondDBESSource::ProxyMap::const_iterator p = m_proxies.find(name);
57  if ( p != m_proxies.end())
58  return (*p).second->proxy()->iov();
60  }
61 
62  CondDBESSource::ProxyMap const & m_proxies;
63  };
64 
65  // This needs to be re-design and implemented...
66  // dump the state of a DataProxy
67  void dumpInfo(std::ostream & out, std::string const & recName, cond::DataProxyWrapperBase const & proxy) {
68  //cond::SequenceState state(proxy.proxy()->iov().state());
69  out << recName << " / " << proxy.label() << ": "
70  << proxy.connString() << ", " << proxy.tag() << "\n "
71  // << state.size() << ", " << state.revision() << ", "
72  // << cond::time::to_boost(state.timestamp()) << "\n "
73  // << state.comment()
74  << "\n "
75  // << "refresh " << proxy.proxy()->stats.nRefresh
76  // << "/" << proxy.proxy()->stats.nArefresh
77  // << ", reconnect " << proxy.proxy()->stats.nReconnect
78  // << "/" << proxy.proxy()->stats.nAreconnect
79  // << ", make " << proxy.proxy()->stats.nMake
80  // << ", load " << proxy.proxy()->stats.nLoad
81  ;
82  //if ( proxy.proxy()->stats.nLoad>0) {
83  out << "Time look up, payloadIds:" <<std::endl;
84  const auto& pids = proxy.proxy()->requests();
85  for (auto id: pids )
86  out << " "<< id.since <<" - "<< id.till <<" : "<<id.payloadId<<std::endl;
87  }
88 
89 }
90 
91 
92 /*
93  * config Param
94  * RefreshEachRun: if true will refresh the IOV at each new run (or lumiSection)
95  * DumpStat: if true dump the statistics of all DataProxy (currently on cout)
96  * DBParameters: configuration set of the connection
97  * globaltag: The GlobalTag
98  * toGet: list of record label tag connection-string to add/overwrite the content of the global-tag
99  */
101  m_connection(),
102  m_connectionString(""),
103  m_lastRun(0), // for the stat
104  m_lastLumi(0), // for the stat
105  m_policy( NOREFRESH ),
106  m_doDump( iConfig.getUntrackedParameter<bool>( "DumpStat", false ) )
107 {
108  if( iConfig.getUntrackedParameter<bool>( "RefreshAlways", false ) ) {
110  }
111  if( iConfig.getUntrackedParameter<bool>( "RefreshOpenIOVs", false ) ) {
113  }
114  if( iConfig.getUntrackedParameter<bool>( "RefreshEachRun", false ) ) {
116  }
117  if( iConfig.getUntrackedParameter<bool>( "ReconnectEachRun", false ) ) {
119  }
120 
121  Stats s = {0,0,0,0,0,0,0,0};
122  m_stats = s;
123  /*parameter set parsing and pool environment setting
124  */
125 
126  // default connection string
127  // inproduction used for the global tag
128  m_connectionString= iConfig.getParameter<std::string>("connect");
129 
130 
131  // connection configuration
132  edm::ParameterSet connectionPset = iConfig.getParameter<edm::ParameterSet>( "DBParameters" );
133  m_connection.setParameters( connectionPset );
135 
136  // load additional record/tag info it will overwrite the global tag
137  std::map<std::string,cond::GTEntry_t> replacements;
138  if( iConfig.exists( "toGet" ) ) {
139  typedef std::vector< edm::ParameterSet > Parameters;
140  Parameters toGet = iConfig.getParameter<Parameters>( "toGet" );
141  for( Parameters::iterator itToGet = toGet.begin(); itToGet != toGet.end(); ++itToGet ) {
142  std::string recordname = itToGet->getParameter<std::string>( "record" );
143  std::string labelname = itToGet->getUntrackedParameter<std::string>( "label", "" );
144  std::string tag = itToGet->getParameter<std::string>( "tag" );
145  std::string pfn = itToGet->getUntrackedParameter<std::string>( "connect", m_connectionString );
146  std::string recordLabelKey = joinRecordAndLabel( recordname, labelname );
147  std::string fullyQualifiedTag = tag+"@["+pfn+"]";
148  replacements.insert( std::make_pair( recordLabelKey, cond::GTEntry_t( std::make_tuple(recordname, labelname, fullyQualifiedTag ) ) ) );
149  }
150  }
151 
152  // get the global tag, merge with "replacement" store in "tagCollection"
153  std::vector<std::string> globaltagList;
154  std::vector<std::string> connectList;
155  std::vector<std::string> pfnPrefixList;
156  std::vector<std::string> pfnPostfixList;
157  if( iConfig.exists( "globaltag" ) ) {
158  std::string pfnPrefix(iConfig.getUntrackedParameter<std::string>( "pfnPrefix", "" ));
159  std::string pfnPostfix(iConfig.getUntrackedParameter<std::string>( "pfnPostfix", "" ));
160  std::string globaltag(iConfig.getParameter<std::string>( "globaltag" ));
161  boost::split( globaltagList, globaltag, boost::is_any_of("|"), boost::token_compress_off );
162  fillList(m_connectionString, connectList, globaltagList.size(), "connection");
163  fillList(pfnPrefix, pfnPrefixList, globaltagList.size(), "pfnPrefix");
164  fillList(pfnPostfix, pfnPostfixList, globaltagList.size(), "pfnPostfix");
165  }
166 
167  fillTagCollectionFromDB(connectList,
168  pfnPrefixList,
169  pfnPostfixList,
170  globaltagList,
171  replacements);
172 
173  TagCollection::iterator it;
174  TagCollection::iterator itBeg = m_tagCollection.begin();
175  TagCollection::iterator itEnd = m_tagCollection.end();
176 
177  std::map<std::string, cond::persistency::Session> sessions;
178 
179  /* load DataProxy Plugin (it is strongly typed due to EventSetup ideosyncrasis)
180  * construct proxy
181  * contrary to EventSetup the "object-name" is not used as identifier: multiple entries in a record are
182  * dinstinguished only by their label...
183  * done in two step: first create ProxyWrapper loading ALL required dictionaries
184  * this will allow to initialize POOL in one go for each "database"
185  * The real initialization of the Data-Proxies is done in the second loop
186  */
187  std::vector<cond::DataProxyWrapperBase *> proxyWrappers(m_tagCollection.size());
188  size_t ipb=0;
189  for(it=itBeg;it!=itEnd;++it){
190  proxyWrappers[ipb++] =
191  cond::ProxyFactory::get()->create(buildName(it->second.recordName()));
192  }
193 
194  // now all required libraries have been loaded
195  // init sessions and DataProxies
196  ipb=0;
197  for(it=itBeg;it!=itEnd;++it){
199  std::string tag = it->second.tagName();
200  std::pair<std::string,std::string> tagParams = cond::persistency::parseTag( it->second.tagName() );
201  if( !tagParams.second.empty() ) {
202  connStr = tagParams.second;
203  tag = tagParams.first;
204  }
205  std::map<std::string, cond::persistency::Session>::iterator p = sessions.find( connStr );
207  if (p == sessions.end()) {
208  //open db get tag info (i.e. the IOV token...)
209  nsess = m_connection.createReadOnlySession( connStr, "" );
210  sessions.insert(std::make_pair( connStr, nsess));
211  } else nsess = (*p).second;
212 
213  // ownership...
214  ProxyP proxy(proxyWrappers[ipb++]);
215  // instert in the map
216  m_proxies.insert(std::make_pair(it->second.recordName(), proxy));
217  // initialize
218  proxy->lateInit(nsess, tag, it->second.recordLabel(), connStr);
219  }
220 
221  // one loaded expose all other tags to the Proxy!
222  CondGetterFromESSource visitor( m_proxies );
223  ProxyMap::iterator b = m_proxies.begin();
224  ProxyMap::iterator e = m_proxies.end();
225  for ( ;b != e; b++ ) {
226 
227  (*b).second->proxy()->loadMore( visitor );
228 
231  if( recordKey.type() != edm::eventsetup::EventSetupRecordKey::TypeTag() ) {
232  findingRecordWithKey( recordKey );
233  usingRecordWithKey( recordKey );
234  }
235  }
236 
237  m_stats.nData=m_proxies.size();
238 
239 }
240 
241 void CondDBESSource::fillList(const std::string & stringList, std::vector<std::string> & listToFill, const unsigned int listSize, const std::string & type)
242 {
243  boost::split( listToFill, stringList, boost::is_any_of("|"), boost::token_compress_off );
244  // If it is one clone it for each GT
245  if( listToFill.size() == 1 ) {
246  for( unsigned int i=1; i<listSize; ++i ) {
247  listToFill.push_back(stringList);
248  }
249  }
250  // else if they don't match the number of GTs throw an exception
251  else if( listSize != listToFill.size() ) {
252  throw cond::Exception( std::string( "ESSource: number of global tag components does not match number of "+type+" strings" ) );
253  }
254 }
255 
257  //dump info FIXME: find a more suitable place...
258  if (m_doDump) {
259  std::cout << "CondDBESSource Statistics" << std::endl
260  << "DataProxy " << m_stats.nData
261  << " setInterval " << m_stats.nSet
262  << " Runs " << m_stats.nRun
263  << " Lumis " << m_stats.nLumi
264  << " Refresh " << m_stats.nRefresh
265  << " Actual Refresh " << m_stats.nActualRefresh
266  << " Reconnect " << m_stats.nReconnect
267  << " Actual Reconnect " << m_stats.nActualReconnect;
268  std::cout << std::endl;
269 
270 
271  ProxyMap::iterator b= m_proxies.begin();
272  ProxyMap::iterator e= m_proxies.end();
273  for ( ;b != e; b++ ) {
274  dumpInfo( std::cout, (*b).first, *(*b).second );
275  std::cout << "\n" << std::endl;
276  }
277 
278  // FIXME
279  // We shall eventually close transaction and session...
280  }
281 }
282 
283 
284 //
285 // invoked by EventSetUp: for a given record return the smallest IOV for which iTime is valid
286 // limit to next run/lumisection of Refresh is required
287 //
288 void
290 
291  std::string recordname=iKey.name();
292 
293  edm::LogInfo( "CondDBESSource" ) << "Getting data for record \""<< recordname
294  << "\" to be consumed by "<< iTime.eventID() << ", timestamp: " << iTime.time().value()
295  << "; from CondDBESSource::setIntervalFor";
296 
297  m_stats.nSet++;
298  //{
299  // not really required, keep here for the time being
300  if(iTime.eventID().run()!=m_lastRun) {
301  m_lastRun=iTime.eventID().run();
302  m_stats.nRun++;
303  }
304  if(iTime.luminosityBlockNumber()!=m_lastLumi) {
306  m_stats.nLumi++;
307  }
308  //}
309 
310  bool doRefresh = false;
312  // find out the last run number for the proxy of the specified record
313  std::map<std::string,unsigned int>::iterator iRec = m_lastRecordRuns.find( recordname );
314  if( iRec != m_lastRecordRuns.end() ){
315  unsigned int lastRecordRun = iRec->second;
316  if( lastRecordRun != m_lastRun ){
317  // a refresh is required!
318  doRefresh = true;
319  iRec->second = m_lastRun;
320  edm::LogInfo( "CondDBESSource" ) << "Preparing refresh for record \"" << recordname
321  << "\" since there has been a transition from run "
322  << lastRecordRun << " to run " << m_lastRun
323  << "; from CondDBESSource::setIntervalFor";
324  }
325  } else {
326  doRefresh = true;
327  m_lastRecordRuns.insert( std::make_pair( recordname, m_lastRun ) );
328  edm::LogInfo( "CondDBESSource" ) << "Preparing refresh for record \"" << recordname
329  << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value()
330  << "; from CondDBESSource::setIntervalFor";
331  }
332  if ( !doRefresh )
333  edm::LogInfo( "CondDBESSource" ) << "Though enabled, refresh not needed for record \"" << recordname
334  << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value()
335  << "; from CondDBESSource::setIntervalFor";
336  } else if( m_policy == REFRESH_ALWAYS || m_policy == REFRESH_OPEN_IOVS ) {
337  doRefresh = true;
338  edm::LogInfo( "CondDBESSource" ) << "Forcing refresh for record \"" << recordname
339  << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value()
340  << "; from CondDBESSource::setIntervalFor";
341  }
342 
344 
345  // compute the smallest interval (assume all objects have the same timetype....)
346  cond::ValidityInterval recordValidity(1,cond::TIMELIMIT);
348  bool userTime=true;
349 
350  //FIXME use equal_range
351  ProxyMap::const_iterator pmBegin = m_proxies.lower_bound(recordname);
352  ProxyMap::const_iterator pmEnd = m_proxies.upper_bound(recordname);
353  if ( pmBegin == pmEnd ) {
354  edm::LogInfo( "CondDBESSource" ) << "No DataProxy (Pluging) found for record \""<< recordname
355  << "\"; from CondDBESSource::setIntervalFor";
356  return;
357  }
358 
359  for ( ProxyMap::const_iterator pmIter = pmBegin; pmIter != pmEnd; ++pmIter ) {
360 
361  edm::LogInfo( "CondDBESSource" ) << "Processing record \"" << recordname
362  << "\" and label \""<< pmIter->second->label()
363  << "\" for " << iTime.eventID() << ", timestamp: " << iTime.time().value()
364  << "; from CondDBESSource::setIntervalFor";
365 
366  timetype = (*pmIter).second->proxy()->timeType();
367 
368  cond::Time_t abtime = cond::time::fromIOVSyncValue( iTime, timetype );
369  userTime = ( 0 == abtime );
370 
371  //std::cout<<"abtime "<<abtime<<std::endl;
372 
373  if (userTime) return; // oInterval invalid to avoid that make is called...
374 
375 
376 
377  if( doRefresh ) {
378 
379  std::string recKey = joinRecordAndLabel( recordname, pmIter->second->label() );
380  TagCollection::const_iterator tcIter = m_tagCollection.find( recKey );
381  if ( tcIter == m_tagCollection.end() ) {
382  edm::LogInfo( "CondDBESSource" ) << "No Tag found for record \""<< recordname
383  << "\" and label \""<< pmIter->second->label()
384  << "\"; from CondDBESSource::setIntervalFor";
385  return;
386  }
387 
388  // first reconnect if required
389  if( m_policy == RECONNECT_EACH_RUN ) {
390  edm::LogInfo( "CondDBESSource" ) << "Checking if the session must be closed and re-opened for getting correct conditions"
391  << "; from CondDBESSource::setIntervalFor";
392  std::stringstream transId;
393  //transId << "long" << m_lastRun;
394  transId << m_lastRun;
396  std::pair<std::string,std::string> tagParams = cond::persistency::parseTag( tcIter->second.tagName() );
397  if( !tagParams.second.empty() ) connStr = tagParams.second;
398  std::map<std::string,std::pair<cond::persistency::Session,std::string> >::iterator iSess = m_sessionPool.find( connStr );
399  bool reopen = false;
400  if( iSess != m_sessionPool.end() ){
401  if( iSess->second.second != transId.str() ) {
402  // the available session is open for a different run: reopen
403  reopen = true;
404  iSess->second.second = transId.str();
405  }
406  } else {
407  // no available session: probably first run analysed...
408  iSess = m_sessionPool.insert(std::make_pair( connStr, std::make_pair( cond::persistency::Session(),transId.str()) )).first;
409  reopen = true;
410  }
411  if( reopen ){
412  iSess->second.first = m_connection.createReadOnlySession( connStr, transId.str() );
413  edm::LogInfo( "CondDBESSource" ) << "Re-opening the session with connection string " << connStr
414  << " and new transaction Id " << transId.str()
415  << "; from CondDBESSource::setIntervalFor";
416  }
417 
418  edm::LogInfo( "CondDBESSource" ) << "Reconnecting to \"" << connStr
419  << "\" for getting new payload for record \"" << recordname
420  << "\" and label \""<< pmIter->second->label()
421  << "\" from IOV tag \"" << tcIter->second.tagName()
422  << "\" to be consumed by " << iTime.eventID() << ", timestamp: " << iTime.time().value()
423  << "; from CondDBESSource::setIntervalFor";
424  pmIter->second->proxy()->setUp( iSess->second.first );
425  pmIter->second->proxy()->reload();
426  //if( isSizeIncreased )
427  //edm::LogInfo( "CondDBESSource" ) << "After reconnecting, an increased size of the IOV sequence labeled by tag \"" << tcIter->second.tag
428  // << "\" was found; from CondDBESSource::setIntervalFor";
429  //m_stats.nActualReconnect += isSizeIncreased;
431  } else {
432  edm::LogInfo( "CondDBESSource" ) << "Refreshing IOV sequence labeled by tag \"" << tcIter->second.tagName()
433  << "\" for getting new payload for record \"" << recordname
434  << "\" and label \""<< pmIter->second->label()
435  << "\" to be consumed by " << iTime.eventID() << ", timestamp: " << iTime.time().value()
436  << "; from CondDBESSource::setIntervalFor";
437  pmIter->second->proxy()->reload();
438  //if( isSizeIncreased )
439  // edm::LogInfo( "CondDBESSource" ) << "After refreshing, an increased size of the IOV sequence labeled by tag \"" << tcIter->second.tag
440  // << "\" was found; from CondDBESSource::setIntervalFor";
441  //m_stats.nActualRefresh += isSizeIncreased;
442  m_stats.nRefresh++;
443  }
444 
445  }
446 
447  /*
448  // make oInterval valid For Ever
449  {
450  oInterval = edm::ValidityInterval(cond::toIOVSyncValue(recordValidity.first, cond::runnumber, true),
451  cond::toIOVSyncValue(recordValidity.second, cond::runnumber, false));
452  return;
453  }
454  */
455 
456  //query the IOVSequence
457  cond::ValidityInterval validity = (*pmIter).second->proxy()->setIntervalFor( abtime );
458 
459  edm::LogInfo( "CondDBESSource" ) << "Validity coming from IOV sequence for record \"" << recordname
460  << "\" and label \""<< pmIter->second->label()
461  << "\": (" << validity.first << ", " << validity.second
462  << ") for time (type: "<< cond::timeTypeNames( timetype ) << ") " << abtime
463  << "; from CondDBESSource::setIntervalFor";
464 
465  recordValidity.first = std::max(recordValidity.first,validity.first);
466  recordValidity.second = std::min(recordValidity.second,validity.second);
467  }
468 
469  if( m_policy == REFRESH_OPEN_IOVS ) {
470  doRefresh = ( recordValidity.second == cond::timeTypeSpecs[timetype].endValue );
471  edm::LogInfo( "CondDBESSource" ) << "Validity for record \"" << recordname
472  << "\" and the corresponding label(s) coming from Condition DB: (" << recordValidity.first
473  << ", "<< recordValidity.first
474  << ") as the last IOV element in the IOV sequence is infinity"
475  << "; from CondDBESSource::setIntervalFor";
476  }
477 
478  // to force refresh we set end-value to the minimum such an IOV can extend to: current run or lumiblock
479 
480  if ( (!userTime) && recordValidity.second !=0 ) {
481  edm::IOVSyncValue start = cond::time::toIOVSyncValue(recordValidity.first, timetype, true);
482  edm::IOVSyncValue stop = doRefresh ? cond::time::limitedIOVSyncValue (iTime, timetype)
483  : cond::time::toIOVSyncValue(recordValidity.second, timetype, false);
484 
485  oInterval = edm::ValidityInterval( start, stop );
486  }
487 
488  edm::LogInfo( "CondDBESSource" ) << "Setting validity for record \"" << recordname
489  << "\" and corresponding label(s): starting at " << oInterval.first().eventID() << ", timestamp: " << oInterval.first().time().value()
490  << ", ending at "<< oInterval.last().eventID() << ", timestamp: " << oInterval.last().time().value()
491  << ", for "<< iTime.eventID() << ", timestamp: " << iTime.time().value()
492  << "; from CondDBESSource::setIntervalFor";
493 }
494 
495 
496 //required by EventSetup System
497 void
499  std::string recordname=iRecordKey.name();
500 
501  ProxyMap::const_iterator b = m_proxies.lower_bound(recordname);
502  ProxyMap::const_iterator e = m_proxies.upper_bound(recordname);
503  if ( b == e) {
504  edm::LogInfo( "CondDBESSource" ) << "No DataProxy (Pluging) found for record \""<< recordname
505  << "\"; from CondDBESSource::registerProxies";
506  return;
507  }
508 
509  for (ProxyMap::const_iterator p=b;p!=e;++p) {
510  if(0 != (*p).second.get()) {
511  edm::eventsetup::TypeTag type = (*p).second->type();
512  edm::eventsetup::DataKey key( type, edm::eventsetup::IdTags((*p).second->label().c_str()) );
513  aProxyList.push_back(KeyedProxies::value_type(key,(*p).second->edmProxy()));
514  }
515  }
516 }
517 
518 // required by the EventSetup System
519 void
521  const edm::ValidityInterval&)
522 {
523  //LogDebug ("CondDBESSource")<<"newInterval";
524  invalidateProxies(iRecordType);
525 }
526 
527 
528 // Fills tag collection from the given globaltag
530  const std::string & prefix,
531  const std::string & postfix,
532  const std::string & roottag,
533  std::set< cond::GTEntry_t > & tagcoll )
534 {
535  if ( !roottag.empty() ) {
536  if ( connectionString.empty() )
537  throw cond::Exception( std::string( "ESSource: requested global tag ") + roottag + std::string( " but not connection string given" ) );
539  session.transaction().start( true );
540  cond::persistency::GTProxy gtp = session.readGlobalTag( roottag, prefix, postfix );
541  for( const auto& gte : gtp ){
542  tagcoll.insert( gte );
543  }
544  session.transaction().commit();
545  }
546 }
547 
548 // fills tagcollection merging with replacement
549 // Note: it assumem the coraldbList and roottagList have the same length. This checked in the constructor that prepares the two lists before calling this method.
550 void CondDBESSource::fillTagCollectionFromDB( const std::vector<std::string> & connectionStringList,
551  const std::vector<std::string> & prefixList,
552  const std::vector<std::string> & postfixList,
553  const std::vector<std::string> & roottagList,
554  std::map<std::string,cond::GTEntry_t>& replacement )
555 {
556  std::set< cond::GTEntry_t > tagcoll;
557 
558  auto connectionString = connectionStringList.begin();
559  auto prefix = prefixList.begin();
560  auto postfix = postfixList.begin();
561  for( auto roottag = roottagList.begin(); roottag != roottagList.end(); ++roottag, ++connectionString, ++prefix, ++postfix) {
562  fillTagCollectionFromGT(*connectionString, *prefix, *postfix, *roottag, tagcoll);
563  }
564 
565  std::set<cond::GTEntry_t>::iterator tagCollIter;
566  std::set<cond::GTEntry_t>::iterator tagCollBegin = tagcoll.begin();
567  std::set<cond::GTEntry_t>::iterator tagCollEnd = tagcoll.end();
568 
569  // FIXME the logic is a bit perverse: can be surely linearized (at least simplified!) ....
570  for( tagCollIter = tagCollBegin; tagCollIter != tagCollEnd; ++tagCollIter ) {
571  std::string recordLabelKey = joinRecordAndLabel( tagCollIter->recordName(), tagCollIter->recordLabel() );
572  std::map<std::string,cond::GTEntry_t>::iterator fid = replacement.find( recordLabelKey );
573  if( fid != replacement.end() ) {
574  cond::GTEntry_t tagMetadata( std::make_tuple( tagCollIter->recordName(), tagCollIter->recordLabel(), fid->second.tagName() ) );
575  m_tagCollection.insert( std::make_pair( recordLabelKey, tagMetadata ) );
576  replacement.erase( fid );
577  edm::LogInfo( "CondDBESSource" ) << "Replacing tag \"" << tagCollIter->tagName()
578  << "\" for record \"" << tagMetadata.recordName()
579  << "\" and label \"" << tagMetadata.recordLabel()
580  << "\" with tag " << tagMetadata.tagName()
581  << "\"; from CondDBESSource::fillTagCollectionFromDB";
582  } else {
583  m_tagCollection.insert( std::make_pair( recordLabelKey, *tagCollIter) );
584  }
585  }
586  std::map<std::string,cond::GTEntry_t>::iterator replacementIter;
587  std::map<std::string,cond::GTEntry_t>::iterator replacementBegin = replacement.begin();
588  std::map<std::string,cond::GTEntry_t>::iterator replacementEnd = replacement.end();
589  for( replacementIter = replacementBegin; replacementIter != replacementEnd; ++replacementIter ){
590  // std::cout<<"appending"<<std::endl;
591  // std::cout<<"pfn "<<replacementIter->second.pfn<<std::endl;
592  // std::cout<<"objectname "<<replacementIter->second.objectname<<std::endl;
593  // std::cout<<"tag "<<replacementIter->second.tag<<std::endl;
594  // std::cout<<"recordname "<<replacementIter->second.recordname<<std::endl;
595  m_tagCollection.insert( *replacementIter );
596  }
597 }
598 
599 
600 // backward compatibility for configuration files
602 public:
603  explicit PoolDBESSource( const edm::ParameterSet& ps) :
604  CondDBESSource(ps){}
605 };
606 
608 //define this as a plug-in
610 
RunNumber_t run() const
Definition: EventID.h:39
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
list pfn
Definition: dbtoconf.py:76
list globaltag
Definition: align_cfg.py:7
const EventID & eventID() const
Definition: IOVSyncValue.h:42
virtual void registerProxies(const edm::eventsetup::EventSetupRecordKey &iRecordKey, KeyedProxies &aProxyList)
void start(bool readOnly=true)
Definition: Session.cc:22
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
void usingRecordWithKey(const EventSetupRecordKey &)
virtual ProxyP proxy() const =0
RefreshPolicy m_policy
Transaction & transaction()
Definition: Session.cc:66
TimeType
Definition: Time.h:21
void setParameters(const edm::ParameterSet &connectionPset)
const IOVSyncValue & last() const
void fillTagCollectionFromGT(const std::string &connectionString, const std::string &prefix, const std::string &postfix, const std::string &roottag, std::set< cond::GTEntry_t > &tagcoll)
Time_t fromIOVSyncValue(edm::IOVSyncValue const &time, TimeType timetype)
Definition: Time.cc:74
std::string const & timeTypeNames(int)
Definition: Time.cc:15
std::string const & label() const
Definition: DataProxy.h:86
unsigned long long Time_t
Definition: Time.h:16
void invalidateProxies(const EventSetupRecordKey &iRecordKey)
vector< ParameterSet > Parameters
std::pair< std::string, std::string > parseTag(const std::string &tag)
Definition: GTProxy.cc:8
std::map< std::string, unsigned int > m_lastRecordRuns
Session createSession(const std::string &connectionString, bool writeCapable=false, BackendType backType=DEFAULT_DB)
std::vector< std::pair< DataKey, boost::shared_ptr< DataProxy > > > KeyedProxies
cond::persistency::ConnectionPool m_connection
edm::IOVSyncValue toIOVSyncValue(cond::Time_t time, TimeType timetype, bool startOrStop)
Definition: Time.cc:52
LuminosityBlockNumber_t luminosityBlockNumber() const
Definition: IOVSyncValue.h:43
virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &)
void fillList(const std::string &pfn, std::vector< std::string > &pfnList, const unsigned int listSize, const std::string &type)
T min(T a, T b)
Definition: MathUtil.h:58
Container::value_type value_type
std::map< std::string, std::pair< cond::persistency::Session, std::string > > m_sessionPool
const std::string & recordLabel() const
Definition: Types.h:121
tuple out
Definition: dbtoconf.py:99
std::multimap< std::string, ProxyP > ProxyMap
std::string const & connString() const
Definition: DataProxy.h:88
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
PoolDBESSource(const edm::ParameterSet &ps)
TagCollection m_tagCollection
const Time_t TIMELIMIT(std::numeric_limits< Time_t >::max())
double b
Definition: hdecay.h:120
std::string const & tag() const
Definition: DataProxy.h:89
heterocontainer::HCTypeTag TypeTag
std::string m_connectionString
ProxyMap m_proxies
unsigned int m_lastRun
const std::string & recordName() const
Definition: Types.h:118
static const ValidityInterval & invalidInterval()
Session createReadOnlySession(const std::string &connectionString, const std::string &transactionId)
const std::string & tagName() const
Definition: Types.h:124
const Timestamp & time() const
Definition: IOVSyncValue.h:44
edm::IOVSyncValue limitedIOVSyncValue(Time_t time, TimeType timetype)
Definition: Time.cc:91
tuple cout
Definition: gather_cfg.py:121
virtual void newInterval(const edm::eventsetup::EventSetupRecordKey &iRecordType, const edm::ValidityInterval &iInterval)
called when a new interval of validity occurs for iRecordType
volatile std::atomic< bool > shutdown_flag false
const IOVSyncValue & first() const
Time_t endValue
Definition: Time.h:46
void fillTagCollectionFromDB(const std::vector< std::string > &connectionStringList, const std::vector< std::string > &prefixList, const std::vector< std::string > &postfixList, const std::vector< std::string > &roottagList, std::map< std::string, cond::GTEntry_t > &replacement)
CondDBESSource(const edm::ParameterSet &)
GTProxy readGlobalTag(const std::string &name)
Definition: Session.cc:164
list fid
Definition: NewTree.py:51
unsigned int m_lastLumi
double split
Definition: MVATrainer.cc:139
TimeValue_t value() const
Definition: Timestamp.h:56
boost::shared_ptr< cond::DataProxyWrapperBase > ProxyP
T get(const Candidate &c)
Definition: component.h:55
void findingRecordWithKey(const eventsetup::EventSetupRecordKey &)
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:125