79 if (iTag.
label().empty()) {
97 const size_t labelSize = iTag.
label().size();
98 const size_t productInstanceSize = iTag.
instance().size();
100 unsigned short delta1 = labelSize + 1;
101 unsigned short delta2 = labelSize + 2 + productInstanceSize;
107 const size_t additionalSize = skipCurrentProcess ? labelSize + productInstanceSize + 3
108 : labelSize + productInstanceSize + iTag.
process().size() + 3;
126 if (!skipCurrentProcess) {
138 bool iPrefetchMayGet) {
145 ++itInfo, ++itKind, ++itLabels) {
146 if (itInfo->m_branchType == iBranchType) {
147 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
152 moduleLabel + itLabels->m_deltaToProductInstance,
153 moduleLabel + itLabels->m_deltaToProcessName),
154 itInfo->m_index.skipCurrentProcess());
174 for (
unsigned int j = 0;
j != matches.numberOfMatches(); ++
j) {
176 if (matches.isFullyResolved(
j)) {
177 auto index = matches.index(
j);
190 if (iPrefetchMayGet) {
196 unsigned int index = 0;
198 auto indexInRecord = iPI.
indexInRecord(it->m_record, it->m_key);
200 const char* componentName = &(
m_tokenLabels[it->m_startOfComponentName]);
201 if (*componentName) {
202 auto component = iPI.
component(it->m_record, it->m_key);
203 if (component->label_.empty()) {
204 if (component->type_ != componentName) {
207 }
else if (component->label_ != componentName) {
214 int negIndex = -1 * (index + 1);
216 for (
auto& itemIndex :
items) {
217 if (itemIndex.value() == negIndex) {
218 itemIndex = indexInRecord;
236 unsigned int startOfComponentName = 0;
237 if (not iTag.
module().empty()) {
262 TypeID const& iType)
const {
285 unsigned int count = 0;
289 ++it, ++itAlwaysGet) {
290 if (iBranch == it->m_branchType) {
299 oIndices.reserve(oIndices.size() +
count);
303 ++it, ++itAlwaysGet) {
304 if (iBranch == it->m_branchType) {
307 oIndices.push_back(it->m_index);
317 unsigned int count = 0;
321 ++it, ++itAlwaysGet) {
322 if (iBranch == it->m_branchType) {
324 if (not*itAlwaysGet) {
331 oIndices.reserve(oIndices.size() +
count);
335 ++it, ++itAlwaysGet) {
336 if (iBranch == it->m_branchType) {
338 if (not*itAlwaysGet) {
339 oIndices.push_back(it->m_index);
357 bool skipCurrentProcess,
360 if (it->m_index.productResolverIndex() == iIndex and it->m_index.skipCurrentProcess() == skipCurrentProcess and
361 it->m_branchType == iBranch) {
372 it->m_branchType == iBranch) {
381 <<
"' but the consumes call was for type '" 383 <<
"'.\n Please modify either the consumes or get call so the types match.";
387 <<
"A get using a EDGetToken was done in " <<
BranchTypeToString(iBranch) <<
" but the consumes call was for " 389 <<
".\n Please modify the consumes call to use the correct branch type.";
395 <<
"' was made using an uninitialized token.\n Please check that the variable is " 396 "being initialized from a 'consumes' call.";
399 <<
"A get using a EDGetToken with the C++ type '" << iType.
className() <<
"' was made using a token with a value " 401 <<
" which is beyond the range used by this module.\n Please check that the variable is being initialized from a " 402 "'consumes' call from this module.\n You can not share EDGetToken values between modules.";
406 throw cms::Exception(
"LogicError") <<
"A module declared it consumes a product after its constructor.\n" 407 <<
"This must be done in the contructor\n" 408 <<
"The product type was: " << typeToGet.
type() <<
"\n" 409 <<
"and " << inputTag <<
"\n";
413 struct CharStarComp {
414 bool operator()(
const char* iLHS,
const char* iRHS)
const {
return strcmp(iLHS, iRHS) < 0; }
419 void insertFoundModuleLabel(
const char* consumedModuleLabel,
420 std::vector<ModuleDescription const*>&
modules,
421 std::set<std::string>& alreadyFound,
422 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
426 auto it = labelsToDesc.find(consumedModuleLabel);
427 if (it != labelsToDesc.end()) {
428 if (alreadyFound.insert(consumedModuleLabel).second) {
429 modules.push_back(it->second);
434 std::vector<std::pair<std::string, std::string> >
const& aliasToOriginal = preg.
aliasToOriginal();
436 auto iter = std::lower_bound(aliasToOriginal.begin(), aliasToOriginal.end(),
target);
437 if (iter != aliasToOriginal.end() && iter->first == consumedModuleLabel) {
438 std::string const& originalModuleLabel = iter->second;
439 auto iter2 = labelsToDesc.find(originalModuleLabel);
440 if (iter2 != labelsToDesc.end()) {
441 if (alreadyFound.insert(originalModuleLabel).second) {
442 modules.push_back(iter2->second);
450 if (
std::string(consumedModuleLabel) !=
"source") {
452 <<
"Couldn't find ModuleDescription for the consumed module label: " <<
std::string(consumedModuleLabel)
460 std::map<std::string, ModuleDescription const*>
const& labelsToDesc,
464 std::set<std::string> alreadyFound;
469 ++itInfo, ++itKind, ++itLabels) {
470 if (itInfo->m_branchType ==
InEvent and (not itInfo->m_index.skipCurrentProcess())) {
471 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
472 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
473 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
475 if (*consumedModuleLabel !=
'\0') {
476 if (*consumedProcessName !=
'\0') {
477 if (processName == consumedProcessName &&
478 iHelper.
index(*itKind,
481 consumedModuleLabel + itLabels->m_deltaToProductInstance,
483 insertFoundModuleLabel(consumedModuleLabel, modules, alreadyFound, labelsToDesc, preg);
487 *itKind, itInfo->m_type, consumedModuleLabel, consumedModuleLabel + itLabels->m_deltaToProductInstance);
488 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
489 if (processName ==
matches.processName(
j)) {
490 insertFoundModuleLabel(consumedModuleLabel, modules, alreadyFound, labelsToDesc, preg);
497 for (
unsigned int j = 0;
j <
matches.numberOfMatches(); ++
j) {
498 if (processName ==
matches.processName(
j)) {
499 insertFoundModuleLabel(
matches.moduleLabel(
j),
modules, alreadyFound, labelsToDesc, preg);
513 std::vector<char> newTokenLabels;
519 newProcessName = &
m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
523 newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
525 newTokenLabels.reserve(newSize);
527 unsigned int newStartOfModuleLabel = 0;
529 unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
530 unsigned short deltaToProcessName = iter->m_deltaToProcessName;
532 iter->m_startOfModuleLabel = newStartOfModuleLabel;
534 newProcessName = &
m_tokenLabels[startOfModuleLabel + deltaToProcessName];
539 newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
542 newTokenLabels.insert(newTokenLabels.end(),
544 m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
546 newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
547 newTokenLabels.push_back(
'\0');
558 std::set<edm::TypeID> alreadySeenTypes;
560 std::vector<ConsumesInfo>
result;
565 ++itInfo, ++itKind, ++itLabels, ++itAlways) {
566 const unsigned int labelStart = itLabels->m_startOfModuleLabel;
567 const char* consumedModuleLabel = &(
m_tokenLabels[labelStart]);
568 const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
569 const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
572 if (*consumedModuleLabel ==
'\0') {
573 if (!alreadySeenTypes.insert(itInfo->m_type).second) {
579 result.emplace_back(itInfo->m_type,
583 itInfo->m_branchType,
586 itInfo->m_index.skipCurrentProcess());
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
constexpr Value_t value() const noexcept
std::array< std::vector< ESProxyIndex >, static_cast< unsigned int >edm::Transition::NumberOfTransitions)> esItemsToGetFromTransition_
std::vector< ConsumesInfo > consumesInfo() const
unsigned int ProductResolverIndex
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
void throwTypeMismatch(edm::TypeID const &, EDGetToken) const
void throwBadToken(edm::TypeID const &iType, EDGetToken iToken) const
bool containsCurrentProcessAlias_
void throwConsumesCallAfterFrozen(TypeToGet const &, InputTag const &) const
void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, 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)
ProductResolverIndexAndSkipBit uncheckedIndexFrom(EDGetToken) const
const char * labelFor(ESTokenIndex) const
ProductResolverIndexAndSkipBit indexFrom(EDGetToken, BranchType, TypeID const &) const
bool registeredToConsume(ProductResolverIndex, bool, BranchType) 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
bool isUninitialized() const
static constexpr ESProxyIndex missingProxyIndex() noexcept
std::vector< char > m_tokenLabels
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
static const edm::InputTag kWasEmpty("@EmptyLabel@")
std::vector< std::pair< std::string, std::string > > const & aliasToOriginal() const
bool registeredToConsumeMany(TypeID const &, BranchType) const
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
ESProxyIndex indexInRecord(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
If the index is not found, returns missingProxyIndex()
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
TypeID const & type() const
std::string const & className() const
ESTokenIndex recordESConsumes(Transition, eventsetup::EventSetupRecordKey const &, eventsetup::heterocontainer::HCTypeTag const &, edm::ESInputTag const &iTag)
ComponentDescription const * component(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
virtual ~EDConsumerBase() noexcept(false)
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name...
unsigned int index() const
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_