CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | 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::one::EDAnalyzerBase edm::one::EDFilterBase edm::one::EDProducerBase edm::one::OutputModuleBase edm::OutputModule edm::stream::EDAnalyzerBase edm::stream::EDFilterBase edm::stream::EDProducerBase

Classes

struct  LabelPlacement
 
struct  Labels
 
struct  TokenLookupInfo
 

Public Member Functions

 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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)
 
 EDConsumerBase (const EDConsumerBase &)=delete
 
const EDConsumerBaseoperator= (const EDConsumerBase &)=delete
 
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 frozen_
 
std::vector
< ProductHolderIndexAndSkipBit
itemsToGetFromEvent_
 
edm::SoATuple< TokenLookupInfo,
bool, LabelPlacement,
edm::KindOfType
m_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 43 of file EDConsumerBase.h.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

edm::EDConsumerBase::EDConsumerBase ( )
inline

Definition at line 47 of file EDConsumerBase.h.

47 : frozen_(false) {}
EDConsumerBase::~EDConsumerBase ( )
virtual

Definition at line 47 of file EDConsumerBase.cc.

48 {
49 }
edm::EDConsumerBase::EDConsumerBase ( const EDConsumerBase )
privatedelete

Member Function Documentation

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

Definition at line 75 of file EDConsumerBase.cc.

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

Referenced by consumes(), and mayConsume().

75  {
76  if (iTag.label().empty()) {
77  return kWasEmpty;
78  }
79  return iTag;
80 }
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 86 of file EDConsumerBase.h.

References checkIfEmpty(), and recordConsumes().

Referenced by TopElectronHLTOfflineSource::beginJob(), BTagPerformanceAnalyzerMC::BTagPerformanceAnalyzerMC(), BTagPerformanceAnalyzerOnData::BTagPerformanceAnalyzerOnData(), edm::ConsumesCollector::consumes(), reco::modules::DuplicateListMerger::DuplicateListMerger(), EcalPileUpDepMonitor::EcalPileUpDepMonitor(), cms::TrackListMerger::edTokens(), EGammaCutBasedEleIdAnalyzer::EGammaCutBasedEleIdAnalyzer(), EmDQMReco::EmDQMReco(), edm::EventContentAnalyzer::EventContentAnalyzer(), FastTrackMerger::FastTrackMerger(), EcalDQMonitorTask::formSchedule(), GoodSeedProducer::GoodSeedProducer(), HLTMuonIsoFilter::HLTMuonIsoFilter(), HLTMuonPFIsoFilter::HLTMuonPFIsoFilter(), JetTagProducer::JetTagProducer(), MixCollectionValidation::MixCollectionValidation(), MultiplicityCorrelator::MultiplicityCorrelator(), MuonProducer::MuonProducer(), MuonTrackValidator::MuonTrackValidator(), pat::PATElectronProducer::PATElectronProducer(), pat::PATGenericParticleProducer::PATGenericParticleProducer(), pat::PATMuonProducer::PATMuonProducer(), pat::PATPFParticleProducer::PATPFParticleProducer(), pat::PATPhotonProducer::PATPhotonProducer(), pat::PATSingleVertexSelector::PATSingleVertexSelector(), pat::PATTauProducer::PATTauProducer(), pat::PATVertexAssociationProducer::PATVertexAssociationProducer(), ReducedEGProducer::ReducedEGProducer(), SeedMultiplicityAnalyzer::SeedMultiplicityAnalyzer(), edm::OutputModule::selectProducts(), edm::one::OutputModuleBase::selectProducts(), SiStripMonitorDigi::SiStripMonitorDigi(), reco::modules::DuplicateListMerger::threeTokens(), TrackCandidateProducer::TrackCandidateProducer(), and TrackClusterRemover::TrackClusterRemover().

86  {
87  TypeToGet tid=TypeToGet::make<ProductType>();
88  return EDGetTokenT<ProductType>{recordConsumes(B,tid, checkIfEmpty(tag),true)};
89  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
EDGetToken edm::EDConsumerBase::consumes ( const TypeToGet id,
edm::InputTag const &  tag 
)
inlineprotected

Definition at line 91 of file EDConsumerBase.h.

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

91  {
92  return EDGetToken{recordConsumes(InEvent, id, checkIfEmpty(tag), true)};
93  }
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 96 of file EDConsumerBase.h.

References checkIfEmpty(), and recordConsumes().

96  {
97  return EDGetToken{recordConsumes(B, id, checkIfEmpty(tag), true)};
98  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
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 67 of file EDConsumerBase.cc.

References trackerHits::c.

Referenced by AlcaBeamMonitor::AlcaBeamMonitor(), AlcaBeamSpotProducer::AlcaBeamSpotProducer(), AlCaIsoTracksProducer::AlCaIsoTracksProducer(), IsolatedParticlesGeneratedJets::analyze(), BeamMonitor::BeamMonitor(), BeamMonitorBx::BeamMonitorBx(), BeamSpotAnalyzer::BeamSpotAnalyzer(), TSGFromL1Muon::beginRun(), FastTSGFromL2Muon::beginRun(), DTTrigTest::beginRun(), BTagHLTOfflineSource::BTagHLTOfflineSource(), pat::CandidateSummaryTable::CandidateSummaryTable(), CandIsoDepositProducer::CandIsoDepositProducer(), CandIsolatorFromDeposits::CandIsolatorFromDeposits(), ConfigurableAnalysis::ConfigurableAnalysis(), CorrectedMETProducerT< T >::CorrectedMETProducerT(), CosmicsMuonIdProducer::CosmicsMuonIdProducer(), CSCDigiValidation::CSCDigiValidation(), CSCMonitorModule::CSCMonitorModule(), CSCRecHitValidation::CSCRecHitValidation(), CtfSpecialSeedGenerator::CtfSpecialSeedGenerator(), edm::DataMixingModule::DataMixingModule(), DTTrigProd::DTTrigProd(), EcalCosmicsHists::EcalCosmicsHists(), EcalDQMonitorTask::EcalDQMonitorTask(), EcalRecHitProducer::EcalRecHitProducer(), EcalSelectiveReadoutValidation::EcalSelectiveReadoutValidation(), EcalUncalibRecHitProducer::EcalUncalibRecHitProducer(), EgammaHLTPixelMatchElectronProducers::EgammaHLTPixelMatchElectronProducers(), EgHLTOfflineSource::EgHLTOfflineSource(), ElectronSeedProducer::ElectronSeedProducer(), EopTreeWriter::EopTreeWriter(), EventWithHistoryEDFilter::EventWithHistoryEDFilter(), edm::FilterWrapper< T >::FilterWrapper(), FourVectorHLTOffline::FourVectorHLTOffline(), GEDPhotonProducer::GEDPhotonProducer(), GlobalCosmicMuonProducer::GlobalCosmicMuonProducer(), GlobalTrackQualityProducer::GlobalTrackQualityProducer(), HighPtTrackEcalDetIdProducer::HighPtTrackEcalDetIdProducer(), HLTAnalyzer::HLTAnalyzer(), HLTBitAnalyzer::HLTBitAnalyzer(), HLTExoticaValidator::HLTExoticaValidator(), HLTHiggsValidator::HLTHiggsValidator(), HLTMuonIsoFilter::HLTMuonIsoFilter(), HLTMuonValidator::HLTMuonValidator(), HLTTauDQMOfflineSource::HLTTauDQMOfflineSource(), InterestingTrackEcalDetIdProducer::InterestingTrackEcalDetIdProducer(), IsolatedTracksCone::IsolatedTracksCone(), JetMETHLTOfflineSource::JetMETHLTOfflineSource(), L1GlobalTrigger::L1GlobalTrigger(), L1MuGlobalMuonTrigger::L1MuGlobalMuonTrigger(), L2MuonIsolationProducer::L2MuonIsolationProducer(), L3MuonCombinedRelativeIsolationProducer::L3MuonCombinedRelativeIsolationProducer(), L3MuonIsolationProducer::L3MuonIsolationProducer(), LogMessageMonitor::LogMessageMonitor(), edm::MixingModule::MixingModule(), MultiplicityCorrelator::MultiplicityCorrelator(), MultiplicityInvestigator::MultiplicityInvestigator(), MultiplicityTimeCorrelations::MultiplicityTimeCorrelations(), MultiTrackValidator::MultiTrackValidator(), MuonAssociatorEDProducer::MuonAssociatorEDProducer(), MuonCaloCleanerAllCrossed::MuonCaloCleanerAllCrossed(), MuonCaloDistanceProducer::MuonCaloDistanceProducer(), MuonDetCleaner::MuonDetCleaner(), MuonIdProducer::MuonIdProducer(), cms::MuonMETValueMapProducer::MuonMETValueMapProducer(), MuonProducer::MuonProducer(), MuonSeedGenerator::MuonSeedGenerator(), MuonSeedProducer::MuonSeedProducer(), MuonShowerInformationProducer::MuonShowerInformationProducer(), MuonTimingProducer::MuonTimingProducer(), MuPFIsoEmbedder::MuPFIsoEmbedder(), pat::PATCleaner< PATObjType >::PATCleaner(), pat::PATCompositeCandidateProducer::PATCompositeCandidateProducer(), pat::PATMETProducer::PATMETProducer(), PFCandIsolatorFromDeposits::PFCandIsolatorFromDeposits(), PFRecHitProducer::PFRecHitProducer(), PFRecoTauChargedHadronProducer::PFRecoTauChargedHadronProducer(), PFRecoTauDiscriminationByNProngs::PFRecoTauDiscriminationByNProngs(), PFTauPrimaryVertexProducer::PFTauPrimaryVertexProducer(), PhotonConversionTrajectorySeedProducerFromQuadruplets::PhotonConversionTrajectorySeedProducerFromQuadruplets(), PhotonConversionTrajectorySeedProducerFromSingleLeg::PhotonConversionTrajectorySeedProducerFromSingleLeg(), PhotonProducer::PhotonProducer(), PixelTracksProducer::PixelTracksProducer(), PlottingDevice::PlottingDevice(), MuIsoDepositProducer::produce(), RecoTauPiZeroProducer::RecoTauPiZeroProducer(), RecoTauProducer::RecoTauProducer(), ReduceHcalRecHitCollectionProducer::ReduceHcalRecHitCollectionProducer(), SeedGeneratorFromRegionHitsEDProducer::SeedGeneratorFromRegionHitsEDProducer(), SeedMultiplicityAnalyzer::SeedMultiplicityAnalyzer(), SelectReplacementCandidates::SelectReplacementCandidates(), SETMuonSeedProducer::SETMuonSeedProducer(), SingleTopTChannelLeptonDQM::SingleTopTChannelLeptonDQM(), SiPixelRawToDigi::SiPixelRawToDigi(), SiStripDCSFilter::SiStripDCSFilter(), SiStripMonitorCluster::SiStripMonitorCluster(), SiStripMonitorDigi::SiStripMonitorDigi(), SiStripMonitorTrack::SiStripMonitorTrack(), TagProbeFitTreeProducer::TagProbeFitTreeProducer(), Tau3MuSkim::Tau3MuSkim(), TauTagValidation::TauTagValidation(), cms::TCMETProducer::TCMETProducer(), TopDiLeptonHLTOfflineDQM::TopDiLeptonHLTOfflineDQM(), TopDiLeptonOfflineDQM::TopDiLeptonOfflineDQM(), TopSingleLeptonDQM::TopSingleLeptonDQM(), TopSingleLeptonHLTOfflineDQM::TopSingleLeptonHLTOfflineDQM(), TrackerSeedValidator::TrackerSeedValidator(), TrackingMonitor::TrackingMonitor(), TriggerValidator::TriggerValidator(), TSGFromL1Muon::TSGFromL1Muon(), TSGFromL2Muon::TSGFromL2Muon(), TtDilepEvtSolutionMaker::TtDilepEvtSolutionMaker(), TtSemiEvtSolutionMaker::TtSemiEvtSolutionMaker(), Type2CorrectionProducer::Type2CorrectionProducer(), and V0Producer::V0Producer().

67  {
68  ConsumesCollector c{this};
69  return c;
70 }
template<typename ProductType , BranchType B = InEvent>
void edm::EDConsumerBase::consumesMany ( )
inlineprotected

Definition at line 116 of file EDConsumerBase.h.

Referenced by edm::ConsumesCollector::consumesMany().

116  {
117  TypeToGet tid=TypeToGet::make<ProductType>();
118  consumesMany<B>(tid);
119  }
void edm::EDConsumerBase::consumesMany ( const TypeToGet id)
inlineprotected

Definition at line 121 of file EDConsumerBase.h.

121  {
122  consumesMany<InEvent>(id);
123  }
template<BranchType B>
void edm::EDConsumerBase::consumesMany ( const TypeToGet id)
inlineprotected

Definition at line 126 of file EDConsumerBase.h.

References recordConsumes().

126  {
127  recordConsumes(B,id,edm::InputTag{},true);
128  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
ProductHolderIndexAndSkipBit EDConsumerBase::indexFrom ( EDGetToken  iToken,
BranchType  iBranch,
TypeID const &  iType 
) const

Definition at line 193 of file EDConsumerBase.cc.

References edm::EDGetToken::index(), info(), kLookupInfo, likely, m_tokenInfo, edm::ProductHolderIndexInvalid, throwBadToken(), throwBranchMismatch(), throwTypeMismatch(), and unlikely.

194 {
195  if(unlikely(iToken.index()>=m_tokenInfo.size())) {
196  throwBadToken(iType,iToken);
197  }
198  const auto& info = m_tokenInfo.get<kLookupInfo>(iToken.index());
199  if (likely(iBranch == info.m_branchType)) {
200  if (likely(iType == info.m_type)) {
201  return info.m_index;
202  } else {
203  throwTypeMismatch(iType, iToken);
204  }
205  } else {
206  throwBranchMismatch(iBranch,iToken);
207  }
209 }
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
#define unlikely(x)
Definition: Likely.h:21
void throwBranchMismatch(BranchType, EDGetToken) const
#define likely(x)
Definition: Likely.h:20
unsigned int index() const
Definition: EDGetToken.h:46
void EDConsumerBase::itemsMayGet ( BranchType  iBranch,
std::vector< ProductHolderIndexAndSkipBit > &  oIndices 
) const

Definition at line 248 of file EDConsumerBase.cc.

References prof2calltree::count, kAlwaysGets, kLookupInfo, m_tokenInfo, and edm::ProductHolderIndexInvalid.

249 {
250  //how many are we adding?
251  unsigned int count=0;
252  {
253  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
254  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
255  itEnd = m_tokenInfo.end<kLookupInfo>();
256  it != itEnd; ++it,++itAlwaysGet) {
257  if(iBranch==it->m_branchType) {
258  if (it->m_index.productHolderIndex() != ProductHolderIndexInvalid) {
259  if(not *itAlwaysGet) {
260  ++count;
261  }
262  }
263  }
264  }
265  }
266  oIndices.reserve(oIndices.size()+count);
267  {
268  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
269  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
270  itEnd = m_tokenInfo.end<kLookupInfo>();
271  it != itEnd; ++it,++itAlwaysGet) {
272  if(iBranch==it->m_branchType) {
273  if (it->m_index.productHolderIndex() != ProductHolderIndexInvalid) {
274  if(not *itAlwaysGet) {
275  oIndices.push_back(it->m_index);
276  }
277  }
278  }
279  }
280  }
281 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void EDConsumerBase::itemsToGet ( BranchType  iBranch,
std::vector< ProductHolderIndexAndSkipBit > &  oIndices 
) const

Definition at line 212 of file EDConsumerBase.cc.

References prof2calltree::count, kAlwaysGets, kLookupInfo, m_tokenInfo, and edm::ProductHolderIndexInvalid.

Referenced by updateLookup().

213 {
214  //how many are we adding?
215  unsigned int count=0;
216  {
217  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
218  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
219  itEnd = m_tokenInfo.end<kLookupInfo>();
220  it != itEnd; ++it,++itAlwaysGet) {
221  if(iBranch==it->m_branchType) {
222  if (it->m_index.productHolderIndex() != ProductHolderIndexInvalid) {
223  if(*itAlwaysGet) {
224  ++count;
225  }
226  }
227  }
228  }
229  }
230  oIndices.reserve(oIndices.size()+count);
231  {
232  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
233  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
234  itEnd = m_tokenInfo.end<kLookupInfo>();
235  it != itEnd; ++it,++itAlwaysGet) {
236  if(iBranch==it->m_branchType) {
237  if (it->m_index.productHolderIndex() != ProductHolderIndexInvalid) {
238  if(*itAlwaysGet) {
239  oIndices.push_back(it->m_index);
240  }
241  }
242  }
243  }
244  }
245 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
std::vector<ProductHolderIndexAndSkipBit> const& edm::EDConsumerBase::itemsToGetFromEvent ( ) const
inline

Definition at line 56 of file EDConsumerBase.h.

References itemsToGetFromEvent_.

56 { return itemsToGetFromEvent_; }
std::vector< ProductHolderIndexAndSkipBit > itemsToGetFromEvent_
void EDConsumerBase::labelsForToken ( EDGetToken  iToken,
Labels oLabels 
) const

Definition at line 284 of file EDConsumerBase.cc.

References edm::EDGetToken::index(), cmsHarvester::index, kLabels, tablePrinter::labels, m_tokenInfo, m_tokenLabels, edm::EDConsumerBase::Labels::module, edm::EDConsumerBase::Labels::process, edm::EDConsumerBase::Labels::productInstance, and dqm_diff::start.

Referenced by EgammaBasicClusters::analyze(), EnergyScaleAnalyzer::analyze(), HLTScalers::analyze(), EgammaObjects::analyzeElectrons(), EgammaObjects::analyzePhotons(), TkAlCaRecoMonitor::beginJob(), ElectronAnalyzer::book(), ElectronTagProbeAnalyzer::book(), TriggerRatesMonitor::dqmBeginRun(), EcalMIPRecHitFilter::filter(), MuonSimHitsValidAnalyzer::MuonSimHitsValidAnalyzer(), ReducedESRecHitCollectionProducer::produce(), ReducedRecHitCollectionProducer::produce(), TrackClusterRemover::produce(), and SeedClusterRemover::produce().

285 {
286  unsigned int index = iToken.index();
287  auto labels = m_tokenInfo.get<kLabels>(index);
288  unsigned int start = labels.m_startOfModuleLabel;
289  oLabels.module = &(m_tokenLabels[start]);
290  oLabels.productInstance = oLabels.module+labels.m_deltaToProductInstance;
291  oLabels.process = oLabels.module+labels.m_deltaToProcessName;
292 }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
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 101 of file EDConsumerBase.h.

References checkIfEmpty(), and recordConsumes().

Referenced by edm::ConsumesCollector::mayConsume(), and pat::PATJetProducer::PATJetProducer().

101  {
102  TypeToGet tid=TypeToGet::make<ProductType>();
103  return EDGetTokenT<ProductType>{recordConsumes(B, tid, checkIfEmpty(tag), false)};
104  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
EDGetToken edm::EDConsumerBase::mayConsume ( const TypeToGet id,
edm::InputTag const &  tag 
)
inlineprotected

Definition at line 106 of file EDConsumerBase.h.

References GlobalPosition_Frontier_DevDB_cff::tag.

106  {
107  return mayConsume<InEvent>(id,tag);
108  }
template<BranchType B>
EDGetToken edm::EDConsumerBase::mayConsume ( const TypeToGet id,
edm::InputTag const &  tag 
)
inlineprotected

Definition at line 111 of file EDConsumerBase.h.

References checkIfEmpty(), and recordConsumes().

111  {
112  return EDGetToken{recordConsumes(B,id,checkIfEmpty(tag),false)};
113  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
edm::InputTag const & checkIfEmpty(edm::InputTag const &tag)
void EDConsumerBase::modulesDependentUpon ( const std::string &  iProcessName,
std::vector< const char * > &  oModuleLabels 
) const

Definition at line 378 of file EDConsumerBase.cc.

References cmsHarvester::index, info(), kLabels, kLookupInfo, tablePrinter::labels, m_tokenInfo, m_tokenLabels, or, and dqm_diff::start.

381 {
382  std::set<const char*, CharStarComp> uniqueModules;
383  for(unsigned int index=0, iEnd=m_tokenInfo.size();index <iEnd; ++index) {
384  auto const& info = m_tokenInfo.get<kLookupInfo>(index);
385  if( not info.m_index.skipCurrentProcess() ) {
386  auto labels = m_tokenInfo.get<kLabels>(index);
387  unsigned int start = labels.m_startOfModuleLabel;
388  const char* processName = &(m_tokenLabels[start+labels.m_deltaToProcessName]);
389  if(processName or processName[0]==0 or
390  iProcessName == processName) {
391  uniqueModules.insert(&(m_tokenLabels[start]));
392  }
393  }
394  }
395 
396  oModuleLabels = std::vector<const char*>(uniqueModules.begin(),uniqueModules.end());
397 }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
static const TGPicture * info(bool iBackgroundIsBlack)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
std::vector< char > m_tokenLabels
const EDConsumerBase& edm::EDConsumerBase::operator= ( const EDConsumerBase )
privatedelete
unsigned int EDConsumerBase::recordConsumes ( BranchType  iBranch,
TypeToGet const &  iType,
edm::InputTag const &  iTag,
bool  iAlwaysGets 
)
private

Definition at line 83 of file EDConsumerBase.cc.

References frozen_, cmsHarvester::index, edm::InputTag::instance(), edm::TypeToGet::kind(), edm::InputTag::label(), m, m_tokenInfo, m_tokenLabels, edm::InputTag::process(), edm::ProductHolderIndexInvalid, AlCaHLTBitMon_QueryRunRegistry::string, throwConsumesCallAfterFrozen(), edm::TypeToGet::type(), and edm::InputTag::willSkipCurrentProcess().

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

83  {
84 
85  if(frozen_) {
86  throwConsumesCallAfterFrozen(iType, iTag);
87  }
88 
89  unsigned int index =m_tokenInfo.size();
90 
91  bool skipCurrentProcess = iTag.willSkipCurrentProcess();
92 
93  const size_t labelSize = iTag.label().size();
94  const size_t productInstanceSize = iTag.instance().size();
95  unsigned int labelStart = m_tokenLabels.size();
96  unsigned short delta1 = labelSize+1;
97  unsigned short delta2 = labelSize+2+productInstanceSize;
98  m_tokenInfo.emplace_back(TokenLookupInfo{iType.type(), ProductHolderIndexInvalid, skipCurrentProcess, iBranch},
99  iAlwaysGets,
100  LabelPlacement{labelStart,delta1,delta2},
101  iType.kind());
102 
103  const size_t additionalSize =
104  skipCurrentProcess ?
105  labelSize+productInstanceSize+3 :
106  labelSize+productInstanceSize+iTag.process().size()+3;
107 
108  m_tokenLabels.reserve(m_tokenLabels.size()+additionalSize);
109  {
110  const std::string& m =iTag.label();
111  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
112  m_tokenLabels.push_back('\0');
113  }
114  {
115  const std::string& m =iTag.instance();
116  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
117  m_tokenLabels.push_back('\0');
118  }
119  {
120  if (!skipCurrentProcess) {
121  const std::string& m =iTag.process();
122  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
123  m_tokenLabels.push_back('\0');
124  } else {
125  m_tokenLabels.push_back('\0');
126  }
127  }
128  return index;
129 }
void throwConsumesCallAfterFrozen(TypeToGet const &, InputTag const &) const
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
std::vector< char > m_tokenLabels
bool EDConsumerBase::registeredToConsume ( ProductHolderIndex  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 295 of file EDConsumerBase.cc.

References kLookupInfo, m_tokenInfo, and edm::PRODUCT_TYPE.

Referenced by edm::Principal::findProductByLabel().

296 {
297  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
298  itEnd = m_tokenInfo.end<kLookupInfo>();
299  it != itEnd; ++it) {
300  if(it->m_index.productHolderIndex() == iIndex and
301  it->m_index.skipCurrentProcess() == skipCurrentProcess and
302  it->m_branchType == iBranch) {
303  return true;
304  }
305  }
306  //TEMPORARY: Remember so we do not have to do this again
307  //non thread-safe
308  EDConsumerBase* nonConstThis = const_cast<EDConsumerBase*>(this);
309  nonConstThis->m_tokenInfo.emplace_back(TokenLookupInfo{TypeID{}, iIndex, skipCurrentProcess, iBranch},
310  true,
311  LabelPlacement{0,0,0},
312  PRODUCT_TYPE);
313 
314  return false;
315 }
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 318 of file EDConsumerBase.cc.

References kLookupInfo, m_tokenInfo, edm::PRODUCT_TYPE, and edm::ProductHolderIndexInvalid.

Referenced by edm::Principal::getManyByType().

319 {
320  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
321  itEnd = m_tokenInfo.end<kLookupInfo>();
322  it != itEnd; ++it) {
323  //consumesMany entries do not have their index resolved
324  if(it->m_index.productHolderIndex() == ProductHolderIndexInvalid and
325  it->m_type == iType and
326  it->m_branchType == iBranch) {
327  return true;
328  }
329  }
330  //TEMPORARY: Remember so we do not have to do this again
331  //non thread-safe
332  EDConsumerBase* nonConstThis = const_cast<EDConsumerBase*>(this);
333  nonConstThis->m_tokenInfo.emplace_back(TokenLookupInfo{iType,ProductHolderIndexInvalid, false, iBranch},
334  true,
335  LabelPlacement{0,0,0},
336  PRODUCT_TYPE);
337  return false;
338 
339 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void EDConsumerBase::throwBadToken ( edm::TypeID const &  iType,
EDGetToken  iToken 
) const
private

Definition at line 353 of file EDConsumerBase.cc.

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

Referenced by indexFrom().

354 {
355  if(iToken.isUninitialized()) {
356  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.";
357  }
358  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.";
359 }
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 348 of file EDConsumerBase.cc.

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

Referenced by indexFrom().

348  {
349  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.";
350 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
std::string const & BranchTypeToString(BranchType const &branchType)
Definition: BranchType.cc:98
unsigned int index() const
Definition: EDGetToken.h:46
void EDConsumerBase::throwConsumesCallAfterFrozen ( TypeToGet const &  typeToGet,
InputTag const &  inputTag 
) const
private

Definition at line 362 of file EDConsumerBase.cc.

References edm::hlt::Exception, and edm::TypeToGet::type().

Referenced by recordConsumes().

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

Definition at line 343 of file EDConsumerBase.cc.

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

Referenced by indexFrom().

344 {
345  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.";
346 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
unsigned int index() const
Definition: EDGetToken.h:46
void EDConsumerBase::updateLookup ( BranchType  iBranchType,
ProductHolderIndexHelper const &  iHelper 
)

Definition at line 132 of file EDConsumerBase.cc.

References frozen_, i, edm::ProductHolderIndexHelper::index(), cmsHarvester::index, edm::InEvent, info(), itemsToGet(), itemsToGetFromEvent_, j, kAlwaysGets, kKind, kLabels, kLookupInfo, tablePrinter::labels, m_tokenInfo, m_tokenLabels, edm::ProductHolderIndexInvalid, and edm::ProductHolderIndexHelper::relatedIndexes().

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

Friends And Related Function Documentation

friend class ConsumesCollector
friend

Definition at line 80 of file EDConsumerBase.h.

template<typename T >
friend class WillGetIfMatch
friend

Definition at line 81 of file EDConsumerBase.h.

Member Data Documentation

bool edm::EDConsumerBase::frozen_
private

Definition at line 178 of file EDConsumerBase.h.

Referenced by recordConsumes(), and updateLookup().

std::vector<ProductHolderIndexAndSkipBit> edm::EDConsumerBase::itemsToGetFromEvent_
private

Definition at line 176 of file EDConsumerBase.h.

Referenced by itemsToGetFromEvent(), and updateLookup().

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