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

std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 48 of file EDConsumerBase.h.

Member Enumeration Documentation

anonymous enum
private

Constructor & Destructor Documentation

edm::EDConsumerBase::EDConsumerBase ( )
inline

Definition at line 52 of file EDConsumerBase.h.

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

Definition at line 51 of file EDConsumerBase.cc.

52 {
53 }
edm::EDConsumerBase::EDConsumerBase ( const EDConsumerBase )
privatedelete

Member Function Documentation

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

Definition at line 79 of file EDConsumerBase.cc.

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

Referenced by consumes(), and mayConsume().

79  {
80  if (iTag.label().empty()) {
81  return kWasEmpty;
82  }
83  return iTag;
84 }
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 98 of file EDConsumerBase.h.

References checkIfEmpty(), and recordConsumes().

Referenced by MixCollectionValidation::bookHistograms(), BTagPerformanceAnalyzerMC::BTagPerformanceAnalyzerMC(), BTagPerformanceAnalyzerOnData::BTagPerformanceAnalyzerOnData(), edm::ConsumesCollector::consumes(), EcalPileUpDepMonitor::EcalPileUpDepMonitor(), EGammaCutBasedEleIdAnalyzer::EGammaCutBasedEleIdAnalyzer(), EmDQMReco::EmDQMReco(), edm::EventContentAnalyzer::EventContentAnalyzer(), EcalDQMonitorTask::formSchedule(), GoodSeedProducer::GoodSeedProducer(), HITrackClusterRemover::HITrackClusterRemover(), HLTMuonIsoFilter::HLTMuonIsoFilter(), HLTMuonPFIsoFilter::HLTMuonPFIsoFilter(), JetTagProducer::JetTagProducer(), edm::OutputModule::keepThisBranch(), edm::one::OutputModuleBase::keepThisBranch(), cms::METSignificanceProducer::METSignificanceProducer(), MultiplicityCorrelator::MultiplicityCorrelator(), MuonProducer::MuonProducer(), MuonTrackValidator::MuonTrackValidator(), NoPileUpPFMEtProducer::NoPileUpPFMEtProducer(), pat::PATElectronProducer::PATElectronProducer(), pat::PATGenericParticleProducer::PATGenericParticleProducer(), pat::PATMuonProducer::PATMuonProducer(), pat::PATPFParticleProducer::PATPFParticleProducer(), pat::PATPhotonProducer::PATPhotonProducer(), pat::PATSingleVertexSelector::PATSingleVertexSelector(), pat::PATTauProducer::PATTauProducer(), pat::PATVertexAssociationProducer::PATVertexAssociationProducer(), PFTrackProducer::PFTrackProducer(), ReducedEGProducer::ReducedEGProducer(), SeedMultiplicityAnalyzer::SeedMultiplicityAnalyzer(), SiStripMonitorDigi::SiStripMonitorDigi(), and TrajectorySeedProducer::TrajectorySeedProducer().

98  {
99  TypeToGet tid=TypeToGet::make<ProductType>();
100  return EDGetTokenT<ProductType>{recordConsumes(B,tid, checkIfEmpty(tag),true)};
101  }
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 103 of file EDConsumerBase.h.

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

103  {
104  return EDGetToken{recordConsumes(InEvent, id, checkIfEmpty(tag), true)};
105  }
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 108 of file EDConsumerBase.h.

References checkIfEmpty(), and recordConsumes().

108  {
109  return EDGetToken{recordConsumes(B, id, checkIfEmpty(tag), true)};
110  }
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 71 of file EDConsumerBase.cc.

References EnergyCorrector::c.

Referenced by AlcaBeamMonitor::AlcaBeamMonitor(), AlcaBeamSpotProducer::AlcaBeamSpotProducer(), AlCaIsoTracksProducer::AlCaIsoTracksProducer(), IsolatedParticlesGeneratedJets::analyze(), BeamMonitor::BeamMonitor(), BeamMonitorBx::BeamMonitorBx(), BeamSpotAnalyzer::BeamSpotAnalyzer(), TSGFromL1Muon::beginRun(), FastTSGFromL2Muon::beginRun(), DTTrigTest::beginRun(), pat::CandidateSummaryTable::CandidateSummaryTable(), CandIsoDepositProducer::CandIsoDepositProducer(), CandIsolatorFromDeposits::CandIsolatorFromDeposits(), ConfigurableAnalysis::ConfigurableAnalysis(), CorrectedECALPFClusterProducer::CorrectedECALPFClusterProducer(), 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(), FSQDiJetAve::FSQDiJetAve(), 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(), JetCorrectorProducer< T >::JetCorrectorProducer(), JetMETHLTOfflineSource::JetMETHLTOfflineSource(), L1GlobalTrigger::L1GlobalTrigger(), L1MuGlobalMuonTrigger::L1MuGlobalMuonTrigger(), l1t::L1TDigiToRaw::L1TDigiToRaw(), 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(), MuonToTrackingParticleAssociatorEDProducer::MuonToTrackingParticleAssociatorEDProducer(), MuPFIsoEmbedder::MuPFIsoEmbedder(), OscarMTProducer::OscarMTProducer(), 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(), QuickTrackAssociatorByHitsProducer::QuickTrackAssociatorByHitsProducer(), 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(), TrackAssociatorByHitsProducer::TrackAssociatorByHitsProducer(), TrackerSeedValidator::TrackerSeedValidator(), TrackingMonitor::TrackingMonitor(), TriggerValidator::TriggerValidator(), TSGFromL1Muon::TSGFromL1Muon(), TSGFromL2Muon::TSGFromL2Muon(), TtDilepEvtSolutionMaker::TtDilepEvtSolutionMaker(), TtSemiEvtSolutionMaker::TtSemiEvtSolutionMaker(), Type2CorrectionProducer::Type2CorrectionProducer(), and VirtualJetProducer::VirtualJetProducer().

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

Definition at line 501 of file EDConsumerBase.cc.

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

501  {
502 
503  // Use this to eliminate duplicate entries related
504  // to consumesMany items where only the type was specified
505  // and the there are multiple matches. In these cases the
506  // label, instance, and process will be empty.
507  std::set<edm::TypeID> alreadySeenTypes;
508 
509  std::vector<ConsumesInfo> result;
510  auto itAlways = m_tokenInfo.begin<kAlwaysGets>();
511  auto itKind = m_tokenInfo.begin<kKind>();
512  auto itLabels = m_tokenInfo.begin<kLabels>();
513  for(auto itInfo = m_tokenInfo.begin<kLookupInfo>(),itEnd = m_tokenInfo.end<kLookupInfo>();
514  itInfo != itEnd; ++itInfo,++itKind,++itLabels, ++itAlways) {
515 
516  const unsigned int labelStart = itLabels->m_startOfModuleLabel;
517  const char* consumedModuleLabel = &(m_tokenLabels[labelStart]);
518  const char* consumedInstance = consumedModuleLabel+itLabels->m_deltaToProductInstance;
519  const char* consumedProcessName = consumedModuleLabel+itLabels->m_deltaToProcessName;
520 
521  // consumesMany case
522  if(*consumedModuleLabel == '\0') {
523  if(!alreadySeenTypes.insert(itInfo->m_type).second) {
524  continue;
525  }
526  }
527 
528  // Just copy the information into the ConsumesInfo data structure
529  result.emplace_back(itInfo->m_type,
530  consumedModuleLabel,
531  consumedInstance,
532  consumedProcessName,
533  itInfo->m_branchType,
534  *itKind,
535  *itAlways,
536  itInfo->m_index.skipCurrentProcess());
537  }
538  return result;
539 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
tuple result
Definition: query.py:137
std::vector< char > m_tokenLabels
template<typename ProductType , BranchType B = InEvent>
void edm::EDConsumerBase::consumesMany ( )
inlineprotected

Definition at line 128 of file EDConsumerBase.h.

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

128  {
129  TypeToGet tid=TypeToGet::make<ProductType>();
130  consumesMany<B>(tid);
131  }
void edm::EDConsumerBase::consumesMany ( const TypeToGet id)
inlineprotected

Definition at line 133 of file EDConsumerBase.h.

133  {
134  consumesMany<InEvent>(id);
135  }
template<BranchType B>
void edm::EDConsumerBase::consumesMany ( const TypeToGet id)
inlineprotected

Definition at line 138 of file EDConsumerBase.h.

References recordConsumes().

138  {
139  recordConsumes(B,id,edm::InputTag{},true);
140  }
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 197 of file EDConsumerBase.cc.

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

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

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

Definition at line 252 of file EDConsumerBase.cc.

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

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

Definition at line 216 of file EDConsumerBase.cc.

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

Referenced by updateLookup().

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

Definition at line 61 of file EDConsumerBase.h.

References itemsToGetFromEvent_.

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

Definition at line 288 of file EDConsumerBase.cc.

References edm::EDGetToken::index(), cmsHarvester::index, kLabels, HLT_25ns14e33_v1_cff::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(), ElectronTagProbeAnalyzer::bookHistograms(), TkAlCaRecoMonitor::bookHistograms(), ElectronAnalyzer::bookHistograms(), TriggerRatesMonitor::dqmBeginRun(), edm::PrincipalGetAdapter::makeFailToGetException(), MuonSimHitsValidAnalyzer::MuonSimHitsValidAnalyzer(), ReducedESRecHitCollectionProducer::produce(), ReducedRecHitCollectionProducer::produce(), SeedClusterRemover::produce(), HITrackClusterRemover::produce(), cms::CosmicTrackFinder::produce(), and edm::PrincipalGetAdapter::throwAmbiguousException().

289 {
290  unsigned int index = iToken.index();
291  auto labels = m_tokenInfo.get<kLabels>(index);
292  unsigned int start = labels.m_startOfModuleLabel;
293  oLabels.module = &(m_tokenLabels[start]);
294  oLabels.productInstance = oLabels.module+labels.m_deltaToProductInstance;
295  oLabels.process = oLabels.module+labels.m_deltaToProcessName;
296 }
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 113 of file EDConsumerBase.h.

References checkIfEmpty(), and recordConsumes().

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

113  {
114  TypeToGet tid=TypeToGet::make<ProductType>();
115  return EDGetTokenT<ProductType>{recordConsumes(B, tid, checkIfEmpty(tag), false)};
116  }
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 118 of file EDConsumerBase.h.

References GlobalPosition_Frontier_DevDB_cff::tag.

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

Definition at line 123 of file EDConsumerBase.h.

References checkIfEmpty(), and recordConsumes().

123  {
124  return EDGetToken{recordConsumes(B,id,checkIfEmpty(tag),false)};
125  }
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 382 of file EDConsumerBase.cc.

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

383  {
384  std::set<const char*, CharStarComp> uniqueModules;
385  for(unsigned int index=0, iEnd=m_tokenInfo.size();index <iEnd; ++index) {
386  auto const& info = m_tokenInfo.get<kLookupInfo>(index);
387  if( not info.m_index.skipCurrentProcess() ) {
388  auto labels = m_tokenInfo.get<kLabels>(index);
389  unsigned int start = labels.m_startOfModuleLabel;
390  const char* processName = &(m_tokenLabels[start+labels.m_deltaToProcessName]);
391  if( (not processName) or processName[0]==0 or
392  iProcessName == processName) {
393  uniqueModules.insert(&(m_tokenLabels[start]));
394  }
395  }
396  }
397 
398  oModuleLabels = std::vector<const char*>(uniqueModules.begin(),uniqueModules.end());
399 }
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
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 445 of file EDConsumerBase.cc.

References edm::ProductHolderIndexHelper::index(), edm::InEvent, j, kKind, kLabels, kLookupInfo, m_tokenInfo, m_tokenLabels, edmConvertToStreamModule::modules, edm::preg, edm::ProductHolderIndexInvalid, edm::ProductRegistry::productLookup(), and edm::ProductHolderIndexHelper::relatedIndexes().

448  {
449 
450  ProductHolderIndexHelper const& iHelper = *preg.productLookup(InEvent);
451 
452  std::set<std::string> alreadyFound;
453 
454  auto itKind = m_tokenInfo.begin<kKind>();
455  auto itLabels = m_tokenInfo.begin<kLabels>();
456  for(auto itInfo = m_tokenInfo.begin<kLookupInfo>(),itEnd = m_tokenInfo.end<kLookupInfo>();
457  itInfo != itEnd; ++itInfo,++itKind,++itLabels) {
458 
459  if(itInfo->m_branchType == InEvent) {
460 
461  const unsigned int labelStart = itLabels->m_startOfModuleLabel;
462  const char* consumedModuleLabel = &(m_tokenLabels[labelStart]);
463  const char* consumedProcessName = consumedModuleLabel+itLabels->m_deltaToProcessName;
464 
465  if(*consumedModuleLabel != '\0') { // not a consumesMany
466  if(*consumedProcessName != '\0') { // process name is specified in consumes call
467  if (processName == consumedProcessName &&
468  iHelper.index(*itKind,
469  itInfo->m_type,
470  consumedModuleLabel,
471  consumedModuleLabel+itLabels->m_deltaToProductInstance,
472  consumedModuleLabel+itLabels->m_deltaToProcessName) != ProductHolderIndexInvalid) {
473  insertFoundModuleLabel(consumedModuleLabel, modules, alreadyFound, labelsToDesc, preg);
474  }
475  } else { // process name was empty
476  auto matches = iHelper.relatedIndexes(*itKind,
477  itInfo->m_type,
478  consumedModuleLabel,
479  consumedModuleLabel+itLabels->m_deltaToProductInstance);
480  for(unsigned int j = 0; j < matches.numberOfMatches(); ++j) {
481  if(processName == matches.processName(j)) {
482  insertFoundModuleLabel(consumedModuleLabel, modules, alreadyFound, labelsToDesc, preg);
483  }
484  }
485  }
486  // consumesMany case
487  } else if(itInfo->m_index.productHolderIndex() == ProductHolderIndexInvalid) {
488  auto matches = iHelper.relatedIndexes(*itKind,
489  itInfo->m_type);
490  for(unsigned int j = 0; j < matches.numberOfMatches(); ++j) {
491  if(processName == matches.processName(j)) {
492  insertFoundModuleLabel(matches.moduleLabel(j), modules, alreadyFound, labelsToDesc, preg);
493  }
494  }
495  }
496  }
497  }
498 }
Matches relatedIndexes(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance) const
ProductHolderIndex index(KindOfType kindOfType, TypeID const &typeID, char const *moduleLabel, char const *instance, char const *process=0) const
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
int j
Definition: DBlmapReader.cc:9
std::vector< char > m_tokenLabels
preg
Definition: Schedule.cc:370
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 87 of file EDConsumerBase.cc.

References frozen_, cmsHarvester::index, edm::InputTag::instance(), edm::TypeToGet::kind(), edm::InputTag::label(), contentValuesFiles::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().

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

References kLookupInfo, m_tokenInfo, and edm::PRODUCT_TYPE.

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

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

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

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

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

Definition at line 357 of file EDConsumerBase.cc.

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

Referenced by indexFrom().

358 {
359  if(iToken.isUninitialized()) {
360  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.";
361  }
362  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.";
363 }
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 352 of file EDConsumerBase.cc.

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

Referenced by indexFrom().

352  {
353  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.";
354 }
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 366 of file EDConsumerBase.cc.

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

Referenced by recordConsumes().

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

Definition at line 347 of file EDConsumerBase.cc.

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

Referenced by indexFrom().

348 {
349  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.";
350 }
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 136 of file EDConsumerBase.cc.

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

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

template<typename T >
friend class WillGetIfMatch
friend

Definition at line 93 of file EDConsumerBase.h.

Member Data Documentation

bool edm::EDConsumerBase::frozen_
private

Definition at line 190 of file EDConsumerBase.h.

Referenced by recordConsumes(), and updateLookup().

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

Definition at line 188 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