CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
23 
24 // Candidate handling
29 
30 
31 // C++
32 #include <iostream>
33 #include <vector>
34 
35 using namespace std;
36 using namespace edm;
37 using namespace reco;
38 
39 
40 // Constructor
42 
43  // Local Debug flag
44  debug = pset.getParameter<bool>("DebugHiggsToZZ4LeptonsSkim");
45 
46  // Reconstructed objects
47  recTrackLabel = pset.getParameter<edm::InputTag>("RecoTrackLabel");
48  theGLBMuonLabel = pset.getParameter<edm::InputTag>("GlobalMuonCollectionLabel");
49  thePixelGsfELabel = pset.getParameter<edm::InputTag>("ElectronCollectionLabel");
50 
51  // Minimum Pt for leptons for skimming
52  // Minimum Pt for leptons for skimming
53  stiffMinPt = pset.getParameter<double>("stiffMinimumPt");
54  softMinPt = pset.getParameter<double>("softMinimumPt");
55  nStiffLeptonMin = pset.getParameter<int>("nStiffLeptonMinimum");
56  nLeptonMin = pset.getParameter<int>("nLeptonMinimum");
57 
58  nEvents = 0;
59  nSelFourE = nSelFourM = nSelTwoETwoM = nSelFourL = nSelTau = 0;
60  nFourE = nFourM = nTwoETwoM = nFourL = nTau = 0;
61 
62 }
63 
64 
65 // Destructor
67 
68  std::cout << "Number of events read " << nEvents << std::endl;
69  std::cout << "*** Efficiency for the various subsamples *** " << endl;
70 
71  std::cout << "Four leptons: "
72  << " pres " << nFourL
73  << " kept " << nSelFourL
74  << " eff " << ((double)nSelFourL)/((double) nFourL + 0.0001) << std::endl;
75  std::cout << "Four muons: "
76  << " pres " << nFourM
77  << " kept " << nSelFourM
78  << " eff " << ((double)nSelFourM)/((double) nFourM + 0.0001) << std::endl;
79  std::cout << "Four elecs: "
80  << " pres " << nFourE
81  << " kept " << nSelFourE
82  << " eff " << ((double)nSelFourE)/((double) nFourE + 0.0001) << std::endl;
83  std::cout << "2 elec 2 mu: "
84  << " pres " << nTwoETwoM
85  << " kept " << nSelTwoETwoM
86  << " eff " << ((double)nSelTwoETwoM)/((double) nTwoETwoM + 0.0001) << std::endl;
87  std::cout << "with taus: "
88  << " pres " << nTau
89  << " kept " << nSelTau
90  << " eff " << ((double)nSelTau)/((double) nTau + 0.0001) << std::endl;
91 
92 }
93 
94 
95 
96 // Filter event
98 
99  nEvents++;
100 
101  using reco::TrackCollection;
102 
103  bool keepEvent = false;
104 
105  // First, pre-selection:
106  int nMuon = 0;
107  int nElec = 0;
108  int nTau = 0;
109 
110  bool isFourE = false;
111  bool isFourM = false;
112  bool isTwoETwoM = false;
113  bool isFourL = false;
114  bool isTau = false;
115 
116  // get gen particle candidates
118  event.getByLabel("genParticleCandidates", genCandidates);
119 
120  for ( CandidateCollection::const_iterator mcIter=genCandidates->begin(); mcIter!=genCandidates->end(); ++mcIter ) {
121 
122  // Muons:
123  if ( mcIter->pdgId() == 13 || mcIter->pdgId() == -13) {
124  // Mother is a Z
125  if ( mcIter->mother()->pdgId() == 23 ) {
126  // In fiducial volume:
127  if ( mcIter->eta() > -2.4 && mcIter->eta() < 2.4 ) nMuon++;
128  }
129  }
130  // Electrons:
131  if ( mcIter->pdgId() == 11 || mcIter->pdgId() == -11) {
132  // Mother is a Z
133  if ( mcIter->mother()->pdgId() == 23 ) {
134  // In fiducial volume:
135  if ( mcIter->eta() > -2.5 && mcIter->eta() < 2.5 ) nElec++;
136  }
137  }
138  // Taus:
139  if ( mcIter->pdgId() == 15 || mcIter->pdgId() == -15) {
140  // Mother is a Z
141  if ( mcIter->mother()->pdgId() == 23 ) {
142  // In fiducial volume:
143  if ( mcIter->eta() > -2.5 && mcIter->eta() < 2.5 ) nTau++;
144  }
145  }
146 
147  }
148 
149  if (nElec > 3) {
150  isFourE = true;
151  nFourE++;
152  }
153  if (nMuon > 3) {
154  isFourM = true;
155  nFourM++;
156  }
157  if (nMuon > 1 && nElec > 1) {
158  isTwoETwoM = true;
159  nTwoETwoM++;
160  }
161  if ( isFourE || isFourM || isTwoETwoM ) {
162  isFourL = true;
163  nFourL++;
164  }
165  if (nTau > 1) {
166  isTau = true;
167  nTau++;
168  }
169 
170  if ( isFourL ) {
171  keepEvent = true;
172  } else {
173  return;
174  }
175 
176 
177  int nStiffLeptons = 0;
178  int nLeptons = 0;
179 
180  // First look at muons:
181 
182  // Get the muon track collection from the event
184  event.getByLabel(theGLBMuonLabel.label(), muTracks);
185 
186  if ( muTracks.isValid() ) {
187  reco::TrackCollection::const_iterator muons;
188 
189  // Loop over muon collections and count how many muons there are,
190  // and how many are above threshold
191  for ( muons = muTracks->begin(); muons != muTracks->end(); ++muons ) {
192  float pt_mu = muons->pt();
193  if ( pt_mu > stiffMinPt ) nStiffLeptons++;
194  if ( pt_mu > softMinPt ) nLeptons++;
195  }
196  }
197 
198 
199  // Now look at electrons:
200 
201  // Get the electron track collection from the event
203  event.getByLabel(thePixelGsfELabel.label(),pTracks);
204 
205  if ( pTracks.isValid() ) {
206 
207  const reco::GsfElectronCollection* eTracks = pTracks.product();
208 
209  reco::GsfElectronCollection::const_iterator electrons;
210 
211  // Loop over electron collections and count how many muons there are,
212  // and how many are above threshold
213  for ( electrons = eTracks->begin(); electrons != eTracks->end(); ++electrons ) {
214  float pt_e = electrons->pt();
215  if ( pt_e > stiffMinPt ) nStiffLeptons++;
216  if ( pt_e > softMinPt ) nLeptons++;
217  }
218  }
219 
220 
221  // Make decision:
222  if ( nStiffLeptons >= nStiffLeptonMin && nLeptons >= nLeptonMin) {
223  keepEvent = true;
224  } else {
225  keepEvent = false;
226  }
227 
228  if ( keepEvent ) {
229  if (isFourE) nSelFourE++;
230  if (isFourM) nSelFourM++;
231  if (isTwoETwoM) nSelTwoETwoM++;
232  if (isFourL) nSelFourL++;
233  if (isTau) nSelTau++;
234  }
235 
236 }
T getParameter(std::string const &) const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
HiggsToZZ4LeptonsSkimEff(const edm::ParameterSet &)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
T const * product() const
Definition: Handle.h:74
tuple muons
Definition: patZpeak.py:38
tuple cout
Definition: gather_cfg.py:121
UInt_t nEvents
Definition: hcalCalib.cc:43
#define debug
Definition: MEtoEDMFormat.h:34
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Get event properties to send to builder to fill seed collection.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
bool isTau(const Candidate &part)
Definition: pdgIdUtils.h:15