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 addRecord (const EventSetupRecordKey &iKey)
 Intended for use only in tests. More...
 
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)
 
EventSetupImpl const & eventSetup () const
 
EventSetupImpl 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
 
ESRecordsToProxyIndices recordsToProxyIndices () 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

using RecordKeys = std::vector< EventSetupRecordKey >
 
using RecordProviders = std::vector< std::shared_ptr< EventSetupRecordProvider >>
 

Private Member Functions

void determinePreferred ()
 
 EventSetupProvider (EventSetupProvider const &)=delete
 
void insert (EventSetupRecordKey const &, std::unique_ptr< EventSetupRecordProvider >)
 
EventSetupProvider const & operator= (EventSetupProvider const &)=delete
 
std::shared_ptr< EventSetupRecordProvider > & recordProvider (const EventSetupRecordKey &iKey)
 
EventSetupRecordProvidertryToGetRecordProvider (const EventSetupRecordKey &iKey)
 

Private Attributes

std::unique_ptr< std::vector< std::shared_ptr< DataProxyProvider > > > dataProviders_
 
EventSetupImpl eventSetup_
 
std::unique_ptr< std::vector< std::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
 
bool mustFinishConfiguration_
 
std::unique_ptr< PreferredProviderInfopreferredProviderInfo_
 
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
 
RecordKeys recordKeys_
 
RecordProviders recordProviders_
 
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 55 of file EventSetupProvider.h.

Definition at line 54 of file EventSetupProvider.h.

Definition at line 53 of file EventSetupProvider.h.

Definition at line 57 of file EventSetupProvider.h.

Definition at line 132 of file EventSetupProvider.h.

Definition at line 52 of file EventSetupProvider.h.

Definition at line 135 of file EventSetupProvider.h.

Definition at line 56 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 53 of file EventSetupProvider.cc.

53 { forceCacheClear(); }
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 99 of file EventSetupProvider.cc.

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

99  {
100  assert(iFinder.get() != nullptr);
101  finders_->push_back(iFinder);
102  }
std::unique_ptr< std::vector< std::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
void EventSetupProvider::addRecord ( const EventSetupRecordKey iKey)

Intended for use only in tests.

Definition at line 733 of file EventSetupProvider.cc.

References edm::EventSetupImpl::insert().

Referenced by subProcessIndex().

733  {
734  insert(iKey, std::unique_ptr<EventSetupRecordProvider>());
736  }
void setKeyIters(std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysBegin, std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysEnd)
void insert(std::unique_ptr< EventSetupRecordProvider > iRecordProvider)
void EventSetupProvider::addRecordToEventSetup ( EventSetupRecordImpl iRecord)

Definition at line 654 of file EventSetupProvider.cc.

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

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

654  {
655  iRecord.setEventSetup(&eventSetup_);
656  eventSetup_.add(iRecord);
657  }
void setEventSetup(EventSetupImpl const *iEventSetup)
void add(const eventsetup::EventSetupRecordImpl &iRecord)
void EventSetupProvider::checkESProducerSharing ( EventSetupProvider precedingESProvider,
std::set< ParameterSetIDHolder > &  sharingCheckDone,
std::map< EventSetupRecordKey, std::vector< ComponentDescription const * >> &  referencedESProducers,
EventSetupsController esController 
)

Definition at line 395 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(), edm::match(), muonDTDigis_cfi::pset, psetIDToRecordKey_, recordProvider(), subProcessIndex(), and subProcessIndex_.

Referenced by eventSetup().

399  {
400  edm::LogVerbatim("EventSetupSharing")
401  << "EventSetupProvider::checkESProducerSharing: Checking processes with SubProcess Indexes "
402  << subProcessIndex() << " and " << precedingESProvider.subProcessIndex();
403 
404  if (referencedESProducers.empty()) {
405  for (auto& recProvider : recordProviders_) {
406  recProvider->getReferencedESProducers(referencedESProducers);
407  }
408  }
409 
410  // This records whether the configurations of all the DataProxyProviders
411  // and finders matches for a particular pair of processes and
412  // a particular record and also the records it depends on.
413  std::map<EventSetupRecordKey, bool> allComponentsMatch;
414 
415  std::map<ParameterSetID, bool> candidateNotRejectedYet;
416 
417  // Loop over all the ESProducers which have a DataProxy
418  // referenced by any EventSetupRecord in this EventSetupProvider
419  for (auto const& iRecord : referencedESProducers) {
420  for (auto const& iComponent : iRecord.second) {
421  ParameterSetID const& psetID = iComponent->pid_;
422  ParameterSetIDHolder psetIDHolder(psetID);
423  if (sharingCheckDone.find(psetIDHolder) != sharingCheckDone.end())
424  continue;
425 
426  bool firstProcessWithThisPSet = false;
427  bool precedingHasMatchingPSet = false;
428 
429  esController.lookForMatches(psetID,
431  precedingESProvider.subProcessIndex_,
432  firstProcessWithThisPSet,
433  precedingHasMatchingPSet);
434 
435  if (firstProcessWithThisPSet) {
436  sharingCheckDone.insert(psetIDHolder);
437  allComponentsMatch[iRecord.first] = false;
438  continue;
439  }
440 
441  if (!precedingHasMatchingPSet) {
442  allComponentsMatch[iRecord.first] = false;
443  continue;
444  }
445 
446  // An ESProducer that survives to this point is a candidate.
447  // It was shared with some other process in the first pass where
448  // ESProducers were constructed and one of three possibilities exists:
449  // 1) It should not have been shared and a new ESProducer needs
450  // to be created and the proper pointers set.
451  // 2) It should have been shared with a different preceding process
452  // in which case some pointers need to be modified.
453  // 3) It was originally shared which the correct prior process
454  // in which case nothing needs to be done, but we do need to
455  // do some work to verify that.
456  // Make an entry in a map for each of these ESProducers. We
457  // will set the value to false if and when we determine
458  // the ESProducer cannot be shared between this pair of processes.
459  auto iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
460  if (iCandidateNotRejectedYet == candidateNotRejectedYet.end()) {
461  candidateNotRejectedYet[psetID] = true;
462  iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
463  }
464 
465  // At this point we know that the two processes both
466  // have an ESProducer matching the type and label in
467  // iComponent and also with exactly the same configuration.
468  // And there was not an earlier preceding process
469  // where the same instance of the ESProducer could
470  // have been shared. And this ESProducer was referenced
471  // by the later process's EventSetupRecord (prefered or
472  // or just the only thing that could have made the data).
473  // To determine if sharing is allowed, now we need to
474  // check if all the DataProxyProviders and all the
475  // finders are the same for this record and also for
476  // all records this record depends on. And even
477  // if this is true, we have to wait until the loop
478  // ends because some other DataProxy associated with
479  // the ESProducer could write to a different record where
480  // the same determination will need to be repeated. Only if
481  // all of the the DataProxy's can be shared, can the ESProducer
482  // instance be shared across processes.
483 
484  if (iCandidateNotRejectedYet->second == true) {
485  auto iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
486  if (iAllComponentsMatch == allComponentsMatch.end()) {
487  // We do not know the value in AllComponents yet and
488  // we need it now so we have to do the difficult calculation
489  // now.
490  bool match = doRecordsMatch(precedingESProvider, iRecord.first, allComponentsMatch, esController);
491  allComponentsMatch[iRecord.first] = match;
492  iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
493  }
494  if (!iAllComponentsMatch->second) {
495  iCandidateNotRejectedYet->second = false;
496  }
497  }
498  } // end loop over components used by record
499  } // end loop over records
500 
501  // Loop over candidates
502  for (auto const& candidate : candidateNotRejectedYet) {
503  ParameterSetID const& psetID = candidate.first;
504  bool canBeShared = candidate.second;
505  if (canBeShared) {
506  ParameterSet const& pset = *esController.getESProducerPSet(psetID, subProcessIndex_);
507  logInfoWhenSharing(pset);
508  ParameterSetIDHolder psetIDHolder(psetID);
509  sharingCheckDone.insert(psetIDHolder);
510  if (esController.isFirstMatch(psetID, subProcessIndex_, precedingESProvider.subProcessIndex_)) {
511  continue; // Proper sharing was already done. Nothing more to do.
512  }
513 
514  // Need to reset the pointer from the EventSetupRecordProvider to the
515  // the DataProxyProvider so these two processes share an ESProducer.
516 
517  std::shared_ptr<DataProxyProvider> dataProxyProvider;
518  std::set<EventSetupRecordKey> const& keysForPSetID1 = (*precedingESProvider.psetIDToRecordKey_)[psetIDHolder];
519  for (auto const& key : keysForPSetID1) {
520  dataProxyProvider = precedingESProvider.recordProvider(key)->proxyProvider(psetIDHolder);
521  assert(dataProxyProvider);
522  break;
523  }
524 
525  std::set<EventSetupRecordKey> const& keysForPSetID2 = (*psetIDToRecordKey_)[psetIDHolder];
526  for (auto const& key : keysForPSetID2) {
527  recordProvider(key)->resetProxyProvider(psetIDHolder, dataProxyProvider);
528  }
529  } else {
530  if (esController.isLastMatch(psetID, subProcessIndex_, precedingESProvider.subProcessIndex_)) {
531  ParameterSet const& pset = *esController.getESProducerPSet(psetID, subProcessIndex_);
532  ModuleFactory::get()->addTo(esController, *this, pset, true);
533  }
534  }
535  }
536  }
std::shared_ptr< EventSetupRecordProvider > & recordProvider(const EventSetupRecordKey &iKey)
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 645 of file EventSetupProvider.cc.

Referenced by eventSetup().

645  {
646  preferredProviderInfo_.reset();
647  referencedDataKeys_.reset();
648  recordToFinders_.reset();
649  psetIDToRecordKey_.reset();
650  recordToPreferred_.reset();
651  recordsWithALooperProxy_.reset();
652  }
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_
void EventSetupProvider::determinePreferred ( )
private

Definition at line 158 of file EventSetupProvider.cc.

References makeMuonMisalignmentScenario::components, Exception, edm::eventsetup::heterocontainer::HCTypeTag::findType(), kp, edm::eventsetup::preferEverything(), edm::eventsetup::EventSetupRecordProvider::proxyProvider(), edm::eventsetup::EventSetupRecordProvider::proxyProviderDescriptions(), align_cfg::recordName, AlCaHLTBitMon_QueryRunRegistry::string, and edm::eventsetup::EventSetupRecordKey::type().

Referenced by subProcessIndex().

158  {
159  using namespace edm::eventsetup;
161  for (auto const& itInfo : *preferredProviderInfo_) {
162  if (itInfo.second.empty()) {
163  //want everything
165  } else {
166  for (EventSetupProvider::RecordToDataMap::const_iterator itRecData = itInfo.second.begin(),
167  itRecDataEnd = itInfo.second.end();
168  itRecData != itRecDataEnd;
169  ++itRecData) {
170  std::string recordName = itRecData->first;
172  if (recordKey.type() == eventsetup::EventSetupRecordKey::TypeTag()) {
173  throw cms::Exception("ESPreferUnknownRecord")
174  << "Unknown record \"" << recordName
175  << "\" used in es_prefer statement for type=" << itInfo.first.type_ << " label=\""
176  << itInfo.first.label_ << "\"\n Please check spelling.";
177  //record not found
178  }
179  //See if the ProxyProvider provides something for this Record
180  EventSetupRecordProvider& recordProviderForKey = *recordProvider(recordKey);
181 
182  std::set<ComponentDescription> components = recordProviderForKey.proxyProviderDescriptions();
183  std::set<ComponentDescription>::iterator itProxyProv = components.find(itInfo.first);
184  if (itProxyProv == components.end()) {
185  throw cms::Exception("ESPreferWrongRecord")
186  << "The type=" << itInfo.first.type_ << " label=\"" << itInfo.first.label_
187  << "\" does not provide data for the Record " << recordName;
188  }
189  //Does it data type exist?
190  eventsetup::TypeTag datumType = eventsetup::TypeTag::findType(itRecData->second.first);
191  if (datumType == eventsetup::TypeTag()) {
192  //not found
193  throw cms::Exception("ESPreferWrongDataType")
194  << "The es_prefer statement for type=" << itInfo.first.type_ << " label=\"" << itInfo.first.label_
195  << "\" has the unknown data type \"" << itRecData->second.first << "\""
196  << "\n Please check spelling";
197  }
198  eventsetup::DataKey datumKey(datumType, itRecData->second.second.c_str());
199 
200  //Does the proxyprovider make this?
201  std::shared_ptr<DataProxyProvider> proxyProv = recordProviderForKey.proxyProvider(*itProxyProv);
202  const DataProxyProvider::KeyedProxies& keyedProxies = proxyProv->keyedProxies(recordKey);
203  if (std::find_if(keyedProxies.begin(), keyedProxies.end(), [&datumKey](auto const& kp) {
204  return kp.first == datumKey;
205  }) == keyedProxies.end()) {
206  throw cms::Exception("ESPreferWrongData")
207  << "The es_prefer statement for type=" << itInfo.first.type_ << " label=\"" << itInfo.first.label_
208  << "\" specifies the data item \n"
209  << " type=\"" << itRecData->second.first << "\" label=\"" << itRecData->second.second << "\""
210  << " which is not provided. Please check spelling.";
211  }
212 
214  (*recordToPreferred_)[recordKey];
215  //has another provider already been specified?
216  if (dataToProviderMap.end() != dataToProviderMap.find(datumKey)) {
217  EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
218  dataToProviderMap.find(datumKey);
219  throw cms::Exception("ESPreferConflict")
220  << "Two providers have been set to be preferred for\n"
221  << datumKey.type().name() << " \"" << datumKey.name().value() << "\""
222  << "\n the providers are "
223  << "\n 1) type=" << itFind->second.type_ << " label=\"" << itFind->second.label_ << "\""
224  << "\n 2) type=" << itProxyProv->type_ << " label=\"" << itProxyProv->label_ << "\""
225  << "\nPlease modify configuration so only one is preferred";
226  }
227  dataToProviderMap.insert(std::make_pair(datumKey, *itProxyProv));
228  }
229  }
230  }
231  }
232  }
std::shared_ptr< EventSetupRecordProvider > & recordProvider(const EventSetupRecordKey &iKey)
std::map< DataKey, ComponentDescription > DataToPreferredProviderMap
int kp
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
std::vector< std::pair< DataKey, edm::propagate_const< std::shared_ptr< DataProxy > > > > KeyedProxies
heterocontainer::HCTypeTag TypeTag
Definition: DataKeyTags.h:30
static void preferEverything(const ComponentDescription &iComponent, const RecordProviders &iRecordProviders, RecordToPreferred &iReturnValue)
find everything made by a DataProxyProvider and add it to the &#39;preferred&#39; list
std::unique_ptr< PreferredProviderInfo > preferredProviderInfo_
std::shared_ptr< DataProxyProvider > proxyProvider(ComponentDescription const &)
returns the first matching DataProxyProvider or a &#39;null&#39; if not found
heterocontainer::HCTypeTag TypeTag
std::set< ComponentDescription > proxyProviderDescriptions() const
return information on which DataProxyProviders are supplying information
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 538 of file EventSetupProvider.cc.

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

Referenced by eventSetup().

541  {
542  // first check if this record matches. If not just return false
543 
544  // then find the directly dependent records and iterate over them
545  // recursively call this function on them. If they return false
546  // set allComponentsMatch to false for them and return false.
547  // if they all return true then set allComponents to true
548  // and return true.
549 
550  if (precedingESProvider.recordsWithALooperProxy_->find(eventSetupRecordKey) !=
551  precedingESProvider.recordsWithALooperProxy_->end()) {
552  return false;
553  }
554 
555  if ((*recordToFinders_)[eventSetupRecordKey].size() !=
556  (*precedingESProvider.recordToFinders_)[eventSetupRecordKey].size()) {
557  return false;
558  }
559 
560  for (auto const& finder : (*recordToFinders_)[eventSetupRecordKey]) {
561  ParameterSetID const& psetID = finder->descriptionForFinder().pid_;
562  bool itMatches =
563  esController.isMatchingESSource(psetID, subProcessIndex_, precedingESProvider.subProcessIndex_);
564  if (!itMatches) {
565  return false;
566  }
567  }
568 
569  fillReferencedDataKeys(eventSetupRecordKey);
570  precedingESProvider.fillReferencedDataKeys(eventSetupRecordKey);
571 
572  std::map<DataKey, ComponentDescription const*> const& dataItems = (*referencedDataKeys_)[eventSetupRecordKey];
573 
574  std::map<DataKey, ComponentDescription const*> const& precedingDataItems =
575  (*precedingESProvider.referencedDataKeys_)[eventSetupRecordKey];
576 
577  if (dataItems.size() != precedingDataItems.size()) {
578  return false;
579  }
580 
581  for (auto const& dataItem : dataItems) {
582  auto precedingDataItem = precedingDataItems.find(dataItem.first);
583  if (precedingDataItem == precedingDataItems.end()) {
584  return false;
585  }
586  if (dataItem.second->pid_ != precedingDataItem->second->pid_) {
587  return false;
588  }
589  // Check that the configurations match exactly for the ESProducers
590  // (We already checked the ESSources above and there should not be
591  // any loopers)
592  if (!dataItem.second->isSource_ && !dataItem.second->isLooper_) {
593  bool itMatches = esController.isMatchingESProducer(
594  dataItem.second->pid_, subProcessIndex_, precedingESProvider.subProcessIndex_);
595  if (!itMatches) {
596  return false;
597  }
598  }
599  }
600  EventSetupRecordProvider* recProvider = tryToGetRecordProvider(eventSetupRecordKey);
601  if (recProvider != nullptr) {
602  std::set<EventSetupRecordKey> dependentRecords = recProvider->dependentRecords();
603  for (auto const& dependentRecord : dependentRecords) {
604  auto iter = allComponentsMatch.find(dependentRecord);
605  if (iter != allComponentsMatch.end()) {
606  if (iter->second) {
607  continue;
608  } else {
609  return false;
610  }
611  }
612  bool match = doRecordsMatch(precedingESProvider, dependentRecord, allComponentsMatch, esController);
613  allComponentsMatch[dependentRecord] = match;
614  if (!match)
615  return false;
616  }
617  }
618  return true;
619  }
EventSetupRecordProvider * tryToGetRecordProvider(const EventSetupRecordKey &iKey)
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_
std::set< EventSetupRecordKey > dependentRecords() const
Returns the list of Records the provided Record depends on (usually none)
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)
EventSetupImpl const& edm::eventsetup::EventSetupProvider::eventSetup ( ) const
inline
EventSetupImpl const & EventSetupProvider::eventSetupForInstance ( IOVSyncValue const &  )

Definition at line 667 of file EventSetupProvider.cc.

References edm::EventSetupImpl::clear().

667  {
668  eventSetup_.clear();
669 
670  // In a cmsRun job this does nothing because the EventSetupsController
671  // will have already called finishConfiguration, but some tests will
672  // call finishConfiguration here.
675  }
676 
677  for (auto const& recProvider : recordProviders_) {
678  recProvider->addRecordToIfValid(*this, iValue);
679  }
680  return eventSetup_;
681  }
void EventSetupProvider::fillReferencedDataKeys ( EventSetupRecordKey const &  eventSetupRecordKey)

Definition at line 621 of file EventSetupProvider.cc.

References edm::eventsetup::EventSetupRecordProvider::fillReferencedDataKeys().

Referenced by doRecordsMatch(), and eventSetup().

621  {
622  if (referencedDataKeys_->find(eventSetupRecordKey) != referencedDataKeys_->end())
623  return;
624 
625  EventSetupRecordProvider* recProvider = tryToGetRecordProvider(eventSetupRecordKey);
626  if (recProvider == nullptr) {
627  (*referencedDataKeys_)[eventSetupRecordKey];
628  return;
629  }
630  recProvider->fillReferencedDataKeys((*referencedDataKeys_)[eventSetupRecordKey]);
631  }
EventSetupRecordProvider * tryToGetRecordProvider(const EventSetupRecordKey &iKey)
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription const * > > > referencedDataKeys_
void fillReferencedDataKeys(std::map< DataKey, ComponentDescription const * > &referencedDataKeys) const
void EventSetupProvider::finishConfiguration ( )

Definition at line 234 of file EventSetupProvider.cc.

References edm::eventsetup::EventSetupRecordProvider::add(), edm::eventsetup::EventSetupRecordProvider::addFinder(), SoftLeptonByDistance_cfi::distance, edm::EventSetupImpl::insert(), crabWrapper::key, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by eventSetup().

234  {
235  //we delayed adding finders to the system till here so that everything would be loaded first
236  recordToFinders_->clear();
237  for (std::vector<std::shared_ptr<EventSetupRecordIntervalFinder>>::iterator itFinder = finders_->begin(),
238  itEnd = finders_->end();
239  itFinder != itEnd;
240  ++itFinder) {
241  typedef std::set<EventSetupRecordKey> Keys;
242  const Keys recordsUsing = (*itFinder)->findingForRecords();
243 
244  for (auto const& key : recordsUsing) {
245  (*recordToFinders_)[key].push_back(*itFinder);
246 
248  if (recProvider == nullptr) {
249  //create a provider for this record
250  insert(key, std::make_unique<EventSetupRecordProvider>(key));
251  recProvider = tryToGetRecordProvider(key);
252  }
253  recProvider->addFinder(*itFinder);
254  }
255  }
256  //we've transfered our ownership so this is no longer needed
257  finders_.reset();
258 
259  //Now handle providers since sources can also be finders and the sources can delay registering
260  // their Records and therefore could delay setting up their Proxies
261  psetIDToRecordKey_->clear();
262  typedef std::set<EventSetupRecordKey> Keys;
263  for (std::vector<std::shared_ptr<DataProxyProvider>>::iterator itProvider = dataProviders_->begin(),
264  itEnd = dataProviders_->end();
265  itProvider != itEnd;
266  ++itProvider) {
267  ParameterSetIDHolder psetID((*itProvider)->description().pid_);
268 
269  const Keys recordsUsing = (*itProvider)->usingRecords();
270 
271  for (auto const& key : recordsUsing) {
272  if ((*itProvider)->description().isLooper_) {
273  recordsWithALooperProxy_->insert(key);
274  }
275 
276  (*psetIDToRecordKey_)[psetID].insert(key);
277 
279  if (recProvider == nullptr) {
280  //create a provider for this record
281  insert(key, std::make_unique<EventSetupRecordProvider>(key));
282  recProvider = tryToGetRecordProvider(key);
283  }
284  recProvider->add(*itProvider);
285  }
286  }
287 
289 
290  //used for the case where no preferred Providers have been specified for the Record
292 
294 
295  //For each Provider, find all the Providers it depends on. If a dependent Provider
296  // can not be found pass in an empty list
297  //CHANGE: now allow for missing Providers
298  for (auto& itRecordProvider : recordProviders_) {
299  const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
300  RecordToPreferred::const_iterator itRecordFound = recordToPreferred_->find(itRecordProvider->key());
301  if (itRecordFound != recordToPreferred_->end()) {
302  preferredInfo = &(itRecordFound->second);
303  }
304  //Give it our list of preferred
305  itRecordProvider->usePreferred(*preferredInfo);
306 
307  std::set<EventSetupRecordKey> records = itRecordProvider->dependentRecords();
308  if (!records.empty()) {
309  std::string missingRecords;
310  std::vector<std::shared_ptr<EventSetupRecordProvider>> depProviders;
311  depProviders.reserve(records.size());
312  bool foundAllProviders = true;
313  for (auto const& key : records) {
314  auto lb = std::lower_bound(recordKeys_.begin(), recordKeys_.end(), key);
315  if (lb == recordKeys_.end() || key != *lb) {
316  foundAllProviders = false;
317  if (missingRecords.empty()) {
318  missingRecords = key.name();
319  } else {
320  missingRecords += ", ";
321  missingRecords += key.name();
322  }
323  } else {
324  auto index = std::distance(recordKeys_.begin(), lb);
325  depProviders.push_back(recordProviders_[index]);
326  }
327  }
328 
329  if (!foundAllProviders) {
330  edm::LogInfo("EventSetupDependency")
331  << "The EventSetup record " << itRecordProvider->key().name() << " depends on at least one Record \n ("
332  << missingRecords
333  << ") which is not present in the job."
334  "\n This may lead to an exception begin thrown during event processing.\n If no exception occurs "
335  "during the job than it is usually safe to ignore this message.";
336 
337  //depProviders.clear();
338  //NOTE: should provide a warning
339  }
340 
341  itRecordProvider->setDependentProviders(depProviders);
342  }
343  }
344 
345  auto indices = recordsToProxyIndices();
346  for (auto& provider : *dataProviders_) {
347  provider->updateLookup(indices);
348  }
349  dataProviders_.reset();
350 
351  mustFinishConfiguration_ = false;
352  }
EventSetupRecordProvider * tryToGetRecordProvider(const EventSetupRecordKey &iKey)
std::map< DataKey, ComponentDescription > DataToPreferredProviderMap
void add(std::shared_ptr< DataProxyProvider >)
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
void setKeyIters(std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysBegin, std::vector< eventsetup::EventSetupRecordKey >::const_iterator const &keysEnd)
void insert(std::unique_ptr< EventSetupRecordProvider > iRecordProvider)
std::unique_ptr< std::set< EventSetupRecordKey > > recordsWithALooperProxy_
std::unique_ptr< std::vector< std::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
ESRecordsToProxyIndices recordsToProxyIndices() const
std::unique_ptr< std::vector< std::shared_ptr< DataProxyProvider > > > dataProviders_
void addFinder(std::shared_ptr< EventSetupRecordIntervalFinder >)
For now, only use one finder.
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 387 of file EventSetupProvider.cc.

Referenced by eventSetup().

387  {
388  for (auto& recProvider : recordProviders_) {
389  if (recProvider) {
390  recProvider->resetProxies();
391  }
392  }
393  }
void EventSetupProvider::insert ( std::unique_ptr< EventSetupRecordProvider iRecordProvider)
protected

Definition at line 659 of file EventSetupProvider.cc.

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

Referenced by subProcessIndex().

659  {
660  auto key = iRecordProvider->key();
661  insert(key, std::move(iRecordProvider));
662  }
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 700 of file EventSetupProvider.cc.

References edm::ValidityInterval::invalidInterval().

700  {
701  for (auto const& recProvider : recordProviders_) {
702  auto const& iov = recProvider->validityInterval();
703  if ((iov != ValidityInterval::invalidInterval()) and (not recProvider->validityInterval().validFor(iSync))) {
704  return false;
705  }
706  }
707  return true;
708  }
static const ValidityInterval & invalidInterval()
void EventSetupProvider::logInfoWhenSharing ( ParameterSet const &  iConfiguration)
static

Definition at line 725 of file EventSetupProvider.cc.

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

Referenced by subProcessIndex().

725  {
726  std::string edmtype = iConfiguration.getParameter<std::string>("@module_edm_type");
727  std::string modtype = iConfiguration.getParameter<std::string>("@module_type");
728  std::string label = iConfiguration.getParameter<std::string>("@module_label");
729  edm::LogVerbatim("EventSetupSharing")
730  << "Sharing " << edmtype << ": class=" << modtype << " label='" << label << "'";
731  }
char const * label
EventSetupProvider const& edm::eventsetup::EventSetupProvider::operator= ( EventSetupProvider const &  )
privatedelete

Referenced by subProcessIndex().

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

Definition at line 683 of file EventSetupProvider.cc.

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

683  {
684  typedef std::set<ComponentDescription> Set;
685  Set descriptions;
686 
687  for (auto const& recProvider : recordProviders_) {
688  auto const& d = recProvider->proxyProviderDescriptions();
689  descriptions.insert(d.begin(), d.end());
690  }
691  if (dataProviders_.get()) {
692  for (auto const& p : *dataProviders_) {
693  descriptions.insert(p->description());
694  }
695  }
696 
697  return descriptions;
698  }
std::unique_ptr< std::vector< std::shared_ptr< DataProxyProvider > > > dataProviders_
std::shared_ptr< EventSetupRecordProvider > & EventSetupProvider::recordProvider ( const EventSetupRecordKey iKey)
private

Definition at line 55 of file EventSetupProvider.cc.

References SoftLeptonByDistance_cfi::distance, and Exception.

Referenced by checkESProducerSharing(), and subProcessIndex().

55  {
56  auto lb = std::lower_bound(recordKeys_.begin(), recordKeys_.end(), iKey);
57  if (lb == recordKeys_.end() || iKey != *lb) {
58  throw cms::Exception("LogicError") << "EventSetupProvider::recordProvider Could not find key\n"
59  << "Should be impossible. Please contact Framework developer.\n";
60  }
61  auto index = std::distance(recordKeys_.begin(), lb);
62  return recordProviders_[index];
63  }
ESRecordsToProxyIndices EventSetupProvider::recordsToProxyIndices ( ) const

Definition at line 710 of file EventSetupProvider.cc.

References edm::eventsetup::ESRecordsToProxyIndices::dataKeysInRecord().

710  {
712 
713  unsigned int index = 0;
714  for (auto provider : recordProviders_) {
715  index = ret.dataKeysInRecord(
716  index, provider->key(), provider->registeredDataKeys(), provider->componentsForRegisteredDataKeys());
717  }
718 
719  return ret;
720  }
void EventSetupProvider::replaceExisting ( std::shared_ptr< DataProxyProvider dataProxyProvider)

Definition at line 91 of file EventSetupProvider.cc.

References crabWrapper::key.

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

91  {
92  ParameterSetIDHolder psetID(dataProxyProvider->description().pid_);
93  std::set<EventSetupRecordKey> const& keysForPSetID = (*psetIDToRecordKey_)[psetID];
94  for (auto const& key : keysForPSetID) {
95  recordProvider(key)->resetProxyProvider(psetID, dataProxyProvider);
96  }
97  }
std::shared_ptr< EventSetupRecordProvider > & recordProvider(const EventSetupRecordKey &iKey)
void EventSetupProvider::resetRecordPlusDependentRecords ( EventSetupRecordKey const &  )

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

Definition at line 370 of file EventSetupProvider.cc.

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

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

370  {
372  if (recProvider == nullptr) {
373  return;
374  }
375 
376  std::vector<std::shared_ptr<EventSetupRecordProvider>> dependents;
377  findDependents(iKey, recordProviders_.begin(), recordProviders_.end(), dependents);
378 
379  dependents.erase(std::unique(dependents.begin(), dependents.end()), dependents.end());
380 
381  recProvider->resetProxies();
382  for (auto& d : dependents) {
383  d->resetProxies();
384  }
385  }
EventSetupRecordProvider * tryToGetRecordProvider(const EventSetupRecordKey &iKey)
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 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 633 of file EventSetupProvider.cc.

Referenced by eventSetup().

633  {
634  for (auto const& recProvider : recordProviders_) {
636  const EventSetupRecordProvider::DataToPreferredProviderMap* preferredInfo = &kEmptyMap;
637  RecordToPreferred::const_iterator itRecordFound = recordToPreferred_->find(recProvider->key());
638  if (itRecordFound != recordToPreferred_->end()) {
639  preferredInfo = &(itRecordFound->second);
640  }
641  recProvider->resetRecordToProxyPointers(*preferredInfo);
642  }
643  }
std::map< DataKey, ComponentDescription > DataToPreferredProviderMap
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
unsigned edm::eventsetup::EventSetupProvider::subProcessIndex ( ) const
inline
EventSetupRecordProvider * EventSetupProvider::tryToGetRecordProvider ( const EventSetupRecordKey iKey)
private

Definition at line 65 of file EventSetupProvider.cc.

References SoftLeptonByDistance_cfi::distance, edm::eventsetup::heterocontainer::insert(), and eostools::move().

Referenced by subProcessIndex().

65  {
66  auto lb = std::lower_bound(recordKeys_.begin(), recordKeys_.end(), iKey);
67  if (lb == recordKeys_.end() || iKey != *lb) {
68  return nullptr;
69  }
70  auto index = std::distance(recordKeys_.begin(), lb);
71  return recordProviders_[index].get();
72  }

Member Data Documentation

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

Definition at line 145 of file EventSetupProvider.h.

EventSetupImpl edm::eventsetup::EventSetupProvider::eventSetup_
private

Definition at line 130 of file EventSetupProvider.h.

Referenced by eventSetup().

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

Definition at line 144 of file EventSetupProvider.h.

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

Definition at line 138 of file EventSetupProvider.h.

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

Definition at line 143 of file EventSetupProvider.h.

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

Definition at line 149 of file EventSetupProvider.h.

Referenced by checkESProducerSharing().

RecordKeys edm::eventsetup::EventSetupProvider::recordKeys_
private

Definition at line 133 of file EventSetupProvider.h.

RecordProviders edm::eventsetup::EventSetupProvider::recordProviders_
private

Definition at line 136 of file EventSetupProvider.h.

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

Definition at line 151 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 148 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 150 of file EventSetupProvider.h.

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

Definition at line 146 of file EventSetupProvider.h.

Referenced by doRecordsMatch().

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

Definition at line 139 of file EventSetupProvider.h.

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