38 namespace eventsetup {
41 unsigned subProcessIndex,
44 mustFinishConfiguration_(
true),
45 subProcessIndex_(subProcessIndex),
61 throw cms::Exception(
"LogicError") <<
"EventSetupProvider::recordProvider Could not find key\n"
62 <<
"Should be impossible. Please contact Framework developer.\n";
78 std::unique_ptr<EventSetupRecordProvider> iProvider) {
90 assert(iProvider.get() !=
nullptr);
96 std::set<EventSetupRecordKey>
const& keysForPSetID = (*psetIDToRecordKey_)[psetID];
97 for (
auto const&
key : keysForPSetID) {
103 assert(iFinder.get() !=
nullptr);
108 using RecordToPreferred = std::map<EventSetupRecordKey, EventSetupRecordProvider::DataToPreferredProviderMap>;
114 bool foundProxyProvider =
false;
115 for (
auto const& recordProvider : iRecordProviders) {
116 std::set<ComponentDescription>
components = recordProvider->proxyProviderDescriptions();
118 std::shared_ptr<DataProxyProvider> proxyProv = recordProvider->proxyProvider(*(
components.find(iComponent)));
121 std::set<EventSetupRecordKey> records = proxyProv->usingRecords();
122 for (
auto const& recordKey : records) {
123 unsigned int iovIndex = 0;
129 for (
auto keyedProxy : keyedProxies) {
130 EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
131 dataToProviderMap.find(keyedProxy.dataKey_);
132 if (itFind != dataToProviderMap.end()) {
134 <<
"Two providers have been set to be preferred for\n"
135 << keyedProxy.dataKey_.type().name() <<
" \"" << keyedProxy.dataKey_.name().value() <<
"\""
136 <<
"\n the providers are "
137 <<
"\n 1) type=" << itFind->second.type_ <<
" label=\"" << itFind->second.label_ <<
"\""
138 <<
"\n 2) type=" << iComponent.
type_ <<
" label=\"" << iComponent.
label_ <<
"\""
139 <<
"\nPlease modify configuration so only one is preferred";
141 dataToProviderMap.insert(std::make_pair(keyedProxy.dataKey_, iComponent));
145 foundProxyProvider =
true;
149 if (!foundProxyProvider) {
151 <<
"Could not make type=\"" << iComponent.
type_ <<
"\" label=\"" << iComponent.
label_
152 <<
"\" a preferred Provider."
153 <<
"\n Please check spelling of name, or that it was loaded into the job.";
161 if (itInfo.second.empty()) {
165 for (
auto const& itRecData : itInfo.second) {
171 <<
"\" used in es_prefer statement for type=" << itInfo.first.type_ <<
" label=\""
172 << itInfo.first.label_ <<
"\"\n Please check spelling.";
179 std::set<ComponentDescription>::iterator itProxyProv =
components.find(itInfo.first);
182 <<
"The type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
183 <<
"\" does not provide data for the Record " <<
recordName;
190 <<
"The es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
191 <<
"\" has the unknown data type \"" << itRecData.second.first <<
"\""
192 <<
"\n Please check spelling";
197 std::shared_ptr<DataProxyProvider> proxyProv = recordProviderForKey.
proxyProvider(*itProxyProv);
198 unsigned int iovIndex = 0;
200 if (!keyedProxies.
contains(datumKey)) {
202 <<
"The es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
203 <<
"\" specifies the data item \n"
204 <<
" type=\"" << itRecData.second.first <<
"\" label=\"" << itRecData.second.second <<
"\""
205 <<
" which is not provided. Please check spelling.";
209 (*recordToPreferred_)[recordKey];
211 if (dataToProviderMap.end() != dataToProviderMap.find(datumKey)) {
212 EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
213 dataToProviderMap.find(datumKey);
215 <<
"Two providers have been set to be preferred for\n"
216 << datumKey.type().name() <<
" \"" << datumKey.name().value() <<
"\""
217 <<
"\n the providers are "
218 <<
"\n 1) type=" << itFind->second.type_ <<
" label=\"" << itFind->second.label_ <<
"\""
219 <<
"\n 2) type=" << itProxyProv->type_ <<
" label=\"" << itProxyProv->label_ <<
"\""
220 <<
"\nPlease modify configuration so only one is preferred";
222 dataToProviderMap.insert(std::make_pair(datumKey, *itProxyProv));
230 bool& hasNonconcurrentFinder) {
234 if (!
finder->concurrentFinder()) {
235 hasNonconcurrentFinder =
true;
238 const std::set<EventSetupRecordKey> recordsUsing =
finder->findingForRecords();
240 for (
auto const&
key : recordsUsing) {
241 (*recordToFinders_)[
key].push_back(
finder);
244 if (recProvider ==
nullptr) {
245 bool printInfoMsg =
true;
264 const std::set<EventSetupRecordKey> recordsUsing = dataProxyProvider->usingRecords();
265 for (
auto const&
key : recordsUsing) {
267 dataProxyProvider->createKeyedProxies(
key, nConcurrentIOVs);
269 if (dataProxyProvider->description().isLooper_) {
273 (*psetIDToRecordKey_)[psetID].insert(
key);
276 if (recProvider ==
nullptr) {
277 bool printInfoMsg =
true;
283 recProvider->
add(dataProxyProvider);
297 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(itRecordProvider->key());
299 preferredInfo = &(itRecordFound->second);
302 itRecordProvider->usePreferred(*preferredInfo);
304 std::set<EventSetupRecordKey> records = itRecordProvider->dependentRecords();
305 if (!records.empty()) {
307 std::vector<std::shared_ptr<EventSetupRecordProvider>> depProviders;
308 depProviders.reserve(records.size());
309 bool foundAllProviders =
true;
310 for (
auto const&
key : records) {
313 foundAllProviders =
false;
314 if (missingRecords.empty()) {
315 missingRecords =
key.name();
317 missingRecords +=
", ";
318 missingRecords +=
key.name();
326 if (!foundAllProviders) {
328 <<
"The EventSetup record " << itRecordProvider->key().name() <<
" depends on at least one Record \n ("
330 <<
") which is not present in the job."
331 "\n This may lead to an exception begin thrown during event processing.\n If no exception occurs "
332 "during the job than it is usually safe to ignore this message.";
338 itRecordProvider->setDependentProviders(depProviders);
344 provider->updateLookup(
indices);
351 using Itr = RecordProviders::iterator;
355 std::vector<std::shared_ptr<EventSetupRecordProvider>>& oDependents) {
356 for (
Itr it = itBegin; it != itEnd; ++it) {
358 const std::set<EventSetupRecordKey>&
deps = (*it)->dependentRecords();
359 if (
deps.end() !=
deps.find(iKey)) {
360 oDependents.push_back(*it);
369 if (recProvider ==
nullptr) {
373 std::vector<std::shared_ptr<EventSetupRecordProvider>> dependents;
376 dependents.erase(
std::unique(dependents.begin(), dependents.end()), dependents.end());
379 for (
auto&
d : dependents) {
387 recProvider->resetProxies();
394 std::set<ParameterSetIDHolder>& sharingCheckDone,
398 <<
"EventSetupProvider::checkESProducerSharing: Checking processes with SubProcess Indexes "
401 if (referencedESProducers.empty()) {
403 recProvider->getReferencedESProducers(referencedESProducers);
410 std::map<EventSetupRecordKey, bool> allComponentsMatch;
412 std::map<ParameterSetID, bool> candidateNotRejectedYet;
416 for (
auto const& iRecord : referencedESProducers) {
417 for (
auto const& iComponent : iRecord.second) {
420 if (sharingCheckDone.find(psetIDHolder) != sharingCheckDone.end())
423 bool firstProcessWithThisPSet =
false;
424 bool precedingHasMatchingPSet =
false;
429 firstProcessWithThisPSet,
430 precedingHasMatchingPSet);
432 if (firstProcessWithThisPSet) {
433 sharingCheckDone.insert(psetIDHolder);
434 allComponentsMatch[iRecord.first] =
false;
438 if (!precedingHasMatchingPSet) {
439 allComponentsMatch[iRecord.first] =
false;
456 auto iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
457 if (iCandidateNotRejectedYet == candidateNotRejectedYet.end()) {
458 candidateNotRejectedYet[psetID] =
true;
459 iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
481 if (iCandidateNotRejectedYet->second ==
true) {
482 auto iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
483 if (iAllComponentsMatch == allComponentsMatch.end()) {
487 bool match =
doRecordsMatch(precedingESProvider, iRecord.first, allComponentsMatch, esController);
488 allComponentsMatch[iRecord.first] =
match;
489 iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
491 if (!iAllComponentsMatch->second) {
492 iCandidateNotRejectedYet->second =
false;
499 for (
auto const& candidate : candidateNotRejectedYet) {
501 bool canBeShared = candidate.second;
506 sharingCheckDone.insert(psetIDHolder);
514 std::shared_ptr<DataProxyProvider> dataProxyProvider;
515 std::set<EventSetupRecordKey>
const& keysForPSetID1 = (*precedingESProvider.
psetIDToRecordKey_)[psetIDHolder];
516 for (
auto const&
key : keysForPSetID1) {
517 dataProxyProvider = precedingESProvider.
recordProvider(
key)->proxyProvider(psetIDHolder);
518 assert(dataProxyProvider);
522 std::set<EventSetupRecordKey>
const& keysForPSetID2 = (*psetIDToRecordKey_)[psetIDHolder];
523 for (
auto const&
key : keysForPSetID2) {
537 std::map<EventSetupRecordKey, bool>& allComponentsMatch,
569 std::map<DataKey, ComponentDescription const*>
const& dataItems = (*referencedDataKeys_)[eventSetupRecordKey];
571 std::map<DataKey, ComponentDescription const*>
const& precedingDataItems =
574 if (dataItems.size() != precedingDataItems.size()) {
578 for (
auto const& dataItem : dataItems) {
579 auto precedingDataItem = precedingDataItems.find(dataItem.first);
580 if (precedingDataItem == precedingDataItems.end()) {
583 if (dataItem.second->pid_ != precedingDataItem->second->pid_) {
589 if (!dataItem.second->isSource_ && !dataItem.second->isLooper_) {
598 if (recProvider !=
nullptr) {
599 std::set<EventSetupRecordKey> dependentRecords = recProvider->
dependentRecords();
600 for (
auto const& dependentRecord : dependentRecords) {
601 auto iter = allComponentsMatch.find(dependentRecord);
602 if (iter != allComponentsMatch.end()) {
609 bool match =
doRecordsMatch(precedingESProvider, dependentRecord, allComponentsMatch, esController);
610 allComponentsMatch[dependentRecord] =
match;
623 if (recProvider ==
nullptr) {
624 (*referencedDataKeys_)[eventSetupRecordKey];
634 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(recProvider->key());
636 preferredInfo = &(itRecordFound->second);
638 recProvider->resetRecordToProxyPointers(*preferredInfo);
652 std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs)
const {
654 dataProxyProvider->fillRecordsNotAllowingConcurrentIOVs(recordsNotAllowingConcurrentIOVs);
663 recProvider->initializeForNewSyncValue();
667 recProvider->setValidityIntervalFor(iValue);
672 bool& newEventSetupImpl) {
680 bool needNewEventSetupImpl =
false;
682 needNewEventSetupImpl =
true;
687 needNewEventSetupImpl =
true;
690 if (recProvider->newIntervalForAnySubProcess()) {
691 needNewEventSetupImpl =
true;
697 if (needNewEventSetupImpl) {
700 newEventSetupImpl =
true;
712 if (recProvider->doWeNeedToWaitForIOVsToFinish(iValue)) {
720 typedef std::set<ComponentDescription> Set;
724 auto const&
d = recProvider->proxyProviderDescriptions();
725 descriptions.insert(
d.begin(),
d.end());
729 descriptions.insert(
p->description());
737 insert(iKey, std::unique_ptr<EventSetupRecordProvider>());
747 keys.insert(recProvider->key());
754 unsigned int index = 0;
757 index, provider->key(), provider->registeredDataKeys(), provider->componentsForRegisteredDataKeys());
771 <<
"Sharing " << edmtype <<
": class=" << modtype <<
" label='" <<
label <<
"'";