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 
19  explicit IsoTracks(edm::ParameterSet const&);
20  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
21 
22 private:
23 
24  double coneRadius_;
25  double threshold_;
27 };
28 
30 // construction
32 
34  : coneRadius_{iConfig.getParameter<double>("radius")}
35  , threshold_{iConfig.getParameter<double>("SumPtFraction")}
36  , v_recoTrackToken_{consumes<std::vector<reco::Track>>(iConfig.getParameter<edm::InputTag>("src"))}
37 {
38  produces<std::vector<reco::Track>>();
39 }
40 
42 // implementation of member functions
44 
45 //______________________________________________________________________________
47 {
48  auto isoTracks = std::make_unique<std::vector<reco::Track>>();
49 
51  iEvent.getByToken(v_recoTrackToken_, dirtyTracks);
52 
53  if (dirtyTracks->empty()) {
54  iEvent.put(std::move(isoTracks));
55  return;
56  }
57 
58  double sumPtInCone {};
59  for (auto it1 = dirtyTracks->begin(); it1 != dirtyTracks->end(); ++it1) {
60  for (auto it2 = dirtyTracks->begin(); it2 != dirtyTracks->end(); ++it2) {
61  if (it1 == it2) continue;
62  if (deltaR(it1->eta(), it1->phi(), it2->eta(), it2->phi()) < coneRadius_) {
63  sumPtInCone += it2->pt();
64  }
65  }
66  if (sumPtInCone <= threshold_*it1->pt()) {
67  isoTracks->push_back(*it1);
68  }
69  }
70 
71  iEvent.put(std::move(isoTracks));
72 }
73 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double coneRadius_
Definition: IsoTracks.cc:24
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
Definition: IsoTracks.cc:46
int iEvent
Definition: GenABIO.cc:230
edm::EDGetTokenT< std::vector< reco::Track > > v_recoTrackToken_
Definition: IsoTracks.cc:26
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
double threshold_
Definition: IsoTracks.cc:25
IsoTracks(edm::ParameterSet const &)
Definition: IsoTracks.cc:33
def move(src, dest)
Definition: eostools.py:510