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();
119 if (components.find(iComponent) != components.end()) {
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.";
160 using namespace edm::eventsetup;
163 if (itInfo.second.empty()) {
167 for (
auto const& itRecData : itInfo.second) {
172 <<
"Unknown record \"" << recordName
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);
182 if (itProxyProv == components.end()) {
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();
324 depProviders.push_back(recordProviders_[
index]);
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);
345 for (
auto& provider : *dataProviders_) {
346 provider->updateLookup(
indices);
348 dataProviders_.reset();
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,
397 std::map<
EventSetupRecordKey, std::vector<ComponentDescription const*>>& referencedESProducers,
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,
560 ParameterSetID const& psetID = finder->descriptionForFinder().pid_;
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();
668 for (
auto& recProvider : recordProviders_) {
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 <<
"'";
static void findDependents(const EventSetupRecordKey &iKey, Itr itBegin, Itr itEnd, std::vector< std::shared_ptr< EventSetupRecordProvider >> &oDependents)
void lookForMatches(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex, bool &firstProcessWithThisPSet, bool &precedingHasMatchingPSet) const
Log< level::Info, true > LogVerbatim
tuple ret
prodAgent to be discontinued
propagate_const< std::shared_ptr< EventSetupImpl > > eventSetupImpl_
bool isFirstMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::set< EventSetupRecordKey > dependentRecords() const
Returns the list of Records the provided Record depends on (usually none)
bool isMatchingESProducer(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
unsigned int dataKeysInRecord(unsigned int iRecordIndex, EventSetupRecordKey const &iRecord, std::vector< DataKey > const &iDataKeys, std::vector< ComponentDescription const * > const &iComponents)
void resetProxies()
This will clear the cache's of all the Proxies so that next time they are called they will run...
std::set< ComponentDescription > proxyProviderDescriptions() const
return information on which DataProxyProviders are supplying information
void clearInitializationData()
bool mustFinishConfiguration_
std::unique_ptr< std::map< ParameterSetIDHolder, std::set< EventSetupRecordKey > > > psetIDToRecordKey_
RecordProviders recordProviders_
bool doWeNeedToWaitForIOVsToFinish(IOVSyncValue const &) const
void addRecord(const EventSetupRecordKey &iKey)
Intended for use only in tests.
bool isLastMatch(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription const * > > > referencedDataKeys_
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 resetRecordToProxyPointers()
ParameterSet const * getESProducerPSet(ParameterSetID const &psetID, unsigned subProcessIndex) const
void fillReferencedDataKeys(std::map< DataKey, ComponentDescription const * > &referencedDataKeys) 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
std::shared_ptr< EventSetupRecordProvider > & recordProvider(const EventSetupRecordKey &iKey)
EventSetupRecordProvider * tryToGetRecordProvider(const EventSetupRecordKey &iKey)
static void logInfoWhenSharing(ParameterSet const &iConfiguration)
void fillReferencedDataKeys(EventSetupRecordKey const &eventSetupRecordKey)
void add(std::shared_ptr< DataProxyProvider >)
std::unique_ptr< std::set< EventSetupRecordKey > > recordsWithALooperProxy_
std::vector< std::shared_ptr< EventSetupRecordProvider >> RecordProviders
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_
std::shared_ptr< DataProxyProvider > proxyProvider(ComponentDescription const &)
returns the first matching DataProxyProvider or a 'null' if not found
tuple key
prepare the HTCondor submission files and eventually submit them
ActivityRegistry const * activityRegistry_
std::unique_ptr< PreferredProviderInfo > preferredProviderInfo_
EventSetupProvider(ActivityRegistry const *, tbb::task_arena *, unsigned subProcessIndex=0U, PreferredProviderInfo const *iInfo=nullptr)
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.
bool contains(DataKey const &dataKey) const
unsigned int numberOfConcurrentIOVs(EventSetupRecordKey const &, bool printInfoMsg=false) const
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)
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)
T getParameter(std::string const &) const
ESRecordsToProxyIndices recordsToProxyIndices() const
void setAllValidityIntervals(const IOVSyncValue &iValue)
Set the validity intervals in all EventSetupRecordProviders.
void fillRecordsNotAllowingConcurrentIOVs(std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
unsigned subProcessIndex() const
heterocontainer::HCTypeTag TypeTag
std::map< EventSetupRecordKey, EventSetupRecordProvider::DataToPreferredProviderMap > RecordToPreferred
void replaceExisting(std::shared_ptr< DataProxyProvider >)
const TypeTag & type() const
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
static ComponentFactory< T > const * get()
bool isMatchingESSource(ParameterSetID const &psetID, unsigned subProcessIndex, unsigned precedingProcessIndex) const
void add(std::shared_ptr< DataProxyProvider >)
std::unique_ptr< std::map< EventSetupRecordKey, std::map< DataKey, ComponentDescription > > > recordToPreferred_
void insert(EventSetupRecordKey const &, std::unique_ptr< EventSetupRecordProvider >)
tbb::task_arena * taskArena_
unsigned subProcessIndex_
tuple size
Write out results.
void fillKeys(std::set< EventSetupRecordKey > &keys) const
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)
bool unInitialized() const
std::set< ComponentDescription > proxyProviderDescriptions() const