CMS 3D CMS Logo

EDConsumerBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: FWCore/Framework
4 // Class : EDConsumerBase
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: Tue, 02 Apr 2013 21:36:06 GMT
11 //
12 
13 // system include files
14 #include <algorithm>
15 #include <cassert>
16 #include <cstring>
17 #include <set>
18 #include <utility>
19 
20 // user include files
32 
33 using namespace edm;
34 
35 namespace {
36  std::vector<char> makeEmptyTokenLabels() { return std::vector<char>{'\0'}; }
37 } // namespace
38 
40  : m_tokenLabels{makeEmptyTokenLabels()}, frozen_(false), containsCurrentProcessAlias_(false) {}
41 
43 
44 //
45 // member functions
46 //
48  ConsumesCollector c{this};
49  return c;
50 }
51 
52 static const edm::InputTag kWasEmpty("@EmptyLabel@");
53 
55  if (iTag.label().empty()) {
56  return kWasEmpty;
57  }
58  return iTag;
59 }
60 
62  TypeToGet const& iType,
63  edm::InputTag const& iTag,
64  bool iAlwaysGets) {
65  if (frozen_) {
66  throwConsumesCallAfterFrozen(iType, iTag);
67  }
68 
69  unsigned int index = m_tokenInfo.size();
70 
71  bool skipCurrentProcess = iTag.willSkipCurrentProcess();
72 
73  const size_t labelSize = iTag.label().size();
74  const size_t productInstanceSize = iTag.instance().size();
75  unsigned int labelStart = m_tokenLabels.size();
76  unsigned short delta1 = labelSize + 1;
77  unsigned short delta2 = labelSize + 2 + productInstanceSize;
78  m_tokenInfo.emplace_back(TokenLookupInfo{iType.type(), ProductResolverIndexInvalid, skipCurrentProcess, iBranch},
79  iAlwaysGets,
80  LabelPlacement{labelStart, delta1, delta2},
81  iType.kind());
82 
83  const size_t additionalSize = skipCurrentProcess ? labelSize + productInstanceSize + 3
84  : labelSize + productInstanceSize + iTag.process().size() + 3;
85 
86  m_tokenLabels.reserve(m_tokenLabels.size() + additionalSize);
87  {
88  const std::string& m = iTag.label();
89  m_tokenLabels.insert(m_tokenLabels.end(), m.begin(), m.end());
90  m_tokenLabels.push_back('\0');
91  }
92  {
93  const std::string& m = iTag.instance();
94  m_tokenLabels.insert(m_tokenLabels.end(), m.begin(), m.end());
95  m_tokenLabels.push_back('\0');
96  }
97  {
98  const std::string& m = iTag.process();
101  }
102  if (!skipCurrentProcess) {
103  m_tokenLabels.insert(m_tokenLabels.end(), m.begin(), m.end());
104  m_tokenLabels.push_back('\0');
105  } else {
106  m_tokenLabels.push_back('\0');
107  }
108  }
109  return index;
110 }
111 
113  ProductResolverIndexHelper const& iHelper,
114  bool iPrefetchMayGet) {
115  frozen_ = true;
117  {
118  auto itKind = m_tokenInfo.begin<kKind>();
119  auto itLabels = m_tokenInfo.begin<kLabels>();
120  for (auto itInfo = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); itInfo != itEnd;
121  ++itInfo, ++itKind, ++itLabels) {
122  if (itInfo->m_branchType == iBranchType) {
123  const unsigned int labelStart = itLabels->m_startOfModuleLabel;
124  const char* moduleLabel = &(m_tokenLabels[labelStart]);
125  itInfo->m_index = ProductResolverIndexAndSkipBit(iHelper.index(*itKind,
126  itInfo->m_type,
127  moduleLabel,
128  moduleLabel + itLabels->m_deltaToProductInstance,
129  moduleLabel + itLabels->m_deltaToProcessName),
130  itInfo->m_index.skipCurrentProcess());
131  }
132  }
133  }
134 
135  //now add resolved requests to get many to the end of our list
136  // a get many will have an empty module label
137  for (size_t i = 0, iEnd = m_tokenInfo.size(); i != iEnd; ++i) {
138  //need to copy since pointer could be invalidated by emplace_back
139  auto const info = m_tokenInfo.get<kLookupInfo>(i);
140  if (info.m_branchType == iBranchType && info.m_index.productResolverIndex() == ProductResolverIndexInvalid &&
141  m_tokenLabels[m_tokenInfo.get<kLabels>(i).m_startOfModuleLabel] == '\0') {
142  //find all matching types
143  const auto kind = m_tokenInfo.get<kKind>(i);
144  auto matches = iHelper.relatedIndexes(kind, info.m_type);
145 
146  //NOTE: This could be changed to contain the true labels for what is being
147  // requested but for now I want to remember these are part of a get many
148  const LabelPlacement labels = m_tokenInfo.get<kLabels>(i);
149  bool alwaysGet = m_tokenInfo.get<kAlwaysGets>(i);
150  for (unsigned int j = 0; j != matches.numberOfMatches(); ++j) {
151  //only keep the ones that are for a specific data item and not a collection
152  if (matches.isFullyResolved(j)) {
153  auto index = matches.index(j);
154  m_tokenInfo.emplace_back(
155  TokenLookupInfo{info.m_type, index, info.m_index.skipCurrentProcess(), info.m_branchType},
156  alwaysGet,
157  labels,
158  kind);
159  }
160  }
161  }
162  }
163  m_tokenInfo.shrink_to_fit();
164 
165  itemsToGet(iBranchType, itemsToGetFromBranch_[iBranchType]);
166  if (iPrefetchMayGet) {
167  itemsMayGet(iBranchType, itemsToGetFromBranch_[iBranchType]);
168  }
169 }
170 
172  // temporarily unfreeze to allow late EventSetup consumes registration
173  frozen_ = false;
175  frozen_ = true;
176 
177  unsigned int index = 0;
178  for (auto it = m_esTokenInfo.begin<kESLookupInfo>(); it != m_esTokenInfo.end<kESLookupInfo>(); ++it, ++index) {
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) {
187  }
188  } else if (component->label_ != componentName) {
190  }
191  }
192  }
193  m_esTokenInfo.get<kESProxyIndex>(index) = indexInRecord;
194 
195  int negIndex = -1 * (index + 1);
196  for (auto& items : esItemsToGetFromTransition_) {
197  for (auto& itemIndex : items) {
198  if (itemIndex.value() == negIndex) {
199  itemIndex = indexInRecord;
200  esRecordsToGetFromTransition_[&items - &esItemsToGetFromTransition_.front()][&itemIndex - &items.front()] =
201  iPI.recordIndexFor(it->m_record);
202  negIndex = 1;
203  break;
204  }
205  }
206  if (negIndex > 0) {
207  break;
208  }
209  }
210  }
211 }
212 
214  eventsetup::EventSetupRecordKey const& iRecord,
216  edm::ESInputTag const& iTag) {
217  if (frozen_) {
218  throwESConsumesCallAfterFrozen(iRecord, iDataType, iTag);
219  }
220 
221  //m_tokenLabels first entry is a null. Since most ES data requests have
222  // empty labels we will assume we can reuse the first entry
223  unsigned int startOfComponentName = 0;
224  if (not iTag.module().empty()) {
225  startOfComponentName = m_tokenLabels.size();
226 
227  m_tokenLabels.reserve(m_tokenLabels.size() + iTag.module().size() + 1);
228  {
229  const std::string& m = iTag.module();
230  m_tokenLabels.insert(m_tokenLabels.end(), m.begin(), m.end());
231  m_tokenLabels.push_back('\0');
232  }
233  }
234 
235  auto index = static_cast<ESProxyIndex::Value_t>(m_esTokenInfo.size());
236  m_esTokenInfo.emplace_back(
237  ESTokenLookupInfo{iRecord, eventsetup::DataKey{iDataType, iTag.data().c_str()}, startOfComponentName},
238  ESProxyIndex{-1});
241  }
242  auto indexForToken = esItemsToGetFromTransition_[static_cast<unsigned int>(iTrans)].size();
243  esItemsToGetFromTransition_[static_cast<unsigned int>(iTrans)].emplace_back(-1 * (index + 1));
244  esRecordsToGetFromTransition_[static_cast<unsigned int>(iTrans)].emplace_back();
245  return ESTokenIndex{static_cast<ESTokenIndex::Value_t>(indexForToken)};
246 }
247 
248 //
249 // const member functions
250 //
252  BranchType iBranch,
253  TypeID const& iType) const {
254  if (UNLIKELY(iToken.index() >= m_tokenInfo.size())) {
255  throwBadToken(iType, iToken);
256  }
257  const auto& info = m_tokenInfo.get<kLookupInfo>(iToken.index());
258  if (LIKELY(iBranch == info.m_branchType)) {
259  if (LIKELY(iType == info.m_type)) {
260  return info.m_index;
261  } else {
262  throwTypeMismatch(iType, iToken);
263  }
264  } else {
265  throwBranchMismatch(iBranch, iToken);
266  }
268 }
269 
271  return m_tokenInfo.get<kLookupInfo>(iToken.index()).m_index;
272 }
273 
274 void EDConsumerBase::itemsToGet(BranchType iBranch, std::vector<ProductResolverIndexAndSkipBit>& oIndices) const {
275  //how many are we adding?
276  unsigned int count = 0;
277  {
278  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
279  for (auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd;
280  ++it, ++itAlwaysGet) {
281  if (iBranch == it->m_branchType) {
282  if (it->m_index.productResolverIndex() != ProductResolverIndexInvalid) {
283  if (*itAlwaysGet) {
284  ++count;
285  }
286  }
287  }
288  }
289  }
290  oIndices.reserve(oIndices.size() + count);
291  {
292  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
293  for (auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd;
294  ++it, ++itAlwaysGet) {
295  if (iBranch == it->m_branchType) {
296  if (it->m_index.productResolverIndex() != ProductResolverIndexInvalid) {
297  if (*itAlwaysGet) {
298  oIndices.push_back(it->m_index);
299  }
300  }
301  }
302  }
303  }
304 }
305 
306 void EDConsumerBase::itemsMayGet(BranchType iBranch, std::vector<ProductResolverIndexAndSkipBit>& oIndices) const {
307  //how many are we adding?
308  unsigned int count = 0;
309  {
310  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
311  for (auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd;
312  ++it, ++itAlwaysGet) {
313  if (iBranch == it->m_branchType) {
314  if (it->m_index.productResolverIndex() != ProductResolverIndexInvalid) {
315  if (not *itAlwaysGet) {
316  ++count;
317  }
318  }
319  }
320  }
321  }
322  oIndices.reserve(oIndices.size() + count);
323  {
324  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
325  for (auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd;
326  ++it, ++itAlwaysGet) {
327  if (iBranch == it->m_branchType) {
328  if (it->m_index.productResolverIndex() != ProductResolverIndexInvalid) {
329  if (not *itAlwaysGet) {
330  oIndices.push_back(it->m_index);
331  }
332  }
333  }
334  }
335  }
336 }
337 
338 void EDConsumerBase::labelsForToken(EDGetToken iToken, Labels& oLabels) const {
339  unsigned int index = iToken.index();
340  auto labels = m_tokenInfo.get<kLabels>(index);
341  unsigned int start = labels.m_startOfModuleLabel;
342  oLabels.module = &(m_tokenLabels[start]);
343  oLabels.productInstance = oLabels.module + labels.m_deltaToProductInstance;
344  oLabels.process = oLabels.module + labels.m_deltaToProcessName;
345 }
346 
348  bool skipCurrentProcess,
349  BranchType iBranch) const {
350  for (auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd; ++it) {
351  if (it->m_index.productResolverIndex() == iIndex and it->m_index.skipCurrentProcess() == skipCurrentProcess and
352  it->m_branchType == iBranch) {
353  return true;
354  }
355  }
356  return false;
357 }
358 
359 bool EDConsumerBase::registeredToConsumeMany(TypeID const& iType, BranchType iBranch) const {
360  for (auto it = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); it != itEnd; ++it) {
361  //consumesMany entries do not have their index resolved
362  if (it->m_index.productResolverIndex() == ProductResolverIndexInvalid and it->m_type == iType and
363  it->m_branchType == iBranch) {
364  return true;
365  }
366  }
367  return false;
368 }
369 
370 void EDConsumerBase::throwTypeMismatch(edm::TypeID const& iType, EDGetToken iToken) const {
371  throw cms::Exception("TypeMismatch") << "A get using a EDGetToken used the C++ type '" << iType.className()
372  << "' but the consumes call was for type '"
373  << m_tokenInfo.get<kLookupInfo>(iToken.index()).m_type.className()
374  << "'.\n Please modify either the consumes or get call so the types match.";
375 }
377  throw cms::Exception("BranchTypeMismatch")
378  << "A get using a EDGetToken was done in " << BranchTypeToString(iBranch) << " but the consumes call was for "
379  << BranchTypeToString(m_tokenInfo.get<kLookupInfo>(iToken.index()).m_branchType)
380  << ".\n Please modify the consumes call to use the correct branch type.";
381 }
382 
383 void EDConsumerBase::throwBadToken(edm::TypeID const& iType, EDGetToken iToken) const {
384  if (iToken.isUninitialized()) {
385  throw cms::Exception("BadToken") << "A get using a EDGetToken with the C++ type '" << iType.className()
386  << "' was made using an uninitialized token.\n Please check that the variable is "
387  "being initialized from a 'consumes' call.";
388  }
389  throw cms::Exception("BadToken")
390  << "A get using a EDGetToken with the C++ type '" << iType.className() << "' was made using a token with a value "
391  << iToken.index()
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.";
394 }
395 
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";
401 }
402 
405  edm::ESInputTag const& iTag) const {
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 "
409  << iRecord.type().name() << "\n"
410  << "and ESInputTag was " << iTag << "\n";
411 }
412 
414  throw cms::Exception("LogicError")
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";
417 }
418 
419 namespace {
420  struct CharStarComp {
421  bool operator()(const char* iLHS, const char* iRHS) const { return strcmp(iLHS, iRHS) < 0; }
422  };
423 } // namespace
424 
425 namespace {
426  void insertFoundModuleLabel(edm::KindOfType consumedTypeKind,
427  edm::TypeID consumedType,
428  const char* consumedModuleLabel,
429  const char* consumedProductInstance,
430  std::vector<ModuleDescription const*>& modules,
431  std::set<std::string>& alreadyFound,
432  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
433  ProductRegistry const& preg) {
434  // Convert from label string to module description, eliminate duplicates,
435  // then insert into the vector of modules
436  if (auto it = labelsToDesc.find(consumedModuleLabel); it != labelsToDesc.end()) {
437  if (alreadyFound.insert(consumedModuleLabel).second) {
438  modules.push_back(it->second);
439  }
440  return;
441  }
442  // Deal with EDAlias's by converting to the original module label first
443  if (auto aliasToModuleLabels =
444  preg.aliasToModules(consumedTypeKind, consumedType, consumedModuleLabel, consumedProductInstance);
445  not aliasToModuleLabels.empty()) {
446  bool foundInLabelsToDesc = false;
447  for (auto const& label : aliasToModuleLabels) {
448  if (auto it = labelsToDesc.find(label); it != labelsToDesc.end()) {
449  if (alreadyFound.insert(label).second) {
450  modules.push_back(it->second);
451  }
452  foundInLabelsToDesc = true;
453  }
454  }
455  if (foundInLabelsToDesc) {
456  return;
457  }
458  }
459  // Ignore the source products, we are only interested in module products.
460  // As far as I know, it should never be anything else so throw if something
461  // unknown gets passed in.
462  if (std::string_view(consumedModuleLabel) != "source") {
463  throw cms::Exception("EDConsumerBase", "insertFoundModuleLabel")
464  << "Couldn't find ModuleDescription for the consumed product type: '" << consumedType.className()
465  << "' module label: '" << consumedModuleLabel << "' product instance name: '" << consumedProductInstance
466  << "'";
467  }
468  }
469 } // namespace
470 
472  std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modulesAll,
473  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
474  ProductRegistry const& preg,
475  std::map<std::string, ModuleDescription const*> const& labelsToDesc,
476  std::string const& processName) const {
477  std::set<std::string> alreadyFound;
478 
479  auto modulesInPreviousProcessesEmplace = [&modulesInPreviousProcesses](std::string_view module,
480  std::string_view process) {
481  auto it = std::lower_bound(
482  modulesInPreviousProcesses.begin(), modulesInPreviousProcesses.end(), ModuleProcessName(module, process));
483  modulesInPreviousProcesses.emplace(it, module, process);
484  };
485 
486  auto itKind = m_tokenInfo.begin<kKind>();
487  auto itLabels = m_tokenInfo.begin<kLabels>();
488  for (auto itInfo = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); itInfo != itEnd;
489  ++itInfo, ++itKind, ++itLabels) {
490  ProductResolverIndexHelper const& helper = *preg.productLookup(itInfo->m_branchType);
491  std::vector<ModuleDescription const*>& modules = *modulesAll[itInfo->m_branchType];
492 
493  const unsigned int labelStart = itLabels->m_startOfModuleLabel;
494  const char* const consumedModuleLabel = &(m_tokenLabels[labelStart]);
495  const char* const consumedProductInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
496  const char* const consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
497 
498  if (not itInfo->m_index.skipCurrentProcess()) {
499  if (*consumedModuleLabel != '\0') { // not a consumesMany
500  if (*consumedProcessName != '\0') { // process name is specified in consumes call
501  if (helper.index(
502  *itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance, consumedProcessName) !=
504  if (processName == consumedProcessName) {
505  insertFoundModuleLabel(*itKind,
506  itInfo->m_type,
507  consumedModuleLabel,
508  consumedProductInstance,
509  modules,
510  alreadyFound,
511  labelsToDesc,
512  preg);
513  } else {
514  // Product explicitly from different process than the current process, so must refer to an earlier process (unless it ends up "not found")
515  modulesInPreviousProcessesEmplace(consumedModuleLabel, consumedProcessName);
516  }
517  }
518  } else { // process name was empty
519  auto matches = helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
520  for (unsigned int j = 0; j < matches.numberOfMatches(); ++j) {
521  if (processName == matches.processName(j)) {
522  insertFoundModuleLabel(*itKind,
523  itInfo->m_type,
524  consumedModuleLabel,
525  consumedProductInstance,
526  modules,
527  alreadyFound,
528  labelsToDesc,
529  preg);
530  } else {
531  // Product did not match to current process, so must refer to an earlier process (unless it ends up "not found")
532  // Recall that empty process name means "in the latest process" that can change event-by-event
533  modulesInPreviousProcessesEmplace(consumedModuleLabel, matches.processName(j));
534  }
535  }
536  }
537  // consumesMany case
538  } else if (itInfo->m_index.productResolverIndex() == ProductResolverIndexInvalid) {
539  auto matches = helper.relatedIndexes(*itKind, itInfo->m_type);
540  for (unsigned int j = 0; j < matches.numberOfMatches(); ++j) {
541  if (processName == matches.processName(j)) {
542  insertFoundModuleLabel(*itKind,
543  itInfo->m_type,
544  matches.moduleLabel(j),
545  matches.productInstanceName(j),
546  modules,
547  alreadyFound,
548  labelsToDesc,
549  preg);
550  } else {
551  modulesInPreviousProcessesEmplace(matches.moduleLabel(j), matches.processName(j));
552  }
553  }
554  }
555  } else {
556  // The skipCurrentProcess means the same as empty process name,
557  // except the current process is skipped. Therefore need to do
558  // the same matching as above. There is no consumesMany branch
559  // in this case.
560  auto matches = helper.relatedIndexes(*itKind, itInfo->m_type, consumedModuleLabel, consumedProductInstance);
561  for (unsigned int j = 0; j < matches.numberOfMatches(); ++j) {
562  if (processName != matches.processName(j)) {
563  modulesInPreviousProcessesEmplace(matches.moduleLabel(j), matches.processName(j));
564  }
565  }
566  }
567  }
568 }
569 
571  frozen_ = true;
572 
575 
576  auto newTokenLabels = makeEmptyTokenLabels();
577 
578  // first calculate the size of the new vector and reserve memory for it
579  std::vector<char>::size_type newSize = newTokenLabels.size();
580  std::string newProcessName;
581  for (auto iter = m_tokenInfo.begin<kLabels>(), itEnd = m_tokenInfo.end<kLabels>(); iter != itEnd; ++iter) {
582  newProcessName = &m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
583  if (newProcessName == InputTag::kCurrentProcess) {
584  newProcessName = processName;
585  }
586  newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
587  }
588  newTokenLabels.reserve(newSize);
589 
590  unsigned int newStartOfModuleLabel = newTokenLabels.size();
591  for (auto iter = m_tokenInfo.begin<kLabels>(), itEnd = m_tokenInfo.end<kLabels>(); iter != itEnd; ++iter) {
592  unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
593  unsigned short deltaToProcessName = iter->m_deltaToProcessName;
594 
595  iter->m_startOfModuleLabel = newStartOfModuleLabel;
596 
597  newProcessName = &m_tokenLabels[startOfModuleLabel + deltaToProcessName];
598  if (newProcessName == InputTag::kCurrentProcess) {
599  newProcessName = processName;
600  }
601 
602  newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
603 
604  // Copy in both the module label and instance, they are the same
605  newTokenLabels.insert(newTokenLabels.end(),
606  m_tokenLabels.begin() + startOfModuleLabel,
607  m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
608 
609  newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
610  newTokenLabels.push_back('\0');
611  }
612  m_tokenLabels = std::move(newTokenLabels);
613  }
614 }
615 
616 std::vector<ConsumesInfo> EDConsumerBase::consumesInfo() const {
617  // Use this to eliminate duplicate entries related
618  // to consumesMany items where only the type was specified
619  // and the there are multiple matches. In these cases the
620  // label, instance, and process will be empty.
621  std::set<edm::TypeID> alreadySeenTypes;
622 
623  std::vector<ConsumesInfo> result;
624  auto itAlways = m_tokenInfo.begin<kAlwaysGets>();
625  auto itKind = m_tokenInfo.begin<kKind>();
626  auto itLabels = m_tokenInfo.begin<kLabels>();
627  for (auto itInfo = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); itInfo != itEnd;
628  ++itInfo, ++itKind, ++itLabels, ++itAlways) {
629  const unsigned int labelStart = itLabels->m_startOfModuleLabel;
630  const char* consumedModuleLabel = &(m_tokenLabels[labelStart]);
631  const char* consumedInstance = consumedModuleLabel + itLabels->m_deltaToProductInstance;
632  const char* consumedProcessName = consumedModuleLabel + itLabels->m_deltaToProcessName;
633 
634  // consumesMany case
635  if (*consumedModuleLabel == '\0') {
636  if (!alreadySeenTypes.insert(itInfo->m_type).second) {
637  continue;
638  }
639  }
640 
641  // Just copy the information into the ConsumesInfo data structure
642  result.emplace_back(itInfo->m_type,
643  consumedModuleLabel,
644  consumedInstance,
645  consumedProcessName,
646  itInfo->m_branchType,
647  *itKind,
648  *itAlways,
649  itInfo->m_index.skipCurrentProcess());
650  }
651  return result;
652 }
653 
654 const char* EDConsumerBase::labelFor(ESTokenIndex iIndex) const {
655  return m_esTokenInfo.get<kESLookupInfo>(iIndex.value()).m_key.name().value();
656 }
edm::EDConsumerBase::throwESConsumesCallAfterFrozen
void throwESConsumesCallAfterFrozen(eventsetup::EventSetupRecordKey const &, eventsetup::heterocontainer::HCTypeTag const &, edm::ESInputTag const &) const
Definition: EDConsumerBase.cc:403
Likely.h
edm::EDGetToken::index
constexpr unsigned int index() const noexcept
Definition: EDGetToken.h:50
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::InputTag::kCurrentProcess
static const std::string kCurrentProcess
Definition: InputTag.h:54
edm::ESTokenIndex
Definition: ESIndices.h:55
ProductResolverIndexHelper.h
edm::ProductResolverIndex
unsigned int ProductResolverIndex
Definition: ProductResolverIndex.h:8
mps_fire.i
i
Definition: mps_fire.py:428
edm::ESInputTag
Definition: ESInputTag.h:87
start
Definition: start.py:1
LogMessageMonitor_cff.modules
modules
Definition: LogMessageMonitor_cff.py:7
MessageLogger.h
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
funct::false
false
Definition: Factorize.h:29
edm::EDConsumerBase::esRecordsToGetFromTransition_
std::array< std::vector< ESRecordIndex >, static_cast< unsigned int >edm::Transition::NumberOfEventSetupTransitions)> esRecordsToGetFromTransition_
Definition: EDConsumerBase.h:308
edm::EDConsumerBase::registeredToConsumeMany
bool registeredToConsumeMany(TypeID const &, BranchType) const
Definition: EDConsumerBase.cc:359
BranchType.h
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
edm::EDConsumerBase::kLabels
Definition: EDConsumerBase.h:279
edm::EDConsumerBase::recordConsumes
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
Definition: EDConsumerBase.cc:61
edm::EDConsumerBase::ESTokenLookupInfo
Definition: EDConsumerBase.h:288
modules
Definition: MuonCleanerBySegments.cc:35
edm::ProductResolverIndexAndSkipBit
Definition: ProductResolverIndexAndSkipBit.h:28
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProductLabels::module
char const * module
Definition: ProductLabels.h:5
edm::ESInputTag::data
const std::string & data() const
Definition: ESInputTag.h:104
oniaPATMuonsWithTrigger_cff.matches
matches
Definition: oniaPATMuonsWithTrigger_cff.py:77
edm::EDConsumerBase::checkIfEmpty
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
Definition: EDConsumerBase.cc:54
ComponentDescription.h
edm::EDConsumerBase::m_esTokenInfo
edm::SoATuple< ESTokenLookupInfo, ESProxyIndex > m_esTokenInfo
Definition: EDConsumerBase.h:304
cms::cuda::assert
assert(be >=bs)
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:47
edm::ProductResolverIndexHelper::index
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
Definition: ProductResolverIndexHelper.cc:81
edm::InputTag::process
std::string const & process() const
Definition: InputTag.h:40
edm::eventsetup::DataKey
Definition: DataKey.h:29
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
edm::EDConsumerBase::kAlwaysGets
Definition: EDConsumerBase.h:279
mps_check.array
array
Definition: mps_check.py:216
edm::ProductRegistry::productLookup
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
Definition: ProductRegistry.cc:145
ESRecordsToProxyIndices.h
ProductRegistry.h
edm::ProductResolverIndexHelper::relatedIndexes
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
Definition: ProductResolverIndexHelper.cc:153
edm::ProductResolverIndexHelper
Definition: ProductResolverIndexHelper.h:89
edm::EDConsumerBase::itemsMayGet
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Definition: EDConsumerBase.cc:306
edm::EDConsumerBase::throwConsumesCallAfterFrozen
void throwConsumesCallAfterFrozen(TypeToGet const &, InputTag const &) const
Definition: EDConsumerBase.cc:396
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
edm::EDConsumerBase::registeredToConsume
bool registeredToConsume(ProductResolverIndex, bool, BranchType) const
Definition: EDConsumerBase.cc:347
edm::BranchType
BranchType
Definition: BranchType.h:11
edm::ESProxyIndex
Definition: ESIndices.h:30
mps_monitormerge.items
list items
Definition: mps_monitormerge.py:29
edm::NumBranchTypes
Definition: BranchType.h:11
edm::EDConsumerBase::m_tokenLabels
std::vector< char > m_tokenLabels
Definition: EDConsumerBase.h:284
edm::ProductLabels::process
char const * process
Definition: ProductLabels.h:7
edm::InputTag::willSkipCurrentProcess
bool willSkipCurrentProcess() const
Definition: InputTag.h:42
edm::EDConsumerBase::consumesInfo
std::vector< ConsumesInfo > consumesInfo() const
Definition: EDConsumerBase.cc:616
edm::ProductRegistry
Definition: ProductRegistry.h:37
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
edm::EDConsumerBase::kLookupInfo
Definition: EDConsumerBase.h:279
edm::EDConsumerBase::uncheckedIndexFrom
ProductResolverIndexAndSkipBit uncheckedIndexFrom(EDGetToken) const
Definition: EDConsumerBase.cc:270
UNLIKELY
#define UNLIKELY(x)
Definition: Likely.h:21
kWasEmpty
static const edm::InputTag kWasEmpty("@EmptyLabel@")
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
edm::ESTokenIndex::value
constexpr Value_t value() const noexcept
Definition: ESIndices.h:70
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
edm::EDConsumerBase::itemsToGet
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
Definition: EDConsumerBase.cc:274
edm::EDConsumerBase::TokenLookupInfo
Definition: EDConsumerBase.h:258
edm::EDConsumerBase::throwESConsumesInProcessBlock
void throwESConsumesInProcessBlock() const
Definition: EDConsumerBase.cc:413
edm::eventsetup::ESRecordsToProxyIndices::missingProxyIndex
static constexpr ESProxyIndex missingProxyIndex() noexcept
Definition: ESRecordsToProxyIndices.h:48
ModuleProcessName.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::EDConsumerBase::modulesWhoseProductsAreConsumed
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
Definition: EDConsumerBase.cc:471
edm::EDConsumerBase::m_tokenInfo
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
Definition: EDConsumerBase.h:280
edm::eventsetup::ESRecordsToProxyIndices::indexInRecord
ESProxyIndex indexInRecord(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
If the index is not found, returns missingProxyIndex()
Definition: ESRecordsToProxyIndices.cc:50
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
edm::Transition
Transition
Definition: Transition.h:12
EDConsumerBase.h
LaserDQM_cfg.process
process
Definition: LaserDQM_cfg.py:3
edm::eventsetup::heterocontainer::HCTypeTag
Definition: HCTypeTag.h:38
helper
Definition: helper.py:1
edm::EDConsumerBase::throwBadToken
void throwBadToken(edm::TypeID const &iType, EDGetToken iToken) const
Definition: EDConsumerBase.cc:383
edm::eventsetup::EventSetupRecordKey::type
const TypeTag & type() const
Definition: EventSetupRecordKey.h:40
edm::ProductResolverIndexInvalid
Definition: ProductResolverIndex.h:16
edm::eventsetup::heterocontainer::HCTypeTag::name
char const * name() const
Definition: HCTypeTag.h:46
edm::EDConsumerBase::updateLookup
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
Definition: EDConsumerBase.cc:112
edm::EDConsumerBase::~EDConsumerBase
virtual ~EDConsumerBase() noexcept(false)
Definition: EDConsumerBase.cc:42
edm::EDConsumerBase::EDConsumerBase
EDConsumerBase()
Definition: EDConsumerBase.cc:39
edm::EDConsumerBase::itemsToGetFromBranch_
std::array< std::vector< ProductResolverIndexAndSkipBit >, edm::NumBranchTypes > itemsToGetFromBranch_
Definition: EDConsumerBase.h:286
edm::EDConsumerBase::kESLookupInfo
Definition: EDConsumerBase.h:303
edm::EDConsumerBase::containsCurrentProcessAlias_
bool containsCurrentProcessAlias_
Definition: EDConsumerBase.h:310
edm::EDGetToken
Definition: EDGetToken.h:35
CalibrationSummaryClient_cfi.kind
kind
Definition: CalibrationSummaryClient_cfi.py:37
edm::TypeToGet::type
TypeID const & type() const
Definition: TypeToGet.h:42
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
edm::TypeID::className
std::string const & className() const
Definition: TypeID.cc:40
edm::EDConsumerBase::kKind
Definition: EDConsumerBase.h:279
edm::EDConsumerBase::labelsForToken
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
Definition: EDConsumerBase.cc:338
edm::ESInputTag::module
const std::string & module() const
Definition: ESInputTag.h:99
edm::ProductLabels::productInstance
char const * productInstance
Definition: ProductLabels.h:6
edm::TypeID
Definition: TypeID.h:22
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::EDGetToken::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:51
edm::KindOfType
KindOfType
Definition: ProductKindOfType.h:5
edm::EDConsumerBase::frozen_
bool frozen_
Definition: EDConsumerBase.h:309
LIKELY
#define LIKELY(x)
Definition: Likely.h:20
Exception
Definition: hltDiff.cc:245
edm::EDConsumerBase::kESProxyIndex
Definition: EDConsumerBase.h:303
edm::EDConsumerBase::labelFor
const char * labelFor(ESTokenIndex) const
Definition: EDConsumerBase.cc:654
edm::EDConsumerBase::throwBranchMismatch
void throwBranchMismatch(BranchType, EDGetToken) const
Definition: EDConsumerBase.cc:376
edm::ModuleProcessName
Definition: ModuleProcessName.h:12
edm::EDConsumerBase::esItemsToGetFromTransition_
std::array< std::vector< ESProxyIndex >, static_cast< unsigned int >edm::Transition::NumberOfEventSetupTransitions)> esItemsToGetFromTransition_
Definition: EDConsumerBase.h:306
edm::ProductRegistry::aliasToModules
std::vector< std::string > aliasToModules(KindOfType kindOfType, TypeID const &type, std::string_view moduleLabel, std::string_view productInstanceName) const
Definition: ProductRegistry.cc:613
Exception.h
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
edm::eventsetup::ESRecordsToProxyIndices::component
ComponentDescription const * component(EventSetupRecordKey const &iRK, DataKey const &iDK) const noexcept
Definition: ESRecordsToProxyIndices.cc:77
mps_fire.result
result
Definition: mps_fire.py:311
ConsumesCollector.h
command_line.start
start
Definition: command_line.py:167
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::EDConsumerBase::LabelPlacement
Definition: EDConsumerBase.h:266
edm::EDConsumerBase::recordESConsumes
ESTokenIndex recordESConsumes(Transition, eventsetup::EventSetupRecordKey const &, eventsetup::heterocontainer::HCTypeTag const &, edm::ESInputTag const &iTag)
Definition: EDConsumerBase.cc:213
edm::TypeToGet
Definition: TypeToGet.h:32
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::TypeToGet::kind
KindOfType kind() const
Definition: TypeToGet.h:43
SimL1EmulatorRepack_Full_cff.inputTag
inputTag
Definition: SimL1EmulatorRepack_Full_cff.py:56
edm::BranchTypeToString
std::string const & BranchTypeToString(BranchType const &branchType)
Definition: BranchType.cc:91
edm::EDConsumerBase::throwTypeMismatch
void throwTypeMismatch(edm::TypeID const &, EDGetToken) const
Definition: EDConsumerBase.cc:370
edm::InputTag
Definition: InputTag.h:15
edm::eventsetup::ESRecordsToProxyIndices::recordIndexFor
ESRecordIndex recordIndexFor(EventSetupRecordKey const &iRK) const noexcept
Definition: ESRecordsToProxyIndices.cc:69
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::EDConsumerBase::indexFrom
ProductResolverIndexAndSkipBit indexFrom(EDGetToken, BranchType, TypeID const &) const
Definition: EDConsumerBase.cc:251
edm::ProductLabels
Definition: ProductLabels.h:4
edm::EDConsumerBase::convertCurrentProcessAlias
void convertCurrentProcessAlias(std::string const &processName)
Convert "@currentProcess" in InputTag process names to the actual current process name.
Definition: EDConsumerBase.cc:570
edm::EDConsumerBase::registerLateConsumes
virtual void registerLateConsumes(eventsetup::ESRecordsToProxyIndices const &)
Definition: EDConsumerBase.h:237
edm::Transition::NumberOfEventSetupTransitions