CMS 3D CMS Logo

HiggsToWW2LeptonsSkim.cc
Go to the documentation of this file.
1 
12 
14 
15 // Muons:
17 
18 // Electrons
20 
22 
23 #include <iostream>
24 
26 
27 using namespace edm;
28 using namespace std;
29 using namespace reco;
30 
31 HiggsToWW2LeptonsSkim::HiggsToWW2LeptonsSkim(const edm::ParameterSet& iConfig) : nEvents_(0), nAccepted_(0) {
32  // Reconstructed objects
33  theGLBMuonToken = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("GlobalMuonCollectionLabel"));
34  theGsfEToken = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("ElectronCollectionLabel"));
35 
36  singleTrackPtMin_ = iConfig.getParameter<double>("SingleTrackPtMin");
37  diTrackPtMin_ = iConfig.getParameter<double>("DiTrackPtMin");
38  etaMin_ = iConfig.getParameter<double>("etaMin");
39  etaMax_ = iConfig.getParameter<double>("etaMax");
40 }
41 
43 
45  edm::LogVerbatim("HiggsToWW2LeptonsSkim")
46  << "Events read " << nEvents_ << " Events accepted " << nAccepted_ << "\nEfficiency "
47  << ((double)nAccepted_) / ((double)nEvents_) << std::endl;
48 }
49 
51  nEvents_++;
52  bool accepted = false;
53  bool accepted1 = false;
54  int nTrackOver2ndCut = 0;
55 
56  // Handle<CandidateCollection> tracks;
57 
59 
60  // Get the muon track collection from the event
62  event.getByToken(theGLBMuonToken, muTracks);
63 
64  if (muTracks.isValid()) {
65  reco::TrackCollection::const_iterator muons;
66 
67  // Loop over muon collections and count how many muons there are,
68  // and how many are above threshold
69  for (muons = muTracks->begin(); muons != muTracks->end(); ++muons) {
70  if (muons->eta() > etaMin_ && muons->eta() < etaMax_) {
71  if (muons->pt() > singleTrackPtMin_)
72  accepted1 = true;
73  if (muons->pt() > diTrackPtMin_)
74  nTrackOver2ndCut++;
75  }
76  }
77  }
78 
79  // Now look at electrons:
80 
81  // Get the electron track collection from the event
83 
84  event.getByToken(theGsfEToken, pTracks);
85 
86  if (pTracks.isValid()) {
87  const reco::GsfElectronCollection* eTracks = pTracks.product();
88 
89  reco::GsfElectronCollection::const_iterator electrons;
90 
91  // Loop over electron collections and count how many muons there are,
92  // and how many are above threshold
93  for (electrons = eTracks->begin(); electrons != eTracks->end(); ++electrons) {
94  if (electrons->eta() > etaMin_ && electrons->eta() < etaMax_) {
95  if (electrons->pt() > singleTrackPtMin_)
96  accepted1 = true;
97  if (electrons->pt() > diTrackPtMin_)
98  nTrackOver2ndCut++;
99  }
100  }
101  }
102 
103  if (accepted1 && nTrackOver2ndCut >= 2)
104  accepted = true;
105 
106  if (accepted)
107  nAccepted_++;
108 
109  return accepted;
110 }
T getParameter(std::string const &) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
bool filter(edm::Event &, const edm::EventSetup &) override
bool isValid() const
Definition: HandleBase.h:70
HiggsToWW2LeptonsSkim(const edm::ParameterSet &)
T const * product() const
Definition: Handle.h:69
bool accepted(std::vector< std::string_view > const &, std::string_view)
edm::EDGetTokenT< reco::TrackCollection > theGLBMuonToken
fixed size matrix
HLT enums.
edm::EDGetTokenT< reco::GsfElectronCollection > theGsfEToken
Definition: event.py:1