CMS 3D CMS Logo

IsolationProducerForTracks.cc
Go to the documentation of this file.
10 
12 public:
14 
15 private:
16  void produce(edm::Event& event, const edm::EventSetup& setup) override;
17 
21  double trackPtMin_;
22  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 
highPtTrackIsolations_cff.isoDeps
isoDeps
Definition: highPtTrackIsolations_cff.py:7
OverlapChecker
Definition: OverlapChecker.h:17
Handle.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:428
EDProducer.h
IsolationProducerForTracks::highPtTracksToken_
edm::EDGetTokenT< reco::CandidateView > highPtTracksToken_
Definition: IsolationProducerForTracks.cc:19
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
Association.h
BeamSpotPI::nTracks
Definition: BeamSpotPayloadInspectorHelper.h:41
edm::Handle
Definition: AssociativeIterator.h:50
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
highPtTrackIsolations_cff.highPtTracks
highPtTracks
Definition: highPtTrackIsolations_cff.py:5
CandidateFwd.h
IsolationProducerForTracks::produce
void produce(edm::Event &event, const edm::EventSetup &setup) override
Definition: IsolationProducerForTracks.cc:47
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
IsolationProducerForTracks::trackPtMin_
double trackPtMin_
Definition: IsolationProducerForTracks.cc:21
IsoDeposit.h
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
IsolationProducerForTracks::tracksToken_
edm::EDGetTokenT< reco::CandidateView > tracksToken_
Definition: IsolationProducerForTracks.cc:18
IsolationProducerForTracks::isoDepsToken_
edm::EDGetTokenT< reco::IsoDepositMap > isoDepsToken_
Definition: IsolationProducerForTracks.cc:20
Event.h
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
goodZToMuMu_cfi.overlap
overlap
Definition: goodZToMuMu_cfi.py:108
IsolationProducerForTracks::IsolationProducerForTracks
IsolationProducerForTracks(const edm::ParameterSet &)
Definition: IsolationProducerForTracks.cc:38
edm::EventSetup
Definition: EventSetup.h:57
InputTag.h
reco::Candidate
Definition: Candidate.h:27
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
Ref.h
reco::IsoDeposit::depositWithin
double depositWithin(double coneSize, const Vetos &vetos=Vetos(), bool skipDepositVeto=false) const
Get deposit.
Definition: IsoDeposit.cc:29
TkIsoMap
edm::ValueMap< float > TkIsoMap
Definition: IsolationProducerForTracks.cc:36
edm::ValueMap< float >
reco::IsoDeposit
Definition: IsoDeposit.h:49
edm::EDProducer
Definition: EDProducer.h:35
edm::RefToBase< Candidate >
IsolationProducerForTracks
Definition: IsolationProducerForTracks.cc:11
OverlapChecker.h
Candidate.h
IsoDepositFwd.h
edm::helper::Filler
Definition: ValueMap.h:22
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
IsolationProducerForTracks::coneSize_
double coneSize_
Definition: IsolationProducerForTracks.cc:22
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27