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

template<typename T >
void insert (std::unique_ptr< T > 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 130 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 insert().

EventSetupProvider::~EventSetupProvider ( )
virtual

Definition at line 89 of file EventSetupProvider.cc.

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

90 {
91 }
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 ( EventSetupRecord iRecord)

Definition at line 737 of file EventSetupProvider.cc.

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

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

737  {
738  iRecord.setEventSetup(&eventSetup_);
739  eventSetup_.add(iRecord);
740 }
void add(const eventsetup::EventSetupRecord &iRecord)
Definition: EventSetup.cc:79
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 454 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().

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

Referenced by eventSetup().

727  {
728  preferredProviderInfo_.reset();
729  referencedDataKeys_.reset();
730  recordToFinders_.reset();
731  psetIDToRecordKey_.reset();
732  recordToPreferred_.reset();
733  recordsWithALooperProxy_.reset();
734 }
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 614 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().

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

References edm::EventSetup::clear().

747 {
748  eventSetup_.clear();
749 
750  // In a cmsRun job this does nothing because the EventSetupsController
751  // will have already called finishConfiguration, but some tests will
752  // call finishConfiguration here.
755  }
756 
757  for(Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
758  itProvider != itProviderEnd;
759  ++itProvider) {
760  itProvider->second->addRecordToIfValid(*this, iValue);
761  }
762  return eventSetup_;
763 }
void EventSetupProvider::fillReferencedDataKeys ( EventSetupRecordKey const &  eventSetupRecordKey)

Definition at line 699 of file EventSetupProvider.cc.

Referenced by doRecordsMatch(), and eventSetup().

699  {
700 
701  if (referencedDataKeys_->find(eventSetupRecordKey) != referencedDataKeys_->end()) return;
702 
703  auto recordProvider = providers_.find(eventSetupRecordKey);
704  if (recordProvider == providers_.end()) {
705  (*referencedDataKeys_)[eventSetupRecordKey];
706  return;
707  }
708  if (recordProvider->second) {
709  recordProvider->second->fillReferencedDataKeys((*referencedDataKeys_)[eventSetupRecordKey]);
710  }
711 }
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(), instance, 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, EventSetupRecordProviderFactoryManager::instance().makeRecordProvider(*itKey));
302  itFound = providers_.find(*itKey);
303  }
304  itFound->second->addFinder(*itFinder);
305  }
306  }
307  //we've transfered our ownership so this is no longer needed
308  finders_.reset();
309 
310  //Now handle providers since sources can also be finders and the sources can delay registering
311  // their Records and therefore could delay setting up their Proxies
312  psetIDToRecordKey_->clear();
313  typedef std::set<EventSetupRecordKey> Keys;
314  for(std::vector<std::shared_ptr<DataProxyProvider> >::iterator itProvider=dataProviders_->begin(),
315  itEnd = dataProviders_->end();
316  itProvider != itEnd;
317  ++itProvider) {
318 
319  ParameterSetIDHolder psetID((*itProvider)->description().pid_);
320 
321  const Keys recordsUsing = (*itProvider)->usingRecords();
322 
323  for(Keys::const_iterator itKey = recordsUsing.begin(), itKeyEnd = recordsUsing.end();
324  itKey != itKeyEnd;
325  ++itKey) {
326 
327  if ((*itProvider)->description().isLooper_) {
328  recordsWithALooperProxy_->insert(*itKey);
329  }
330 
331  (*psetIDToRecordKey_)[psetID].insert(*itKey);
332 
333  Providers::iterator itFound = providers_.find(*itKey);
334  if(providers_.end() == itFound) {
335  //create a provider for this record
336  insert(*itKey, EventSetupRecordProviderFactoryManager::instance().makeRecordProvider(*itKey));
337  itFound = providers_.find(*itKey);
338  }
339  itFound->second->add(*itProvider);
340  }
341  }
342  dataProviders_.reset();
343 
344  //used for the case where no preferred Providers have been specified for the Record
346 
348  //For each Provider, find all the Providers it depends on. If a dependent Provider
349  // can not be found pass in an empty list
350  //CHANGE: now allow for missing Providers
351  for(Providers::iterator itProvider = providers_.begin(), itProviderEnd = providers_.end();
352  itProvider != itProviderEnd;
353  ++itProvider) {
354  const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
355  RecordToPreferred::const_iterator itRecordFound = recordToPreferred_->find(itProvider->first);
356  if(itRecordFound != recordToPreferred_->end()) {
357  preferredInfo = &(itRecordFound->second);
358  }
359  //Give it our list of preferred
360  itProvider->second->usePreferred(*preferredInfo);
361 
362  std::set<EventSetupRecordKey> records = itProvider->second->dependentRecords();
363  if(!records.empty()) {
364  std::string missingRecords;
365  std::vector<std::shared_ptr<EventSetupRecordProvider> > depProviders;
366  depProviders.reserve(records.size());
367  bool foundAllProviders = true;
368  for(std::set<EventSetupRecordKey>::iterator itRecord = records.begin(),
369  itRecordEnd = records.end();
370  itRecord != itRecordEnd;
371  ++itRecord) {
372  Providers::iterator itFound = providers_.find(*itRecord);
373  if(itFound == providers_.end()) {
374  foundAllProviders = false;
375  if(missingRecords.empty()) {
376  missingRecords = itRecord->name();
377  } else {
378  missingRecords += ", ";
379  missingRecords += itRecord->name();
380  }
381  //break;
382  } else {
383  depProviders.push_back(itFound->second);
384  }
385  }
386 
387  if(!foundAllProviders) {
388  edm::LogInfo("EventSetupDependency")<<"The EventSetup record "<<itProvider->second->key().name()
389  <<" depends on at least one Record \n ("<<missingRecords<<") which is not present in the job."
390  "\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.";
391 
392  //depProviders.clear();
393  //NOTE: should provide a warning
394  }
395 
396  itProvider->second->setDependentProviders(depProviders);
397  }
398  }
399  mustFinishConfiguration_ = false;
400 }
std::map< DataKey, ComponentDescription > DataToPreferredProviderMap
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
void insert(std::unique_ptr< T > 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 444 of file EventSetupProvider.cc.

Referenced by eventSetup().

445 {
446  for(Providers::iterator it=providers_.begin(), itEnd = providers_.end();
447  it != itEnd;
448  ++it) {
449  it->second->resetProxies();
450  }
451 }
template<typename T >
void edm::eventsetup::EventSetupProvider::insert ( std::unique_ptr< T iRecordProvider)
inlineprotected

Definition at line 113 of file EventSetupProvider.h.

References EventSetupProvider(), edm::eventsetup::heterocontainer::makeKey(), eostools::move(), operator=(), and groupFilesInBlocks::temp.

113  {
114  std::unique_ptr<EventSetupRecordProvider> temp(iRecordProvider.release());
116  typename T::RecordType,
117  eventsetup::EventSetupRecordKey>(),
118  std::move(temp));
119  }
Key makeKey(const IdTag &iIdTag)
Definition: HCMethods.h:28
void insert(std::unique_ptr< T > iRecordProvider)
def move(src, dest)
Definition: eostools.py:510
void edm::eventsetup::EventSetupProvider::insert ( EventSetupRecordKey const &  ,
std::unique_ptr< EventSetupRecordProvider  
)
private
bool EventSetupProvider::isWithinValidityInterval ( IOVSyncValue const &  iSync) const

Definition at line 785 of file EventSetupProvider.cc.

785  {
786  for( auto const& provider: providers_) {
787  auto const& iov =provider.second->validityInterval();
788  if( (iov != ValidityInterval::invalidInterval()) and
789  (not provider.second->validityInterval().validFor(iSync)) ) {
790  return false;
791  }
792  }
793  return true;
794 }
static const ValidityInterval & invalidInterval()
void EventSetupProvider::logInfoWhenSharing ( ParameterSet const &  iConfiguration)
static

Definition at line 798 of file EventSetupProvider.cc.

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

Referenced by subProcessIndex().

798  {
799 
800  std::string edmtype = iConfiguration.getParameter<std::string>("@module_edm_type");
801  std::string modtype = iConfiguration.getParameter<std::string>("@module_type");
802  std::string label = iConfiguration.getParameter<std::string>("@module_label");
803  edm::LogVerbatim("EventSetupSharing") << "Sharing " << edmtype << ": class=" << modtype << " label='" << label << "'";
804 }
EventSetupProvider const& edm::eventsetup::EventSetupProvider::operator= ( EventSetupProvider const &  )
privatedelete

Referenced by insert().

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

Definition at line 766 of file EventSetupProvider.cc.

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

767 {
768  typedef std::set<ComponentDescription> Set;
769  Set descriptions;
770 
771  for(auto const& p: providers_) {
772  auto const& d = p.second->proxyProviderDescriptions();
773  descriptions.insert(d.begin(),d.end());
774  }
775  if(dataProviders_.get()) {
776  for(auto const& p: *dataProviders_) {
777  descriptions.insert(p->description());
778  }
779  }
780 
781  return descriptions;
782 }
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 424 of file EventSetupProvider.cc.

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

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

425 {
426  Providers::iterator itFind = providers_.find(iKey);
427  if(itFind == providers_.end()) {
428  return;
429  }
430 
431 
432  std::vector<std::shared_ptr<EventSetupRecordProvider> > dependents;
433  findDependents(iKey, providers_.begin(), providers_.end(), dependents);
434 
435  dependents.erase(std::unique(dependents.begin(),dependents.end()), dependents.end());
436 
437  itFind->second->resetProxies();
438  for(auto& d: dependents) {
439  d->resetProxies();
440  }
441 }
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:24
void EventSetupProvider::resetRecordToProxyPointers ( )

Definition at line 714 of file EventSetupProvider.cc.

Referenced by eventSetup().

714  {
715  for (auto const& recordProvider : providers_) {
717  const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
718  RecordToPreferred::const_iterator itRecordFound = recordToPreferred_->find(recordProvider.first);
719  if(itRecordFound != recordToPreferred_->end()) {
720  preferredInfo = &(itRecordFound->second);
721  }
722  recordProvider.second->resetRecordToProxyPointers(*preferredInfo);
723  }
724 }
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 106 of file EventSetupProvider.h.

References logInfoWhenSharing(), and subProcessIndex_.

Referenced by checkESProducerSharing().

Member Data Documentation

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

Definition at line 140 of file EventSetupProvider.h.

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

Definition at line 129 of file EventSetupProvider.h.

Referenced by eventSetup().

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

Definition at line 139 of file EventSetupProvider.h.

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

Definition at line 132 of file EventSetupProvider.h.

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

Definition at line 133 of file EventSetupProvider.h.

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

Definition at line 138 of file EventSetupProvider.h.

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

Definition at line 131 of file EventSetupProvider.h.

Referenced by checkESProducerSharing().

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

Definition at line 143 of file EventSetupProvider.h.

Referenced by checkESProducerSharing().

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

Definition at line 145 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 142 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 144 of file EventSetupProvider.h.

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

Definition at line 141 of file EventSetupProvider.h.

Referenced by doRecordsMatch().

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

Definition at line 134 of file EventSetupProvider.h.

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