37 std::vector<char> makeEmptyTokenLabels() {
return std::vector<char>{
'\0'}; }
41 : m_tokenLabels{makeEmptyTokenLabels()}, frozen_(
false), containsCurrentProcessAlias_(
false) {}
56 if (iTag.
label().empty()) {
74 const size_t labelSize = iTag.
label().size();
75 const size_t productInstanceSize = iTag.
instance().size();
77 unsigned short delta1 = labelSize + 1;
78 unsigned short delta2 = labelSize + 2 + productInstanceSize;
84 const size_t additionalSize = skipCurrentProcess ? labelSize + productInstanceSize + 3
85 : labelSize + productInstanceSize + iTag.
process().size() + 3;
103 if (!skipCurrentProcess) {
115 bool iPrefetchMayGet) {
122 ++itInfo, ++itKind, ++itLabels) {
123 if (itInfo->m_branchType == iBranchType) {
124 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
131 itInfo->m_index.skipCurrentProcess());
151 for (
unsigned int j = 0;
j !=
matches.numberOfMatches(); ++
j) {
167 if (iPrefetchMayGet) {
178 unsigned int index = 0;
180 auto indexInRecord = iPI.
indexInRecord(it->m_record, it->m_key);
182 const char* componentName = &(
m_tokenLabels[it->m_startOfComponentName]);
183 if (*componentName) {
184 auto component = iPI.
component(it->m_record, it->m_key);
185 if (component->label_.empty()) {
186 if (component->type_ != componentName) {
189 }
else if (component->label_ != componentName) {
196 int negIndex = -1 * (
index + 1);
198 for (
auto& itemIndex :
items) {
199 if (itemIndex.value() == negIndex) {
200 itemIndex = indexInRecord;
224 unsigned int startOfComponentName = 0;
225 if (not iTag.
module().empty()) {
254 TypeID const& iType)
const {
277 unsigned int count = 0;
281 ++it, ++itAlwaysGet) {
282 if (iBranch == it->m_branchType) {
291 oIndices.reserve(oIndices.size() +
count);
295 ++it, ++itAlwaysGet) {
296 if (iBranch == it->m_branchType) {
299 oIndices.push_back(it->m_index);
309 unsigned int count = 0;
313 ++it, ++itAlwaysGet) {
314 if (iBranch == it->m_branchType) {
316 if (not *itAlwaysGet) {
323 oIndices.reserve(oIndices.size() +
count);
327 ++it, ++itAlwaysGet) {
328 if (iBranch == it->m_branchType) {
330 if (not *itAlwaysGet) {
331 oIndices.push_back(it->m_index);
349 bool skipCurrentProcess,
352 if (it->m_index.productResolverIndex() == iIndex and it->m_index.skipCurrentProcess() == skipCurrentProcess and
353 it->m_branchType == iBranch) {
364 it->m_branchType == iBranch) {
373 <<
"' but the consumes call was for type '" 375 <<
"'.\n Please modify either the consumes or get call so the types match.";
379 <<
"A get using a EDGetToken was done in " <<
BranchTypeToString(iBranch) <<
" but the consumes call was for " 381 <<
".\n Please modify the consumes call to use the correct branch type.";
387 <<
"' was made using an uninitialized token.\n Please check that the variable is " 388 "being initialized from a 'consumes' call.";
391 <<
"A get using a EDGetToken with the C++ type '" << iType.
className() <<
"' was made using a token with a value " 393 <<
" which is beyond the range used by this module.\n Please check that the variable is being initialized from a " 394 "'consumes' call from this module.\n You can not share EDGetToken values between modules.";
398 throw cms::Exception(
"LogicError") <<
"A module declared it consumes a product after its constructor.\n" 399 <<
"This must be done in the contructor\n" 400 <<
"The product type was: " << typeToGet.
type() <<
"\n" 407 throw cms::Exception(
"LogicError") <<
"A module declared it consumes an EventSetup product after its constructor.\n" 408 <<
"This must be done in the contructor\n" 409 <<
"The product type was: " << iDataType.
name() <<
" in record " 411 <<
"and ESInputTag was " << iTag <<
"\n";
416 <<
"A module declared it consumes an EventSetup product during a ProcessBlock transition.\n" 417 <<
"EventSetup products can only be consumed in Event, Lumi, or Run transitions.\n";
423 struct CharStarComp {
424 bool operator()(
const char* iLHS,
const char* iRHS)
const {
return strcmp(iLHS, iRHS) < 0; }
431 const char* consumedModuleLabel,
432 const char* consumedProductInstance,
433 std::vector<ModuleDescription const*>&
modules,
434 std::set<std::string>& alreadyFound,
435 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
439 if (
auto it = labelsToDesc.find(consumedModuleLabel); it != labelsToDesc.end()) {
440 if (alreadyFound.insert(consumedModuleLabel).second) {
446 if (
auto aliasToModuleLabels =
447 preg.
aliasToModules(consumedTypeKind, consumedType, consumedModuleLabel, consumedProductInstance);
448 not aliasToModuleLabels.empty()) {
449 bool foundInLabelsToDesc =
false;
450 for (
auto const&
label : aliasToModuleLabels) {
451 if (
auto it = labelsToDesc.find(
label); it != labelsToDesc.end()) {
452 if (alreadyFound.insert(
label).second) {
455 foundInLabelsToDesc =
true;
457 if (
label ==
"source") {
458 foundInLabelsToDesc =
true;
462 if (foundInLabelsToDesc) {
469 if (std::string_view(consumedModuleLabel) !=
"source") {
471 <<
"Couldn't find ModuleDescription for the consumed product type: '" << consumedType.
className()
472 <<
"' module label: '" << consumedModuleLabel <<
"' product instance name: '" << consumedProductInstance
480 std::vector<ModuleProcessName>& modulesInPreviousProcesses,
482 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
484 std::set<std::string> alreadyFound;
486 auto modulesInPreviousProcessesEmplace = [&modulesInPreviousProcesses](std::string_view
module,
496 ++itInfo, ++itKind, ++itLabels) {
498 std::vector<ModuleDescription const*>&
modules = *modulesAll[itInfo->m_branchType];
500 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
501 const char*
const consumedModuleLabel = &(
m_tokenLabels[labelStart]);
502 const char*
const consumedProductInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
503 const char*
const consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
505 if (not itInfo->m_index.skipCurrentProcess()) {
506 if (*consumedModuleLabel !=
'\0') {
507 if (*consumedProcessName !=
'\0') {
509 *itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance, consumedProcessName) !=
512 insertFoundModuleLabel(*itKind,
515 consumedProductInstance,
522 modulesInPreviousProcessesEmplace(consumedModuleLabel, consumedProcessName);
526 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
527 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
529 insertFoundModuleLabel(*itKind,
532 consumedProductInstance,
540 modulesInPreviousProcessesEmplace(consumedModuleLabel,
matches.processName(
j));
546 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type);
547 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
549 insertFoundModuleLabel(*itKind,
558 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
567 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
568 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
570 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
583 auto newTokenLabels = makeEmptyTokenLabels();
589 newProcessName = &
m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
593 newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
595 newTokenLabels.reserve(newSize);
597 unsigned int newStartOfModuleLabel = newTokenLabels.size();
599 unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
600 unsigned short deltaToProcessName = iter->m_deltaToProcessName;
602 iter->m_startOfModuleLabel = newStartOfModuleLabel;
604 newProcessName = &
m_tokenLabels[startOfModuleLabel + deltaToProcessName];
609 newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
612 newTokenLabels.insert(newTokenLabels.end(),
614 m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
616 newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
617 newTokenLabels.push_back(
'\0');
628 std::set<edm::TypeID> alreadySeenTypes;
630 std::vector<ConsumesInfo>
result;
635 ++itInfo, ++itKind, ++itLabels, ++itAlways) {
636 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
637 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
638 const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
639 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
642 if (*consumedModuleLabel ==
'\0') {
643 if (!alreadySeenTypes.insert(itInfo->m_type).second) {
649 result.emplace_back(itInfo->m_type,
653 itInfo->m_branchType,
656 itInfo->m_index.skipCurrentProcess());
const TypeTag & type() const
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
ProductResolverIndexAndSkipBit uncheckedIndexFrom(EDGetToken) const
TypeID const & type() const
const char * labelFor(ESTokenIndex) const
constexpr unsigned int index() const noexcept
unsigned int ProductResolverIndex
virtual void doSelectInputProcessBlocks(ProductRegistry const &, ProcessBlockHelperBase const &)
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
void throwESConsumesInProcessBlock() const
std::vector< std::string > aliasToModules(KindOfType kindOfType, TypeID const &type, std::string_view moduleLabel, std::string_view productInstanceName) const
constexpr Value_t value() const noexcept
void throwTypeMismatch(edm::TypeID const &, EDGetToken) const
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
bool containsCurrentProcessAlias_
ProductResolverIndexAndSkipBit indexFrom(EDGetToken, BranchType, TypeID const &) 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
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) 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_
char const * name() const
ESProxyIndex indexInRecord(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
If the index is not found, returns missingProxyIndex()
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
std::string const & BranchTypeToString(BranchType const &branchType)
virtual void registerLateConsumes(eventsetup::ESRecordsToProxyIndices const &)
void throwESConsumesCallAfterFrozen(eventsetup::EventSetupRecordKey const &, eventsetup::heterocontainer::HCTypeTag const &, edm::ESInputTag const &) const
std::vector< ConsumesInfo > consumesInfo() const
std::array< std::vector< ESRecordIndex >, static_cast< unsigned int >edm::Transition::NumberOfEventSetupTransitions)> esRecordsToGetFromTransition_
static constexpr ESProxyIndex missingProxyIndex() noexcept
bool registeredToConsume(ProductResolverIndex, bool, BranchType) const
ComponentDescription const * component(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
std::vector< char > m_tokenLabels
std::string const & className() const
static const edm::InputTag kWasEmpty("@EmptyLabel@")
void throwBadToken(edm::TypeID const &iType, EDGetToken iToken) const
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
edm::SoATuple< ESTokenLookupInfo, ESProxyIndex > m_esTokenInfo
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
bool registeredToConsumeMany(TypeID const &, BranchType) const
void throwConsumesCallAfterFrozen(TypeToGet const &, InputTag const &) const
char const * productInstance
ESTokenIndex recordESConsumes(Transition, eventsetup::EventSetupRecordKey const &, eventsetup::heterocontainer::HCTypeTag const &, edm::ESInputTag const &iTag)
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
virtual ~EDConsumerBase() noexcept(false)
constexpr bool isUninitialized() const noexcept
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name...
void throwBranchMismatch(BranchType, EDGetToken) const
std::array< std::vector< ProductResolverIndexAndSkipBit >, edm::NumBranchTypes > itemsToGetFromBranch_
void labelsForToken(EDGetToken iToken, Labels &oLabels) const