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