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
 
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

 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 46 of file EDConsumerBase.cc.

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

Member Function Documentation

template<typename ProductType , BranchType B = InEvent>
EDGetTokenT<ProductType> edm::EDConsumerBase::consumes ( edm::InputTag const &  tag)
inlineprotected

Definition at line 83 of file EDConsumerBase.h.

References recordConsumes().

Referenced by BTagPerformanceAnalyzerMC::BTagPerformanceAnalyzerMC(), BTagPerformanceAnalyzerOnData::BTagPerformanceAnalyzerOnData(), edm::ConsumesCollector::consumes(), reco::modules::DuplicateListMerger::DuplicateListMerger(), cms::TrackListMerger::edTokens(), EGammaCutBasedEleIdAnalyzer::EGammaCutBasedEleIdAnalyzer(), EmDQMReco::EmDQMReco(), edm::EventContentAnalyzer::EventContentAnalyzer(), HLTHtMhtFilter::HLTHtMhtFilter(), HLTMuonIsoFilter::HLTMuonIsoFilter(), HLTMuonPFIsoFilter::HLTMuonPFIsoFilter(), JetTagProducer::JetTagProducer(), MixCollectionValidation::MixCollectionValidation(), 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(), edm::OutputModule::selectProducts(), edm::one::OutputModuleBase::selectProducts(), SiStripMonitorDigi::SiStripMonitorDigi(), reco::modules::DuplicateListMerger::threeTokens(), TopHLTDiLeptonOfflineDQM::TopHLTDiLeptonOfflineDQM(), TopHLTSingleLeptonDQM::TopHLTSingleLeptonDQM(), and TrackClusterRemover::TrackClusterRemover().

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

Definition at line 88 of file EDConsumerBase.h.

References edm::InEvent, and recordConsumes().

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

Definition at line 93 of file EDConsumerBase.h.

References recordConsumes().

93  {
94  return EDGetToken{recordConsumes(B, id, tag, true)};
95  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
ConsumesCollector EDConsumerBase::consumesCollector ( )
protected

Use a ConsumesCollector to gather consumes information from helper functions.

Definition at line 66 of file EDConsumerBase.cc.

References trackerHits::c.

Referenced by AlcaBeamMonitor::AlcaBeamMonitor(), AlcaBeamSpotProducer::AlcaBeamSpotProducer(), TopHLTSingleLeptonDQM::analyze(), SingleTopTChannelLeptonDQM::analyze(), TopHLTDiLeptonOfflineDQM::analyze(), BeamMonitor::BeamMonitor(), BeamMonitorBx::BeamMonitorBx(), BeamSpotAnalyzer::BeamSpotAnalyzer(), TSGFromL1Muon::beginRun(), pat::CandidateSummaryTable::CandidateSummaryTable(), CandIsoDepositProducer::CandIsoDepositProducer(), CandIsolatorFromDeposits::CandIsolatorFromDeposits(), ConfigurableAnalysis::ConfigurableAnalysis(), CorrectedMETProducerT< T >::CorrectedMETProducerT(), CosmicsMuonIdProducer::CosmicsMuonIdProducer(), CSCDigiValidation::CSCDigiValidation(), CSCMonitorModule::CSCMonitorModule(), CtfSpecialSeedGenerator::CtfSpecialSeedGenerator(), edm::DataMixingModule::DataMixingModule(), EcalRecHitProducer::EcalRecHitProducer(), EcalUncalibRecHitProducer::EcalUncalibRecHitProducer(), ElectronSeedProducer::ElectronSeedProducer(), GEDPhotonProducer::GEDPhotonProducer(), GlobalCosmicMuonProducer::GlobalCosmicMuonProducer(), HLTAnalyzer::HLTAnalyzer(), HLTBitAnalyzer::HLTBitAnalyzer(), HLTHiggsValidator::HLTHiggsValidator(), HLTMuonValidator::HLTMuonValidator(), HLTTauDQMOfflineSource::HLTTauDQMOfflineSource(), L2MuonIsolationProducer::L2MuonIsolationProducer(), L3MuonCombinedRelativeIsolationProducer::L3MuonCombinedRelativeIsolationProducer(), L3MuonIsolationProducer::L3MuonIsolationProducer(), LogMessageMonitor::LogMessageMonitor(), cms::METProducer::METProducer(), edm::MixingModule::MixingModule(), MultiTrackValidator::MultiTrackValidator(), MuonIdProducer::MuonIdProducer(), MuonProducer::MuonProducer(), MuonSeedGenerator::MuonSeedGenerator(), MuonSeedProducer::MuonSeedProducer(), MuonShowerInformationProducer::MuonShowerInformationProducer(), MuonTimingProducer::MuonTimingProducer(), MuPFIsoEmbedder::MuPFIsoEmbedder(), pat::PATCleaner< PATObjType >::PATCleaner(), pat::PATCompositeCandidateProducer::PATCompositeCandidateProducer(), pat::PATMETProducer::PATMETProducer(), PFCandIsolatorFromDeposits::PFCandIsolatorFromDeposits(), PFRecoTauChargedHadronProducer::PFRecoTauChargedHadronProducer(), PhotonConversionTrajectorySeedProducerFromQuadruplets::PhotonConversionTrajectorySeedProducerFromQuadruplets(), PhotonConversionTrajectorySeedProducerFromSingleLeg::PhotonConversionTrajectorySeedProducerFromSingleLeg(), PixelTracksProducer::PixelTracksProducer(), MuIsoDepositProducer::produce(), RecoTauPiZeroProducer::RecoTauPiZeroProducer(), RecoTauProducer::RecoTauProducer(), SeedGeneratorFromRegionHitsEDProducer::SeedGeneratorFromRegionHitsEDProducer(), SETMuonSeedProducer::SETMuonSeedProducer(), SiPixelRawToDigi::SiPixelRawToDigi(), SiStripMonitorCluster::SiStripMonitorCluster(), TagProbeFitTreeProducer::TagProbeFitTreeProducer(), TauTagValidation::TauTagValidation(), cms::TCMETProducer::TCMETProducer(), TopDiLeptonOfflineDQM::TopDiLeptonOfflineDQM(), TopSingleLeptonDQM::TopSingleLeptonDQM(), TrackerSeedValidator::TrackerSeedValidator(), TrackingMonitor::TrackingMonitor(), TriggerValidator::TriggerValidator(), TSGFromL1Muon::TSGFromL1Muon(), TSGFromL2Muon::TSGFromL2Muon(), TtDilepEvtSolutionMaker::TtDilepEvtSolutionMaker(), TtSemiEvtSolutionMaker::TtSemiEvtSolutionMaker(), Type2CorrectionProducer::Type2CorrectionProducer(), and V0Producer::V0Producer().

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

Definition at line 113 of file EDConsumerBase.h.

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

113  {
114  TypeToGet tid=TypeToGet::make<ProductType>();
115  consumesMany<B>(tid);
116  }
void edm::EDConsumerBase::consumesMany ( const TypeToGet id)
inlineprotected

Definition at line 118 of file EDConsumerBase.h.

118  {
119  consumesMany<InEvent>(id);
120  }
template<BranchType B>
void edm::EDConsumerBase::consumesMany ( const TypeToGet id)
inlineprotected

Definition at line 123 of file EDConsumerBase.h.

References recordConsumes().

123  {
124  recordConsumes(B,id,edm::InputTag{},true);
125  }
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 183 of file EDConsumerBase.cc.

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

184 {
185  if(unlikely(iToken.index()>=m_tokenInfo.size())) {
186  throwBadToken(iType,iToken);
187  }
188  const auto& info = m_tokenInfo.get<kLookupInfo>(iToken.index());
189  if (likely(iBranch == info.m_branchType)) {
190  if (likely(iType == info.m_type)) {
191  return info.m_index;
192  } else {
193  throwTypeMismatch(iType, iToken);
194  }
195  } else {
196  throwBranchMismatch(iBranch,iToken);
197  }
199 }
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 238 of file EDConsumerBase.cc.

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

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

Definition at line 202 of file EDConsumerBase.cc.

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

Referenced by updateLookup().

203 {
204  //how many are we adding?
205  unsigned int count=0;
206  {
207  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
208  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
209  itEnd = m_tokenInfo.end<kLookupInfo>();
210  it != itEnd; ++it,++itAlwaysGet) {
211  if(iBranch==it->m_branchType) {
212  if (it->m_index.productHolderIndex() != ProductHolderIndexInvalid) {
213  if(*itAlwaysGet) {
214  ++count;
215  }
216  }
217  }
218  }
219  }
220  oIndices.reserve(oIndices.size()+count);
221  {
222  auto itAlwaysGet = m_tokenInfo.begin<kAlwaysGets>();
223  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
224  itEnd = m_tokenInfo.end<kLookupInfo>();
225  it != itEnd; ++it,++itAlwaysGet) {
226  if(iBranch==it->m_branchType) {
227  if (it->m_index.productHolderIndex() != ProductHolderIndexInvalid) {
228  if(*itAlwaysGet) {
229  oIndices.push_back(it->m_index);
230  }
231  }
232  }
233  }
234  }
235 }
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 274 of file EDConsumerBase.cc.

References edm::EDGetToken::index(), getHLTprescales::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 EgammaObjects::analyzeElectrons(), EgammaObjects::analyzePhotons(), TkAlCaRecoMonitor::beginJob(), ElectronAnalyzer::book(), ElectronTagProbeAnalyzer::book(), EcalMIPRecHitFilter::filter(), MuonSimHitsValidAnalyzer::MuonSimHitsValidAnalyzer(), ReducedESRecHitCollectionProducer::produce(), ReducedRecHitCollectionProducer::produce(), TrackClusterRemover::produce(), and SeedClusterRemover::produce().

275 {
276  unsigned int index = iToken.index();
277  auto labels = m_tokenInfo.get<kLabels>(index);
278  unsigned int start = labels.m_startOfModuleLabel;
279  oLabels.module = &(m_tokenLabels[start]);
280  oLabels.productInstance = oLabels.module+labels.m_deltaToProductInstance;
281  oLabels.process = oLabels.module+labels.m_deltaToProcessName;
282 }
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 98 of file EDConsumerBase.h.

References recordConsumes().

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

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

Definition at line 103 of file EDConsumerBase.h.

References GlobalPosition_Frontier_DevDB_cff::tag.

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

Definition at line 108 of file EDConsumerBase.h.

References recordConsumes().

108  {
109  return EDGetToken{recordConsumes(B,id,tag,false)};
110  }
unsigned int recordConsumes(BranchType iBranch, TypeToGet const &iType, edm::InputTag const &iTag, bool iAlwaysGets)
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 73 of file EDConsumerBase.cc.

References frozen_, getHLTprescales::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().

73  {
74 
75  if(frozen_) {
76  throwConsumesCallAfterFrozen(iType, iTag);
77  }
78 
79  unsigned int index =m_tokenInfo.size();
80 
81  bool skipCurrentProcess = iTag.willSkipCurrentProcess();
82 
83  const size_t labelSize = iTag.label().size();
84  const size_t productInstanceSize = iTag.instance().size();
85  unsigned int labelStart = m_tokenLabels.size();
86  unsigned short delta1 = labelSize+1;
87  unsigned short delta2 = labelSize+2+productInstanceSize;
88  m_tokenInfo.emplace_back(TokenLookupInfo{iType.type(), ProductHolderIndexInvalid, skipCurrentProcess, iBranch},
89  iAlwaysGets,
90  LabelPlacement{labelStart,delta1,delta2},
91  iType.kind());
92 
93  const size_t additionalSize =
94  skipCurrentProcess ?
95  labelSize+productInstanceSize+3 :
96  labelSize+productInstanceSize+iTag.process().size()+3;
97 
98  m_tokenLabels.reserve(m_tokenLabels.size()+additionalSize);
99  {
100  const std::string& m =iTag.label();
101  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
102  m_tokenLabels.push_back('\0');
103  }
104  {
105  const std::string& m =iTag.instance();
106  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
107  m_tokenLabels.push_back('\0');
108  }
109  {
110  if (!skipCurrentProcess) {
111  const std::string& m =iTag.process();
112  m_tokenLabels.insert(m_tokenLabels.end(),m.begin(),m.end());
113  m_tokenLabels.push_back('\0');
114  } else {
115  m_tokenLabels.push_back('\0');
116  }
117  }
118  return index;
119 }
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 285 of file EDConsumerBase.cc.

References kLookupInfo, m_tokenInfo, and edm::PRODUCT_TYPE.

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

286 {
287  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
288  itEnd = m_tokenInfo.end<kLookupInfo>();
289  it != itEnd; ++it) {
290  if(it->m_index.productHolderIndex() == iIndex and
291  it->m_index.skipCurrentProcess() == skipCurrentProcess and
292  it->m_branchType == iBranch) {
293  return true;
294  }
295  }
296  //TEMPORARY: Remember so we do not have to do this again
297  //non thread-safe
298  EDConsumerBase* nonConstThis = const_cast<EDConsumerBase*>(this);
299  nonConstThis->m_tokenInfo.emplace_back(TokenLookupInfo{TypeID{}, iIndex, skipCurrentProcess, iBranch},
300  true,
301  LabelPlacement{0,0,0},
302  PRODUCT_TYPE);
303 
304  return false;
305 }
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 308 of file EDConsumerBase.cc.

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

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

309 {
310  for(auto it = m_tokenInfo.begin<kLookupInfo>(),
311  itEnd = m_tokenInfo.end<kLookupInfo>();
312  it != itEnd; ++it) {
313  //consumesMany entries do not have their index resolved
314  if(it->m_index.productHolderIndex() == ProductHolderIndexInvalid and
315  it->m_type == iType and
316  it->m_branchType == iBranch) {
317  return true;
318  }
319  }
320  //TEMPORARY: Remember so we do not have to do this again
321  //non thread-safe
322  EDConsumerBase* nonConstThis = const_cast<EDConsumerBase*>(this);
323  nonConstThis->m_tokenInfo.emplace_back(TokenLookupInfo{iType,ProductHolderIndexInvalid, false, iBranch},
324  true,
325  LabelPlacement{0,0,0},
326  PRODUCT_TYPE);
327  return false;
328 
329 }
edm::SoATuple< TokenLookupInfo, bool, LabelPlacement, edm::KindOfType > m_tokenInfo
void EDConsumerBase::throwBadToken ( 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(), and edm::EDGetToken::isUninitialized().

Referenced by indexFrom().

344 {
345  if(iToken.isUninitialized()) {
346  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.";
347  }
348  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.";
349 }
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 338 of file EDConsumerBase.cc.

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

Referenced by indexFrom().

338  {
339  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.";
340 }
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 352 of file EDConsumerBase.cc.

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

Referenced by recordConsumes().

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

Definition at line 333 of file EDConsumerBase.cc.

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

Referenced by indexFrom().

334 {
335  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.";
336 }
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 122 of file EDConsumerBase.cc.

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

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

template<typename T >
friend class WillGetIfMatch
friend

Definition at line 78 of file EDConsumerBase.h.

Member Data Documentation

bool edm::EDConsumerBase::frozen_
private

Definition at line 174 of file EDConsumerBase.h.

Referenced by recordConsumes(), and updateLookup().

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

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

Definition at line 170 of file EDConsumerBase.h.

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