26 |
|
#include "DataFormats/PatCandidates/interface/MET.h" |
27 |
|
#include "DataFormats/PatCandidates/interface/TriggerPath.h" |
28 |
|
#include "DataFormats/BeamSpot/interface/BeamSpot.h" |
29 |
< |
|
29 |
> |
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" |
30 |
|
|
31 |
|
using namespace edm; |
32 |
|
|
42 |
|
c_3->setPrintCount(false); |
43 |
|
c_4->setPrintCount(false); |
44 |
|
c_5->setPrintCount(false); |
45 |
+ |
|
46 |
+ |
muon_index = -1; |
47 |
+ |
electron_index = -1; |
48 |
|
} |
49 |
|
|
50 |
|
|
64 |
|
{ |
65 |
|
c_total->count(); |
66 |
|
while(1){ |
67 |
< |
if ( is_trigger("HLT_Mu9", iEvent) ) c_1->count(); |
67 |
> |
if ( is_trigger("HLT_Mu9", iEvent) ){ |
68 |
> |
} |
69 |
> |
else break; |
70 |
> |
if ( has_global_muon("selectedLayer1Muons", iEvent) ){ |
71 |
> |
c_1->count(); |
72 |
> |
} |
73 |
|
else break; |
74 |
|
if ( is_muon("selectedLayer1Muons", |
75 |
|
20.0, |
84 |
|
c_2->count(); |
85 |
|
} |
86 |
|
else break; |
87 |
< |
cout << "Cut Flow: passed muon" << endl; |
87 |
> |
if ( is_jets("selectedLayer1Jets", |
88 |
> |
30.0, |
89 |
> |
2.4, |
90 |
> |
iEvent) ){ |
91 |
> |
c_3->count(); |
92 |
> |
} |
93 |
> |
else break; |
94 |
> |
if ( no_loose_muon("selectedLayer1Muons", |
95 |
> |
2.5, |
96 |
> |
10.0, |
97 |
> |
0.2, |
98 |
> |
iEvent) ){ |
99 |
> |
c_4->count(); |
100 |
> |
} |
101 |
> |
else break; |
102 |
> |
if ( no_loose_electron("selectedLayer1Electrons", |
103 |
> |
2.5, |
104 |
> |
15.0, |
105 |
> |
0.2, |
106 |
> |
iEvent) ){ |
107 |
> |
c_5->count(); |
108 |
> |
} |
109 |
> |
else break; |
110 |
> |
cout << "Cut Flow: passed stage 5 " << endl; |
111 |
|
break; |
112 |
|
} |
113 |
|
} |
131 |
|
cout << "================================================================" << endl; |
132 |
|
} |
133 |
|
|
134 |
< |
bool CutFlow::is_trigger(std::string mLabel, const edm::Event& iEvent){ |
134 |
> |
bool CutFlow::is_trigger(std::string mTriggerName, const edm::Event& iEvent){ |
135 |
|
bool result = false; |
136 |
|
Handle<std::vector<pat::TriggerPath> > trigs; |
137 |
|
iEvent.getByLabel("patTrigger", trigs); |
139 |
|
trig!=trigs->end(); |
140 |
|
++trig){ |
141 |
|
//cout << "Trigger name and number: " << trig->name() << ", " << trig->index() << endl; |
142 |
< |
if( trig->name().find(mLabel)!=std::string::npos ){ |
142 |
> |
if( trig->name().find(mTriggerName)!=std::string::npos ){ |
143 |
|
result = trig->wasAccept(); |
144 |
|
} |
145 |
|
} |
146 |
|
return result; |
147 |
|
} |
148 |
|
|
149 |
+ |
bool CutFlow::has_global_muon(std::string mLabel, |
150 |
+ |
const edm::Event& iEvent){ |
151 |
+ |
bool result = false; |
152 |
+ |
cout << "Cut Flow: passed trigger "; |
153 |
+ |
Handle< vector< pat::Muon > > muons; |
154 |
+ |
iEvent . getByLabel( mLabel, muons ); |
155 |
+ |
// |
156 |
+ |
//_____ loop over muons _______________________________________________ |
157 |
+ |
// |
158 |
+ |
MeanCounter passed_muons(""); |
159 |
+ |
for ( vector<pat::Muon>::const_iterator mu = muons -> begin(); mu != muons -> end(); mu++){ |
160 |
+ |
if ( mu->isGlobalMuon() ){ |
161 |
+ |
passed_muons.count(); |
162 |
+ |
} |
163 |
+ |
} |
164 |
+ |
result = passed_muons.getCount()>0; |
165 |
+ |
return result; |
166 |
+ |
} |
167 |
+ |
|
168 |
+ |
|
169 |
|
bool CutFlow::is_muon(std::string mLabel, |
170 |
|
double mPt, |
171 |
|
double mEta, |
177 |
|
double mRelIso, |
178 |
|
const edm::Event& iEvent){ |
179 |
|
bool result = false; |
180 |
+ |
cout << "Cut Flow: passed stage 1: "; |
181 |
|
Handle< vector< pat::Muon > > muons; |
182 |
|
iEvent . getByLabel( "selectedLayer1Muons", muons ); |
183 |
|
Handle< reco::BeamSpot > beamSpotHandle; |
207 |
|
double _trackiso = 10000.0; |
208 |
|
double _caloiso = 10000.0; |
209 |
|
double _reliso = 10000.0; |
210 |
+ |
MeanCounter passed_muons(""); |
211 |
|
for ( vector<pat::Muon>::const_iterator mu = muons -> begin(); mu != muons -> end(); mu++){ |
212 |
+ |
//_____ check that the muon is global |
213 |
+ |
if( !(mu->isGlobalMuon()) ) continue; |
214 |
|
_pt = mu->pt(); |
215 |
|
_abseta = fabs(mu->eta()); |
216 |
< |
_d0 = mu->dB(); |
216 |
> |
//_d0 = mu->dB(); // global track |
217 |
> |
_d0 = -(mu->innerTrack()->dxy(_bs)); |
218 |
|
_chi2ndof = mu->normChi2(); |
219 |
|
_nhits = mu->numberOfValidHits(); |
220 |
|
reco::TrackRef _track = mu->track(); |
234 |
|
if (_pt > mPt && |
235 |
|
_abseta < mEta && |
236 |
|
_nhits >= mNHits && |
237 |
< |
_d0 < mD0 && |
237 |
> |
fabs(_d0) < mD0 && |
238 |
|
_chi2ndof < mChi2Ndof && |
239 |
< |
_emveto < mEmVeto && |
240 |
< |
_hadveto < mHadVeto && |
241 |
< |
_reliso < mRelIso |
239 |
> |
fabs(_emveto) < mEmVeto && |
240 |
> |
fabs(_hadveto) < mHadVeto && |
241 |
> |
fabs(_reliso) < mRelIso |
242 |
|
){ |
243 |
< |
result = true; |
244 |
< |
break; |
243 |
> |
passed_muons.count(); |
244 |
> |
muon_index = (int)(mu - muons->begin()); |
245 |
> |
if (passed_muons.getCount()==1){ |
246 |
> |
cout << _pt << ", "; |
247 |
> |
cout << _abseta << ", "; |
248 |
> |
cout << _nhits << ", "; |
249 |
> |
cout << _d0 << ", "; |
250 |
> |
cout << _chi2ndof << ", "; |
251 |
> |
cout << _emveto << ", "; |
252 |
> |
cout << _hadveto << ", "; |
253 |
> |
cout << _trackiso << ", "; |
254 |
> |
cout << _caloiso << ", "; |
255 |
> |
cout << _reliso << ", "; |
256 |
> |
cout << endl; |
257 |
> |
} |
258 |
|
} |
259 |
|
} |
260 |
< |
cout << "Cut Flow: passed trigger: " << _pt << ", "; |
192 |
< |
cout << _abseta << ", "; |
193 |
< |
cout << _nhits << ", "; |
194 |
< |
cout << _d0 << ", "; |
195 |
< |
cout << _chi2ndof << ", "; |
196 |
< |
cout << _emveto << ", "; |
197 |
< |
cout << _hadveto << ", "; |
198 |
< |
cout << _trackiso << ", "; |
199 |
< |
cout << _caloiso << ", "; |
200 |
< |
cout << _reliso << ", "; |
201 |
< |
cout << endl; |
260 |
> |
result = passed_muons.getCount()==1; |
261 |
|
return result; |
262 |
|
} |
263 |
|
|
264 |
|
|
265 |
+ |
bool CutFlow::is_jets(std::string mLabel, |
266 |
+ |
double mPt, |
267 |
+ |
double mEta, |
268 |
+ |
const edm::Event& iEvent){ |
269 |
+ |
bool result = false; |
270 |
+ |
|
271 |
+ |
cout << "Cut Flow: passed stage 2: "; |
272 |
+ |
|
273 |
+ |
Handle< vector< pat::Jet > > jets; |
274 |
+ |
iEvent . getByLabel( mLabel, jets ); |
275 |
+ |
MeanCounter c_jets(""); |
276 |
+ |
MeanCounter passed_jets(""); |
277 |
+ |
for ( vector<pat::Jet>::const_iterator jet = jets -> begin(); jet != jets -> end(); jet++ ){ |
278 |
+ |
c_jets.count(); |
279 |
+ |
double _pt = jet->pt(); |
280 |
+ |
double _eta = jet->eta(); |
281 |
+ |
if ( |
282 |
+ |
( fabs( _eta ) < mEta ) && |
283 |
+ |
( _pt > mPt ) |
284 |
+ |
) |
285 |
+ |
{ |
286 |
+ |
passed_jets.count(); |
287 |
+ |
} |
288 |
+ |
if (c_jets.getCount()<=4){ |
289 |
+ |
cout << _pt << ", "; |
290 |
+ |
cout << _eta << ", "; |
291 |
+ |
} |
292 |
+ |
} |
293 |
+ |
cout << endl; |
294 |
+ |
result = passed_jets.getCount() >=4; |
295 |
+ |
return result; |
296 |
+ |
} |
297 |
+ |
|
298 |
+ |
|
299 |
+ |
bool CutFlow::no_loose_muon(std::string mLabel, |
300 |
+ |
double mEta, |
301 |
+ |
double mPt, |
302 |
+ |
double mRelIso, |
303 |
+ |
const edm::Event& iEvent){ |
304 |
+ |
bool result = false; |
305 |
+ |
cout << "Cut Flow: passed stage 3: "; |
306 |
+ |
Handle< vector< pat::Muon > > muons; |
307 |
+ |
iEvent . getByLabel( "selectedLayer1Muons", muons ); |
308 |
+ |
// |
309 |
+ |
//_____ loop over muons _______________________________________________ |
310 |
+ |
// |
311 |
+ |
double _pt = 0.0; |
312 |
+ |
double _abseta = 0.0; |
313 |
+ |
double _trackiso = 10000.0; |
314 |
+ |
double _caloiso = 10000.0; |
315 |
+ |
double _reliso = 10000.0; |
316 |
+ |
MeanCounter passed_muons(""); |
317 |
+ |
for ( vector<pat::Muon>::const_iterator mu = muons -> begin(); mu != muons -> end(); mu++){ |
318 |
+ |
//_____ check that the muon is global |
319 |
+ |
if( !(mu->isGlobalMuon()) ) continue; |
320 |
+ |
_pt = mu->pt(); |
321 |
+ |
_abseta = fabs(mu->eta()); |
322 |
+ |
//_____ check that isolation is valid |
323 |
+ |
if ( !(mu->isIsolationValid()) ) continue; |
324 |
+ |
_trackiso = mu->isolationR03().sumPt; |
325 |
+ |
_caloiso = mu->isolationR03().emEt + mu->isolationR03().hadEt; |
326 |
+ |
_reliso = (_trackiso + _caloiso)/_pt; |
327 |
+ |
int _index = (int)(mu - muons->begin()); |
328 |
+ |
if (_pt > mPt && |
329 |
+ |
_abseta < mEta && |
330 |
+ |
_reliso < mRelIso && |
331 |
+ |
_index != muon_index |
332 |
+ |
){ |
333 |
+ |
passed_muons.count(); |
334 |
+ |
cout << "DEBUG: found a loose muon!!!!!" << endl; |
335 |
+ |
cout << "DEBUG: index = " << _index << endl; |
336 |
+ |
cout << "DEBUG: abseta = " << _abseta << endl; |
337 |
+ |
cout << "DEBUG: pt = " << _pt << endl; |
338 |
+ |
cout << "DEBUG: reliso = " << _reliso << endl << endl; |
339 |
+ |
} |
340 |
+ |
} |
341 |
+ |
result = passed_muons.getCount()==0; |
342 |
+ |
return result; |
343 |
+ |
} |
344 |
+ |
|
345 |
+ |
|
346 |
+ |
bool CutFlow::no_loose_electron(std::string mLabel, |
347 |
+ |
double mEta, |
348 |
+ |
double mPt, |
349 |
+ |
double mRelIso, |
350 |
+ |
const edm::Event& iEvent){ |
351 |
+ |
bool result = false; |
352 |
+ |
cout << "Cut Flow: passed stage 4: "; |
353 |
+ |
Handle< vector< pat::Electron > > electrons; |
354 |
+ |
iEvent . getByLabel( "selectedLayer1Electrons", electrons ); |
355 |
+ |
// |
356 |
+ |
//_____ loop over electrons _______________________________________________ |
357 |
+ |
// |
358 |
+ |
double _pt = 0.0; |
359 |
+ |
double _abseta = 0.0; |
360 |
+ |
double _trackiso = 10000.0; |
361 |
+ |
double _caloiso = 10000.0; |
362 |
+ |
double _reliso = 10000.0; |
363 |
+ |
MeanCounter passed_electrons(""); |
364 |
+ |
for ( vector<pat::Electron>::const_iterator e = electrons -> begin(); e != electrons -> end(); e++){ |
365 |
+ |
_pt = e->pt(); |
366 |
+ |
_abseta = fabs(e->eta()); |
367 |
+ |
_trackiso = e->dr03IsolationVariables().tkSumPt; |
368 |
+ |
_caloiso = e->dr03IsolationVariables().ecalRecHitSumEt + e->dr03IsolationVariables().hcalDepth1TowerSumEt + e->dr03IsolationVariables().hcalDepth2TowerSumEt; |
369 |
+ |
_reliso = (_trackiso + _caloiso)/_pt; |
370 |
+ |
int _index = (int)(e - electrons->begin()); |
371 |
+ |
//cout << "DEBUG: " << _index << endl; |
372 |
+ |
//cout << "DEBUG: " << _abseta << endl; |
373 |
+ |
//cout << "DEBUG: " << _pt << endl; |
374 |
+ |
//cout << "DEBUG: " << _reliso << endl << endl; |
375 |
+ |
if (_pt > mPt && |
376 |
+ |
_abseta < mEta && |
377 |
+ |
_reliso < mRelIso && |
378 |
+ |
_index != electron_index |
379 |
+ |
){ |
380 |
+ |
passed_electrons.count(); |
381 |
+ |
cout << "DEBUG: found a loose electron!!!!!" << endl; |
382 |
+ |
cout << "DEBUG: index = " << _index << endl; |
383 |
+ |
cout << "DEBUG: abseta = " << _abseta << endl; |
384 |
+ |
cout << "DEBUG: pt = " << _pt << endl; |
385 |
+ |
cout << "DEBUG: reliso = " << _reliso << endl << endl; |
386 |
+ |
} |
387 |
+ |
} |
388 |
+ |
result = passed_electrons.getCount()==0; |
389 |
+ |
return result; |
390 |
+ |
} |
391 |
+ |
|
392 |
+ |
|
393 |
|
//define this as a plug-in |
394 |
|
DEFINE_FWK_MODULE(CutFlow); |