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();
398 std::set<ParameterSetIDHolder>& sharingCheckDone,
402 <<
"EventSetupProvider::checkESProducerSharing: Checking processes with SubProcess Indexes " 405 if (referencedESProducers.empty()) {
407 recProvider->getReferencedESProducers(referencedESProducers);
414 std::map<EventSetupRecordKey, bool> allComponentsMatch;
416 std::map<ParameterSetID, bool> candidateNotRejectedYet;
420 for (
auto const& iRecord : referencedESProducers) {
421 for (
auto const& iComponent : iRecord.second) {
424 if (sharingCheckDone.find(psetIDHolder) != sharingCheckDone.end())
427 bool firstProcessWithThisPSet =
false;
428 bool precedingHasMatchingPSet =
false;
433 firstProcessWithThisPSet,
434 precedingHasMatchingPSet);
436 if (firstProcessWithThisPSet) {
437 sharingCheckDone.insert(psetIDHolder);
438 allComponentsMatch[iRecord.first] =
false;
442 if (!precedingHasMatchingPSet) {
443 allComponentsMatch[iRecord.first] =
false;
460 auto iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
461 if (iCandidateNotRejectedYet == candidateNotRejectedYet.end()) {
462 candidateNotRejectedYet[psetID] =
true;
463 iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
485 if (iCandidateNotRejectedYet->second ==
true) {
486 auto iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
487 if (iAllComponentsMatch == allComponentsMatch.end()) {
491 bool match =
doRecordsMatch(precedingESProvider, iRecord.first, allComponentsMatch, esController);
492 allComponentsMatch[iRecord.first] =
match;
493 iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
495 if (!iAllComponentsMatch->second) {
496 iCandidateNotRejectedYet->second =
false;
503 for (
auto const& candidate : candidateNotRejectedYet) {
505 bool canBeShared = candidate.second;
510 sharingCheckDone.insert(psetIDHolder);
518 std::shared_ptr<DataProxyProvider> dataProxyProvider;
519 std::set<EventSetupRecordKey>
const& keysForPSetID1 = (*precedingESProvider.
psetIDToRecordKey_)[psetIDHolder];
520 for (
auto const&
key : keysForPSetID1) {
521 dataProxyProvider = precedingESProvider.
recordProvider(
key)->proxyProvider(psetIDHolder);
522 assert(dataProxyProvider);
526 std::set<EventSetupRecordKey>
const& keysForPSetID2 = (*psetIDToRecordKey_)[psetIDHolder];
527 for (
auto const&
key : keysForPSetID2) {
541 std::map<EventSetupRecordKey, bool>& allComponentsMatch,
573 std::map<DataKey, ComponentDescription const*>
const& dataItems = (*referencedDataKeys_)[eventSetupRecordKey];
575 std::map<DataKey, ComponentDescription const*>
const& precedingDataItems =
578 if (dataItems.size() != precedingDataItems.size()) {
582 for (
auto const& dataItem : dataItems) {
583 auto precedingDataItem = precedingDataItems.find(dataItem.first);
584 if (precedingDataItem == precedingDataItems.end()) {
587 if (dataItem.second->pid_ != precedingDataItem->second->pid_) {
593 if (!dataItem.second->isSource_ && !dataItem.second->isLooper_) {
602 if (recProvider !=
nullptr) {
603 std::set<EventSetupRecordKey> dependentRecords = recProvider->
dependentRecords();
604 for (
auto const& dependentRecord : dependentRecords) {
605 auto iter = allComponentsMatch.find(dependentRecord);
606 if (iter != allComponentsMatch.end()) {
613 bool match =
doRecordsMatch(precedingESProvider, dependentRecord, allComponentsMatch, esController);
614 allComponentsMatch[dependentRecord] =
match;
627 if (recProvider ==
nullptr) {
628 (*referencedDataKeys_)[eventSetupRecordKey];
638 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(recProvider->key());
640 preferredInfo = &(itRecordFound->second);
642 recProvider->resetRecordToProxyPointers(*preferredInfo);
656 std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs)
const {
658 dataProxyProvider->fillRecordsNotAllowingConcurrentIOVs(recordsNotAllowingConcurrentIOVs);
667 recProvider->initializeForNewSyncValue();
671 recProvider->setValidityIntervalFor(iValue);
676 bool& newEventSetupImpl) {
684 bool needNewEventSetupImpl =
false;
686 needNewEventSetupImpl =
true;
691 needNewEventSetupImpl =
true;
694 if (recProvider->newIntervalForAnySubProcess()) {
695 needNewEventSetupImpl =
true;
701 if (needNewEventSetupImpl) {
704 newEventSetupImpl =
true;
716 if (recProvider->doWeNeedToWaitForIOVsToFinish(iValue)) {
724 typedef std::set<ComponentDescription> Set;
728 auto const&
d = recProvider->proxyProviderDescriptions();
729 descriptions.insert(
d.begin(),
d.end());
733 descriptions.insert(
p->description());
741 insert(iKey, std::unique_ptr<EventSetupRecordProvider>());
751 keys.insert(recProvider->key());
758 unsigned int index = 0;
761 index, provider->key(), provider->registeredDataKeys(), provider->componentsForRegisteredDataKeys());
775 <<
"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_
ParameterSet const * getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex) const
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
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 checkESProducerSharing(EventSetupProvider &precedingESProvider, std::set< ParameterSetIDHolder > &sharingCheckDone, std::map< EventSetupRecordKey, std::vector< ComponentDescription const *>> &referencedESProducers, EventSetupsController &esController)
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 >)
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
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)