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 (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 (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 (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 &)
 
void insert (EventSetupRecordKey const &, std::unique_ptr< EventSetupRecordProvider >)
 
EventSetupProvider const & operator= (EventSetupProvider const &)
 

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
< EventSetupKnownRecordsSupplier
knownRecordsSupplier_
 
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< 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 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 65 of file EventSetupProvider.cc.

References eventSetup_, knownRecordsSupplier_, and edm::EventSetup::setKnownRecordsSupplier().

65  :
66 eventSetup_(),
67 providers_(),
68 knownRecordsSupplier_( std::make_unique<KnownRecordsSupplierImpl>(providers_)),
71 preferredProviderInfo_((0!=iInfo) ? (new PreferredProviderInfo(*iInfo)): 0),
72 finders_(new std::vector<std::shared_ptr<EventSetupRecordIntervalFinder> >() ),
73 dataProviders_(new std::vector<std::shared_ptr<DataProxyProvider> >() ),
74 referencedDataKeys_(new std::map<EventSetupRecordKey, std::map<DataKey, ComponentDescription const*> >),
75 recordToFinders_(new std::map<EventSetupRecordKey, std::vector<std::shared_ptr<EventSetupRecordIntervalFinder> > >),
76 psetIDToRecordKey_(new std::map<ParameterSetIDHolder, std::set<EventSetupRecordKey> >),
77 recordToPreferred_(new std::map<EventSetupRecordKey, std::map<DataKey, ComponentDescription> >),
78 recordsWithALooperProxy_(new std::set<EventSetupRecordKey>)
79 {
81 }
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
void setKnownRecordsSupplier(eventsetup::EventSetupKnownRecordsSupplier const *iSupplier)
Definition: EventSetup.h:122
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_
std::unique_ptr< std::map< EventSetupRecordKey, std::vector< std::shared_ptr< EventSetupRecordIntervalFinder > > > > recordToFinders_
std::unique_ptr< EventSetupKnownRecordsSupplier > knownRecordsSupplier_
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
EventSetupProvider::~EventSetupProvider ( )
virtual

Definition at line 88 of file EventSetupProvider.cc.

89 {
90 }
edm::eventsetup::EventSetupProvider::EventSetupProvider ( EventSetupProvider const &  )
private

Member Function Documentation

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

Definition at line 116 of file EventSetupProvider.cc.

References assert(), and dataProviders_.

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

117 {
118  assert(iProvider.get() != 0);
119  dataProviders_->push_back(iProvider);
120 }
assert(m_qm.get())
std::unique_ptr< std::vector< std::shared_ptr< DataProxyProvider > > > dataProviders_
void EventSetupProvider::add ( std::shared_ptr< EventSetupRecordIntervalFinder iFinder)

Definition at line 134 of file EventSetupProvider.cc.

References assert(), and finders_.

Referenced by counter.Counter::register().

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

Definition at line 736 of file EventSetupProvider.cc.

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

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

736  {
737  iRecord.setEventSetup(&eventSetup_);
738  eventSetup_.add(iRecord);
739 }
void add(const eventsetup::EventSetupRecord &iRecord)
Definition: EventSetup.cc:82
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 453 of file EventSetupProvider.cc.

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

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

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

726  {
727  preferredProviderInfo_.reset();
728  referencedDataKeys_.reset();
729  recordToFinders_.reset();
730  psetIDToRecordKey_.reset();
731  recordToPreferred_.reset();
732  recordsWithALooperProxy_.reset();
733 }
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 613 of file EventSetupProvider.cc.

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

Referenced by checkESProducerSharing().

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

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

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

Definition at line 698 of file EventSetupProvider.cc.

References providers_, and referencedDataKeys_.

Referenced by doRecordsMatch().

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

Definition at line 282 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().

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

References providers_.

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

Definition at line 111 of file EventSetupProvider.h.

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

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

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

Definition at line 108 of file EventSetupProvider.cc.

References providers_, and groupFilesInBlocks::temp.

Referenced by BeautifulSoup.PageElement::_invert().

109 {
110  std::shared_ptr<EventSetupRecordProvider> temp(iProvider.release());
111  providers_[iKey] = temp;
112  //temp->addRecordTo(*this);
113 }
void EventSetupProvider::logInfoWhenSharing ( ParameterSet const &  iConfiguration)
static

Definition at line 804 of file EventSetupProvider.cc.

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

Referenced by checkESProducerSharing().

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

Definition at line 778 of file EventSetupProvider.cc.

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

779 {
780  using boost::bind;
781  typedef std::set<ComponentDescription> Set;
782  Set descriptions;
783 
785  bind(InsertAll(descriptions),
787  bind(&Providers::value_type::second,_1))));
788  if(dataProviders_.get()) {
789  for(std::vector<std::shared_ptr<DataProxyProvider> >::const_iterator it = dataProviders_->begin(),
790  itEnd = dataProviders_->end();
791  it != itEnd;
792  ++it) {
793  descriptions.insert((*it)->description());
794  }
795 
796  }
797 
798  return descriptions;
799 }
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::unique_ptr< std::vector< std::shared_ptr< DataProxyProvider > > > dataProviders_
std::set< ComponentDescription > proxyProviderDescriptions() const
return information on which DataProxyProviders are supplying information
void EventSetupProvider::replaceExisting ( std::shared_ptr< DataProxyProvider dataProxyProvider)

Definition at line 123 of file EventSetupProvider.cc.

References relval_steps::key, and providers_.

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

124 {
125  ParameterSetIDHolder psetID(dataProxyProvider->description().pid_);
126  std::set<EventSetupRecordKey> const& keysForPSetID = (*psetIDToRecordKey_)[psetID];
127  for (auto const& key : keysForPSetID) {
128  std::shared_ptr<EventSetupRecordProvider> const& recordProvider = providers_[key];
129  recordProvider->resetProxyProvider(psetID, dataProxyProvider);
130  }
131 }
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
void EventSetupProvider::resetRecordPlusDependentRecords ( EventSetupRecordKey const &  iKey)

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

Definition at line 423 of file EventSetupProvider.cc.

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

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

424 {
425  Providers::iterator itFind = providers_.find(iKey);
426  if(itFind == providers_.end()) {
427  return;
428  }
429 
430 
431  std::vector<std::shared_ptr<EventSetupRecordProvider> > dependents;
432  findDependents(iKey, providers_.begin(), providers_.end(), dependents);
433 
434  dependents.erase(std::unique(dependents.begin(),dependents.end()), dependents.end());
435 
436  itFind->second->resetProxies();
437  for_all(dependents,
439  _1));
440 }
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< std::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 713 of file EventSetupProvider.cc.

References providers_, and recordToPreferred_.

713  {
714  for (auto const& recordProvider : providers_) {
716  const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
717  RecordToPreferred::const_iterator itRecordFound = recordToPreferred_->find(recordProvider.first);
718  if(itRecordFound != recordToPreferred_->end()) {
719  preferredInfo = &(itRecordFound->second);
720  }
721  recordProvider.second->resetRecordToProxyPointers(*preferredInfo);
722  }
723 }
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<std::shared_ptr<DataProxyProvider> > > edm::eventsetup::EventSetupProvider::dataProviders_
private

Definition at line 138 of file EventSetupProvider.h.

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

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

Definition at line 137 of file EventSetupProvider.h.

Referenced by add(), and finishConfiguration().

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

Definition at line 130 of file EventSetupProvider.h.

Referenced by EventSetupProvider().

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

Definition at line 131 of file EventSetupProvider.h.

Referenced by eventSetupForInstance(), and finishConfiguration().

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

Definition at line 136 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<std::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 132 of file EventSetupProvider.h.

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