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 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
double coneRadius_
Definition: IsoTracks.cc:22
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Definition: IsoTracks.cc:43
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< std::vector< reco::Track > > v_recoTrackToken_
Definition: IsoTracks.cc:24
double threshold_
Definition: IsoTracks.cc:23
IsoTracks(edm::ParameterSet const &)
Definition: IsoTracks.cc:31
def move(src, dest)
Definition: eostools.py:511