CMS 3D CMS Logo

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

#include <EventSetupProvider.h>

Public Types

typedef std::pair< DataType,
DataLabel
DataKeyInfo
 
typedef std::string DataLabel
 
typedef std::string DataType
 
typedef std::map
< ComponentDescription,
RecordToDataMap
PreferredProviderInfo
 
typedef std::string RecordName
 
typedef std::multimap
< RecordName, DataKeyInfo
RecordToDataMap
 

Public Member Functions

void add (boost::shared_ptr< DataProxyProvider >)
 
void add (boost::shared_ptr< EventSetupRecordIntervalFinder >)
 
void addRecordToEventSetup (EventSetupRecord &iRecord)
 
void checkESProducerSharing (EventSetupProvider &precedingESProvider, std::set< ParameterSetIDHolder > &sharingCheckDone, std::map< EventSetupRecordKey, std::vector< ComponentDescription const * > > &referencedESProducers, EventSetupsController &esController)
 
void clearInitializationData ()
 
bool doRecordsMatch (EventSetupProvider &precedingESProvider, EventSetupRecordKey const &eventSetupRecordKey, std::map< EventSetupRecordKey, bool > &allComponentsMatch, EventSetupsController const &esController)
 
EventSetup const & eventSetup () const
 
EventSetup const & eventSetupForInstance (IOVSyncValue const &)
 
 EventSetupProvider (unsigned subProcessIndex=0U, PreferredProviderInfo const *iInfo=0)
 
void fillReferencedDataKeys (EventSetupRecordKey const &eventSetupRecordKey)
 
void finishConfiguration ()
 
void forceCacheClear ()
 Used when testing that all code properly updates on IOV changes of all Records. More...
 
std::set< ComponentDescriptionproxyProviderDescriptions () const
 
void replaceExisting (boost::shared_ptr< DataProxyProvider >)
 
void resetRecordPlusDependentRecords (EventSetupRecordKey const &)
 Used when we need to force a Record to reset all its proxies. More...
 
void resetRecordToProxyPointers ()
 
unsigned subProcessIndex () const
 
virtual ~EventSetupProvider ()
 

Static Public Member Functions

static void logInfoWhenSharing (ParameterSet const &iConfiguration)
 

Protected Member Functions

template<typename T >
void insert (std::auto_ptr< T > iRecordProvider)
 

Private Types

typedef std::map
< EventSetupRecordKey,
boost::shared_ptr
< EventSetupRecordProvider > > 
Providers
 

Private Member Functions

 EventSetupProvider (EventSetupProvider const &)
 
void insert (EventSetupRecordKey const &, std::auto_ptr< EventSetupRecordProvider >)
 
EventSetupProvider const & operator= (EventSetupProvider const &)
 

Private Attributes

std::unique_ptr< std::vector
< boost::shared_ptr
< DataProxyProvider > > > 
dataProviders_
 
EventSetup eventSetup_
 
std::unique_ptr< std::vector
< boost::shared_ptr
< EventSetupRecordIntervalFinder > > > 
finders_
 
bool mustFinishConfiguration_
 
std::unique_ptr
< PreferredProviderInfo
preferredProviderInfo_
 
Providers providers_
 
std::unique_ptr< std::map
< ParameterSetIDHolder,
std::set< EventSetupRecordKey > > > 
psetIDToRecordKey_
 
std::unique_ptr< std::set
< EventSetupRecordKey > > 
recordsWithALooperProxy_
 
std::unique_ptr< std::map
< EventSetupRecordKey,
std::vector< boost::shared_ptr
< EventSetupRecordIntervalFinder > > > > 
recordToFinders_
 
std::unique_ptr< std::map
< EventSetupRecordKey,
std::map< DataKey,
ComponentDescription > > > 
recordToPreferred_
 
std::unique_ptr< std::map
< EventSetupRecordKey,
std::map< DataKey,
ComponentDescription const * > > > 
referencedDataKeys_
 
unsigned subProcessIndex_
 

Detailed Description

Definition at line 50 of file EventSetupProvider.h.

Member Typedef Documentation

Definition at line 56 of file EventSetupProvider.h.

Definition at line 55 of file EventSetupProvider.h.

Definition at line 54 of file EventSetupProvider.h.

Definition at line 58 of file EventSetupProvider.h.

Definition at line 128 of file EventSetupProvider.h.

Definition at line 53 of file EventSetupProvider.h.

Definition at line 57 of file EventSetupProvider.h.

Constructor & Destructor Documentation

EventSetupProvider::EventSetupProvider ( unsigned  subProcessIndex = 0U,
PreferredProviderInfo const *  iInfo = 0 
)

Definition at line 48 of file EventSetupProvider.cc.

48  :
49 eventSetup_(),
50 providers_(),
53 preferredProviderInfo_((0!=iInfo) ? (new PreferredProviderInfo(*iInfo)): 0),
54 finders_(new std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> >() ),
55 dataProviders_(new std::vector<boost::shared_ptr<DataProxyProvider> >() ),
56 referencedDataKeys_(new std::map<EventSetupRecordKey, std::map<DataKey, ComponentDescription const*> >),
57 recordToFinders_(new std::map<EventSetupRecordKey, std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> > >),
58 psetIDToRecordKey_(new std::map<ParameterSetIDHolder, std::set<EventSetupRecordKey> >),
59 recordToPreferred_(new std::map<EventSetupRecordKey, std::map<DataKey, ComponentDescription> >),
60 recordsWithALooperProxy_(new std::set<EventSetupRecordKey>)
61 {
62 }
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription const * > > > referencedDataKeys_
std::map< ComponentDescription, RecordToDataMap > PreferredProviderInfo
std::unique_ptr< std::set< EventSetupRecordKey > > recordsWithALooperProxy_
std::unique_ptr< PreferredProviderInfo > preferredProviderInfo_
std::unique_ptr< std::vector< boost::shared_ptr< DataProxyProvider > > > dataProviders_
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
std::unique_ptr< std::map< EventSetupRecordKey, std::vector< boost::shared_ptr< EventSetupRecordIntervalFinder > > > > recordToFinders_
std::unique_ptr< std::vector< boost::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
EventSetupProvider::~EventSetupProvider ( )
virtual

Definition at line 69 of file EventSetupProvider.cc.

70 {
71 }
edm::eventsetup::EventSetupProvider::EventSetupProvider ( EventSetupProvider const &  )
private

Member Function Documentation

void EventSetupProvider::add ( boost::shared_ptr< DataProxyProvider iProvider)

Definition at line 97 of file EventSetupProvider.cc.

References dataProviders_.

Referenced by edm::eventsetup::looper::addFinderTo(), edm::eventsetup::addProviderTo(), edm::eventsetup::looper::addProviderTo(), edm::eventsetup::ModuleMakerTraits::addTo(), and edm::eventsetup::SourceMakerTraits::addTo().

98 {
99  assert(&(*iProvider) != 0);
100  dataProviders_->push_back(iProvider);
101 }
std::unique_ptr< std::vector< boost::shared_ptr< DataProxyProvider > > > dataProviders_
void EventSetupProvider::add ( boost::shared_ptr< EventSetupRecordIntervalFinder iFinder)

Definition at line 115 of file EventSetupProvider.cc.

References finders_.

116 {
117  assert(&(*iFinder) != 0);
118  finders_->push_back(iFinder);
119 }
std::unique_ptr< std::vector< boost::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
void EventSetupProvider::addRecordToEventSetup ( EventSetupRecord iRecord)

Definition at line 717 of file EventSetupProvider.cc.

References edm::EventSetup::add(), eventSetup_, and edm::eventsetup::EventSetupRecord::setEventSetup().

Referenced by edm::eventsetup::EventSetupRecordProvider::addRecordTo().

717  {
718  iRecord.setEventSetup(&eventSetup_);
719  eventSetup_.add(iRecord);
720 }
void add(const eventsetup::EventSetupRecord &iRecord)
Definition: EventSetup.cc:81
void setEventSetup(EventSetup const *iEventSetup)
void EventSetupProvider::checkESProducerSharing ( EventSetupProvider precedingESProvider,
std::set< ParameterSetIDHolder > &  sharingCheckDone,
std::map< EventSetupRecordKey, std::vector< ComponentDescription const * > > &  referencedESProducers,
EventSetupsController esController 
)

Definition at line 434 of file EventSetupProvider.cc.

References doRecordsMatch(), edm::eventsetup::ComponentFactory< T >::get(), edm::eventsetup::EventSetupsController::getESProducerPSet(), edm::eventsetup::EventSetupsController::isFirstMatch(), edm::eventsetup::EventSetupsController::isLastMatch(), combine::key, logInfoWhenSharing(), edm::eventsetup::EventSetupsController::lookForMatches(), edm::match(), providers_, psetIDToRecordKey_, subProcessIndex(), and subProcessIndex_.

437  {
438 
439  edm::LogVerbatim("EventSetupSharing") << "EventSetupProvider::checkESProducerSharing: Checking processes with SubProcess Indexes "
440  << subProcessIndex() << " and " << precedingESProvider.subProcessIndex();
441 
442  if (referencedESProducers.empty()) {
443  for (auto const& recordProvider : providers_) {
444  recordProvider.second->getReferencedESProducers(referencedESProducers);
445  }
446  }
447 
448  // This records whether the configurations of all the DataProxyProviders
449  // and finders matches for a particular pair of processes and
450  // a particular record and also the records it depends on.
451  std::map<EventSetupRecordKey, bool> allComponentsMatch;
452 
453  std::map<ParameterSetID, bool> candidateNotRejectedYet;
454 
455  // Loop over all the ESProducers which have a DataProxy
456  // referenced by any EventSetupRecord in this EventSetupProvider
457  for (auto const& iRecord : referencedESProducers) {
458  for (auto const& iComponent : iRecord.second) {
459 
460  ParameterSetID const& psetID = iComponent->pid_;
461  ParameterSetIDHolder psetIDHolder(psetID);
462  if (sharingCheckDone.find(psetIDHolder) != sharingCheckDone.end()) continue;
463 
464  bool firstProcessWithThisPSet = false;
465  bool precedingHasMatchingPSet = false;
466 
467  esController.lookForMatches(psetID,
469  precedingESProvider.subProcessIndex_,
470  firstProcessWithThisPSet,
471  precedingHasMatchingPSet);
472 
473  if (firstProcessWithThisPSet) {
474  sharingCheckDone.insert(psetIDHolder);
475  allComponentsMatch[iRecord.first] = false;
476  continue;
477  }
478 
479  if (!precedingHasMatchingPSet) {
480  allComponentsMatch[iRecord.first] = false;
481  continue;
482  }
483 
484  // An ESProducer that survives to this point is a candidate.
485  // It was shared with some other process in the first pass where
486  // ESProducers were constructed and one of three possibilities exists:
487  // 1) It should not have been shared and a new ESProducer needs
488  // to be created and the proper pointers set.
489  // 2) It should have been shared with a different preceding process
490  // in which case some pointers need to be modified.
491  // 3) It was originally shared which the correct prior process
492  // in which case nothing needs to be done, but we do need to
493  // do some work to verify that.
494  // Make an entry in a map for each of these ESProducers. We
495  // will set the value to false if and when we determine
496  // the ESProducer cannot be shared between this pair of processes.
497  auto iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
498  if (iCandidateNotRejectedYet == candidateNotRejectedYet.end()) {
499  candidateNotRejectedYet[psetID] = true;
500  iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
501  }
502 
503  // At this point we know that the two processes both
504  // have an ESProducer matching the type and label in
505  // iComponent and also with exactly the same configuration.
506  // And there was not an earlier preceding process
507  // where the same instance of the ESProducer could
508  // have been shared. And this ESProducer was referenced
509  // by the later process's EventSetupRecord (prefered or
510  // or just the only thing that could have made the data).
511  // To determine if sharing is allowed, now we need to
512  // check if all the DataProxyProviders and all the
513  // finders are the same for this record and also for
514  // all records this record depends on. And even
515  // if this is true, we have to wait until the loop
516  // ends because some other DataProxy associated with
517  // the ESProducer could write to a different record where
518  // the same determination will need to be repeated. Only if
519  // all of the the DataProxy's can be shared, can the ESProducer
520  // instance be shared across processes.
521 
522  if (iCandidateNotRejectedYet->second == true) {
523 
524  auto iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
525  if (iAllComponentsMatch == allComponentsMatch.end()) {
526 
527  // We do not know the value in AllComponents yet and
528  // we need it now so we have to do the difficult calculation
529  // now.
530  bool match = doRecordsMatch(precedingESProvider,
531  iRecord.first,
532  allComponentsMatch,
533  esController);
534  allComponentsMatch[iRecord.first] = match;
535  iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
536  }
537  if (!iAllComponentsMatch->second) {
538  iCandidateNotRejectedYet->second = false;
539  }
540  }
541  } // end loop over components used by record
542  } // end loop over records
543 
544  // Loop over candidates
545  for (auto const& candidate : candidateNotRejectedYet) {
546  ParameterSetID const& psetID = candidate.first;
547  bool canBeShared = candidate.second;
548  if (canBeShared) {
549  ParameterSet const& pset = *esController.getESProducerPSet(psetID, subProcessIndex_);
550  logInfoWhenSharing(pset);
551  ParameterSetIDHolder psetIDHolder(psetID);
552  sharingCheckDone.insert(psetIDHolder);
553  if (esController.isFirstMatch(psetID,
555  precedingESProvider.subProcessIndex_)) {
556  continue; // Proper sharing was already done. Nothing more to do.
557  }
558 
559  // Need to reset the pointer from the EventSetupRecordProvider to the
560  // the DataProxyProvider so these two processes share an ESProducer.
561 
562  boost::shared_ptr<DataProxyProvider> dataProxyProvider;
563  std::set<EventSetupRecordKey> const& keysForPSetID1 = (*precedingESProvider.psetIDToRecordKey_)[psetIDHolder];
564  for (auto const& key : keysForPSetID1) {
565  boost::shared_ptr<EventSetupRecordProvider> const& recordProvider = precedingESProvider.providers_[key];
566  dataProxyProvider = recordProvider->proxyProvider(psetIDHolder);
567  assert(dataProxyProvider);
568  break;
569  }
570 
571  std::set<EventSetupRecordKey> const& keysForPSetID2 = (*psetIDToRecordKey_)[psetIDHolder];
572  for (auto const& key : keysForPSetID2) {
573  boost::shared_ptr<EventSetupRecordProvider> const& recordProvider = providers_[key];
574  recordProvider->resetProxyProvider(psetIDHolder, dataProxyProvider);
575  }
576  } else {
577  if (esController.isLastMatch(psetID,
579  precedingESProvider.subProcessIndex_)) {
580 
581 
582  ParameterSet const& pset = *esController.getESProducerPSet(psetID, subProcessIndex_);
583  ModuleFactory::get()->addTo(esController,
584  *this,
585  pset,
586  true);
587 
588  }
589  }
590  }
591 }
void lookForMatches(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
bool isFirstMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
static void logInfoWhenSharing(ParameterSet const &iConfiguration)
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
bool isLastMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
ParameterSet const * getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex) const
Hash< ParameterSetType > ParameterSetID
list key
Definition: combine.py:13
static ComponentFactory< T > const * get()
bool doRecordsMatch(EventSetupProvider &precedingESProvider, EventSetupRecordKey const &eventSetupRecordKey, std::map< EventSetupRecordKey, bool > &allComponentsMatch, EventSetupsController const &esController)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
void EventSetupProvider::clearInitializationData ( )

Definition at line 707 of file EventSetupProvider.cc.

References preferredProviderInfo_, psetIDToRecordKey_, recordsWithALooperProxy_, recordToFinders_, recordToPreferred_, and referencedDataKeys_.

707  {
708  preferredProviderInfo_.reset();
709  referencedDataKeys_.reset();
710  recordToFinders_.reset();
711  psetIDToRecordKey_.reset();
712  recordToPreferred_.reset();
713  recordsWithALooperProxy_.reset();
714 }
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription const * > > > referencedDataKeys_
std::unique_ptr< std::set< EventSetupRecordKey > > recordsWithALooperProxy_
std::unique_ptr< PreferredProviderInfo > preferredProviderInfo_
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
std::unique_ptr< std::map< EventSetupRecordKey, std::vector< boost::shared_ptr< EventSetupRecordIntervalFinder > > > > recordToFinders_
bool EventSetupProvider::doRecordsMatch ( EventSetupProvider precedingESProvider,
EventSetupRecordKey const &  eventSetupRecordKey,
std::map< EventSetupRecordKey, bool > &  allComponentsMatch,
EventSetupsController const &  esController 
)

Definition at line 594 of file EventSetupProvider.cc.

References fillReferencedDataKeys(), edm::eventsetup::EventSetupsController::isMatchingESProducer(), edm::eventsetup::EventSetupsController::isMatchingESSource(), getDQMSummary::iter, edm::match(), providers_, recordsWithALooperProxy_, recordToFinders_, referencedDataKeys_, findQualityFiles::size, and subProcessIndex_.

Referenced by checkESProducerSharing().

597  {
598  // first check if this record matches. If not just return false
599 
600  // then find the directly dependent records and iterate over them
601  // recursively call this function on them. If they return false
602  // set allComponentsMatch to false for them and return false.
603  // if they all return true then set allComponents to true
604  // and return true.
605 
606  if (precedingESProvider.recordsWithALooperProxy_->find(eventSetupRecordKey) != precedingESProvider.recordsWithALooperProxy_->end()) {
607  return false;
608  }
609 
610  if ((*recordToFinders_)[eventSetupRecordKey].size() != (*precedingESProvider.recordToFinders_)[eventSetupRecordKey].size()) {
611  return false;
612  }
613 
614  for (auto const& finder : (*recordToFinders_)[eventSetupRecordKey]) {
615  ParameterSetID const& psetID = finder->descriptionForFinder().pid_;
616  bool itMatches = esController.isMatchingESSource(psetID,
618  precedingESProvider.subProcessIndex_);
619  if (!itMatches) {
620  return false;
621  }
622  }
623 
624  fillReferencedDataKeys(eventSetupRecordKey);
625  precedingESProvider.fillReferencedDataKeys(eventSetupRecordKey);
626 
627  std::map<DataKey, ComponentDescription const*> const& dataItems = (*referencedDataKeys_)[eventSetupRecordKey];
628 
629  std::map<DataKey, ComponentDescription const*> const& precedingDataItems = (*precedingESProvider.referencedDataKeys_)[eventSetupRecordKey];
630 
631  if (dataItems.size() != precedingDataItems.size()) {
632  return false;
633  }
634 
635  for (auto const& dataItem : dataItems) {
636  auto precedingDataItem = precedingDataItems.find(dataItem.first);
637  if (precedingDataItem == precedingDataItems.end()) {
638  return false;
639  }
640  if (dataItem.second->pid_ != precedingDataItem->second->pid_) {
641  return false;
642  }
643  // Check that the configurations match exactly for the ESProducers
644  // (We already checked the ESSources above and there should not be
645  // any loopers)
646  if (!dataItem.second->isSource_ && !dataItem.second->isLooper_) {
647  bool itMatches = esController.isMatchingESProducer(dataItem.second->pid_,
649  precedingESProvider.subProcessIndex_);
650  if (!itMatches) {
651  return false;
652  }
653  }
654  }
655  Providers::iterator itFound = providers_.find(eventSetupRecordKey);
656  if (itFound != providers_.end()) {
657  std::set<EventSetupRecordKey> dependentRecords = itFound->second->dependentRecords();
658  for (auto const& dependentRecord : dependentRecords) {
659  auto iter = allComponentsMatch.find(dependentRecord);
660  if (iter != allComponentsMatch.end()) {
661  if (iter->second) {
662  continue;
663  } else {
664  return false;
665  }
666  }
667  bool match = doRecordsMatch(precedingESProvider,
668  dependentRecord,
669  allComponentsMatch,
670  esController);
671  allComponentsMatch[dependentRecord] = match;
672  if (!match) return false;
673  }
674  }
675  return true;
676 }
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription const * > > > referencedDataKeys_
void fillReferencedDataKeys(EventSetupRecordKey const &eventSetupRecordKey)
std::unique_ptr< std::set< EventSetupRecordKey > > recordsWithALooperProxy_
Hash< ParameterSetType > ParameterSetID
std::unique_ptr< std::map< EventSetupRecordKey, std::vector< boost::shared_ptr< EventSetupRecordIntervalFinder > > > > recordToFinders_
tuple size
Write out results.
bool doRecordsMatch(EventSetupProvider &precedingESProvider, EventSetupRecordKey const &eventSetupRecordKey, std::map< EventSetupRecordKey, bool > &allComponentsMatch, EventSetupsController const &esController)
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
EventSetup const& edm::eventsetup::EventSetupProvider::eventSetup ( ) const
inline

Definition at line 71 of file EventSetupProvider.h.

References eventSetup_.

EventSetup const & EventSetupProvider::eventSetupForInstance ( IOVSyncValue const &  iValue)

Definition at line 726 of file EventSetupProvider.cc.

References edm::EventSetup::clear(), eventSetup_, finishConfiguration(), mustFinishConfiguration_, providers_, and edm::EventSetup::setIOVSyncValue().

727 {
729 
730  eventSetup_.clear();
731 
732  // In a cmsRun job this does nothing because the EventSetupsController
733  // will have already called finishConfiguration, but some tests will
734  // call finishConfiguration here.
737  }
738 
739  for(Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
740  itProvider != itProviderEnd;
741  ++itProvider) {
742  itProvider->second->addRecordToIfValid(*this, iValue);
743  }
744  return eventSetup_;
745 }
void setIOVSyncValue(const IOVSyncValue &)
Definition: EventSetup.cc:62
void EventSetupProvider::fillReferencedDataKeys ( EventSetupRecordKey const &  eventSetupRecordKey)

Definition at line 679 of file EventSetupProvider.cc.

References providers_, and referencedDataKeys_.

Referenced by doRecordsMatch().

679  {
680 
681  if (referencedDataKeys_->find(eventSetupRecordKey) != referencedDataKeys_->end()) return;
682 
683  auto recordProvider = providers_.find(eventSetupRecordKey);
684  if (recordProvider == providers_.end()) {
685  (*referencedDataKeys_)[eventSetupRecordKey];
686  return;
687  }
688  if (recordProvider->second) {
689  recordProvider->second->fillReferencedDataKeys((*referencedDataKeys_)[eventSetupRecordKey]);
690  }
691 }
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription const * > > > referencedDataKeys_
void EventSetupProvider::finishConfiguration ( )

Definition at line 263 of file EventSetupProvider.cc.

References dataProviders_, edm::eventsetup::determinePreferred(), finders_, insert(), edm::eventsetup::EventSetupRecordProviderFactoryManager::instance(), mustFinishConfiguration_, preferredProviderInfo_, providers_, psetIDToRecordKey_, recordsWithALooperProxy_, recordToFinders_, recordToPreferred_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by eventSetupForInstance().

264 {
265  //we delayed adding finders to the system till here so that everything would be loaded first
266  recordToFinders_->clear();
267  for(std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> >::iterator itFinder=finders_->begin(),
268  itEnd = finders_->end();
269  itFinder != itEnd;
270  ++itFinder) {
271  typedef std::set<EventSetupRecordKey> Keys;
272  const Keys recordsUsing = (*itFinder)->findingForRecords();
273 
274  for(Keys::const_iterator itKey = recordsUsing.begin(), itKeyEnd = recordsUsing.end();
275  itKey != itKeyEnd;
276  ++itKey) {
277  (*recordToFinders_)[*itKey].push_back(*itFinder);
278  Providers::iterator itFound = providers_.find(*itKey);
279  if(providers_.end() == itFound) {
280  //create a provider for this record
281  insert(*itKey, EventSetupRecordProviderFactoryManager::instance().makeRecordProvider(*itKey));
282  itFound = providers_.find(*itKey);
283  }
284  itFound->second->addFinder(*itFinder);
285  }
286  }
287  //we've transfered our ownership so this is no longer needed
288  finders_.reset();
289 
290  //Now handle providers since sources can also be finders and the sources can delay registering
291  // their Records and therefore could delay setting up their Proxies
292  psetIDToRecordKey_->clear();
293  typedef std::set<EventSetupRecordKey> Keys;
294  for(std::vector<boost::shared_ptr<DataProxyProvider> >::iterator itProvider=dataProviders_->begin(),
295  itEnd = dataProviders_->end();
296  itProvider != itEnd;
297  ++itProvider) {
298 
299  ParameterSetIDHolder psetID((*itProvider)->description().pid_);
300 
301  const Keys recordsUsing = (*itProvider)->usingRecords();
302 
303  for(Keys::const_iterator itKey = recordsUsing.begin(), itKeyEnd = recordsUsing.end();
304  itKey != itKeyEnd;
305  ++itKey) {
306 
307  if ((*itProvider)->description().isLooper_) {
308  recordsWithALooperProxy_->insert(*itKey);
309  }
310 
311  (*psetIDToRecordKey_)[psetID].insert(*itKey);
312 
313  Providers::iterator itFound = providers_.find(*itKey);
314  if(providers_.end() == itFound) {
315  //create a provider for this record
316  insert(*itKey, EventSetupRecordProviderFactoryManager::instance().makeRecordProvider(*itKey));
317  itFound = providers_.find(*itKey);
318  }
319  itFound->second->add(*itProvider);
320  }
321  }
322  dataProviders_.reset();
323 
324  //used for the case where no preferred Providers have been specified for the Record
326 
328  //For each Provider, find all the Providers it depends on. If a dependent Provider
329  // can not be found pass in an empty list
330  //CHANGE: now allow for missing Providers
331  for(Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
332  itProvider != itProviderEnd;
333  ++itProvider) {
334  const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
335  RecordToPreferred::const_iterator itRecordFound = recordToPreferred_->find(itProvider->first);
336  if(itRecordFound != recordToPreferred_->end()) {
337  preferredInfo = &(itRecordFound->second);
338  }
339  //Give it our list of preferred
340  itProvider->second->usePreferred(*preferredInfo);
341 
342  std::set<EventSetupRecordKey> records = itProvider->second->dependentRecords();
343  if(records.size() != 0) {
344  std::string missingRecords;
345  std::vector<boost::shared_ptr<EventSetupRecordProvider> > depProviders;
346  depProviders.reserve(records.size());
347  bool foundAllProviders = true;
348  for(std::set<EventSetupRecordKey>::iterator itRecord = records.begin(),
349  itRecordEnd = records.end();
350  itRecord != itRecordEnd;
351  ++itRecord) {
352  Providers::iterator itFound = providers_.find(*itRecord);
353  if(itFound == providers_.end()) {
354  foundAllProviders = false;
355  if(missingRecords.size() == 0) {
356  missingRecords = itRecord->name();
357  } else {
358  missingRecords += ", ";
359  missingRecords += itRecord->name();
360  }
361  //break;
362  } else {
363  depProviders.push_back(itFound->second);
364  }
365  }
366 
367  if(!foundAllProviders) {
368  edm::LogInfo("EventSetupDependency")<<"The EventSetup record "<<itProvider->second->key().name()
369  <<" depends on at least one Record \n ("<<missingRecords<<") which is not present in the job."
370  "\n This may lead to an exception begin thrown during event processing.\n If no exception occurs during the job than it is usually safe to ignore this message.";
371 
372  //depProviders.clear();
373  //NOTE: should provide a warning
374  }
375 
376  itProvider->second->setDependentProviders(depProviders);
377  }
378  }
379  mustFinishConfiguration_ = false;
380 }
std::map< DataKey, ComponentDescription > DataToPreferredProviderMap
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
void insert(std::auto_ptr< T > iRecordProvider)
std::unique_ptr< std::set< EventSetupRecordKey > > recordsWithALooperProxy_
std::unique_ptr< PreferredProviderInfo > preferredProviderInfo_
static RecordToPreferred determinePreferred(const EventSetupProvider::PreferredProviderInfo *iInfo, const Providers &iProviders)
std::vector< size_type > Keys
std::unique_ptr< std::vector< boost::shared_ptr< DataProxyProvider > > > dataProviders_
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
std::unique_ptr< std::map< EventSetupRecordKey, std::vector< boost::shared_ptr< EventSetupRecordIntervalFinder > > > > recordToFinders_
std::unique_ptr< std::vector< boost::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
void EventSetupProvider::forceCacheClear ( )

Used when testing that all code properly updates on IOV changes of all Records.

Definition at line 424 of file EventSetupProvider.cc.

References providers_.

425 {
426  for(Providers::iterator it=providers_.begin(), itEnd = providers_.end();
427  it != itEnd;
428  ++it) {
429  it->second->resetProxies();
430  }
431 }
template<typename T >
void edm::eventsetup::EventSetupProvider::insert ( std::auto_ptr< T iRecordProvider)
inlineprotected

Definition at line 111 of file EventSetupProvider.h.

References edm::eventsetup::heterocontainer::makeKey(), and groupFilesInBlocks::temp.

Referenced by BeautifulSoup.PageElement::_invert(), and finishConfiguration().

111  {
112  std::auto_ptr<EventSetupRecordProvider> temp(iRecordProvider.release());
114  typename T::RecordType,
115  eventsetup::EventSetupRecordKey>(),
116  temp);
117  }
Key makeKey(const IdTag &iIdTag)
Definition: HCMethods.h:28
void insert(std::auto_ptr< T > iRecordProvider)
void EventSetupProvider::insert ( EventSetupRecordKey const &  iKey,
std::auto_ptr< EventSetupRecordProvider iProvider 
)
private

Definition at line 89 of file EventSetupProvider.cc.

References providers_, and groupFilesInBlocks::temp.

Referenced by BeautifulSoup.PageElement::_invert().

90 {
91  boost::shared_ptr<EventSetupRecordProvider> temp(iProvider.release());
92  providers_[iKey] = temp;
93  //temp->addRecordTo(*this);
94 }
void EventSetupProvider::logInfoWhenSharing ( ParameterSet const &  iConfiguration)
static

Definition at line 785 of file EventSetupProvider.cc.

References edm::ParameterSet::getParameter(), diffTwoXMLs::label, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by checkESProducerSharing().

785  {
786 
787  std::string edmtype = iConfiguration.getParameter<std::string>("@module_edm_type");
788  std::string modtype = iConfiguration.getParameter<std::string>("@module_type");
789  std::string label = iConfiguration.getParameter<std::string>("@module_label");
790  edm::LogVerbatim("EventSetupSharing") << "Sharing " << edmtype << ": class=" << modtype << " label='" << label << "'";
791 }
EventSetupProvider const& edm::eventsetup::EventSetupProvider::operator= ( EventSetupProvider const &  )
private
std::set< ComponentDescription > EventSetupProvider::proxyProviderDescriptions ( ) const

Definition at line 759 of file EventSetupProvider.cc.

References dataProviders_, edm::for_all(), providers_, edm::eventsetup::EventSetupRecordProvider::proxyProviderDescriptions(), and edm::second().

760 {
761  using boost::bind;
762  typedef std::set<ComponentDescription> Set;
763  Set descriptions;
764 
766  bind(InsertAll(descriptions),
768  bind(&Providers::value_type::second,_1))));
769  if(dataProviders_.get()) {
770  for(std::vector<boost::shared_ptr<DataProxyProvider> >::const_iterator it = dataProviders_->begin(),
771  itEnd = dataProviders_->end();
772  it != itEnd;
773  ++it) {
774  descriptions.insert((*it)->description());
775  }
776 
777  }
778 
779  return descriptions;
780 }
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
U second(std::pair< T, U > const &p)
std::set< ComponentDescription > proxyProviderDescriptions() const
return information on which DataProxyProviders are supplying information
std::unique_ptr< std::vector< boost::shared_ptr< DataProxyProvider > > > dataProviders_
void EventSetupProvider::replaceExisting ( boost::shared_ptr< DataProxyProvider dataProxyProvider)

Definition at line 104 of file EventSetupProvider.cc.

References combine::key, and providers_.

Referenced by edm::eventsetup::ModuleMakerTraits::replaceExisting().

105 {
106  ParameterSetIDHolder psetID(dataProxyProvider->description().pid_);
107  std::set<EventSetupRecordKey> const& keysForPSetID = (*psetIDToRecordKey_)[psetID];
108  for (auto const& key : keysForPSetID) {
109  boost::shared_ptr<EventSetupRecordProvider> const& recordProvider = providers_[key];
110  recordProvider->resetProxyProvider(psetID, dataProxyProvider);
111  }
112 }
list key
Definition: combine.py:13
void EventSetupProvider::resetRecordPlusDependentRecords ( EventSetupRecordKey const &  iKey)

Used when we need to force a Record to reset all its proxies.

Definition at line 404 of file EventSetupProvider.cc.

References edm::eventsetup::findDependents(), edm::for_all(), providers_, and edm::eventsetup::EventSetupRecordProvider::resetProxies().

Referenced by edm::EDLooperBase::prepareForNextLoop().

405 {
406  Providers::iterator itFind = providers_.find(iKey);
407  if(itFind == providers_.end()) {
408  return;
409  }
410 
411 
412  std::vector<boost::shared_ptr<EventSetupRecordProvider> > dependents;
413  findDependents(iKey, providers_.begin(), providers_.end(), dependents);
414 
415  dependents.erase(std::unique(dependents.begin(),dependents.end()), dependents.end());
416 
417  itFind->second->resetProxies();
418  for_all(dependents,
420  _1));
421 }
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
static void findDependents(const EventSetupRecordKey &iKey, Itr itBegin, Itr itEnd, std::vector< boost::shared_ptr< EventSetupRecordProvider > > &oDependents)
void resetProxies()
This will clear the cache&#39;s of all the Proxies so that next time they are called they will run...
void EventSetupProvider::resetRecordToProxyPointers ( )

Definition at line 694 of file EventSetupProvider.cc.

References providers_, and recordToPreferred_.

694  {
695  for (auto const& recordProvider : providers_) {
697  const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
698  RecordToPreferred::const_iterator itRecordFound = recordToPreferred_->find(recordProvider.first);
699  if(itRecordFound != recordToPreferred_->end()) {
700  preferredInfo = &(itRecordFound->second);
701  }
702  recordProvider.second->resetRecordToProxyPointers(*preferredInfo);
703  }
704 }
std::map< DataKey, ComponentDescription > DataToPreferredProviderMap
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
unsigned edm::eventsetup::EventSetupProvider::subProcessIndex ( ) const
inline

Definition at line 104 of file EventSetupProvider.h.

References subProcessIndex_.

Referenced by checkESProducerSharing().

Member Data Documentation

std::unique_ptr<std::vector<boost::shared_ptr<DataProxyProvider> > > edm::eventsetup::EventSetupProvider::dataProviders_
private

Definition at line 137 of file EventSetupProvider.h.

Referenced by add(), finishConfiguration(), and proxyProviderDescriptions().

EventSetup edm::eventsetup::EventSetupProvider::eventSetup_
private

Definition at line 127 of file EventSetupProvider.h.

Referenced by addRecordToEventSetup(), eventSetup(), and eventSetupForInstance().

std::unique_ptr<std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> > > edm::eventsetup::EventSetupProvider::finders_
private

Definition at line 136 of file EventSetupProvider.h.

Referenced by add(), and finishConfiguration().

bool edm::eventsetup::EventSetupProvider::mustFinishConfiguration_
private

Definition at line 130 of file EventSetupProvider.h.

Referenced by eventSetupForInstance(), and finishConfiguration().

std::unique_ptr<PreferredProviderInfo> edm::eventsetup::EventSetupProvider::preferredProviderInfo_
private

Definition at line 135 of file EventSetupProvider.h.

Referenced by clearInitializationData(), and finishConfiguration().

Providers edm::eventsetup::EventSetupProvider::providers_
private
std::unique_ptr<std::map<ParameterSetIDHolder, std::set<EventSetupRecordKey> > > edm::eventsetup::EventSetupProvider::psetIDToRecordKey_
private
std::unique_ptr<std::set<EventSetupRecordKey> > edm::eventsetup::EventSetupProvider::recordsWithALooperProxy_
private
std::unique_ptr<std::map<EventSetupRecordKey, std::vector<boost::shared_ptr<EventSetupRecordIntervalFinder> > > > edm::eventsetup::EventSetupProvider::recordToFinders_
private
std::unique_ptr<std::map<EventSetupRecordKey, std::map<DataKey, ComponentDescription> > > edm::eventsetup::EventSetupProvider::recordToPreferred_
private
std::unique_ptr<std::map<EventSetupRecordKey, std::map<DataKey, ComponentDescription const*> > > edm::eventsetup::EventSetupProvider::referencedDataKeys_
private
unsigned edm::eventsetup::EventSetupProvider::subProcessIndex_
private

Definition at line 131 of file EventSetupProvider.h.

Referenced by checkESProducerSharing(), doRecordsMatch(), and subProcessIndex().