CMS 3D CMS Logo

pfTracksProducer.cc
Go to the documentation of this file.
6 
10 
13 
19 
21 public:
22  explicit pfTracksProducer(const edm::ParameterSet& iConfig)
23  : PFCands_(consumes<std::vector<pat::PackedCandidate>>(iConfig.getParameter<edm::InputTag>("PFCands"))),
24  LostTracks_(consumes<std::vector<pat::PackedCandidate>>(iConfig.getParameter<edm::InputTag>("lostTracks"))),
25  trkSelection_(iConfig.getParameter<std::string>("trkSelection")),
26  HighPurity_(iConfig.getParameter<bool>("TrkHPurity")) {
27  produces<reco::TrackCollection>();
28  }
29  ~pfTracksProducer() override {}
30 
31 private:
32  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
33 
37  const bool HighPurity_;
38 };
39 
42  iEvent.getByToken(PFCands_, pfcands);
43 
45  iEvent.getByToken(LostTracks_, lostTracks);
46 
47  std::unique_ptr<std::vector<reco::Track>> tracks(new std::vector<reco::Track>());
48  tracks->reserve(pfcands->size() + lostTracks->size());
49 
50  for (const auto& container : {pfcands, lostTracks}) {
51  for (const pat::PackedCandidate& trk : *container) {
52  if (!trk.hasTrackDetails())
53  continue;
54  if (!trkSelection_(trk))
55  continue;
56  if (HighPurity_ && !trk.trackHighPurity())
57  continue;
58  tracks->emplace_back(*trk.bestTrack());
59  }
60  }
61 
62  iEvent.put(std::move(tracks));
63 }
64 
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
pfTracksProducer(const edm::ParameterSet &iConfig)
edm::EDGetToken LostTracks_
~pfTracksProducer() override
Definition: HeavyIon.h:7
int iEvent
Definition: GenABIO.cc:224
const StringCutObjectSelector< pat::PackedCandidate > trkSelection_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HLT enums.
edm::EDGetToken PFCands_
const bool HighPurity_
def move(src, dest)
Definition: eostools.py:511