36 std::vector<char> makeEmptyTokenLabels() {
return std::vector<char>{
'\0'}; }
40 : m_tokenLabels{makeEmptyTokenLabels()}, frozen_(
false), containsCurrentProcessAlias_(
false) {}
55 if (iTag.
label().empty()) {
73 const size_t labelSize = iTag.
label().size();
74 const size_t productInstanceSize = iTag.
instance().size();
76 unsigned short delta1 = labelSize + 1;
77 unsigned short delta2 = labelSize + 2 + productInstanceSize;
83 const size_t additionalSize = skipCurrentProcess ? labelSize + productInstanceSize + 3
84 : labelSize + productInstanceSize + iTag.
process().size() + 3;
102 if (!skipCurrentProcess) {
114 bool iPrefetchMayGet) {
121 ++itInfo, ++itKind, ++itLabels) {
122 if (itInfo->m_branchType == iBranchType) {
123 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
128 moduleLabel + itLabels->m_deltaToProductInstance,
129 moduleLabel + itLabels->m_deltaToProcessName),
130 itInfo->m_index.skipCurrentProcess());
150 for (
unsigned int j = 0;
j != matches.numberOfMatches(); ++
j) {
152 if (matches.isFullyResolved(
j)) {
153 auto index = matches.index(
j);
166 if (iPrefetchMayGet) {
177 unsigned int index = 0;
179 auto indexInRecord = iPI.
indexInRecord(it->m_record, it->m_key);
181 const char* componentName = &(
m_tokenLabels[it->m_startOfComponentName]);
182 if (*componentName) {
183 auto component = iPI.
component(it->m_record, it->m_key);
184 if (component->label_.empty()) {
185 if (component->type_ != componentName) {
188 }
else if (component->label_ != componentName) {
195 int negIndex = -1 * (index + 1);
197 for (
auto& itemIndex :
items) {
198 if (itemIndex.value() == negIndex) {
199 itemIndex = indexInRecord;
223 unsigned int startOfComponentName = 0;
224 if (not iTag.
module().empty()) {
253 TypeID const& iType)
const {
276 unsigned int count = 0;
280 ++it, ++itAlwaysGet) {
281 if (iBranch == it->m_branchType) {
290 oIndices.reserve(oIndices.size() +
count);
294 ++it, ++itAlwaysGet) {
295 if (iBranch == it->m_branchType) {
298 oIndices.push_back(it->m_index);
308 unsigned int count = 0;
312 ++it, ++itAlwaysGet) {
313 if (iBranch == it->m_branchType) {
315 if (not *itAlwaysGet) {
322 oIndices.reserve(oIndices.size() +
count);
326 ++it, ++itAlwaysGet) {
327 if (iBranch == it->m_branchType) {
329 if (not *itAlwaysGet) {
330 oIndices.push_back(it->m_index);
348 bool skipCurrentProcess,
351 if (it->m_index.productResolverIndex() == iIndex and it->m_index.skipCurrentProcess() == skipCurrentProcess and
352 it->m_branchType == iBranch) {
363 it->m_branchType == iBranch) {
372 <<
"' but the consumes call was for type '"
374 <<
"'.\n Please modify either the consumes or get call so the types match.";
378 <<
"A get using a EDGetToken was done in " <<
BranchTypeToString(iBranch) <<
" but the consumes call was for "
380 <<
".\n Please modify the consumes call to use the correct branch type.";
386 <<
"' was made using an uninitialized token.\n Please check that the variable is "
387 "being initialized from a 'consumes' call.";
390 <<
"A get using a EDGetToken with the C++ type '" << iType.
className() <<
"' was made using a token with a value "
392 <<
" which is beyond the range used by this module.\n Please check that the variable is being initialized from a "
393 "'consumes' call from this module.\n You can not share EDGetToken values between modules.";
397 throw cms::Exception(
"LogicError") <<
"A module declared it consumes a product after its constructor.\n"
398 <<
"This must be done in the contructor\n"
399 <<
"The product type was: " << typeToGet.
type() <<
"\n"
400 <<
"and " << inputTag <<
"\n";
406 throw cms::Exception(
"LogicError") <<
"A module declared it consumes an EventSetup product after its constructor.\n"
407 <<
"This must be done in the contructor\n"
408 <<
"The product type was: " << iDataType.
name() <<
" in record "
410 <<
"and ESInputTag was " << iTag <<
"\n";
415 <<
"A module declared it consumes an EventSetup product during a ProcessBlock transition.\n"
416 <<
"EventSetup products can only be consumed in Event, Lumi, or Run transitions.\n";
422 struct CharStarComp {
423 bool operator()(
const char* iLHS,
const char* iRHS)
const {
return strcmp(iLHS, iRHS) < 0; }
430 const char* consumedModuleLabel,
431 const char* consumedProductInstance,
432 std::vector<ModuleDescription const*>&
modules,
433 std::set<std::string>& alreadyFound,
434 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
438 if (
auto it = labelsToDesc.find(consumedModuleLabel); it != labelsToDesc.end()) {
439 if (alreadyFound.insert(consumedModuleLabel).second) {
440 modules.push_back(it->second);
445 if (
auto aliasToModuleLabels =
446 preg.
aliasToModules(consumedTypeKind, consumedType, consumedModuleLabel, consumedProductInstance);
447 not aliasToModuleLabels.empty()) {
448 bool foundInLabelsToDesc =
false;
449 for (
auto const&
label : aliasToModuleLabels) {
450 if (
auto it = labelsToDesc.find(
label); it != labelsToDesc.end()) {
451 if (alreadyFound.insert(
label).second) {
452 modules.push_back(it->second);
454 foundInLabelsToDesc =
true;
456 if (
label ==
"source") {
457 foundInLabelsToDesc =
true;
461 if (foundInLabelsToDesc) {
468 if (std::string_view(consumedModuleLabel) !=
"source") {
470 <<
"Couldn't find ModuleDescription for the consumed product type: '" << consumedType.
className()
471 <<
"' module label: '" << consumedModuleLabel <<
"' product instance name: '" << consumedProductInstance
479 std::vector<ModuleProcessName>& modulesInPreviousProcesses,
481 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
483 std::set<std::string> alreadyFound;
485 auto modulesInPreviousProcessesEmplace = [&modulesInPreviousProcesses](std::string_view
module,
489 modulesInPreviousProcesses.emplace(it, module,
process);
495 ++itInfo, ++itKind, ++itLabels) {
497 std::vector<ModuleDescription const*>& modules = *modulesAll[itInfo->m_branchType];
499 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
500 const char*
const consumedModuleLabel = &(
m_tokenLabels[labelStart]);
501 const char*
const consumedProductInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
502 const char*
const consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
504 if (not itInfo->m_index.skipCurrentProcess()) {
505 if (*consumedModuleLabel !=
'\0') {
506 if (*consumedProcessName !=
'\0') {
508 *itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance, consumedProcessName) !=
510 if (processName == consumedProcessName) {
511 insertFoundModuleLabel(*itKind,
514 consumedProductInstance,
521 modulesInPreviousProcessesEmplace(consumedModuleLabel, consumedProcessName);
525 auto matches = helper.
relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
526 for (
unsigned int j = 0;
j < matches.numberOfMatches(); ++
j) {
527 if (processName == matches.processName(
j)) {
528 insertFoundModuleLabel(*itKind,
531 consumedProductInstance,
539 modulesInPreviousProcessesEmplace(consumedModuleLabel, matches.processName(
j));
546 for (
unsigned int j = 0;
j < matches.numberOfMatches(); ++
j) {
547 if (processName == matches.processName(
j)) {
548 insertFoundModuleLabel(*itKind,
550 matches.moduleLabel(
j),
551 matches.productInstanceName(
j),
557 modulesInPreviousProcessesEmplace(matches.moduleLabel(
j), matches.processName(
j));
566 auto matches = helper.
relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
567 for (
unsigned int j = 0;
j < matches.numberOfMatches(); ++
j) {
568 if (processName != matches.processName(
j)) {
569 modulesInPreviousProcessesEmplace(matches.moduleLabel(
j), matches.processName(
j));
582 auto newTokenLabels = makeEmptyTokenLabels();
588 newProcessName = &
m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
592 newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
594 newTokenLabels.reserve(newSize);
596 unsigned int newStartOfModuleLabel = newTokenLabels.size();
598 unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
599 unsigned short deltaToProcessName = iter->m_deltaToProcessName;
601 iter->m_startOfModuleLabel = newStartOfModuleLabel;
603 newProcessName = &
m_tokenLabels[startOfModuleLabel + deltaToProcessName];
608 newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
611 newTokenLabels.insert(newTokenLabels.end(),
613 m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
615 newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
616 newTokenLabels.push_back(
'\0');
627 std::set<edm::TypeID> alreadySeenTypes;
629 std::vector<ConsumesInfo>
result;
634 ++itInfo, ++itKind, ++itLabels, ++itAlways) {
635 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
636 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
637 const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
638 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
641 if (*consumedModuleLabel ==
'\0') {
642 if (!alreadySeenTypes.insert(itInfo->m_type).second) {
648 result.emplace_back(itInfo->m_type,
652 itInfo->m_branchType,
655 itInfo->m_index.skipCurrentProcess());
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void throwESConsumesCallAfterFrozen(eventsetup::EventSetupRecordKey const &, eventsetup::heterocontainer::HCTypeTag const &, edm::ESInputTag const &) const
const edm::EventSetup & c
constexpr unsigned int index() const noexcept
std::vector< ConsumesInfo > consumesInfo() const
unsigned int ProductResolverIndex
virtual void doSelectInputProcessBlocks(ProductRegistry const &, ProcessBlockHelperBase const &)
char const * name() const
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
constexpr Value_t value() const noexcept
void throwTypeMismatch(edm::TypeID const &, EDGetToken) const
void throwBadToken(edm::TypeID const &iType, EDGetToken iToken) const
bool containsCurrentProcessAlias_
ComponentDescription const * component(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
void throwConsumesCallAfterFrozen(TypeToGet const &, InputTag const &) const
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
ESRecordIndex recordIndexFor(EventSetupRecordKey const &iRK) const noexcept
std::array< std::vector< ESProxyIndex >, static_cast< unsigned int >edm::Transition::NumberOfEventSetupTransitions)> esItemsToGetFromTransition_
ProductResolverIndexAndSkipBit uncheckedIndexFrom(EDGetToken) const
ESProxyIndex indexInRecord(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
If the index is not found, returns missingProxyIndex()
const char * labelFor(ESTokenIndex) const
ProductResolverIndexAndSkipBit indexFrom(EDGetToken, BranchType, TypeID const &) const
bool registeredToConsume(ProductResolverIndex, bool, BranchType) const
void modulesWhoseProductsAreConsumed(std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
void throwBranchMismatch(BranchType, EDGetToken) const
virtual void registerLateConsumes(eventsetup::ESRecordsToProxyIndices const &)
std::array< std::vector< ESRecordIndex >, static_cast< unsigned int >edm::Transition::NumberOfEventSetupTransitions)> esRecordsToGetFromTransition_
static constexpr ESProxyIndex missingProxyIndex() noexcept
void throwESConsumesInProcessBlock() const
std::vector< char > m_tokenLabels
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
static const edm::InputTag kWasEmpty("@EmptyLabel@")
bool registeredToConsumeMany(TypeID const &, BranchType) const
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
edm::SoATuple< ESTokenLookupInfo, ESProxyIndex > m_esTokenInfo
std::string const & BranchTypeToString(BranchType const &branchType)
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
char const * productInstance
const TypeTag & type() const
TypeID const & type() const
__host__ __device__ constexpr RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
std::string const & className() const
ESTokenIndex recordESConsumes(Transition, eventsetup::EventSetupRecordKey const &, eventsetup::heterocontainer::HCTypeTag const &, edm::ESInputTag const &iTag)
virtual ~EDConsumerBase() noexcept(false)
constexpr bool isUninitialized() const noexcept
std::vector< std::string > aliasToModules(KindOfType kindOfType, TypeID const &type, std::string_view moduleLabel, std::string_view productInstanceName) const
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name...
tuple size
Write out results.
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
std::array< std::vector< ProductResolverIndexAndSkipBit >, edm::NumBranchTypes > itemsToGetFromBranch_