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) {
117 bool iPrefetchMayGet) {
125 ++itInfo, ++itKind, ++itLabels) {
126 if (itInfo->m_branchType == iBranchType) {
127 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
134 itInfo->m_index.skipCurrentProcess());
154 for (
unsigned int j = 0;
j !=
matches.numberOfMatches(); ++
j) {
170 if (iPrefetchMayGet) {
181 unsigned int index = 0;
183 auto indexInRecord = iPI.
indexInRecord(it->m_record, it->m_key);
185 const char* componentName = &(
m_tokenLabels[it->m_startOfComponentName]);
186 if (*componentName) {
187 auto component = iPI.
component(it->m_record, it->m_key);
188 if (component->label_.empty()) {
189 if (component->type_ != componentName) {
192 }
else if (component->label_ != componentName) {
199 int negIndex = -1 * (
index + 1);
201 for (
auto& itemIndex :
items) {
202 if (itemIndex.value() == negIndex) {
203 itemIndex = indexInRecord;
227 unsigned int startOfComponentName = 0;
228 if (not iTag.
module().empty()) {
257 TypeID const& iType)
const {
280 unsigned int count = 0;
284 ++it, ++itAlwaysGet) {
285 if (iBranch == it->m_branchType) {
294 oIndices.reserve(oIndices.size() +
count);
298 ++it, ++itAlwaysGet) {
299 if (iBranch == it->m_branchType) {
302 oIndices.push_back(it->m_index);
312 unsigned int count = 0;
316 ++it, ++itAlwaysGet) {
317 if (iBranch == it->m_branchType) {
319 if (not *itAlwaysGet) {
326 oIndices.reserve(oIndices.size() +
count);
330 ++it, ++itAlwaysGet) {
331 if (iBranch == it->m_branchType) {
333 if (not *itAlwaysGet) {
334 oIndices.push_back(it->m_index);
352 bool skipCurrentProcess,
355 if (it->m_index.productResolverIndex() == iIndex and it->m_index.skipCurrentProcess() == skipCurrentProcess and
356 it->m_branchType == iBranch) {
367 it->m_branchType == iBranch) {
376 <<
"' but the consumes call was for type '" 378 <<
"'.\n Please modify either the consumes or get call so the types match.";
382 <<
"A get using a EDGetToken was done in " <<
BranchTypeToString(iBranch) <<
" but the consumes call was for " 384 <<
".\n Please modify the consumes call to use the correct branch type.";
390 <<
"' was made using an uninitialized token.\n Please check that the variable is " 391 "being initialized from a 'consumes' call.";
394 <<
"A get using a EDGetToken with the C++ type '" << iType.
className() <<
"' was made using a token with a value " 396 <<
" which is beyond the range used by this module.\n Please check that the variable is being initialized from a " 397 "'consumes' call from this module.\n You can not share EDGetToken values between modules.";
401 throw cms::Exception(
"LogicError") <<
"A module declared it consumes a product after its constructor.\n" 402 <<
"This must be done in the contructor\n" 403 <<
"The product type was: " << typeToGet.
type() <<
"\n" 410 throw cms::Exception(
"LogicError") <<
"A module declared it consumes an EventSetup product after its constructor.\n" 411 <<
"This must be done in the contructor\n" 412 <<
"The product type was: " << iDataType.
name() <<
" in record " 414 <<
"and ESInputTag was " << iTag <<
"\n";
419 <<
"A module declared it consumes an EventSetup product during a ProcessBlock transition.\n" 420 <<
"EventSetup products can only be consumed in Event, Lumi, or Run transitions.\n";
426 struct CharStarComp {
427 bool operator()(
const char* iLHS,
const char* iRHS)
const {
return strcmp(iLHS, iRHS) < 0; }
434 const char* consumedModuleLabel,
435 const char* consumedProductInstance,
436 std::vector<ModuleDescription const*>&
modules,
437 std::set<std::string>& alreadyFound,
438 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
442 if (
auto it = labelsToDesc.find(consumedModuleLabel); it != labelsToDesc.end()) {
443 if (alreadyFound.insert(consumedModuleLabel).second) {
449 if (
auto aliasToModuleLabels =
450 preg.
aliasToModules(consumedTypeKind, consumedType, consumedModuleLabel, consumedProductInstance);
451 not aliasToModuleLabels.empty()) {
452 bool foundInLabelsToDesc =
false;
453 for (
auto const&
label : aliasToModuleLabels) {
454 if (
auto it = labelsToDesc.find(
label); it != labelsToDesc.end()) {
455 if (alreadyFound.insert(
label).second) {
458 foundInLabelsToDesc =
true;
460 if (
label ==
"source") {
461 foundInLabelsToDesc =
true;
465 if (foundInLabelsToDesc) {
472 if (std::string_view(consumedModuleLabel) !=
"source") {
474 <<
"Couldn't find ModuleDescription for the consumed product type: '" << consumedType.
className()
475 <<
"' module label: '" << consumedModuleLabel <<
"' product instance name: '" << consumedProductInstance
483 std::vector<ModuleProcessName>& modulesInPreviousProcesses,
485 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
487 std::set<std::string> alreadyFound;
489 auto modulesInPreviousProcessesEmplace = [&modulesInPreviousProcesses](std::string_view
module,
499 ++itInfo, ++itKind, ++itLabels) {
501 std::vector<ModuleDescription const*>&
modules = *modulesAll[itInfo->m_branchType];
503 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
504 const char*
const consumedModuleLabel = &(
m_tokenLabels[labelStart]);
505 const char*
const consumedProductInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
506 const char*
const consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
508 if (not itInfo->m_index.skipCurrentProcess()) {
509 if (*consumedModuleLabel !=
'\0') {
510 if (*consumedProcessName !=
'\0') {
512 *itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance, consumedProcessName) !=
515 insertFoundModuleLabel(*itKind,
518 consumedProductInstance,
525 modulesInPreviousProcessesEmplace(consumedModuleLabel, consumedProcessName);
529 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
530 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
532 insertFoundModuleLabel(*itKind,
535 consumedProductInstance,
543 modulesInPreviousProcessesEmplace(consumedModuleLabel,
matches.processName(
j));
549 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type);
550 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
552 insertFoundModuleLabel(*itKind,
561 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
570 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
571 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
573 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
586 auto newTokenLabels = makeEmptyTokenLabels();
592 newProcessName = &
m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
596 newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
598 newTokenLabels.reserve(newSize);
600 unsigned int newStartOfModuleLabel = newTokenLabels.size();
602 unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
603 unsigned short deltaToProcessName = iter->m_deltaToProcessName;
605 iter->m_startOfModuleLabel = newStartOfModuleLabel;
607 newProcessName = &
m_tokenLabels[startOfModuleLabel + deltaToProcessName];
612 newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
615 newTokenLabels.insert(newTokenLabels.end(),
617 m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
619 newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
620 newTokenLabels.push_back(
'\0');
631 std::set<edm::TypeID> alreadySeenTypes;
633 std::vector<ConsumesInfo>
result;
638 ++itInfo, ++itKind, ++itLabels, ++itAlways) {
639 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
640 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
641 const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
642 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
645 if (*consumedModuleLabel ==
'\0') {
646 if (!alreadySeenTypes.insert(itInfo->m_type).second) {
652 result.emplace_back(itInfo->m_type,
656 itInfo->m_branchType,
659 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 &)
virtual void extendUpdateLookup(BranchType iBranchType, ProductResolverIndexHelper 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