CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
edm::EDConsumerBase Class Reference

#include <EDConsumerBase.h>

Inheritance diagram for edm::EDConsumerBase:
edm::EDAnalyzer edm::EDFilter edm::EDProducer edm::global::EDAnalyzerBase edm::global::EDFilterBase edm::global::EDProducerBase edm::global::OutputModuleBase edm::limited::EDAnalyzerBase edm::limited::EDFilterBase edm::limited::EDProducerBase edm::limited::OutputModuleBase edm::one::EDAnalyzerBase edm::one::EDFilterBase edm::one::EDProducerBase edm::one::OutputModuleBase edm::OutputModule edm::stream::EDAnalyzerBase edm::stream::EDFilterBase edm::stream::EDProducerBase edm::SubProcess

Classes

struct  LabelPlacement
 
struct  TokenLookupInfo
 

Public Types

typedef ProductLabels Labels
 

Public Member Functions

std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Types

enum  { kLookupInfo, kAlwaysGets, kLabels, kKind }
 

Private Member Functions

edm::InputTag const & checkIfEmpty (edm::InputTag const &tag)
 
unsigned int recordConsumes (BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
 
void throwBadToken (edm::TypeID const &iType, EDGetToken iToken) const
 
void throwBranchMismatch (BranchType, EDGetToken) const
 
void throwConsumesCallAfterFrozen (TypeToGet const &, InputTag const &) const
 
void throwTypeMismatch (edm::TypeID const &, EDGetToken) const
 

Private Attributes

bool containsCurrentProcessAlias_
 
bool frozen_
 
std::array< std::vector< ProductResolverIndexAndSkipBit >, edm::NumBranchTypesitemsToGetFromBranch_
 
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfTypem_tokenInfo
 
std::vector< char > m_tokenLabels
 

Friends

class ConsumesCollector
 
template<typename T >
class WillGetIfMatch
 

Detailed Description

Description: Allows declaration of what data is being consumed

Usage: The EDM modules all inherit from this base class

Definition at line 49 of file EDConsumerBase.h.

Member Typedef Documentation

Definition at line 85 of file EDConsumerBase.h.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

edm::EDConsumerBase::EDConsumerBase ( )
inline
EDConsumerBase::~EDConsumerBase ( )
virtualnoexcept

Definition at line 52 of file EDConsumerBase.cc.

Referenced by EDConsumerBase().

53 {
54 }
edm::EDConsumerBase::EDConsumerBase ( EDConsumerBase const &  )
delete
edm::EDConsumerBase::EDConsumerBase ( EDConsumerBase &&  )
default

Member Function Documentation

edm::InputTag const & EDConsumerBase::checkIfEmpty ( edm::InputTag const &  tag)
private

Definition at line 80 of file EDConsumerBase.cc.

References kWasEmpty, and edm::InputTag::label().

Referenced by consumes(), consumesMany(), and mayConsume().

80  {
81  if (iTag.label().empty()) {
82  return kWasEmpty;
83  }
84  return iTag;
85 }
static const edm::InputTag kWasEmpty("@EmptyLabel@")
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT<ProductType> edm::EDConsumerBase::consumes ( edm::InputTag const &  tag)
inlineprotected

Definition at line 105 of file EDConsumerBase.h.

References TtFullHadDaughter::B, checkIfEmpty(), and recordConsumes().

Referenced by AlCaECALRecHitReducer::AlCaECALRecHitReducer(), MixCollectionValidation::bookHistograms(), BTagPerformanceAnalyzerMC::BTagPerformanceAnalyzerMC(), BTagPerformanceAnalyzerOnData::BTagPerformanceAnalyzerOnData(), CrossingFramePSimHitToPSimHitsConverter::CrossingFramePSimHitToPSimHitsConverter(), EcalPileUpDepMonitor::EcalPileUpDepMonitor(), ElectronMVANtuplizer::ElectronMVANtuplizer(), EmDQMReco::EmDQMReco(), edm::EventContentAnalyzer::EventContentAnalyzer(), EcalDQMonitorTask::formSchedule(), HLTMuonIsoFilter::HLTMuonIsoFilter(), HLTMuonPFIsoFilter::HLTMuonPFIsoFilter(), JetCollectionReducerT< T >::JetCollectionReducerT(), edm::OutputModule::keepThisBranch(), edm::SubProcess::keepThisBranch(), edm::one::OutputModuleBase::keepThisBranch(), edm::global::OutputModuleBase::keepThisBranch(), edm::limited::OutputModuleBase::keepThisBranch(), edm::LogErrorHarvester::LogErrorHarvester(), MultiplicityCorrelator::MultiplicityCorrelator(), MultiTrackValidator::MultiTrackValidator(), MuonTrackValidator::MuonTrackValidator(), pat::PATPackedCandidateProducer::PATPackedCandidateProducer(), PhotonMVANtuplizer::PhotonMVANtuplizer(), PrimaryVertexAnalyzer4PUSlimmed::PrimaryVertexAnalyzer4PUSlimmed(), SeedMultiplicityAnalyzer::SeedMultiplicityAnalyzer(), ShallowSimhitClustersProducer::ShallowSimhitClustersProducer(), SiPixelPhase1TrackingParticleV::SiPixelPhase1TrackingParticleV(), SiStripMonitorDigi::SiStripMonitorDigi(), TrackingParticleNumberOfLayersProducer::TrackingParticleNumberOfLayersProducer(), and TTClusterBuilder< T >::TTClusterBuilder().

105  {
106  TypeToGet tid=TypeToGet::make<ProductType>();
107  return EDGetTokenT<ProductType>{recordConsumes(B,tid, checkIfEmpty(tag),true)};
108  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
static const std::string B
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
EDGetToken edm::EDConsumerBase::consumes ( const TypeToGet id,
edm::InputTag const &  tag 
)
inlineprotected

Definition at line 110 of file EDConsumerBase.h.

References checkIfEmpty(), edm::InEvent, and recordConsumes().

110  {
111  return EDGetToken{recordConsumes(InEvent, id, checkIfEmpty(tag), true)};
112  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
template<BranchType B>
EDGetToken edm::EDConsumerBase::consumes ( TypeToGet const &  id,
edm::InputTag const &  tag 
)
inlineprotected

Definition at line 115 of file EDConsumerBase.h.

References TtFullHadDaughter::B, checkIfEmpty(), and recordConsumes().

115  {
116  return EDGetToken{recordConsumes(B, id, checkIfEmpty(tag), true)};
117  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
static const std::string B
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
ConsumesCollector EDConsumerBase::consumesCollector ( )
protected

Use a ConsumesCollector to gather consumes information from helper functions.

Definition at line 72 of file EDConsumerBase.cc.

References EnergyCorrector::c, and kWasEmpty.

Referenced by AlcaBeamMonitor::AlcaBeamMonitor(), AlcaBeamSpotProducer::AlcaBeamSpotProducer(), IsolatedParticlesGeneratedJets::analyze(), edm::AnalyzerWrapper< T >::AnalyzerWrapper(), BCToEFilter::BCToEFilter(), BeamMonitor::BeamMonitor(), BeamMonitorBx::BeamMonitorBx(), BeamSpotAnalyzer::BeamSpotAnalyzer(), DTTrigTest::beginRun(), CaloParticleDebugger::CaloParticleDebugger(), ConfigurableAnalysis::ConfigurableAnalysis(), CosmicSplitterValidation::CosmicSplitterValidation(), CSCDigiValidation::CSCDigiValidation(), CSCMonitorModule::CSCMonitorModule(), CSCRecHitValidation::CSCRecHitValidation(), edm::OutputModule::doPreallocate(), edm::global::OutputModuleBase::doPreallocate(), edm::limited::OutputModuleBase::doPreallocate(), edm::one::OutputModuleBase::doPreallocate(), DTTrigProd::DTTrigProd(), EcalCosmicsHists::EcalCosmicsHists(), EcalDQMonitorTask::EcalDQMonitorTask(), EcalSelectiveReadoutValidation::EcalSelectiveReadoutValidation(), EDMtoMEConverter::EDMtoMEConverter(), EgammaHLTPixelMatchElectronProducers::EgammaHLTPixelMatchElectronProducers(), EgHLTOfflineSource::EgHLTOfflineSource(), EopTreeWriter::EopTreeWriter(), EventWithHistoryEDFilter::EventWithHistoryEDFilter(), edm::FilterWrapper< T >::FilterWrapper(), FSQDiJetAve::FSQDiJetAve(), HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer(), HGCalTriggerNtupleManager::HGCalTriggerNtupleManager(), HighPtTrackEcalDetIdProducer::HighPtTrackEcalDetIdProducer(), HLTBitAnalyzer::HLTBitAnalyzer(), HLTExoticaValidator::HLTExoticaValidator(), HLTHiggsValidator::HLTHiggsValidator(), HLTMuonIsoFilter::HLTMuonIsoFilter(), HLTTagAndProbeOfflineSource< TagType, TagCollType, ProbeType, ProbeCollType >::HLTTagAndProbeOfflineSource(), HLTTauDQMOfflineSource::HLTTauDQMOfflineSource(), cms::CkfDebugTrackCandidateMaker::initDebugger(), IsolatedTracksCone::IsolatedTracksCone(), JetMETHLTOfflineSource::JetMETHLTOfflineSource(), L1EventTreeProducer::L1EventTreeProducer(), L1MuGlobalMuonTrigger::L1MuGlobalMuonTrigger(), LogMessageMonitor::LogMessageMonitor(), pat::helper::ManyThingsToValueMaps< Adaptor, Collection, value_type >::ManyThingsToValueMaps(), pat::PATMETSlimmer::maybeReadShifts(), MultiplicityCorrelator::MultiplicityCorrelator(), MultiplicityInvestigator::MultiplicityInvestigator(), MultiplicityTimeCorrelations::MultiplicityTimeCorrelations(), MuPFIsoEmbedder::MuPFIsoEmbedder(), OccupancyPlots::OccupancyPlots(), edm::OutputModule::OutputModule(), edm::global::OutputModuleBase::OutputModuleBase(), edm::limited::OutputModuleBase::OutputModuleBase(), edm::one::OutputModuleBase::OutputModuleBase(), edm::PathStatusFilter::PathStatusFilter(), PlottingDevice::PlottingDevice(), QuickTrackAssociatorByHitsProducer::QuickTrackAssociatorByHitsProducer(), ReduceHcalRecHitCollectionProducer::ReduceHcalRecHitCollectionProducer(), SeedMultiplicityAnalyzer::SeedMultiplicityAnalyzer(), SingleTopTChannelLeptonDQM::SingleTopTChannelLeptonDQM(), SingleTopTChannelLeptonDQM_miniAOD::SingleTopTChannelLeptonDQM_miniAOD(), SiPixelPhase1Base::SiPixelPhase1Base(), SiPixelStatusHarvester::SiPixelStatusHarvester(), SiStripDCSFilter::SiStripDCSFilter(), SiStripMonitorCluster::SiStripMonitorCluster(), SiStripMonitorDigi::SiStripMonitorDigi(), SiStripMonitorTrack::SiStripMonitorTrack(), edm::SubProcess::SubProcess(), TagAndProbeBtagTriggerMonitor::TagAndProbeBtagTriggerMonitor(), TagProbeFitTreeProducer::TagProbeFitTreeProducer(), Tau3MuSkim::Tau3MuSkim(), TauTagValidation::TauTagValidation(), TopDiLeptonHLTOfflineDQM::TopDiLeptonHLTOfflineDQM(), TopDiLeptonOfflineDQM::TopDiLeptonOfflineDQM(), TopSingleLeptonDQM::TopSingleLeptonDQM(), TopSingleLeptonDQM_miniAOD::TopSingleLeptonDQM_miniAOD(), TopSingleLeptonHLTOfflineDQM::TopSingleLeptonHLTOfflineDQM(), TrackingMonitor::TrackingMonitor(), TtDilepEvtSolutionMaker::TtDilepEvtSolutionMaker(), and TtSemiEvtSolutionMaker::TtSemiEvtSolutionMaker().

72  {
73  ConsumesCollector c{this};
74  return c;
75 }
std::vector< ConsumesInfo > EDConsumerBase::consumesInfo ( ) const

Definition at line 530 of file EDConsumerBase.cc.

References kAlwaysGets, kKind, kLabels, kLookupInfo, m_tokenInfo, m_tokenLabels, and mps_fire::result.

530  {
531 
532  // Use this to eliminate duplicate entries related
533  // to consumesMany items where only the type was specified
534  // and the there are multiple matches. In these cases the
535  // label, instance, and process will be empty.
536  std::set<edm::TypeID> alreadySeenTypes;
537 
538  std::vector<ConsumesInfo> result;
539  auto itAlways = m_tokenInfo.begin<kAlwaysGets>();
540  auto itKind = m_tokenInfo.begin<kKind>();
541  auto itLabels = m_tokenInfo.begin<kLabels>();
542  for(auto itInfo = m_tokenInfo.begin<kLookupInfo>(),itEnd = m_tokenInfo.end<kLookupInfo>();
543  itInfo != itEnd; ++itInfo,++itKind,++itLabels, ++itAlways) {
544 
545  const unsigned int labelStart = itLabels->m_startOfModuleLabel;
546  const char* consumedModuleLabel = &(m_tokenLabels[labelStart]);
547  const char* consumedInstance = consumedModuleLabel+itLabels->m_deltaToProductInstance;
548  const char* consumedProcessName = consumedModuleLabel+itLabels->m_deltaToProcessName;
549 
550  // consumesMany case
551  if(*consumedModuleLabel == '\0') {
552  if(!alreadySeenTypes.insert(itInfo->m_type).second) {
553  continue;
554  }
555  }
556 
557  // Just copy the information into the ConsumesInfo data structure
558  result.emplace_back(itInfo->m_type,
559  consumedModuleLabel,
560  consumedInstance,
561  consumedProcessName,
562  itInfo->m_branchType,
563  *itKind,
564  *itAlways,
565  itInfo->m_index.skipCurrentProcess());
566  }
567  return result;
568 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
std::vector< char > m_tokenLabels
template<typename ProductType , BranchType B = InEvent>
void edm::EDConsumerBase::consumesMany ( )
inlineprotected

Definition at line 135 of file EDConsumerBase.h.

135  {
136  TypeToGet tid=TypeToGet::make<ProductType>();
137  consumesMany<B>(tid);
138  }
void edm::EDConsumerBase::consumesMany ( const TypeToGet id)
inlineprotected

Definition at line 140 of file EDConsumerBase.h.

References triggerObjects_cff::id.

140  {
141  consumesMany<InEvent>(id);
142  }
template<BranchType B>
void edm::EDConsumerBase::consumesMany ( const TypeToGet id)
inlineprotected

Definition at line 145 of file EDConsumerBase.h.

References TtFullHadDaughter::B, checkIfEmpty(), recordConsumes(), GlobalPosition_Frontier_DevDB_cff::tag, throwBadToken(), throwBranchMismatch(), throwConsumesCallAfterFrozen(), and throwTypeMismatch().

145  {
146  recordConsumes(B,id,edm::InputTag{},true);
147  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
static const std::string B
void EDConsumerBase::convertCurrentProcessAlias ( std::string const &  processName)

Convert "@currentProcess" in InputTag process names to the actual current process name.

Definition at line 479 of file EDConsumerBase.cc.

References containsCurrentProcessAlias_, frozen_, edm::InputTag::kCurrentProcess, kLabels, m_tokenInfo, m_tokenLabels, eostools::move(), modifiedElectrons_cfi::processName, and AlCaHLTBitMon_QueryRunRegistry::string.

479  {
480 
481  frozen_ = true;
482 
485 
486  std::vector<char> newTokenLabels;
487 
488  // first calculate the size of the new vector and reserve memory for it
489  std::vector<char>::size_type newSize = 0;
490  std::string newProcessName;
491  for(auto iter = m_tokenInfo.begin<kLabels>(), itEnd = m_tokenInfo.end<kLabels>();
492  iter != itEnd; ++iter) {
493  newProcessName = &m_tokenLabels[iter->m_startOfModuleLabel + iter->m_deltaToProcessName];
494  if (newProcessName == InputTag::kCurrentProcess) {
495  newProcessName = processName;
496  }
497  newSize += (iter->m_deltaToProcessName + newProcessName.size() + 1);
498  }
499  newTokenLabels.reserve(newSize);
500 
501  unsigned int newStartOfModuleLabel = 0;
502  for(auto iter = m_tokenInfo.begin<kLabels>(), itEnd = m_tokenInfo.end<kLabels>();
503  iter != itEnd; ++iter) {
504 
505  unsigned int startOfModuleLabel = iter->m_startOfModuleLabel;
506  unsigned short deltaToProcessName = iter->m_deltaToProcessName;
507 
508  iter->m_startOfModuleLabel = newStartOfModuleLabel;
509 
510  newProcessName = &m_tokenLabels[startOfModuleLabel + deltaToProcessName];
511  if (newProcessName == InputTag::kCurrentProcess) {
512  newProcessName = processName;
513  }
514 
515  newStartOfModuleLabel += (deltaToProcessName + newProcessName.size() + 1);
516 
517  // Copy in both the module label and instance, they are the same
518  newTokenLabels.insert(newTokenLabels.end(),
519  m_tokenLabels.begin() + startOfModuleLabel,
520  m_tokenLabels.begin() + (startOfModuleLabel + deltaToProcessName));
521 
522  newTokenLabels.insert(newTokenLabels.end(), newProcessName.begin(), newProcessName.end());
523  newTokenLabels.push_back('\0');
524  }
525  m_tokenLabels = std::move(newTokenLabels);
526  }
527 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
uint16_t size_type
static const std::string kCurrentProcess
Definition: InputTag.h:51
std::vector< char > m_tokenLabels
def move(src, dest)
Definition: eostools.py:510
ProductResolverIndexAndSkipBit EDConsumerBase::indexFrom ( EDGetToken  iToken,
BranchType  iBranch,
TypeID const &  iType 
) const

Definition at line 204 of file EDConsumerBase.cc.

References edm::EDGetToken::index(), info(), kLookupInfo, LIKELY, m_tokenInfo, edm::ProductResolverIndexInvalid, throwBadToken(), throwBranchMismatch(), throwTypeMismatch(), and UNLIKELY.

Referenced by EDConsumerBase(), and edm::PrincipalGetAdapter::getByToken_().

205 {
206  if(UNLIKELY(iToken.index()>=m_tokenInfo.size())) {
207  throwBadToken(iType,iToken);
208  }
209  const auto& info = m_tokenInfo.get<kLookupInfo>(iToken.index());
210  if (LIKELY(iBranch == info.m_branchType)) {
211  if (LIKELY(iType == info.m_type)) {
212  return info.m_index;
213  } else {
214  throwTypeMismatch(iType, iToken);
215  }
216  } else {
217  throwBranchMismatch(iBranch,iToken);
218  }
220 }
static const TGPicture * info(bool iBackgroundIsBlack)
void throwTypeMismatch(edm::TypeID const &, EDGetToken) const
void throwBadToken(edm::TypeID const &iType, EDGetToken iToken) const
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void throwBranchMismatch(BranchType, EDGetToken) const
#define LIKELY(x)
unsigned int index() const
Definition: EDGetToken.h:46
#define UNLIKELY(x)
void EDConsumerBase::itemsMayGet ( BranchType  iBranch,
std::vector< ProductResolverIndexAndSkipBit > &  oIndices 
) const

Definition at line 265 of file EDConsumerBase.cc.

References KineDebug3::count(), kAlwaysGets, kLookupInfo, m_tokenInfo, and edm::ProductResolverIndexInvalid.

Referenced by EDConsumerBase(), and updateLookup().

266 {
267  //how many are we adding?
268  unsigned int count=0;
269  {
270  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
271  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
272  itEnd = m_tokenInfo.end<kLookupInfo>();
273  it != itEnd; ++it,++itAlwaysGet) {
274  if(iBranch==it->m_branchType) {
275  if (it->m_index.productResolverIndex() != ProductResolverIndexInvalid) {
276  if(not *itAlwaysGet) {
277  ++count;
278  }
279  }
280  }
281  }
282  }
283  oIndices.reserve(oIndices.size()+count);
284  {
285  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
286  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
287  itEnd = m_tokenInfo.end<kLookupInfo>();
288  it != itEnd; ++it,++itAlwaysGet) {
289  if(iBranch==it->m_branchType) {
290  if (it->m_index.productResolverIndex() != ProductResolverIndexInvalid) {
291  if(not *itAlwaysGet) {
292  oIndices.push_back(it->m_index);
293  }
294  }
295  }
296  }
297  }
298 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void EDConsumerBase::itemsToGet ( BranchType  iBranch,
std::vector< ProductResolverIndexAndSkipBit > &  oIndices 
) const

Definition at line 229 of file EDConsumerBase.cc.

References KineDebug3::count(), kAlwaysGets, kLookupInfo, m_tokenInfo, and edm::ProductResolverIndexInvalid.

Referenced by EDConsumerBase(), and updateLookup().

230 {
231  //how many are we adding?
232  unsigned int count=0;
233  {
234  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
235  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
236  itEnd = m_tokenInfo.end<kLookupInfo>();
237  it != itEnd; ++it,++itAlwaysGet) {
238  if(iBranch==it->m_branchType) {
239  if (it->m_index.productResolverIndex() != ProductResolverIndexInvalid) {
240  if(*itAlwaysGet) {
241  ++count;
242  }
243  }
244  }
245  }
246  }
247  oIndices.reserve(oIndices.size()+count);
248  {
249  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
250  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
251  itEnd = m_tokenInfo.end<kLookupInfo>();
252  it != itEnd; ++it,++itAlwaysGet) {
253  if(iBranch==it->m_branchType) {
254  if (it->m_index.productResolverIndex() != ProductResolverIndexInvalid) {
255  if(*itAlwaysGet) {
256  oIndices.push_back(it->m_index);
257  }
258  }
259  }
260  }
261  }
262 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
std::vector<ProductResolverIndexAndSkipBit> const& edm::EDConsumerBase::itemsToGetFrom ( BranchType  iType) const
inline

Definition at line 71 of file EDConsumerBase.h.

References itemsToGetFromBranch_, registeredToConsume(), registeredToConsumeMany(), and updateLookup().

Referenced by edm::PrincipalGetAdapter::numberOfProductsConsumed().

71 { return itemsToGetFromBranch_[iType]; }
std::array< std::vector< ProductResolverIndexAndSkipBit >, edm::NumBranchTypes > itemsToGetFromBranch_
void EDConsumerBase::labelsForToken ( EDGetToken  iToken,
Labels oLabels 
) const

Definition at line 301 of file EDConsumerBase.cc.

References edm::EDGetToken::index(), kLabels, tablePrinter::labels, m_tokenInfo, m_tokenLabels, edm::ProductLabels::module, edm::ProductLabels::process, edm::ProductLabels::productInstance, and command_line::start.

Referenced by EgammaBasicClusters::analyze(), AlCaElectronsTest::analyze(), SiPixelHitEfficiencySource::analyze(), EnergyScaleAnalyzer::analyze(), SiPixelTrackResidualSource::analyze(), HLTScalers::analyze(), EgammaObjects::analyzeElectrons(), EgammaObjects::analyzePhotons(), ElectronTagProbeAnalyzer::bookHistograms(), TkAlCaRecoMonitor::bookHistograms(), ElectronAnalyzer::bookHistograms(), HLTVertexPerformanceAnalyzer::dqmBeginRun(), HLTBTagPerformanceAnalyzer::dqmBeginRun(), TriggerBxMonitor::dqmBeginRun(), TriggerRatesMonitor::dqmBeginRun(), TrackingNtuple::fillSeeds(), TrackingNtuple::fillTracks(), EcalSimpleUncalibRecHitFilter::filter(), EcalMIPRecHitFilter::filter(), HLTBTagPerformanceAnalyzer::HLTBTagPerformanceAnalyzer(), HLTVertexPerformanceAnalyzer::HLTVertexPerformanceAnalyzer(), edm::PrincipalGetAdapter::labelsForToken(), edm::PrincipalGetAdapter::makeFailToGetException(), MultiTrackValidator::MultiTrackValidator(), MuonSimHitsValidAnalyzer::MuonSimHitsValidAnalyzer(), HIPixelTrackFilterProducer::produce(), HIProtoTrackFilterProducer::produce(), and edm::PrincipalGetAdapter::throwAmbiguousException().

302 {
303  unsigned int index = iToken.index();
304  auto labels = m_tokenInfo.get<kLabels>(index);
305  unsigned int start = labels.m_startOfModuleLabel;
306  oLabels.module = &(m_tokenLabels[start]);
307  oLabels.productInstance = oLabels.module+labels.m_deltaToProductInstance;
308  oLabels.process = oLabels.module+labels.m_deltaToProcessName;
309 }
Definition: start.py:1
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
std::vector< char > m_tokenLabels
unsigned int index() const
Definition: EDGetToken.h:46
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT<ProductType> edm::EDConsumerBase::mayConsume ( edm::InputTag const &  tag)
inlineprotected

Definition at line 120 of file EDConsumerBase.h.

References TtFullHadDaughter::B, checkIfEmpty(), and recordConsumes().

120  {
121  TypeToGet tid=TypeToGet::make<ProductType>();
122  return EDGetTokenT<ProductType>{recordConsumes(B, tid, checkIfEmpty(tag), false)};
123  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
static const std::string B
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
EDGetToken edm::EDConsumerBase::mayConsume ( const TypeToGet id,
edm::InputTag const &  tag 
)
inlineprotected
template<BranchType B>
EDGetToken edm::EDConsumerBase::mayConsume ( const TypeToGet id,
edm::InputTag const &  tag 
)
inlineprotected

Definition at line 130 of file EDConsumerBase.h.

References TtFullHadDaughter::B, checkIfEmpty(), and recordConsumes().

130  {
131  return EDGetToken{recordConsumes(B,id,checkIfEmpty(tag),false)};
132  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
static const std::string B
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
void EDConsumerBase::modulesWhoseProductsAreConsumed ( std::vector< ModuleDescription const * > &  modules,
ProductRegistry const &  preg,
std::map< std::string, ModuleDescription const * > const &  labelsToDesc,
std::string const &  processName 
) const

Definition at line 422 of file EDConsumerBase.cc.

References edm::ProductResolverIndexHelper::index(), edm::InEvent, kKind, kLabels, kLookupInfo, m_tokenInfo, m_tokenLabels, patRefSel_triggerMatching_cfi::matches, electrons_cff::modules, edm::ProductRegistry::productLookup(), edm::ProductResolverIndexInvalid, and edm::ProductResolverIndexHelper::relatedIndexes().

425  {
426 
427  ProductResolverIndexHelper const& iHelper = *preg.productLookup(InEvent);
428 
429  std::set<std::string> alreadyFound;
430 
431  auto itKind = m_tokenInfo.begin<kKind>();
432  auto itLabels = m_tokenInfo.begin<kLabels>();
433  for(auto itInfo = m_tokenInfo.begin<kLookupInfo>(),itEnd = m_tokenInfo.end<kLookupInfo>();
434  itInfo != itEnd; ++itInfo,++itKind,++itLabels) {
435 
436  if(itInfo->m_branchType == InEvent and
437  (not itInfo->m_index.skipCurrentProcess())) {
438 
439  const unsigned int labelStart = itLabels->m_startOfModuleLabel;
440  const char* consumedModuleLabel = &(m_tokenLabels[labelStart]);
441  const char* consumedProcessName = consumedModuleLabel+itLabels->m_deltaToProcessName;
442 
443  if(*consumedModuleLabel != '\0') { // not a consumesMany
444  if(*consumedProcessName != '\0') { // process name is specified in consumes call
445  if (processName == consumedProcessName &&
446  iHelper.index(*itKind,
447  itInfo->m_type,
448  consumedModuleLabel,
449  consumedModuleLabel+itLabels->m_deltaToProductInstance,
450  consumedModuleLabel+itLabels->m_deltaToProcessName) != ProductResolverIndexInvalid) {
451  insertFoundModuleLabel(consumedModuleLabel, modules, alreadyFound, labelsToDesc, preg);
452  }
453  } else { // process name was empty
454  auto matches = iHelper.relatedIndexes(*itKind,
455  itInfo->m_type,
456  consumedModuleLabel,
457  consumedModuleLabel+itLabels->m_deltaToProductInstance);
458  for(unsigned int j = 0; j < matches.numberOfMatches(); ++j) {
459  if(processName == matches.processName(j)) {
460  insertFoundModuleLabel(consumedModuleLabel, modules, alreadyFound, labelsToDesc, preg);
461  }
462  }
463  }
464  // consumesMany case
465  } else if(itInfo->m_index.productResolverIndex() == ProductResolverIndexInvalid) {
466  auto matches = iHelper.relatedIndexes(*itKind,
467  itInfo->m_type);
468  for(unsigned int j = 0; j < matches.numberOfMatches(); ++j) {
469  if(processName == matches.processName(j)) {
470  insertFoundModuleLabel(matches.moduleLabel(j), modules, alreadyFound, labelsToDesc, preg);
471  }
472  }
473  }
474  }
475  }
476 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
std::vector< char > m_tokenLabels
ProductResolverIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=nullptr) const
EDConsumerBase const& edm::EDConsumerBase::operator= ( EDConsumerBase const &  )
delete

Referenced by EDConsumerBase().

EDConsumerBase& edm::EDConsumerBase::operator= ( EDConsumerBase &&  )
default
unsigned int EDConsumerBase::recordConsumes ( BranchType  iBranch,
TypeToGet const &  iType,
edm::InputTag const &  iTag,
bool  iAlwaysGets 
)
private

Definition at line 88 of file EDConsumerBase.cc.

References containsCurrentProcessAlias_, frozen_, edm::InputTag::instance(), edm::InputTag::kCurrentProcess, edm::TypeToGet::kind(), edm::InputTag::label(), funct::m, m_tokenInfo, m_tokenLabels, edm::InputTag::process(), edm::ProductResolverIndexInvalid, AlCaHLTBitMon_QueryRunRegistry::string, throwConsumesCallAfterFrozen(), edm::TypeToGet::type(), and edm::InputTag::willSkipCurrentProcess().

Referenced by consumes(), consumesMany(), and mayConsume().

88  {
89 
90  if(frozen_) {
91  throwConsumesCallAfterFrozen(iType, iTag);
92  }
93 
94  unsigned int index =m_tokenInfo.size();
95 
96  bool skipCurrentProcess = iTag.willSkipCurrentProcess();
97 
98  const size_t labelSize = iTag.label().size();
99  const size_t productInstanceSize = iTag.instance().size();
100  unsigned int labelStart = m_tokenLabels.size();
101  unsigned short delta1 = labelSize+1;
102  unsigned short delta2 = labelSize+2+productInstanceSize;
103  m_tokenInfo.emplace_back(TokenLookupInfo{iType.type(), ProductResolverIndexInvalid, skipCurrentProcess, iBranch},
104  iAlwaysGets,
105  LabelPlacement{labelStart,delta1,delta2},
106  iType.kind());
107 
108  const size_t additionalSize =
109  skipCurrentProcess ?
110  labelSize+productInstanceSize+3 :
111  labelSize+productInstanceSize+iTag.process().size()+3;
112 
113  m_tokenLabels.reserve(m_tokenLabels.size()+additionalSize);
114  {
115  const std::string& m =iTag.label();
116  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
117  m_tokenLabels.push_back('\0');
118  }
119  {
120  const std::string& m =iTag.instance();
121  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
122  m_tokenLabels.push_back('\0');
123  }
124  {
125  const std::string& m = iTag.process();
126  if (m == InputTag::kCurrentProcess) {
128  }
129  if (!skipCurrentProcess) {
130  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
131  m_tokenLabels.push_back('\0');
132  } else {
133  m_tokenLabels.push_back('\0');
134  }
135  }
136  return index;
137 }
void throwConsumesCallAfterFrozen(TypeToGet const &, InputTag const &) const
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
static const std::string kCurrentProcess
Definition: InputTag.h:51
std::vector< char > m_tokenLabels
bool EDConsumerBase::registeredToConsume ( ProductResolverIndex  iIndex,
bool  skipCurrentProcess,
BranchType  iBranch 
) const
Returns
true if the product corresponding to the index was registered via consumes or mayConsume call

Definition at line 312 of file EDConsumerBase.cc.

References kLookupInfo, and m_tokenInfo.

Referenced by edm::Principal::findProductByLabel(), and itemsToGetFrom().

313 {
314  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
315  itEnd = m_tokenInfo.end<kLookupInfo>();
316  it != itEnd; ++it) {
317  if(it->m_index.productResolverIndex() == iIndex and
318  it->m_index.skipCurrentProcess() == skipCurrentProcess and
319  it->m_branchType == iBranch) {
320  return true;
321  }
322  }
323  return false;
324 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
bool EDConsumerBase::registeredToConsumeMany ( TypeID const &  iType,
BranchType  iBranch 
) const
Returns
true of TypeID corresponds to a type specified in a consumesMany call

Definition at line 327 of file EDConsumerBase.cc.

References kLookupInfo, m_tokenInfo, and edm::ProductResolverIndexInvalid.

Referenced by edm::Principal::getManyByType(), and itemsToGetFrom().

328 {
329  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
330  itEnd = m_tokenInfo.end<kLookupInfo>();
331  it != itEnd; ++it) {
332  //consumesMany entries do not have their index resolved
333  if(it->m_index.productResolverIndex() == ProductResolverIndexInvalid and
334  it->m_type == iType and
335  it->m_branchType == iBranch) {
336  return true;
337  }
338  }
339  return false;
340 
341 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void EDConsumerBase::throwBadToken ( edm::TypeID const &  iType,
EDGetToken  iToken 
) const
private

Definition at line 355 of file EDConsumerBase.cc.

References edm::TypeID::className(), Exception, edm::EDGetToken::index(), and edm::EDGetToken::isUninitialized().

Referenced by consumesMany(), and indexFrom().

356 {
357  if(iToken.isUninitialized()) {
358  throw cms::Exception("BadToken")<<"A get using a EDGetToken with the C++ type '"<<iType.className()<<"' was made using an uninitialized token.\n Please check that the variable is being initialized from a 'consumes' call.";
359  }
360  throw cms::Exception("BadToken")<<"A get using a EDGetToken with the C++ type '"<<iType.className()<<"' was made using a token with a value "<<iToken.index()<<" which is beyond the range used by this module.\n Please check that the variable is being initialized from a 'consumes' call from this module.\n You can not share EDGetToken values between modules.";
361 }
bool isUninitialized() const
Definition: EDGetToken.h:47
unsigned int index() const
Definition: EDGetToken.h:46
void EDConsumerBase::throwBranchMismatch ( BranchType  iBranch,
EDGetToken  iToken 
) const
private

Definition at line 350 of file EDConsumerBase.cc.

References edm::BranchTypeToString(), Exception, edm::EDGetToken::index(), kLookupInfo, and m_tokenInfo.

Referenced by consumesMany(), and indexFrom().

350  {
351  throw cms::Exception("BranchTypeMismatch")<<"A get using a EDGetToken was done in "<<BranchTypeToString(iBranch)<<" but the consumes call was for "<<BranchTypeToString(m_tokenInfo.get<kLookupInfo>(iToken.index()).m_branchType)<<".\n Please modify the consumes call to use the correct branch type.";
352 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
std::string const & BranchTypeToString(BranchType const &branchType)
Definition: BranchType.cc:99
unsigned int index() const
Definition: EDGetToken.h:46
void EDConsumerBase::throwConsumesCallAfterFrozen ( TypeToGet const &  typeToGet,
InputTag const &  inputTag 
) const
private

Definition at line 364 of file EDConsumerBase.cc.

References edm::ProductRegistry::aliasToOriginal(), Exception, AlCaHLTBitMon_QueryRunRegistry::string, edmPickEvents::target, and edm::TypeToGet::type().

Referenced by consumesMany(), and recordConsumes().

364  {
365  throw cms::Exception("LogicError") << "A module declared it consumes a product after its constructor.\n"
366  << "This must be done in the contructor\n"
367  << "The product type was: " << typeToGet.type() << "\n"
368  << "and " << inputTag << "\n";
369 }
void EDConsumerBase::throwTypeMismatch ( edm::TypeID const &  iType,
EDGetToken  iToken 
) const
private

Definition at line 345 of file EDConsumerBase.cc.

References edm::TypeID::className(), Exception, edm::EDGetToken::index(), kLookupInfo, and m_tokenInfo.

Referenced by consumesMany(), and indexFrom().

346 {
347  throw cms::Exception("TypeMismatch")<<"A get using a EDGetToken used the C++ type '"<<iType.className()<<"' but the consumes call was for type '"<<m_tokenInfo.get<kLookupInfo>(iToken.index()).m_type.className()<<"'.\n Please modify either the consumes or get call so the types match.";
348 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
unsigned int index() const
Definition: EDGetToken.h:46
ProductResolverIndexAndSkipBit EDConsumerBase::uncheckedIndexFrom ( EDGetToken  iToken) const
void EDConsumerBase::updateLookup ( BranchType  iBranchType,
ProductResolverIndexHelper const &  iHelper,
bool  iPrefetchMayGet 
)

Definition at line 140 of file EDConsumerBase.cc.

References containsCurrentProcessAlias_, frozen_, mps_fire::i, edm::ProductResolverIndexHelper::index(), info(), itemsMayGet(), itemsToGet(), itemsToGetFromBranch_, kAlwaysGets, callgraph::kind, kKind, kLabels, kLookupInfo, tablePrinter::labels, m_tokenInfo, m_tokenLabels, patRefSel_triggerMatching_cfi::matches, edm::ProductResolverIndexInvalid, and edm::ProductResolverIndexHelper::relatedIndexes().

Referenced by edm::SubProcess::beginJob(), and itemsToGetFrom().

143 {
144  frozen_ = true;
146  {
147  auto itKind = m_tokenInfo.begin<kKind>();
148  auto itLabels = m_tokenInfo.begin<kLabels>();
149  for(auto itInfo = m_tokenInfo.begin<kLookupInfo>(),itEnd = m_tokenInfo.end<kLookupInfo>();
150  itInfo != itEnd; ++itInfo,++itKind,++itLabels) {
151  if(itInfo->m_branchType == iBranchType) {
152  const unsigned int labelStart = itLabels->m_startOfModuleLabel;
153  const char* moduleLabel = &(m_tokenLabels[labelStart]);
154  itInfo->m_index = ProductResolverIndexAndSkipBit(iHelper.index(*itKind,
155  itInfo->m_type,
156  moduleLabel,
157  moduleLabel+itLabels->m_deltaToProductInstance,
158  moduleLabel+itLabels->m_deltaToProcessName),
159  itInfo->m_index.skipCurrentProcess());
160  }
161  }
162  }
163 
164  //now add resolved requests to get many to the end of our list
165  // a get many will have an empty module label
166  for(size_t i=0, iEnd = m_tokenInfo.size(); i!=iEnd;++i) {
167  //need to copy since pointer could be invalidated by emplace_back
168  auto const info = m_tokenInfo.get<kLookupInfo>(i);
169  if(info.m_branchType == iBranchType &&
170  info.m_index.productResolverIndex() == ProductResolverIndexInvalid &&
171  m_tokenLabels[m_tokenInfo.get<kLabels>(i).m_startOfModuleLabel]=='\0') {
172  //find all matching types
173  const auto kind=m_tokenInfo.get<kKind>(i);
174  auto matches = iHelper.relatedIndexes(kind,info.m_type);
175 
176  //NOTE: This could be changed to contain the true labels for what is being
177  // requested but for now I want to remember these are part of a get many
178  const LabelPlacement labels= m_tokenInfo.get<kLabels>(i);
179  bool alwaysGet = m_tokenInfo.get<kAlwaysGets>(i);
180  for(unsigned int j=0;j!=matches.numberOfMatches();++j) {
181  //only keep the ones that are for a specific data item and not a collection
182  if(matches.isFullyResolved(j)) {
183  auto index =matches.index(j);
184  m_tokenInfo.emplace_back(TokenLookupInfo{info.m_type, index, info.m_index.skipCurrentProcess(), info.m_branchType},
185  alwaysGet,
186  labels,
187  kind);
188  }
189  }
190  }
191  }
192  m_tokenInfo.shrink_to_fit();
193 
194  itemsToGet(iBranchType, itemsToGetFromBranch_[iBranchType]);
195  if(iPrefetchMayGet) {
196  itemsMayGet(iBranchType, itemsToGetFromBranch_[iBranchType]);
197  }
198 }
static const TGPicture * info(bool iBackgroundIsBlack)
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void itemsToGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
std::vector< char > m_tokenLabels
void itemsMayGet(BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
std::array< std::vector< ProductResolverIndexAndSkipBit >, edm::NumBranchTypes > itemsToGetFromBranch_

Friends And Related Function Documentation

friend class ConsumesCollector
friend

Definition at line 99 of file EDConsumerBase.h.

template<typename T >
friend class WillGetIfMatch
friend

Definition at line 100 of file EDConsumerBase.h.

Member Data Documentation

bool edm::EDConsumerBase::containsCurrentProcessAlias_
private

Definition at line 194 of file EDConsumerBase.h.

Referenced by convertCurrentProcessAlias(), recordConsumes(), and updateLookup().

bool edm::EDConsumerBase::frozen_
private

Definition at line 193 of file EDConsumerBase.h.

Referenced by convertCurrentProcessAlias(), recordConsumes(), and updateLookup().

std::array<std::vector<ProductResolverIndexAndSkipBit>, edm::NumBranchTypes> edm::EDConsumerBase::itemsToGetFromBranch_
private

Definition at line 191 of file EDConsumerBase.h.

Referenced by itemsToGetFrom(), and updateLookup().

edm::SoATuple<TokenLookupInfo,bool,LabelPlacement,edm::KindOfType> edm::EDConsumerBase::m_tokenInfo
private
std::vector<char> edm::EDConsumerBase::m_tokenLabels
private