CMS 3D CMS Logo

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, DataLabelDataKeyInfo
 
typedef std::string DataLabel
 
typedef std::string DataType
 
typedef std::map< ComponentDescription, RecordToDataMapPreferredProviderInfo
 
typedef std::string RecordName
 
typedef std::multimap< RecordName, DataKeyInfoRecordToDataMap
 

Public Member Functions

void add (std::shared_ptr< DataProxyProvider >)
 
void add (std::shared_ptr< EventSetupRecordIntervalFinder >)
 
void addRecordToEventSetup (EventSetupRecordImpl &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 (ActivityRegistry *, 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...
 
bool isWithinValidityInterval (IOVSyncValue const &) const
 
std::set< ComponentDescriptionproxyProviderDescriptions () const
 
void replaceExisting (std::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

void insert (std::unique_ptr< EventSetupRecordProvider > iRecordProvider)
 

Private Types

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

Private Member Functions

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

Private Attributes

std::unique_ptr< std::vector< std::shared_ptr< DataProxyProvider > > > dataProviders_
 
EventSetup eventSetup_
 
std::unique_ptr< std::vector< std::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
 
std::unique_ptr< EventSetupKnownRecordsSupplierknownRecordsSupplier_
 
bool mustFinishConfiguration_
 
std::unique_ptr< PreferredProviderInfopreferredProviderInfo_
 
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< std::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 51 of file EventSetupProvider.h.

Member Typedef Documentation

Definition at line 57 of file EventSetupProvider.h.

Definition at line 56 of file EventSetupProvider.h.

Definition at line 55 of file EventSetupProvider.h.

Definition at line 59 of file EventSetupProvider.h.

Definition at line 123 of file EventSetupProvider.h.

Definition at line 54 of file EventSetupProvider.h.

Definition at line 58 of file EventSetupProvider.h.

Constructor & Destructor Documentation

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

Referenced by subProcessIndex().

EventSetupProvider::~EventSetupProvider ( )
virtual

Definition at line 88 of file EventSetupProvider.cc.

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

89 {
91 }
void forceCacheClear()
Used when testing that all code properly updates on IOV changes of all Records.
edm::eventsetup::EventSetupProvider::EventSetupProvider ( EventSetupProvider const &  )
privatedelete

Member Function Documentation

void EventSetupProvider::add ( std::shared_ptr< DataProxyProvider iProvider)
void EventSetupProvider::add ( std::shared_ptr< EventSetupRecordIntervalFinder iFinder)

Definition at line 135 of file EventSetupProvider.cc.

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

136 {
137  assert(iFinder.get() != nullptr);
138  finders_->push_back(iFinder);
139 }
std::unique_ptr< std::vector< std::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
void EventSetupProvider::addRecordToEventSetup ( EventSetupRecordImpl iRecord)

Definition at line 738 of file EventSetupProvider.cc.

References edm::eventsetup::EventSetupRecordImpl::setEventSetup().

Referenced by edm::eventsetup::EventSetupRecordProvider::addRecordTo(), and eventSetup().

738  {
739  iRecord.setEventSetup(&eventSetup_);
740  eventSetup_.add(iRecord);
741 }
void setEventSetup(EventSetup const *iEventSetup)
void add(const eventsetup::EventSetupRecordImpl &iRecord)
Definition: EventSetup.cc:79
void EventSetupProvider::checkESProducerSharing ( EventSetupProvider precedingESProvider,
std::set< ParameterSetIDHolder > &  sharingCheckDone,
std::map< EventSetupRecordKey, std::vector< ComponentDescription const * > > &  referencedESProducers,
EventSetupsController esController 
)

Definition at line 455 of file EventSetupProvider.cc.

References reco::get(), edm::eventsetup::EventSetupsController::getESProducerPSet(), edm::eventsetup::EventSetupsController::isFirstMatch(), edm::eventsetup::EventSetupsController::isLastMatch(), crabWrapper::key, edm::eventsetup::EventSetupsController::lookForMatches(), match(), providers_, muonDTDigis_cfi::pset, psetIDToRecordKey_, subProcessIndex(), and subProcessIndex_.

Referenced by eventSetup().

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

Referenced by eventSetup().

728  {
729  preferredProviderInfo_.reset();
730  referencedDataKeys_.reset();
731  recordToFinders_.reset();
732  psetIDToRecordKey_.reset();
733  recordToPreferred_.reset();
734  recordsWithALooperProxy_.reset();
735 }
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::vector< std::shared_ptr< EventSetupRecordIntervalFinder > > > > recordToFinders_
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
bool EventSetupProvider::doRecordsMatch ( EventSetupProvider precedingESProvider,
EventSetupRecordKey const &  eventSetupRecordKey,
std::map< EventSetupRecordKey, bool > &  allComponentsMatch,
EventSetupsController const &  esController 
)

Definition at line 615 of file EventSetupProvider.cc.

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

Referenced by eventSetup().

618  {
619  // first check if this record matches. If not just return false
620 
621  // then find the directly dependent records and iterate over them
622  // recursively call this function on them. If they return false
623  // set allComponentsMatch to false for them and return false.
624  // if they all return true then set allComponents to true
625  // and return true.
626 
627  if (precedingESProvider.recordsWithALooperProxy_->find(eventSetupRecordKey) != precedingESProvider.recordsWithALooperProxy_->end()) {
628  return false;
629  }
630 
631  if ((*recordToFinders_)[eventSetupRecordKey].size() != (*precedingESProvider.recordToFinders_)[eventSetupRecordKey].size()) {
632  return false;
633  }
634 
635  for (auto const& finder : (*recordToFinders_)[eventSetupRecordKey]) {
636  ParameterSetID const& psetID = finder->descriptionForFinder().pid_;
637  bool itMatches = esController.isMatchingESSource(psetID,
639  precedingESProvider.subProcessIndex_);
640  if (!itMatches) {
641  return false;
642  }
643  }
644 
645  fillReferencedDataKeys(eventSetupRecordKey);
646  precedingESProvider.fillReferencedDataKeys(eventSetupRecordKey);
647 
648  std::map<DataKey, ComponentDescription const*> const& dataItems = (*referencedDataKeys_)[eventSetupRecordKey];
649 
650  std::map<DataKey, ComponentDescription const*> const& precedingDataItems = (*precedingESProvider.referencedDataKeys_)[eventSetupRecordKey];
651 
652  if (dataItems.size() != precedingDataItems.size()) {
653  return false;
654  }
655 
656  for (auto const& dataItem : dataItems) {
657  auto precedingDataItem = precedingDataItems.find(dataItem.first);
658  if (precedingDataItem == precedingDataItems.end()) {
659  return false;
660  }
661  if (dataItem.second->pid_ != precedingDataItem->second->pid_) {
662  return false;
663  }
664  // Check that the configurations match exactly for the ESProducers
665  // (We already checked the ESSources above and there should not be
666  // any loopers)
667  if (!dataItem.second->isSource_ && !dataItem.second->isLooper_) {
668  bool itMatches = esController.isMatchingESProducer(dataItem.second->pid_,
670  precedingESProvider.subProcessIndex_);
671  if (!itMatches) {
672  return false;
673  }
674  }
675  }
676  Providers::iterator itFound = providers_.find(eventSetupRecordKey);
677  if (itFound != providers_.end()) {
678  std::set<EventSetupRecordKey> dependentRecords = itFound->second->dependentRecords();
679  for (auto const& dependentRecord : dependentRecords) {
680  auto iter = allComponentsMatch.find(dependentRecord);
681  if (iter != allComponentsMatch.end()) {
682  if (iter->second) {
683  continue;
684  } else {
685  return false;
686  }
687  }
688  bool match = doRecordsMatch(precedingESProvider,
689  dependentRecord,
690  allComponentsMatch,
691  esController);
692  allComponentsMatch[dependentRecord] = match;
693  if (!match) return false;
694  }
695  }
696  return true;
697 }
size
Write out results.
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< std::shared_ptr< EventSetupRecordIntervalFinder > > > > recordToFinders_
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
EventSetup const & EventSetupProvider::eventSetupForInstance ( IOVSyncValue const &  )

Definition at line 753 of file EventSetupProvider.cc.

References edm::EventSetup::clear().

754 {
755  eventSetup_.clear();
756 
757  // In a cmsRun job this does nothing because the EventSetupsController
758  // will have already called finishConfiguration, but some tests will
759  // call finishConfiguration here.
762  }
763 
764  for(Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
765  itProvider != itProviderEnd;
766  ++itProvider) {
767  itProvider->second->addRecordToIfValid(*this, iValue);
768  }
769  return eventSetup_;
770 }
void EventSetupProvider::fillReferencedDataKeys ( EventSetupRecordKey const &  eventSetupRecordKey)

Definition at line 700 of file EventSetupProvider.cc.

Referenced by doRecordsMatch(), and eventSetup().

700  {
701 
702  if (referencedDataKeys_->find(eventSetupRecordKey) != referencedDataKeys_->end()) return;
703 
704  auto recordProvider = providers_.find(eventSetupRecordKey);
705  if (recordProvider == providers_.end()) {
706  (*referencedDataKeys_)[eventSetupRecordKey];
707  return;
708  }
709  if (recordProvider->second) {
710  recordProvider->second->fillReferencedDataKeys((*referencedDataKeys_)[eventSetupRecordKey]);
711  }
712 }
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription const * > > > referencedDataKeys_
void EventSetupProvider::finishConfiguration ( )

Definition at line 283 of file EventSetupProvider.cc.

References edm::eventsetup::determinePreferred(), edm::eventsetup::heterocontainer::insert(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by eventSetup().

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

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

Definition at line 445 of file EventSetupProvider.cc.

Referenced by eventSetup().

446 {
447  for(Providers::iterator it=providers_.begin(), itEnd = providers_.end();
448  it != itEnd;
449  ++it) {
450  it->second->resetProxies();
451  }
452 }
void EventSetupProvider::insert ( std::unique_ptr< EventSetupRecordProvider iRecordProvider)
protected

Definition at line 744 of file EventSetupProvider.cc.

References edm::eventsetup::heterocontainer::insert(), crabWrapper::key, and eostools::move().

Referenced by subProcessIndex().

744  {
745  auto key =iRecordProvider->key();
746  insert( key, std::move(iRecordProvider));
747 }
void insert(std::unique_ptr< EventSetupRecordProvider > iRecordProvider)
def move(src, dest)
Definition: eostools.py:511
void edm::eventsetup::EventSetupProvider::insert ( EventSetupRecordKey const &  ,
std::unique_ptr< EventSetupRecordProvider  
)
private
bool EventSetupProvider::isWithinValidityInterval ( IOVSyncValue const &  iSync) const

Definition at line 792 of file EventSetupProvider.cc.

792  {
793  for( auto const& provider: providers_) {
794  auto const& iov =provider.second->validityInterval();
795  if( (iov != ValidityInterval::invalidInterval()) and
796  (not provider.second->validityInterval().validFor(iSync)) ) {
797  return false;
798  }
799  }
800  return true;
801 }
static const ValidityInterval & invalidInterval()
void EventSetupProvider::logInfoWhenSharing ( ParameterSet const &  iConfiguration)
static

Definition at line 805 of file EventSetupProvider.cc.

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

Referenced by subProcessIndex().

805  {
806 
807  std::string edmtype = iConfiguration.getParameter<std::string>("@module_edm_type");
808  std::string modtype = iConfiguration.getParameter<std::string>("@module_type");
809  std::string label = iConfiguration.getParameter<std::string>("@module_label");
810  edm::LogVerbatim("EventSetupSharing") << "Sharing " << edmtype << ": class=" << modtype << " label='" << label << "'";
811 }
EventSetupProvider const& edm::eventsetup::EventSetupProvider::operator= ( EventSetupProvider const &  )
privatedelete

Referenced by subProcessIndex().

std::set< ComponentDescription > EventSetupProvider::proxyProviderDescriptions ( ) const

Definition at line 773 of file EventSetupProvider.cc.

References edmIntegrityCheck::d, and AlCaHLTBitMon_ParallelJobs::p.

774 {
775  typedef std::set<ComponentDescription> Set;
776  Set descriptions;
777 
778  for(auto const& p: providers_) {
779  auto const& d = p.second->proxyProviderDescriptions();
780  descriptions.insert(d.begin(),d.end());
781  }
782  if(dataProviders_.get()) {
783  for(auto const& p: *dataProviders_) {
784  descriptions.insert(p->description());
785  }
786  }
787 
788  return descriptions;
789 }
std::unique_ptr< std::vector< std::shared_ptr< DataProxyProvider > > > dataProviders_
void EventSetupProvider::replaceExisting ( std::shared_ptr< DataProxyProvider dataProxyProvider)

Definition at line 124 of file EventSetupProvider.cc.

References crabWrapper::key.

Referenced by eventSetup(), and edm::eventsetup::ModuleMakerTraits::replaceExisting().

125 {
126  ParameterSetIDHolder psetID(dataProxyProvider->description().pid_);
127  std::set<EventSetupRecordKey> const& keysForPSetID = (*psetIDToRecordKey_)[psetID];
128  for (auto const& key : keysForPSetID) {
129  std::shared_ptr<EventSetupRecordProvider> const& recordProvider = providers_[key];
130  recordProvider->resetProxyProvider(psetID, dataProxyProvider);
131  }
132 }
void EventSetupProvider::resetRecordPlusDependentRecords ( EventSetupRecordKey const &  )

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

Definition at line 425 of file EventSetupProvider.cc.

References edmIntegrityCheck::d, edm::eventsetup::findDependents(), and tier0::unique().

Referenced by eventSetup(), and edm::EDLooperBase::prepareForNextLoop().

426 {
427  Providers::iterator itFind = providers_.find(iKey);
428  if(itFind == providers_.end()) {
429  return;
430  }
431 
432 
433  std::vector<std::shared_ptr<EventSetupRecordProvider> > dependents;
434  findDependents(iKey, providers_.begin(), providers_.end(), dependents);
435 
436  dependents.erase(std::unique(dependents.begin(),dependents.end()), dependents.end());
437 
438  itFind->second->resetProxies();
439  for(auto& d: dependents) {
440  d->resetProxies();
441  }
442 }
static void findDependents(const EventSetupRecordKey &iKey, Itr itBegin, Itr itEnd, std::vector< std::shared_ptr< EventSetupRecordProvider > > &oDependents)
def unique(seq, keepstr=True)
Definition: tier0.py:25
void EventSetupProvider::resetRecordToProxyPointers ( )

Definition at line 715 of file EventSetupProvider.cc.

Referenced by eventSetup().

715  {
716  for (auto const& recordProvider : providers_) {
718  const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
719  RecordToPreferred::const_iterator itRecordFound = recordToPreferred_->find(recordProvider.first);
720  if(itRecordFound != recordToPreferred_->end()) {
721  preferredInfo = &(itRecordFound->second);
722  }
723  recordProvider.second->resetRecordToProxyPointers(*preferredInfo);
724  }
725 }
std::map< DataKey, ComponentDescription > DataToPreferredProviderMap
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
unsigned edm::eventsetup::EventSetupProvider::subProcessIndex ( ) const
inline

Member Data Documentation

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

Definition at line 133 of file EventSetupProvider.h.

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

Definition at line 122 of file EventSetupProvider.h.

Referenced by eventSetup().

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

Definition at line 132 of file EventSetupProvider.h.

std::unique_ptr<EventSetupKnownRecordsSupplier> edm::eventsetup::EventSetupProvider::knownRecordsSupplier_
private

Definition at line 125 of file EventSetupProvider.h.

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

Definition at line 126 of file EventSetupProvider.h.

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

Definition at line 131 of file EventSetupProvider.h.

Providers edm::eventsetup::EventSetupProvider::providers_
private

Definition at line 124 of file EventSetupProvider.h.

Referenced by checkESProducerSharing().

std::unique_ptr<std::map<ParameterSetIDHolder, std::set<EventSetupRecordKey> > > edm::eventsetup::EventSetupProvider::psetIDToRecordKey_
private

Definition at line 136 of file EventSetupProvider.h.

Referenced by checkESProducerSharing().

std::unique_ptr<std::set<EventSetupRecordKey> > edm::eventsetup::EventSetupProvider::recordsWithALooperProxy_
private

Definition at line 138 of file EventSetupProvider.h.

Referenced by doRecordsMatch().

std::unique_ptr<std::map<EventSetupRecordKey, std::vector<std::shared_ptr<EventSetupRecordIntervalFinder> > > > edm::eventsetup::EventSetupProvider::recordToFinders_
private

Definition at line 135 of file EventSetupProvider.h.

Referenced by doRecordsMatch().

std::unique_ptr<std::map<EventSetupRecordKey, std::map<DataKey, ComponentDescription> > > edm::eventsetup::EventSetupProvider::recordToPreferred_
private

Definition at line 137 of file EventSetupProvider.h.

std::unique_ptr<std::map<EventSetupRecordKey, std::map<DataKey, ComponentDescription const*> > > edm::eventsetup::EventSetupProvider::referencedDataKeys_
private

Definition at line 134 of file EventSetupProvider.h.

Referenced by doRecordsMatch().

unsigned edm::eventsetup::EventSetupProvider::subProcessIndex_
private

Definition at line 127 of file EventSetupProvider.h.

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