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());
142 if (iPrefetchMayGet) {
153 unsigned int index = 0;
157 const char* componentName = &(
m_tokenLabels[
it->m_startOfComponentName]);
158 if (*componentName) {
160 if (component->label_.empty()) {
161 if (component->type_ != componentName) {
164 }
else if (component->label_ != componentName) {
171 int negIndex = -1 * (
index + 1);
173 for (
auto& itemIndex :
items) {
174 if (itemIndex.value() == negIndex) {
175 itemIndex = indexInRecord;
199 unsigned int startOfComponentName = 0;
200 if (not iTag.
module().empty()) {
229 TypeID const& iType)
const {
252 unsigned int count = 0;
256 ++
it, ++itAlwaysGet) {
257 if (iBranch ==
it->m_branchType) {
266 oIndices.reserve(oIndices.size() +
count);
270 ++
it, ++itAlwaysGet) {
271 if (iBranch ==
it->m_branchType) {
274 oIndices.push_back(
it->m_index);
284 unsigned int count = 0;
288 ++
it, ++itAlwaysGet) {
289 if (iBranch ==
it->m_branchType) {
291 if (not *itAlwaysGet) {
298 oIndices.reserve(oIndices.size() +
count);
302 ++
it, ++itAlwaysGet) {
303 if (iBranch ==
it->m_branchType) {
305 if (not *itAlwaysGet) {
306 oIndices.push_back(
it->m_index);
324 bool skipCurrentProcess,
327 if (
it->m_index.productResolverIndex() == iIndex and
it->m_index.skipCurrentProcess() == skipCurrentProcess and
328 it->m_branchType == iBranch) {
337 <<
"' but the consumes call was for type '" 339 <<
"'.\n Please modify either the consumes or get call so the types match.";
343 <<
"A get using a EDGetToken was done in " <<
BranchTypeToString(iBranch) <<
" but the consumes call was for " 345 <<
".\n Please modify the consumes call to use the correct branch type.";
351 <<
"' was made using an uninitialized token.\n Please check that the variable is " 352 "being initialized from a 'consumes' call.";
355 <<
"A get using a EDGetToken with the C++ type '" << iType.
className() <<
"' was made using a token with a value " 357 <<
" which is beyond the range used by this module.\n Please check that the variable is being initialized from a " 358 "'consumes' call from this module.\n You can not share EDGetToken values between modules.";
362 throw cms::Exception(
"LogicError") <<
"A module declared it consumes a product after its constructor.\n" 363 <<
"This must be done in the contructor\n" 364 <<
"The product type was: " << typeToGet.
type() <<
"\n" 371 throw cms::Exception(
"LogicError") <<
"A module declared it consumes an EventSetup product after its constructor.\n" 372 <<
"This must be done in the contructor\n" 373 <<
"The product type was: " << iDataType.
name() <<
" in record " 375 <<
"and ESInputTag was " << iTag <<
"\n";
380 <<
"A module declared it consumes an EventSetup product during a ProcessBlock transition.\n" 381 <<
"EventSetup products can only be consumed in Event, Lumi, or Run transitions.\n";
387 struct CharStarComp {
388 bool operator()(
const char* iLHS,
const char* iRHS)
const {
return strcmp(iLHS, iRHS) < 0; }
395 const char* consumedModuleLabel,
396 const char* consumedProductInstance,
397 std::vector<ModuleDescription const*>&
modules,
398 std::set<std::string>& alreadyFound,
399 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
403 if (
auto it = labelsToDesc.find(consumedModuleLabel);
it != labelsToDesc.end()) {
404 if (alreadyFound.insert(consumedModuleLabel).second) {
410 if (
auto aliasToModuleLabels =
411 preg.
aliasToModules(consumedTypeKind, consumedType, consumedModuleLabel, consumedProductInstance);
412 not aliasToModuleLabels.empty()) {
413 bool foundInLabelsToDesc =
false;
414 for (
auto const&
label : aliasToModuleLabels) {
415 if (
auto it = labelsToDesc.find(
label);
it != labelsToDesc.end()) {
416 if (alreadyFound.insert(
label).second) {
419 foundInLabelsToDesc =
true;
421 if (
label ==
"source") {
422 foundInLabelsToDesc =
true;
426 if (foundInLabelsToDesc) {
433 if (std::string_view(consumedModuleLabel) !=
"source") {
435 <<
"Couldn't find ModuleDescription for the consumed product type: '" << consumedType.
className()
436 <<
"' module label: '" << consumedModuleLabel <<
"' product instance name: '" << consumedProductInstance
444 std::vector<ModuleProcessName>& modulesInPreviousProcesses,
446 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
448 std::set<std::string> alreadyFound;
450 auto modulesInPreviousProcessesEmplace = [&modulesInPreviousProcesses](std::string_view
module,
460 ++itInfo, ++itKind, ++itLabels) {
462 std::vector<ModuleDescription const*>&
modules = *modulesAll[itInfo->m_branchType];
464 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
465 const char*
const consumedModuleLabel = &(
m_tokenLabels[labelStart]);
466 const char*
const consumedProductInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
467 const char*
const consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
469 if (not itInfo->m_index.skipCurrentProcess()) {
470 assert(*consumedModuleLabel !=
'\0');
471 if (*consumedProcessName !=
'\0') {
472 if (
helper.index(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance, consumedProcessName) !=
475 insertFoundModuleLabel(*itKind,
478 consumedProductInstance,
485 modulesInPreviousProcessesEmplace(consumedModuleLabel, consumedProcessName);
489 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
490 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
492 insertFoundModuleLabel(*itKind,
495 consumedProductInstance,
503 modulesInPreviousProcessesEmplace(consumedModuleLabel,
matches.processName(
j));
511 auto matches =
helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
512 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
514 modulesInPreviousProcessesEmplace(
matches.moduleLabel(
j),
matches.processName(
j));
527 auto newTokenLabels = makeEmptyTokenLabels();
533 newProcessName = &
m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
537 newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
539 newTokenLabels.reserve(newSize);
541 unsigned int newStartOfModuleLabel = newTokenLabels.size();
543 unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
544 unsigned short deltaToProcessName = iter->m_deltaToProcessName;
546 iter->m_startOfModuleLabel = newStartOfModuleLabel;
548 newProcessName = &
m_tokenLabels[startOfModuleLabel + deltaToProcessName];
553 newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
556 newTokenLabels.insert(newTokenLabels.end(),
558 m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
560 newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
561 newTokenLabels.push_back(
'\0');
568 std::vector<ConsumesInfo>
result;
573 ++itInfo, ++itKind, ++itLabels, ++itAlways) {
574 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
575 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
576 const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
577 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
579 assert(*consumedModuleLabel !=
'\0');
582 result.emplace_back(itInfo->m_type,
586 itInfo->m_branchType,
589 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
static constexpr ESResolverIndex missingResolverIndex() noexcept
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
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
char const * name() const
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)
ESResolverIndex indexInRecord(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
If the index is not found, returns missingResolverIndex()
void throwESConsumesCallAfterFrozen(eventsetup::EventSetupRecordKey const &, eventsetup::heterocontainer::HCTypeTag const &, edm::ESInputTag const &) const
std::vector< ConsumesInfo > consumesInfo() const
std::array< std::vector< ESResolverIndex >, static_cast< unsigned int >edm::Transition::NumberOfEventSetupTransitions)> esItemsToGetFromTransition_
std::array< std::vector< ESRecordIndex >, static_cast< unsigned int >edm::Transition::NumberOfEventSetupTransitions)> esRecordsToGetFromTransition_
bool registeredToConsume(ProductResolverIndex, bool, BranchType) const
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
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) 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)
virtual void registerLateConsumes(eventsetup::ESRecordsToProductResolverIndices const &)
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
virtual ~EDConsumerBase() noexcept(false)
ComponentDescription const * component(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
constexpr bool isUninitialized() const noexcept
edm::SoATuple< ESTokenLookupInfo, ESResolverIndex > m_esTokenInfo
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name...
void throwBranchMismatch(BranchType, EDGetToken) const
ESRecordIndex recordIndexFor(EventSetupRecordKey const &iRK) const noexcept
std::array< std::vector< ProductResolverIndexAndSkipBit >, edm::NumBranchTypes > itemsToGetFromBranch_
void labelsForToken(EDGetToken iToken, Labels &oLabels) const