39 namespace eventsetup {
42 unsigned subProcessIndex,
44 : activityRegistry_(activityRegistry),
45 mustFinishConfiguration_(
true),
46 subProcessIndex_(subProcessIndex),
62 throw cms::Exception(
"LogicError") <<
"EventSetupProvider::recordProvider Could not find key\n" 63 <<
"Should be impossible. Please contact Framework developer.\n";
79 std::unique_ptr<EventSetupRecordProvider> iProvider) {
91 assert(iProvider.get() !=
nullptr);
100 std::set<EventSetupRecordKey>
const& keysForPSetID = (*psetIDToRecordKey_)[psetID];
101 for (
auto const&
key : keysForPSetID) {
107 assert(iFinder.get() !=
nullptr);
112 using RecordToPreferred = std::map<EventSetupRecordKey, EventSetupRecordProvider::DataToPreferredProviderMap>;
118 bool foundProxyProvider =
false;
119 for (
auto const& recordProvider : iRecordProviders) {
120 std::set<ComponentDescription>
components = recordProvider->proxyProviderDescriptions();
122 std::shared_ptr<DataProxyProvider> proxyProv = recordProvider->proxyProvider(*(
components.find(iComponent)));
125 std::set<EventSetupRecordKey> records = proxyProv->usingRecords();
126 for (
auto const& recordKey : records) {
127 unsigned int iovIndex = 0;
133 for (
auto keyedProxy : keyedProxies) {
134 EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
135 dataToProviderMap.find(keyedProxy.dataKey_);
136 if (itFind != dataToProviderMap.end()) {
138 <<
"Two providers have been set to be preferred for\n" 139 << keyedProxy.dataKey_.type().name() <<
" \"" << keyedProxy.dataKey_.name().value() <<
"\"" 140 <<
"\n the providers are " 141 <<
"\n 1) type=" << itFind->second.type_ <<
" label=\"" << itFind->second.label_ <<
"\"" 142 <<
"\n 2) type=" << iComponent.
type_ <<
" label=\"" << iComponent.
label_ <<
"\"" 143 <<
"\nPlease modify configuration so only one is preferred";
145 dataToProviderMap.insert(std::make_pair(keyedProxy.dataKey_, iComponent));
149 foundProxyProvider =
true;
153 if (!foundProxyProvider) {
155 <<
"Could not make type=\"" << iComponent.
type_ <<
"\" label=\"" << iComponent.
label_ 156 <<
"\" a preferred Provider." 157 <<
"\n Please check spelling of name, or that it was loaded into the job.";
165 if (itInfo.second.empty()) {
169 for (
auto const& itRecData : itInfo.second) {
175 <<
"\" used in es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" 176 << itInfo.first.label_ <<
"\"\n Please check spelling.";
183 std::set<ComponentDescription>::iterator itProxyProv =
components.find(itInfo.first);
186 <<
"The type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
187 <<
"\" does not provide data for the Record " <<
recordName;
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";
201 std::shared_ptr<DataProxyProvider> proxyProv = recordProviderForKey.
proxyProvider(*itProxyProv);
202 unsigned int iovIndex = 0;
204 if (!keyedProxies.
contains(datumKey)) {
206 <<
"The es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
207 <<
"\" specifies the data item \n" 208 <<
" type=\"" << itRecData.second.first <<
"\" label=\"" << itRecData.second.second <<
"\"" 209 <<
" which is not provided. Please check spelling.";
213 (*recordToPreferred_)[recordKey];
215 if (dataToProviderMap.end() != dataToProviderMap.find(datumKey)) {
216 EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
217 dataToProviderMap.find(datumKey);
219 <<
"Two providers have been set to be preferred for\n" 220 << datumKey.type().name() <<
" \"" << datumKey.name().value() <<
"\"" 221 <<
"\n the providers are " 222 <<
"\n 1) type=" << itFind->second.type_ <<
" label=\"" << itFind->second.label_ <<
"\"" 223 <<
"\n 2) type=" << itProxyProv->type_ <<
" label=\"" << itProxyProv->label_ <<
"\"" 224 <<
"\nPlease modify configuration so only one is preferred";
226 dataToProviderMap.insert(std::make_pair(datumKey, *itProxyProv));
234 bool& hasNonconcurrentFinder) {
238 if (!
finder->concurrentFinder()) {
239 hasNonconcurrentFinder =
true;
242 const std::set<EventSetupRecordKey> recordsUsing =
finder->findingForRecords();
244 for (
auto const&
key : recordsUsing) {
245 (*recordToFinders_)[
key].push_back(
finder);
248 if (recProvider ==
nullptr) {
249 bool printInfoMsg =
true;
268 const std::set<EventSetupRecordKey> recordsUsing = dataProxyProvider->usingRecords();
269 for (
auto const&
key : recordsUsing) {
271 dataProxyProvider->createKeyedProxies(
key, nConcurrentIOVs);
273 if (dataProxyProvider->description().isLooper_) {
277 (*psetIDToRecordKey_)[psetID].insert(
key);
280 if (recProvider ==
nullptr) {
281 bool printInfoMsg =
true;
287 recProvider->
add(dataProxyProvider);
301 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(itRecordProvider->key());
303 preferredInfo = &(itRecordFound->second);
306 itRecordProvider->usePreferred(*preferredInfo);
308 std::set<EventSetupRecordKey> records = itRecordProvider->dependentRecords();
309 if (!records.empty()) {
311 std::vector<std::shared_ptr<EventSetupRecordProvider>> depProviders;
312 depProviders.reserve(records.size());
313 bool foundAllProviders =
true;
314 for (
auto const&
key : records) {
317 foundAllProviders =
false;
318 if (missingRecords.empty()) {
319 missingRecords =
key.name();
321 missingRecords +=
", ";
322 missingRecords +=
key.name();
330 if (!foundAllProviders) {
332 <<
"The EventSetup record " << itRecordProvider->key().name() <<
" depends on at least one Record \n (" 334 <<
") which is not present in the job." 335 "\n This may lead to an exception begin thrown during event processing.\n If no exception occurs " 336 "during the job than it is usually safe to ignore this message.";
342 itRecordProvider->setDependentProviders(depProviders);
348 provider->updateLookup(
indices);
355 using Itr = RecordProviders::iterator;
359 std::vector<std::shared_ptr<EventSetupRecordProvider>>& oDependents) {
360 for (
Itr it = itBegin; it != itEnd; ++it) {
362 const std::set<EventSetupRecordKey>&
deps = (*it)->dependentRecords();
363 if (
deps.end() !=
deps.find(iKey)) {
364 oDependents.push_back(*it);
373 if (recProvider ==
nullptr) {
377 std::vector<std::shared_ptr<EventSetupRecordProvider>> dependents;
380 dependents.erase(
std::unique(dependents.begin(), dependents.end()), dependents.end());
383 for (
auto&
d : dependents) {
391 recProvider->resetProxies();
399 std::set<ParameterSetIDHolder>& sharingCheckDone,
403 <<
"EventSetupProvider::checkESProducerSharing: Checking processes with SubProcess Indexes " 406 if (referencedESProducers.empty()) {
408 recProvider->getReferencedESProducers(referencedESProducers);
415 std::map<EventSetupRecordKey, bool> allComponentsMatch;
417 std::map<ParameterSetID, bool> candidateNotRejectedYet;
421 for (
auto const& iRecord : referencedESProducers) {
422 for (
auto const& iComponent : iRecord.second) {
425 if (sharingCheckDone.find(psetIDHolder) != sharingCheckDone.end())
428 bool firstProcessWithThisPSet =
false;
429 bool precedingHasMatchingPSet =
false;
434 firstProcessWithThisPSet,
435 precedingHasMatchingPSet);
437 if (firstProcessWithThisPSet) {
438 sharingCheckDone.insert(psetIDHolder);
439 allComponentsMatch[iRecord.first] =
false;
443 if (!precedingHasMatchingPSet) {
444 allComponentsMatch[iRecord.first] =
false;
461 auto iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
462 if (iCandidateNotRejectedYet == candidateNotRejectedYet.end()) {
463 candidateNotRejectedYet[psetID] =
true;
464 iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
486 if (iCandidateNotRejectedYet->second ==
true) {
487 auto iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
488 if (iAllComponentsMatch == allComponentsMatch.end()) {
492 bool match =
doRecordsMatch(precedingESProvider, iRecord.first, allComponentsMatch, esController);
493 allComponentsMatch[iRecord.first] = match;
494 iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
496 if (!iAllComponentsMatch->second) {
497 iCandidateNotRejectedYet->second =
false;
504 for (
auto const& candidate : candidateNotRejectedYet) {
506 bool canBeShared = candidate.second;
511 sharingCheckDone.insert(psetIDHolder);
519 std::shared_ptr<DataProxyProvider> dataProxyProvider;
520 std::set<EventSetupRecordKey>
const& keysForPSetID1 = (*precedingESProvider.
psetIDToRecordKey_)[psetIDHolder];
521 for (
auto const&
key : keysForPSetID1) {
522 dataProxyProvider = precedingESProvider.
recordProvider(
key)->proxyProvider(psetIDHolder);
523 assert(dataProxyProvider);
527 std::set<EventSetupRecordKey>
const& keysForPSetID2 = (*psetIDToRecordKey_)[psetIDHolder];
528 for (
auto const&
key : keysForPSetID2) {
542 std::map<EventSetupRecordKey, bool>& allComponentsMatch,
574 std::map<DataKey, ComponentDescription const*>
const& dataItems = (*referencedDataKeys_)[eventSetupRecordKey];
576 std::map<DataKey, ComponentDescription const*>
const& precedingDataItems =
579 if (dataItems.size() != precedingDataItems.size()) {
583 for (
auto const& dataItem : dataItems) {
584 auto precedingDataItem = precedingDataItems.find(dataItem.first);
585 if (precedingDataItem == precedingDataItems.end()) {
588 if (dataItem.second->pid_ != precedingDataItem->second->pid_) {
594 if (!dataItem.second->isSource_ && !dataItem.second->isLooper_) {
603 if (recProvider !=
nullptr) {
604 std::set<EventSetupRecordKey> dependentRecords = recProvider->
dependentRecords();
605 for (
auto const& dependentRecord : dependentRecords) {
606 auto iter = allComponentsMatch.find(dependentRecord);
607 if (iter != allComponentsMatch.end()) {
614 bool match =
doRecordsMatch(precedingESProvider, dependentRecord, allComponentsMatch, esController);
615 allComponentsMatch[dependentRecord] = match;
628 if (recProvider ==
nullptr) {
629 (*referencedDataKeys_)[eventSetupRecordKey];
639 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(recProvider->key());
641 preferredInfo = &(itRecordFound->second);
643 recProvider->resetRecordToProxyPointers(*preferredInfo);
657 std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs)
const {
659 dataProxyProvider->fillRecordsNotAllowingConcurrentIOVs(recordsNotAllowingConcurrentIOVs);
668 recProvider->initializeForNewSyncValue();
672 recProvider->setValidityIntervalFor(iValue);
677 bool& newEventSetupImpl) {
685 bool needNewEventSetupImpl =
false;
687 needNewEventSetupImpl =
true;
692 needNewEventSetupImpl =
true;
695 if (recProvider->newIntervalForAnySubProcess()) {
696 needNewEventSetupImpl =
true;
702 if (needNewEventSetupImpl) {
705 newEventSetupImpl =
true;
717 if (recProvider->doWeNeedToWaitForIOVsToFinish(iValue)) {
725 typedef std::set<ComponentDescription> Set;
729 auto const&
d = recProvider->proxyProviderDescriptions();
730 descriptions.insert(
d.begin(),
d.end());
734 descriptions.insert(
p->description());
742 insert(iKey, std::unique_ptr<EventSetupRecordProvider>());
752 keys.insert(recProvider->key());
759 unsigned int index = 0;
762 index, provider->key(), provider->registeredDataKeys(), provider->componentsForRegisteredDataKeys());
776 <<
"Sharing " << edmtype <<
": class=" << modtype <<
" label='" <<
label <<
"'";
const TypeTag & type() const
static void findDependents(const EventSetupRecordKey &iKey, Itr itBegin, Itr itEnd, std::vector< std::shared_ptr< EventSetupRecordProvider >> &oDependents)
Log< level::Info, true > LogVerbatim
std::set< EventSetupRecordKey > dependentRecords() const
Returns the list of Records the provided Record depends on (usually none)
ESRecordsToProxyIndices recordsToProxyIndices() const
T getParameter(std::string const &) const
propagate_const< std::shared_ptr< EventSetupImpl > > eventSetupImpl_
void resetProxies()
This will clear the cache's of all the Proxies so that next time they are called they will run...
void clearInitializationData()
ret
prodAgent to be discontinued
bool mustFinishConfiguration_
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
RecordProviders recordProviders_
std::set< ComponentDescription > proxyProviderDescriptions() const
return information on which DataProxyProviders are supplying information
bool isMatchingESSource(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
void addRecord(const EventSetupRecordKey &iKey)
Intended for use only in tests.
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription const * > > > referencedDataKeys_
void fillKeys(std::set< EventSetupRecordKey > &keys) const
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void addFinder(std::shared_ptr< EventSetupRecordIntervalFinder >)
For now, only use one finder.
void lookForMatches(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
void resetRecordToProxyPointers()
void finishConfiguration(NumberOfConcurrentIOVs const &, bool &hasNonconcurrentFinder)
std::map< ComponentDescription, RecordToDataMap > PreferredProviderInfo
std::set< ComponentDescription > proxyProviderDescriptions() const
void forceCacheClear()
Used when testing that all code properly updates on IOV changes of all Records.
bool unInitialized() const
RecordProviders::iterator Itr
ParameterSet & getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex)
bool isLastMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::shared_ptr< EventSetupRecordProvider > & recordProvider(const EventSetupRecordKey &iKey)
EventSetupRecordProvider * tryToGetRecordProvider(const EventSetupRecordKey &iKey)
bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const &) const
static void logInfoWhenSharing(ParameterSet const &iConfiguration)
void fillReferencedDataKeys(EventSetupRecordKey const &eventSetupRecordKey)
void add(std::shared_ptr< DataProxyProvider >)
std::unique_ptr< std::set< EventSetupRecordKey > > recordsWithALooperProxy_
void fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
static void preferEverything(const ComponentDescription &iComponent, const RecordProviders &iRecordProviders, RecordToPreferred &iReturnValue)
find everything made by a DataProxyProvider and add it to the 'preferred' list
std::unique_ptr< std::vector< std::shared_ptr< EventSetupRecordIntervalFinder > > > finders_
def unique(seq, keepstr=True)
bool isMatchingESProducer(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::shared_ptr< DataProxyProvider > proxyProvider(ComponentDescription const &)
returns the first matching DataProxyProvider or a 'null' if not found
ActivityRegistry const * activityRegistry_
unsigned subProcessIndex() const
void fillReferencedDataKeys(std::map< DataKey, ComponentDescription const *> &referencedDataKeys) const
std::unique_ptr< PreferredProviderInfo > preferredProviderInfo_
std::shared_ptr< const EventSetupImpl > eventSetupForInstance(IOVSyncValue const &, bool &newEventSetupImpl)
void resetRecordPlusDependentRecords(EventSetupRecordKey const &)
Used when we need to force a Record to reset all its proxies.
std::unique_ptr< std::vector< std::shared_ptr< DataProxyProvider > > > dataProviders_
void determinePreferred()
Log< level::Info, false > LogInfo
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)
EventSetupProvider(ActivityRegistry const *, unsigned subProcessIndex=0U, PreferredProviderInfo const *iInfo=nullptr)
std::map< DataKey, ComponentDescription > DataToPreferredProviderMap
void setPreferredProviderInfo(PreferredProviderInfo const &iInfo)
void setAllValidityIntervals(const IOVSyncValue &iValue)
Set the validity intervals in all EventSetupRecordProviders.
bool isFirstMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
heterocontainer::HCTypeTag TypeTag
std::map< EventSetupRecordKey, EventSetupRecordProvider::DataToPreferredProviderMap > RecordToPreferred
void replaceExisting(std::shared_ptr< DataProxyProvider >)
static ComponentFactory< T > const * get()
void add(std::shared_ptr< DataProxyProvider >)
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
bool contains(DataKey const &dataKey) const
void insert(EventSetupRecordKey const &, std::unique_ptr< EventSetupRecordProvider >)
void checkESProducerSharing(ModuleTypeResolverBase const *resolver, EventSetupProvider &precedingESProvider, std::set< ParameterSetIDHolder > &sharingCheckDone, std::map< EventSetupRecordKey, std::vector< ComponentDescription const *>> &referencedESProducers, EventSetupsController &esController)
unsigned subProcessIndex_
PostESModuleRegistration postESModuleRegistrationSignal_
std::vector< std::shared_ptr< EventSetupRecordProvider > > RecordProviders
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag