CMS 3D CMS Logo

HiggsToZZ4LeptonsSkimEff.cc
Go to the documentation of this file.
1 
2 /* \class HiggsTo4LeptonsSkimEff
3  *
4  * Consult header file for description
5  *
6  * author: Dominique Fortin - UC Riverside
7  *
8  */
9 
10 
11 // system include files
13 
14 // User include files
16 
17 // Muons:
19 
20 // Electrons
22 
23 // Candidate handling
27 
28 
29 // C++
30 #include <iostream>
31 #include <vector>
32 
33 using namespace std;
34 using namespace edm;
35 using namespace reco;
36 
37 
38 // Constructor
40 
41  // Local Debug flag
42  debug = pset.getParameter<bool>("DebugHiggsToZZ4LeptonsSkim");
43 
44  // Reconstructed objects
45  theGLBMuonToken = consumes<reco::TrackCollection>(pset.getParameter<edm::InputTag>("GlobalMuonCollectionLabel"));
46  theGsfEToken = consumes<reco::GsfElectronCollection>(pset.getParameter<edm::InputTag>("ElectronCollectionLabel"));
47  genToken = consumes<GenParticleCollection>(edm::InputTag("genParticles"));
48 
49  // Minimum Pt for leptons for skimming
50  // Minimum Pt for leptons for skimming
51  stiffMinPt = pset.getParameter<double>("stiffMinimumPt");
52  softMinPt = pset.getParameter<double>("softMinimumPt");
53  nStiffLeptonMin = pset.getParameter<int>("nStiffLeptonMinimum");
54  nLeptonMin = pset.getParameter<int>("nLeptonMinimum");
55 
56  nEvents = 0;
57  nSelFourE = nSelFourM = nSelTwoETwoM = nSelFourL = nSelTau = 0;
58  nFourE = nFourM = nTwoETwoM = nFourL = nTau = 0;
59 
60 }
61 
62 
63 // Destructor
65 
66  std::cout << "Number of events read " << nEvents << std::endl;
67  std::cout << "*** Efficiency for the various subsamples *** " << endl;
68 
69  std::cout << "Four leptons: "
70  << " pres " << nFourL
71  << " kept " << nSelFourL
72  << " eff " << ((double)nSelFourL)/((double) nFourL + 0.0001) << std::endl;
73  std::cout << "Four muons: "
74  << " pres " << nFourM
75  << " kept " << nSelFourM
76  << " eff " << ((double)nSelFourM)/((double) nFourM + 0.0001) << std::endl;
77  std::cout << "Four elecs: "
78  << " pres " << nFourE
79  << " kept " << nSelFourE
80  << " eff " << ((double)nSelFourE)/((double) nFourE + 0.0001) << std::endl;
81  std::cout << "2 elec 2 mu: "
82  << " pres " << nTwoETwoM
83  << " kept " << nSelTwoETwoM
84  << " eff " << ((double)nSelTwoETwoM)/((double) nTwoETwoM + 0.0001) << std::endl;
85  std::cout << "with taus: "
86  << " pres " << nTau
87  << " kept " << nSelTau
88  << " eff " << ((double)nSelTau)/((double) nTau + 0.0001) << std::endl;
89 
90 }
91 
92 
93 
94 // Filter event
96 
97  nEvents++;
98 
100 
101  bool keepEvent = false;
102 
103  // First, pre-selection:
104  int nMuon = 0;
105  int nElec = 0;
106  int nTau = 0;
107 
108  bool isFourE = false;
109  bool isFourM = false;
110  bool isTwoETwoM = false;
111  bool isFourL = false;
112  bool isTau = false;
113 
114  // get gen particle candidates
115  edm::Handle<CandidateCollection> genCandidates;
116  event.getByToken(genToken, genCandidates);
117 
118  for ( CandidateCollection::const_iterator mcIter=genCandidates->begin(); mcIter!=genCandidates->end(); ++mcIter ) {
119 
120  // Muons:
121  if ( mcIter->pdgId() == 13 || mcIter->pdgId() == -13) {
122  // Mother is a Z
123  if ( mcIter->mother()->pdgId() == 23 ) {
124  // In fiducial volume:
125  if ( mcIter->eta() > -2.4 && mcIter->eta() < 2.4 ) nMuon++;
126  }
127  }
128  // Electrons:
129  if ( mcIter->pdgId() == 11 || mcIter->pdgId() == -11) {
130  // Mother is a Z
131  if ( mcIter->mother()->pdgId() == 23 ) {
132  // In fiducial volume:
133  if ( mcIter->eta() > -2.5 && mcIter->eta() < 2.5 ) nElec++;
134  }
135  }
136  // Taus:
137  if ( mcIter->pdgId() == 15 || mcIter->pdgId() == -15) {
138  // Mother is a Z
139  if ( mcIter->mother()->pdgId() == 23 ) {
140  // In fiducial volume:
141  if ( mcIter->eta() > -2.5 && mcIter->eta() < 2.5 ) nTau++;
142  }
143  }
144 
145  }
146 
147  if (nElec > 3) {
148  isFourE = true;
149  nFourE++;
150  }
151  if (nMuon > 3) {
152  isFourM = true;
153  nFourM++;
154  }
155  if (nMuon > 1 && nElec > 1) {
156  isTwoETwoM = true;
157  nTwoETwoM++;
158  }
159  if ( isFourE || isFourM || isTwoETwoM ) {
160  isFourL = true;
161  nFourL++;
162  }
163  if (nTau > 1) {
164  isTau = true;
165  nTau++;
166  }
167 
168  if ( isFourL ) {
169  keepEvent = true;
170  } else {
171  return;
172  }
173 
174 
175  int nStiffLeptons = 0;
176  int nLeptons = 0;
177 
178  // First look at muons:
179 
180  // Get the muon track collection from the event
182  event.getByToken(theGLBMuonToken, muTracks);
183 
184  if ( muTracks.isValid() ) {
185  reco::TrackCollection::const_iterator muons;
186 
187  // Loop over muon collections and count how many muons there are,
188  // and how many are above threshold
189  for ( muons = muTracks->begin(); muons != muTracks->end(); ++muons ) {
190  float pt_mu = muons->pt();
191  if ( pt_mu > stiffMinPt ) nStiffLeptons++;
192  if ( pt_mu > softMinPt ) nLeptons++;
193  }
194  }
195 
196 
197  // Now look at electrons:
198 
199  // Get the electron track collection from the event
201  event.getByToken(theGsfEToken,pTracks);
202 
203  if ( pTracks.isValid() ) {
204 
205  const reco::GsfElectronCollection* eTracks = pTracks.product();
206 
207  reco::GsfElectronCollection::const_iterator electrons;
208 
209  // Loop over electron collections and count how many muons there are,
210  // and how many are above threshold
211  for ( electrons = eTracks->begin(); electrons != eTracks->end(); ++electrons ) {
212  float pt_e = electrons->pt();
213  if ( pt_e > stiffMinPt ) nStiffLeptons++;
214  if ( pt_e > softMinPt ) nLeptons++;
215  }
216  }
217 
218 
219  // Make decision:
220  if ( nStiffLeptons >= nStiffLeptonMin && nLeptons >= nLeptonMin) {
221  keepEvent = true;
222  } else {
223  keepEvent = false;
224  }
225 
226  if ( keepEvent ) {
227  if (isFourE) nSelFourE++;
228  if (isFourM) nSelFourM++;
229  if (isTwoETwoM) nSelTwoETwoM++;
230  if (isFourL) nSelFourL++;
231  if (isTau) nSelTau++;
232  }
233 
234 }
T getParameter(std::string const &) const
void analyze(const edm::Event &, const edm::EventSetup &) override
Get event properties to send to builder to fill seed collection.
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
iterator begin()
Definition: OwnVector.h:244
HiggsToZZ4LeptonsSkimEff(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:74
iterator end()
Definition: OwnVector.h:249
#define debug
Definition: HDRShower.cc:19
T const * product() const
Definition: Handle.h:74
fixed size matrix
HLT enums.
UInt_t nEvents
Definition: hcalCalib.cc:41
Definition: event.py:1
bool isTau(const Candidate &part)
Definition: pdgIdUtils.h:15