38 namespace eventsetup {
41 tbb::task_arena* taskArena,
42 unsigned subProcessIndex,
44 : activityRegistry_(activityRegistry),
45 taskArena_(taskArena),
46 mustFinishConfiguration_(
true),
47 subProcessIndex_(subProcessIndex),
63 throw cms::Exception(
"LogicError") <<
"EventSetupProvider::recordProvider Could not find key\n"
64 <<
"Should be impossible. Please contact Framework developer.\n";
80 std::unique_ptr<EventSetupRecordProvider> iProvider) {
92 assert(iProvider.get() !=
nullptr);
98 std::set<EventSetupRecordKey>
const& keysForPSetID = (*psetIDToRecordKey_)[psetID];
99 for (
auto const&
key : keysForPSetID) {
105 assert(iFinder.get() !=
nullptr);
110 using RecordToPreferred = std::map<EventSetupRecordKey, EventSetupRecordProvider::DataToPreferredProviderMap>;
116 bool foundProxyProvider =
false;
117 for (
auto const& recordProvider : iRecordProviders) {
118 std::set<ComponentDescription>
components = recordProvider->proxyProviderDescriptions();
120 std::shared_ptr<DataProxyProvider> proxyProv = recordProvider->proxyProvider(*(
components.find(iComponent)));
123 std::set<EventSetupRecordKey> records = proxyProv->usingRecords();
124 for (
auto const& recordKey : records) {
125 unsigned int iovIndex = 0;
131 for (
auto keyedProxy : keyedProxies) {
132 EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
133 dataToProviderMap.find(keyedProxy.dataKey_);
134 if (itFind != dataToProviderMap.end()) {
136 <<
"Two providers have been set to be preferred for\n"
137 << keyedProxy.dataKey_.type().name() <<
" \"" << keyedProxy.dataKey_.name().value() <<
"\""
138 <<
"\n the providers are "
139 <<
"\n 1) type=" << itFind->second.type_ <<
" label=\"" << itFind->second.label_ <<
"\""
140 <<
"\n 2) type=" << iComponent.
type_ <<
" label=\"" << iComponent.
label_ <<
"\""
141 <<
"\nPlease modify configuration so only one is preferred";
143 dataToProviderMap.insert(std::make_pair(keyedProxy.dataKey_, iComponent));
147 foundProxyProvider =
true;
151 if (!foundProxyProvider) {
153 <<
"Could not make type=\"" << iComponent.
type_ <<
"\" label=\"" << iComponent.
label_
154 <<
"\" a preferred Provider."
155 <<
"\n Please check spelling of name, or that it was loaded into the job.";
163 if (itInfo.second.empty()) {
167 for (
auto const& itRecData : itInfo.second) {
173 <<
"\" used in es_prefer statement for type=" << itInfo.first.type_ <<
" label=\""
174 << itInfo.first.label_ <<
"\"\n Please check spelling.";
181 std::set<ComponentDescription>::iterator itProxyProv =
components.find(itInfo.first);
184 <<
"The type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
185 <<
"\" does not provide data for the Record " <<
recordName;
192 <<
"The es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
193 <<
"\" has the unknown data type \"" << itRecData.second.first <<
"\""
194 <<
"\n Please check spelling";
199 std::shared_ptr<DataProxyProvider> proxyProv = recordProviderForKey.
proxyProvider(*itProxyProv);
200 unsigned int iovIndex = 0;
202 if (!keyedProxies.
contains(datumKey)) {
204 <<
"The es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
205 <<
"\" specifies the data item \n"
206 <<
" type=\"" << itRecData.second.first <<
"\" label=\"" << itRecData.second.second <<
"\""
207 <<
" which is not provided. Please check spelling.";
211 (*recordToPreferred_)[recordKey];
213 if (dataToProviderMap.end() != dataToProviderMap.find(datumKey)) {
214 EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
215 dataToProviderMap.find(datumKey);
217 <<
"Two providers have been set to be preferred for\n"
218 << datumKey.type().name() <<
" \"" << datumKey.name().value() <<
"\""
219 <<
"\n the providers are "
220 <<
"\n 1) type=" << itFind->second.type_ <<
" label=\"" << itFind->second.label_ <<
"\""
221 <<
"\n 2) type=" << itProxyProv->type_ <<
" label=\"" << itProxyProv->label_ <<
"\""
222 <<
"\nPlease modify configuration so only one is preferred";
224 dataToProviderMap.insert(std::make_pair(datumKey, *itProxyProv));
232 bool& hasNonconcurrentFinder) {
236 if (!
finder->concurrentFinder()) {
237 hasNonconcurrentFinder =
true;
240 const std::set<EventSetupRecordKey> recordsUsing =
finder->findingForRecords();
242 for (
auto const&
key : recordsUsing) {
243 (*recordToFinders_)[
key].push_back(
finder);
246 if (recProvider ==
nullptr) {
247 bool printInfoMsg =
true;
266 const std::set<EventSetupRecordKey> recordsUsing = dataProxyProvider->usingRecords();
267 for (
auto const&
key : recordsUsing) {
269 dataProxyProvider->createKeyedProxies(
key, nConcurrentIOVs);
271 if (dataProxyProvider->description().isLooper_) {
275 (*psetIDToRecordKey_)[psetID].insert(
key);
278 if (recProvider ==
nullptr) {
279 bool printInfoMsg =
true;
285 recProvider->
add(dataProxyProvider);
299 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(itRecordProvider->key());
301 preferredInfo = &(itRecordFound->second);
304 itRecordProvider->usePreferred(*preferredInfo);
306 std::set<EventSetupRecordKey> records = itRecordProvider->dependentRecords();
307 if (!records.empty()) {
309 std::vector<std::shared_ptr<EventSetupRecordProvider>> depProviders;
310 depProviders.reserve(records.size());
311 bool foundAllProviders =
true;
312 for (
auto const&
key : records) {
315 foundAllProviders =
false;
316 if (missingRecords.empty()) {
317 missingRecords =
key.name();
319 missingRecords +=
", ";
320 missingRecords +=
key.name();
328 if (!foundAllProviders) {
330 <<
"The EventSetup record " << itRecordProvider->key().name() <<
" depends on at least one Record \n ("
332 <<
") which is not present in the job."
333 "\n This may lead to an exception begin thrown during event processing.\n If no exception occurs "
334 "during the job than it is usually safe to ignore this message.";
340 itRecordProvider->setDependentProviders(depProviders);
346 provider->updateLookup(
indices);
353 using Itr = RecordProviders::iterator;
357 std::vector<std::shared_ptr<EventSetupRecordProvider>>& oDependents) {
358 for (
Itr it = itBegin; it != itEnd; ++it) {
360 const std::set<EventSetupRecordKey>&
deps = (*it)->dependentRecords();
361 if (
deps.end() !=
deps.find(iKey)) {
362 oDependents.push_back(*it);
371 if (recProvider ==
nullptr) {
375 std::vector<std::shared_ptr<EventSetupRecordProvider>> dependents;
378 dependents.erase(
std::unique(dependents.begin(), dependents.end()), dependents.end());
381 for (
auto&
d : dependents) {
389 recProvider->resetProxies();
396 std::set<ParameterSetIDHolder>& sharingCheckDone,
400 <<
"EventSetupProvider::checkESProducerSharing: Checking processes with SubProcess Indexes "
403 if (referencedESProducers.empty()) {
405 recProvider->getReferencedESProducers(referencedESProducers);
412 std::map<EventSetupRecordKey, bool> allComponentsMatch;
414 std::map<ParameterSetID, bool> candidateNotRejectedYet;
418 for (
auto const& iRecord : referencedESProducers) {
419 for (
auto const& iComponent : iRecord.second) {
422 if (sharingCheckDone.find(psetIDHolder) != sharingCheckDone.end())
425 bool firstProcessWithThisPSet =
false;
426 bool precedingHasMatchingPSet =
false;
431 firstProcessWithThisPSet,
432 precedingHasMatchingPSet);
434 if (firstProcessWithThisPSet) {
435 sharingCheckDone.insert(psetIDHolder);
436 allComponentsMatch[iRecord.first] =
false;
440 if (!precedingHasMatchingPSet) {
441 allComponentsMatch[iRecord.first] =
false;
458 auto iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
459 if (iCandidateNotRejectedYet == candidateNotRejectedYet.end()) {
460 candidateNotRejectedYet[psetID] =
true;
461 iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
483 if (iCandidateNotRejectedYet->second ==
true) {
484 auto iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
485 if (iAllComponentsMatch == allComponentsMatch.end()) {
489 bool match =
doRecordsMatch(precedingESProvider, iRecord.first, allComponentsMatch, esController);
490 allComponentsMatch[iRecord.first] =
match;
491 iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
493 if (!iAllComponentsMatch->second) {
494 iCandidateNotRejectedYet->second =
false;
501 for (
auto const& candidate : candidateNotRejectedYet) {
503 bool canBeShared = candidate.second;
508 sharingCheckDone.insert(psetIDHolder);
516 std::shared_ptr<DataProxyProvider> dataProxyProvider;
517 std::set<EventSetupRecordKey>
const& keysForPSetID1 = (*precedingESProvider.
psetIDToRecordKey_)[psetIDHolder];
518 for (
auto const&
key : keysForPSetID1) {
519 dataProxyProvider = precedingESProvider.
recordProvider(
key)->proxyProvider(psetIDHolder);
520 assert(dataProxyProvider);
524 std::set<EventSetupRecordKey>
const& keysForPSetID2 = (*psetIDToRecordKey_)[psetIDHolder];
525 for (
auto const&
key : keysForPSetID2) {
539 std::map<EventSetupRecordKey, bool>& allComponentsMatch,
571 std::map<DataKey, ComponentDescription const*>
const& dataItems = (*referencedDataKeys_)[eventSetupRecordKey];
573 std::map<DataKey, ComponentDescription const*>
const& precedingDataItems =
576 if (dataItems.size() != precedingDataItems.size()) {
580 for (
auto const& dataItem : dataItems) {
581 auto precedingDataItem = precedingDataItems.find(dataItem.first);
582 if (precedingDataItem == precedingDataItems.end()) {
585 if (dataItem.second->pid_ != precedingDataItem->second->pid_) {
591 if (!dataItem.second->isSource_ && !dataItem.second->isLooper_) {
600 if (recProvider !=
nullptr) {
601 std::set<EventSetupRecordKey> dependentRecords = recProvider->
dependentRecords();
602 for (
auto const& dependentRecord : dependentRecords) {
603 auto iter = allComponentsMatch.find(dependentRecord);
604 if (iter != allComponentsMatch.end()) {
611 bool match =
doRecordsMatch(precedingESProvider, dependentRecord, allComponentsMatch, esController);
612 allComponentsMatch[dependentRecord] =
match;
625 if (recProvider ==
nullptr) {
626 (*referencedDataKeys_)[eventSetupRecordKey];
636 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(recProvider->key());
638 preferredInfo = &(itRecordFound->second);
640 recProvider->resetRecordToProxyPointers(*preferredInfo);
654 std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs)
const {
656 dataProxyProvider->fillRecordsNotAllowingConcurrentIOVs(recordsNotAllowingConcurrentIOVs);
665 recProvider->initializeForNewSyncValue();
669 recProvider->setValidityIntervalFor(iValue);
674 bool& newEventSetupImpl) {
682 bool needNewEventSetupImpl =
false;
684 needNewEventSetupImpl =
true;
689 needNewEventSetupImpl =
true;
692 if (recProvider->newIntervalForAnySubProcess()) {
693 needNewEventSetupImpl =
true;
699 if (needNewEventSetupImpl) {
702 newEventSetupImpl =
true;
714 if (recProvider->doWeNeedToWaitForIOVsToFinish(iValue)) {
722 typedef std::set<ComponentDescription> Set;
726 auto const&
d = recProvider->proxyProviderDescriptions();
727 descriptions.insert(
d.begin(),
d.end());
731 descriptions.insert(
p->description());
739 insert(iKey, std::unique_ptr<EventSetupRecordProvider>());
749 keys.insert(recProvider->key());
756 unsigned int index = 0;
759 index, provider->key(), provider->registeredDataKeys(), provider->componentsForRegisteredDataKeys());
773 <<
"Sharing " << edmtype <<
": class=" << modtype <<
" label='" <<
label <<
"'";