CMS 3D CMS Logo

IsolationProducerForTracks.cc
Go to the documentation of this file.
10 
12 public:
14 
15 private:
16  void produce(edm::StreamID, edm::Event& event, const edm::EventSetup& setup) const override;
17 
21  const double trackPtMin_;
22  const double coneSize_;
23 };
24 
29 #include <iostream>
30 #include <iterator>
31 #include <vector>
32 
33 using namespace edm;
34 using namespace reco;
35 
37 
39  : tracksToken_(consumes<CandidateView>(pset.getParameter<InputTag>("tracks"))),
40  highPtTracksToken_(consumes<CandidateView>(pset.getParameter<InputTag>("highPtTracks"))),
41  isoDepsToken_(consumes<IsoDepositMap>(pset.getParameter<InputTag>("isoDeps"))),
42  trackPtMin_(pset.getParameter<double>("trackPtMin")),
43  coneSize_(pset.getParameter<double>("coneSize")) {
44  produces<TkIsoMap>();
45 }
46 
48  auto caloIsolations = std::make_unique<TkIsoMap>();
49  TkIsoMap::Filler filler(*caloIsolations);
50  {
52  event.getByToken(tracksToken_, tracks);
53 
55  event.getByToken(highPtTracksToken_, highPtTracks);
56 
58  event.getByToken(isoDepsToken_, isoDeps);
59 
60  int nTracks = tracks->size();
61  int nHighPtTracks = highPtTracks->size();
62  std::vector<double> iso(nTracks);
63 
65 
66  for (int i = 0; i < nTracks; ++i) {
67  const Candidate& tkCand = (*tracks)[i];
68  double caloIso = -1.0;
69  if (tkCand.pt() > trackPtMin_) {
70  for (int j = 0; j < nHighPtTracks; ++j) {
71  const Candidate& highPtTkCand = (*highPtTracks)[j];
72  if (overlap(tkCand, highPtTkCand)) {
73  CandidateBaseRef tkRef = highPtTracks->refAt(j);
74  const IsoDeposit& isoDep = (*isoDeps)[tkRef];
75  caloIso = isoDep.depositWithin(coneSize_);
76  break;
77  }
78  }
79  }
80  iso[i] = caloIso;
81  }
82  filler.insert(tracks, iso.begin(), iso.end());
83  }
84 
85  // really fill the association map
86  filler.fill();
87  event.put(std::move(caloIsolations));
88 }
89 
91 
virtual double pt() const =0
transverse momentum
const edm::EDGetTokenT< reco::IsoDepositMap > isoDepsToken_
void produce(edm::StreamID, edm::Event &event, const edm::EventSetup &setup) const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double depositWithin(double coneSize, const Vetos &vetos=Vetos(), bool skipDepositVeto=false) const
Get deposit.
Definition: IsoDeposit.cc:29
edm::ValueMap< float > TkIsoMap
IsolationProducerForTracks(const edm::ParameterSet &)
fixed size matrix
const edm::EDGetTokenT< reco::CandidateView > tracksToken_
HLT enums.
const edm::EDGetTokenT< reco::CandidateView > highPtTracksToken_
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1