CMS 3D CMS Logo

IsoTracks.cc
Go to the documentation of this file.
3 
9 
10 #include <memory>
11 #include <vector>
12 
14 // class definition
17 public:
18  explicit IsoTracks(edm::ParameterSet const&);
19  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
20 
21 private:
22  double coneRadius_;
23  double threshold_;
25 };
26 
28 // construction
30 
32  : coneRadius_{iConfig.getParameter<double>("radius")},
33  threshold_{iConfig.getParameter<double>("SumPtFraction")},
34  v_recoTrackToken_{consumes<std::vector<reco::Track>>(iConfig.getParameter<edm::InputTag>("src"))} {
35  produces<std::vector<reco::Track>>();
36 }
37 
39 // implementation of member functions
41 
42 //______________________________________________________________________________
44  auto isoTracks = std::make_unique<std::vector<reco::Track>>();
45 
47  iEvent.getByToken(v_recoTrackToken_, dirtyTracks);
48 
49  if (dirtyTracks->empty()) {
50  iEvent.put(std::move(isoTracks));
51  return;
52  }
53 
54  double sumPtInCone{};
55  for (auto it1 = dirtyTracks->begin(); it1 != dirtyTracks->end(); ++it1) {
56  for (auto it2 = dirtyTracks->begin(); it2 != dirtyTracks->end(); ++it2) {
57  if (it1 == it2)
58  continue;
59  if (deltaR(it1->eta(), it1->phi(), it2->eta(), it2->phi()) < coneRadius_) {
60  sumPtInCone += it2->pt();
61  }
62  }
63  if (sumPtInCone <= threshold_ * it1->pt()) {
64  isoTracks->push_back(*it1);
65  }
66  }
67 
68  iEvent.put(std::move(isoTracks));
69 }
70 
edm::StreamID
Definition: StreamID.h:30
IsoTracks
Definition: IsoTracks.cc:16
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::EDGetTokenT
Definition: EDGetToken.h:33
IsoTracks::coneRadius_
double coneRadius_
Definition: IsoTracks.cc:22
edm::Handle
Definition: AssociativeIterator.h:50
IsoTracks::produce
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Definition: IsoTracks.cc:43
deltaR.h
MakerMacros.h
IsoTracks::threshold_
double threshold_
Definition: IsoTracks.cc:23
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
IsoTracks::v_recoTrackToken_
edm::EDGetTokenT< std::vector< reco::Track > > v_recoTrackToken_
Definition: IsoTracks.cc:24
InputTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
eostools.move
def move(src, dest)
Definition: eostools.py:511
ParameterSet.h
EDProducer.h
IsoTracks::IsoTracks
IsoTracks(edm::ParameterSet const &)
Definition: IsoTracks.cc:31
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15