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) {
102 recordProvider(
key)->resetProductResolverProvider(psetID, productResolverProvider);
107 assert(iFinder.get() !=
nullptr);
112 using RecordToPreferred = std::map<EventSetupRecordKey, EventSetupRecordProvider::DataToPreferredProviderMap>;
118 bool foundResolverProvider =
false;
119 for (
auto const& recordProvider : iRecordProviders) {
120 std::set<ComponentDescription>
components = recordProvider->resolverProviderDescriptions();
122 std::shared_ptr<ESProductResolverProvider> resolverProv =
123 recordProvider->resolverProvider(*(
components.find(iComponent)));
124 assert(resolverProv.get());
126 std::set<EventSetupRecordKey> records = resolverProv->usingRecords();
127 for (
auto const& recordKey : records) {
128 unsigned int iovIndex = 0;
130 resolverProv->keyedResolvers(recordKey, iovIndex);
135 for (
auto keyedResolver : keyedResolvers) {
136 EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
137 dataToProviderMap.find(keyedResolver.dataKey_);
138 if (itFind != dataToProviderMap.end()) {
140 <<
"Two providers have been set to be preferred for\n" 141 << keyedResolver.dataKey_.type().name() <<
" \"" << keyedResolver.dataKey_.name().value() <<
"\"" 142 <<
"\n the providers are " 143 <<
"\n 1) type=" << itFind->second.type_ <<
" label=\"" << itFind->second.label_ <<
"\"" 144 <<
"\n 2) type=" << iComponent.
type_ <<
" label=\"" << iComponent.
label_ <<
"\"" 145 <<
"\nPlease modify configuration so only one is preferred";
147 dataToProviderMap.insert(std::make_pair(keyedResolver.dataKey_, iComponent));
151 foundResolverProvider =
true;
155 if (!foundResolverProvider) {
157 <<
"Could not make type=\"" << iComponent.
type_ <<
"\" label=\"" << iComponent.
label_ 158 <<
"\" a preferred Provider." 159 <<
"\n Please check spelling of name, or that it was loaded into the job.";
167 if (itInfo.second.empty()) {
171 for (
auto const& itRecData : itInfo.second) {
177 <<
"\" used in es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" 178 << itInfo.first.label_ <<
"\"\n Please check spelling.";
185 std::set<ComponentDescription>::iterator itResolverProv =
components.find(itInfo.first);
188 <<
"The type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
189 <<
"\" does not provide data for the Record " <<
recordName;
196 <<
"The es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
197 <<
"\" has the unknown data type \"" << itRecData.second.first <<
"\"" 198 <<
"\n Please check spelling";
203 std::shared_ptr<ESProductResolverProvider> resolverProv =
205 unsigned int iovIndex = 0;
207 resolverProv->keyedResolvers(recordKey, iovIndex);
208 if (!keyedResolvers.
contains(datumKey)) {
210 <<
"The es_prefer statement for type=" << itInfo.first.type_ <<
" label=\"" << itInfo.first.label_
211 <<
"\" specifies the data item \n" 212 <<
" type=\"" << itRecData.second.first <<
"\" label=\"" << itRecData.second.second <<
"\"" 213 <<
" which is not provided. Please check spelling.";
217 (*recordToPreferred_)[recordKey];
219 if (dataToProviderMap.end() != dataToProviderMap.find(datumKey)) {
220 EventSetupRecordProvider::DataToPreferredProviderMap::iterator itFind =
221 dataToProviderMap.find(datumKey);
223 <<
"Two providers have been set to be preferred for\n" 224 << datumKey.type().name() <<
" \"" << datumKey.name().value() <<
"\"" 225 <<
"\n the providers are " 226 <<
"\n 1) type=" << itFind->second.type_ <<
" label=\"" << itFind->second.label_ <<
"\"" 227 <<
"\n 2) type=" << itResolverProv->type_ <<
" label=\"" << itResolverProv->label_ <<
"\"" 228 <<
"\nPlease modify configuration so only one is preferred";
230 dataToProviderMap.insert(std::make_pair(datumKey, *itResolverProv));
238 bool& hasNonconcurrentFinder) {
242 if (!
finder->concurrentFinder()) {
243 hasNonconcurrentFinder =
true;
246 const std::set<EventSetupRecordKey> recordsUsing =
finder->findingForRecords();
248 for (
auto const&
key : recordsUsing) {
249 (*recordToFinders_)[
key].push_back(
finder);
252 if (recProvider ==
nullptr) {
253 bool printInfoMsg =
true;
272 const std::set<EventSetupRecordKey> recordsUsing = productResolverProvider->usingRecords();
273 for (
auto const&
key : recordsUsing) {
275 productResolverProvider->createKeyedResolvers(
key, nConcurrentIOVs);
277 if (productResolverProvider->description().isLooper_) {
281 (*psetIDToRecordKey_)[psetID].insert(
key);
284 if (recProvider ==
nullptr) {
285 bool printInfoMsg =
true;
291 recProvider->
add(productResolverProvider);
305 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(itRecordProvider->key());
307 preferredInfo = &(itRecordFound->second);
310 itRecordProvider->usePreferred(*preferredInfo);
312 std::set<EventSetupRecordKey> records = itRecordProvider->dependentRecords();
313 if (!records.empty()) {
315 std::vector<std::shared_ptr<EventSetupRecordProvider>> depProviders;
316 depProviders.reserve(records.size());
317 bool foundAllProviders =
true;
318 for (
auto const&
key : records) {
321 foundAllProviders =
false;
322 if (missingRecords.empty()) {
323 missingRecords =
key.name();
325 missingRecords +=
", ";
326 missingRecords +=
key.name();
334 if (!foundAllProviders) {
336 <<
"The EventSetup record " << itRecordProvider->key().name() <<
" depends on at least one Record \n (" 338 <<
") which is not present in the job." 339 "\n This may lead to an exception begin thrown during event processing.\n If no exception occurs " 340 "during the job than it is usually safe to ignore this message.";
346 itRecordProvider->setDependentProviders(depProviders);
352 provider->updateLookup(
indices);
359 using Itr = RecordProviders::iterator;
363 std::vector<std::shared_ptr<EventSetupRecordProvider>>& oDependents) {
364 for (
Itr it = itBegin; it != itEnd; ++it) {
366 const std::set<EventSetupRecordKey>&
deps = (*it)->dependentRecords();
367 if (
deps.end() !=
deps.find(iKey)) {
368 oDependents.push_back(*it);
377 if (recProvider ==
nullptr) {
381 std::vector<std::shared_ptr<EventSetupRecordProvider>> dependents;
384 dependents.erase(
std::unique(dependents.begin(), dependents.end()), dependents.end());
387 for (
auto&
d : dependents) {
395 recProvider->resetProxies();
403 std::set<ParameterSetIDHolder>& sharingCheckDone,
407 <<
"EventSetupProvider::checkESProducerSharing: Checking processes with SubProcess Indexes " 410 if (referencedESProducers.empty()) {
412 recProvider->getReferencedESProducers(referencedESProducers);
419 std::map<EventSetupRecordKey, bool> allComponentsMatch;
421 std::map<ParameterSetID, bool> candidateNotRejectedYet;
425 for (
auto const& iRecord : referencedESProducers) {
426 for (
auto const& iComponent : iRecord.second) {
429 if (sharingCheckDone.find(psetIDHolder) != sharingCheckDone.end())
432 bool firstProcessWithThisPSet =
false;
433 bool precedingHasMatchingPSet =
false;
438 firstProcessWithThisPSet,
439 precedingHasMatchingPSet);
441 if (firstProcessWithThisPSet) {
442 sharingCheckDone.insert(psetIDHolder);
443 allComponentsMatch[iRecord.first] =
false;
447 if (!precedingHasMatchingPSet) {
448 allComponentsMatch[iRecord.first] =
false;
465 auto iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
466 if (iCandidateNotRejectedYet == candidateNotRejectedYet.end()) {
467 candidateNotRejectedYet[psetID] =
true;
468 iCandidateNotRejectedYet = candidateNotRejectedYet.find(psetID);
490 if (iCandidateNotRejectedYet->second ==
true) {
491 auto iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
492 if (iAllComponentsMatch == allComponentsMatch.end()) {
496 bool match =
doRecordsMatch(precedingESProvider, iRecord.first, allComponentsMatch, esController);
497 allComponentsMatch[iRecord.first] = match;
498 iAllComponentsMatch = allComponentsMatch.find(iRecord.first);
500 if (!iAllComponentsMatch->second) {
501 iCandidateNotRejectedYet->second =
false;
508 for (
auto const& candidate : candidateNotRejectedYet) {
510 bool canBeShared = candidate.second;
515 sharingCheckDone.insert(psetIDHolder);
523 std::shared_ptr<ESProductResolverProvider> productResolverProvider;
524 std::set<EventSetupRecordKey>
const& keysForPSetID1 = (*precedingESProvider.
psetIDToRecordKey_)[psetIDHolder];
525 for (
auto const&
key : keysForPSetID1) {
526 productResolverProvider = precedingESProvider.
recordProvider(
key)->resolverProvider(psetIDHolder);
527 assert(productResolverProvider);
531 std::set<EventSetupRecordKey>
const& keysForPSetID2 = (*psetIDToRecordKey_)[psetIDHolder];
532 for (
auto const&
key : keysForPSetID2) {
533 recordProvider(
key)->resetProductResolverProvider(psetIDHolder, productResolverProvider);
546 std::map<EventSetupRecordKey, bool>& allComponentsMatch,
578 std::map<DataKey, ComponentDescription const*>
const& dataItems = (*referencedDataKeys_)[eventSetupRecordKey];
580 std::map<DataKey, ComponentDescription const*>
const& precedingDataItems =
583 if (dataItems.size() != precedingDataItems.size()) {
587 for (
auto const& dataItem : dataItems) {
588 auto precedingDataItem = precedingDataItems.find(dataItem.first);
589 if (precedingDataItem == precedingDataItems.end()) {
592 if (dataItem.second->pid_ != precedingDataItem->second->pid_) {
598 if (!dataItem.second->isSource_ && !dataItem.second->isLooper_) {
607 if (recProvider !=
nullptr) {
608 std::set<EventSetupRecordKey> dependentRecords = recProvider->
dependentRecords();
609 for (
auto const& dependentRecord : dependentRecords) {
610 auto iter = allComponentsMatch.find(dependentRecord);
611 if (iter != allComponentsMatch.end()) {
618 bool match =
doRecordsMatch(precedingESProvider, dependentRecord, allComponentsMatch, esController);
619 allComponentsMatch[dependentRecord] = match;
632 if (recProvider ==
nullptr) {
633 (*referencedDataKeys_)[eventSetupRecordKey];
643 RecordToPreferred::const_iterator itRecordFound =
recordToPreferred_->find(recProvider->key());
645 preferredInfo = &(itRecordFound->second);
647 recProvider->resetRecordToResolverPointers(*preferredInfo);
661 std::set<EventSetupRecordKey>& recordsNotAllowingConcurrentIOVs)
const {
663 productResolverProvider->fillRecordsNotAllowingConcurrentIOVs(recordsNotAllowingConcurrentIOVs);
672 recProvider->initializeForNewSyncValue();
676 recProvider->setValidityIntervalFor(iValue);
681 bool& newEventSetupImpl) {
689 bool needNewEventSetupImpl =
false;
691 needNewEventSetupImpl =
true;
696 needNewEventSetupImpl =
true;
699 if (recProvider->newIntervalForAnySubProcess()) {
700 needNewEventSetupImpl =
true;
706 if (needNewEventSetupImpl) {
709 newEventSetupImpl =
true;
721 if (recProvider->doWeNeedToWaitForIOVsToFinish(iValue)) {
729 typedef std::set<ComponentDescription> Set;
733 auto const&
d = recProvider->resolverProviderDescriptions();
734 descriptions.insert(
d.begin(),
d.end());
738 descriptions.insert(
p->description());
746 insert(iKey, std::unique_ptr<EventSetupRecordProvider>());
756 keys.insert(recProvider->key());
763 unsigned int index = 0;
766 index, provider->key(), provider->registeredDataKeys(), provider->componentsForRegisteredDataKeys());
780 <<
"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)
T getParameter(std::string const &) const
propagate_const< std::shared_ptr< EventSetupImpl > > eventSetupImpl_
void add(std::shared_ptr< ESProductResolverProvider >)
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_
bool isMatchingESSource(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
void resetRecordToResolverPointers()
void addRecord(const EventSetupRecordKey &iKey)
Intended for use only in tests.
ESRecordsToProductResolverIndices recordsToResolverIndices() const
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 finishConfiguration(NumberOfConcurrentIOVs const &, bool &hasNonconcurrentFinder)
std::map< ComponentDescription, RecordToDataMap > PreferredProviderInfo
void forceCacheClear()
Used when testing that all code properly updates on IOV changes of all Records.
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 fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
static void preferEverything(const ComponentDescription &iComponent, const RecordProviders &iRecordProviders, RecordToPreferred &iReturnValue)
find everything made by a ESProductResolverProvider 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
ActivityRegistry const * activityRegistry_
std::unique_ptr< std::vector< std::shared_ptr< ESProductResolverProvider > > > dataProviders_
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.
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(ModuleTypeResolverMaker const *resolverMaker, 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
static ComponentFactory< T > const * get()
void add(std::shared_ptr< ESProductResolverProvider >)
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
void insert(EventSetupRecordKey const &, std::unique_ptr< EventSetupRecordProvider >)
std::unique_ptr< std::set< EventSetupRecordKey > > recordsWithALooperResolver_
std::set< ComponentDescription > resolverProviderDescriptions() const
unsigned subProcessIndex_
std::set< ComponentDescription > resolverProviderDescriptions() const
return information on which ESProductResolverProviders are supplying information
void replaceExisting(std::shared_ptr< ESProductResolverProvider >)
PostESModuleRegistration postESModuleRegistrationSignal_
std::shared_ptr< ESProductResolverProvider > resolverProvider(ComponentDescription const &)
returns the first matching ESProductResolverProvider or a 'null' if not found
std::vector< std::shared_ptr< EventSetupRecordProvider > > RecordProviders
bool unInitialized() const
bool contains(DataKey const &dataKey) const
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag