CMS 3D CMS Logo

TrackingParticleBHadronRefSelector.cc
Go to the documentation of this file.
7 
11 
13 
14 #include "HepPDT/ParticleID.hh"
15 
17 public:
19 
20  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
21 
22  void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override;
23 
24 private:
26 
28 };
29 
31  : tpToken_(consumes<TrackingParticleCollection>(iConfig.getParameter<edm::InputTag>("src"))) {
32  tracer_.depth(-2); // as in SimTracker/TrackHistory/src/TrackClassifier.cc
33 
34  produces<TrackingParticleRefVector>();
35 }
36 
39  desc.add<edm::InputTag>("src", edm::InputTag("mix", "MergedTrackTruth"));
40  descriptions.add("trackingParticleBHadronRefSelectorDefault", desc);
41 }
42 
45  iEvent.getByToken(tpToken_, h_tps);
46 
47  auto ret = std::make_unique<TrackingParticleRefVector>();
48 
49  // Logic is similar to SimTracker/TrackHistory
50  for (size_t i = 0, end = h_tps->size(); i < end; ++i) {
51  auto tpRef = TrackingParticleRef(h_tps, i);
52  if (tracer_.evaluate(tpRef)) { // ignore TP if history can not be traced
53  // following is from TrackClassifier::processesAtGenerator()
54  HistoryBase::RecoGenParticleTrail const &recoGenParticleTrail = tracer_.recoGenParticleTrail();
55  for (const auto &particle : recoGenParticleTrail) {
56  HepPDT::ParticleID particleID(particle->pdgId());
57  if (particleID.hasBottom()) {
58  ret->push_back(tpRef);
59  break;
60  }
61  }
62  }
63  }
64 
65  iEvent.put(std::move(ret));
66 }
67 
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ret
prodAgent to be discontinued
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
std::vector< const reco::GenParticle * > RecoGenParticleTrail
reco::GenParticle trail type.
Definition: HistoryBase.h:18
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< TrackingParticleCollection > tpToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackingParticleBHadronRefSelector(const edm::ParameterSet &iConfig)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Base class to all the history types.
Definition: HistoryBase.h:12
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: HistoryBase.h:96
HLT enums.
void depth(int d)
Set the depth of the history.
Definition: HistoryBase.h:49
RecoGenParticleTrail const & recoGenParticleTrail() const
Return all reco::GenParticle in the history.
Definition: HistoryBase.h:64
std::vector< TrackingParticle > TrackingParticleCollection
edm::Ref< TrackingParticleCollection > TrackingParticleRef
def move(src, dest)
Definition: eostools.py:511