27 |
|
#include "DataFormats/PatCandidates/interface/TriggerPath.h" |
28 |
|
#include "DataFormats/BeamSpot/interface/BeamSpot.h" |
29 |
|
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" |
30 |
+ |
#include "DataFormats/Math/interface/deltaR.h" |
31 |
|
|
32 |
|
using namespace edm; |
33 |
|
|
64 |
|
CutFlow::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) |
65 |
|
{ |
66 |
|
c_total->count(); |
67 |
+ |
// |
68 |
+ |
//_____ mu+jets cut flow |
69 |
+ |
// |
70 |
+ |
/* |
71 |
|
while(1){ |
72 |
< |
if ( is_trigger("HLT_Mu9", iEvent) ){ |
72 |
> |
// |
73 |
> |
//_____ stage 1 |
74 |
> |
// |
75 |
> |
if ( is_trigger("HLT_Mu9", iEvent) ){ |
76 |
|
} |
77 |
|
else break; |
78 |
|
if ( has_global_muon("selectedLayer1Muons", iEvent) ){ |
79 |
|
c_1->count(); |
80 |
|
} |
81 |
|
else break; |
82 |
+ |
|
83 |
|
if ( is_muon("selectedLayer1Muons", |
84 |
|
20.0, |
85 |
|
2.1, |
119 |
|
cout << "Cut Flow: passed stage 5 " << endl; |
120 |
|
break; |
121 |
|
} |
122 |
+ |
*/ |
123 |
+ |
// |
124 |
+ |
//_____ e+jets cut flow |
125 |
+ |
// |
126 |
+ |
while(1){ |
127 |
+ |
// |
128 |
+ |
//_____ stage 1 |
129 |
+ |
// |
130 |
+ |
if ( is_trigger("HLT_Ele15_LW_L1R", iEvent) ){ |
131 |
+ |
} |
132 |
+ |
else break; |
133 |
+ |
if ( has_electron("selectedLayer1Electrons", iEvent) ){ |
134 |
+ |
c_1->count(); |
135 |
+ |
} |
136 |
+ |
else break; |
137 |
+ |
// |
138 |
+ |
//_____ stage 2 |
139 |
+ |
// |
140 |
+ |
cout << "CutFlow: passed stage 1: "; |
141 |
+ |
if ( is_electron("selectedLayer1Electrons", |
142 |
+ |
30.0, |
143 |
+ |
2.4, |
144 |
+ |
0.02, |
145 |
+ |
0.1, |
146 |
+ |
iEvent) ){ |
147 |
+ |
c_2->count(); |
148 |
+ |
cout << endl; |
149 |
+ |
} |
150 |
+ |
else{ |
151 |
+ |
cout << endl; |
152 |
+ |
break; |
153 |
+ |
} |
154 |
+ |
// |
155 |
+ |
//_____ stage 3 |
156 |
+ |
// |
157 |
+ |
cout << "CutFlow: passed stage 2: "; |
158 |
+ |
if ( !is_muon("selectedLayer1Muons", |
159 |
+ |
30.0, |
160 |
+ |
2.1, |
161 |
+ |
11, |
162 |
+ |
0.02, |
163 |
+ |
10, |
164 |
+ |
4000000.0, |
165 |
+ |
6000000.0, |
166 |
+ |
0.05, |
167 |
+ |
iEvent) ){ |
168 |
+ |
c_3->count(); |
169 |
+ |
cout << endl; |
170 |
+ |
} |
171 |
+ |
else{ |
172 |
+ |
cout << endl; |
173 |
+ |
break; |
174 |
+ |
} |
175 |
+ |
// |
176 |
+ |
//_____ stage 4 |
177 |
+ |
// |
178 |
+ |
cout << "CutFlow: passed stage 3: "; |
179 |
+ |
int n_jets = count_jets("selectedLayer1Jets", |
180 |
+ |
30.0, |
181 |
+ |
2.4, |
182 |
+ |
"selectedLayer1Electrons", |
183 |
+ |
30.0, |
184 |
+ |
2.4, |
185 |
+ |
0.02, |
186 |
+ |
0.3, |
187 |
+ |
iEvent); |
188 |
+ |
if ( n_jets >= 0){ |
189 |
+ |
c_4->count(); |
190 |
+ |
cout << endl; |
191 |
+ |
} |
192 |
+ |
else{ |
193 |
+ |
cout << endl; |
194 |
+ |
break; |
195 |
+ |
} |
196 |
+ |
// |
197 |
+ |
//_____ stage 5 |
198 |
+ |
// |
199 |
+ |
cout << "CutFlow: passed stage 4: "; |
200 |
+ |
if ( n_jets >= 4 ){ |
201 |
+ |
c_5->count(); |
202 |
+ |
cout << endl; |
203 |
+ |
} |
204 |
+ |
else{ |
205 |
+ |
cout << endl; |
206 |
+ |
break; |
207 |
+ |
} |
208 |
+ |
cout << "Cut Flow: passed stage 5 " << endl; |
209 |
+ |
break; |
210 |
+ |
} |
211 |
|
} |
212 |
|
|
213 |
|
|
221 |
|
CutFlow::endJob() { |
222 |
|
cout << "========= Cut Flow Report ==========================================" << endl; |
223 |
|
cout << "Total events: " << c_total->getCount() << endl; |
224 |
< |
cout << "Pass stage 1 (trigger+global): " << c_1->getCount() << endl; |
225 |
< |
cout << "Pass stage 2 (muon kinematics): " << c_2->getCount() << endl; |
226 |
< |
cout << "Pass stage 3 (jets): " << c_3->getCount() << endl; |
227 |
< |
cout << "Pass stage 4 (no loose muon): " << c_4->getCount() << endl; |
228 |
< |
cout << "Pass stage 5 (no loose electron): " << c_5->getCount() << endl; |
224 |
> |
cout << "Pass stage 1: " << c_1->getCount() << endl; |
225 |
> |
cout << "Pass stage 2: " << c_2->getCount() << endl; |
226 |
> |
cout << "Pass stage 3: " << c_3->getCount() << endl; |
227 |
> |
cout << "Pass stage 4: " << c_4->getCount() << endl; |
228 |
> |
cout << "Pass stage 5: " << c_5->getCount() << endl; |
229 |
|
cout << "================================================================" << endl; |
230 |
|
} |
231 |
|
|
247 |
|
bool CutFlow::has_global_muon(std::string mLabel, |
248 |
|
const edm::Event& iEvent){ |
249 |
|
bool result = false; |
250 |
< |
cout << "Cut Flow: passed trigger "; |
250 |
> |
//cout << "Cut Flow: passed trigger "; |
251 |
|
Handle< vector< pat::Muon > > muons; |
252 |
|
iEvent . getByLabel( mLabel, muons ); |
253 |
|
// |
260 |
|
} |
261 |
|
} |
262 |
|
result = passed_muons.getCount()>0; |
263 |
+ |
//cout << endl; |
264 |
|
return result; |
265 |
|
} |
266 |
|
|
276 |
|
double mRelIso, |
277 |
|
const edm::Event& iEvent){ |
278 |
|
bool result = false; |
279 |
< |
cout << "Cut Flow: passed stage 1: "; |
279 |
> |
//cout << "Cut Flow: passed stage 1 (mu+jets) or stage 2 (e+jets): "; |
280 |
|
Handle< vector< pat::Muon > > muons; |
281 |
|
iEvent . getByLabel( "selectedLayer1Muons", muons ); |
282 |
|
Handle< reco::BeamSpot > beamSpotHandle; |
351 |
|
cout << _hadveto << ", "; |
352 |
|
cout << _trackiso << ", "; |
353 |
|
cout << _caloiso << ", "; |
354 |
< |
cout << _reliso << ", "; |
355 |
< |
cout << endl; |
354 |
> |
cout << _reliso; |
355 |
> |
//cout << endl; |
356 |
|
} |
357 |
|
} |
358 |
|
} |
359 |
+ |
cout << "Number of good muons: " << passed_muons.getCount(); |
360 |
|
result = passed_muons.getCount()==1; |
361 |
|
return result; |
362 |
|
} |
368 |
|
const edm::Event& iEvent){ |
369 |
|
bool result = false; |
370 |
|
|
371 |
< |
cout << "Cut Flow: passed stage 2: "; |
371 |
> |
//cout << "Cut Flow: passed stage 2: "; |
372 |
|
|
373 |
|
Handle< vector< pat::Jet > > jets; |
374 |
|
iEvent . getByLabel( mLabel, jets ); |
387 |
|
} |
388 |
|
if (c_jets.getCount()<=4){ |
389 |
|
cout << _pt << ", "; |
390 |
< |
cout << _eta << ", "; |
390 |
> |
cout << _eta; |
391 |
|
} |
392 |
|
} |
393 |
< |
cout << endl; |
393 |
> |
//cout << endl; |
394 |
|
result = passed_jets.getCount() >=4; |
395 |
|
return result; |
396 |
|
} |
402 |
|
double mRelIso, |
403 |
|
const edm::Event& iEvent){ |
404 |
|
bool result = false; |
405 |
< |
cout << "Cut Flow: passed stage 3: "; |
405 |
> |
//cout << "Cut Flow: passed stage 3: "; |
406 |
|
Handle< vector< pat::Muon > > muons; |
407 |
|
iEvent . getByLabel( "selectedLayer1Muons", muons ); |
408 |
|
// |
431 |
|
_index != muon_index |
432 |
|
){ |
433 |
|
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; |
434 |
|
} |
435 |
|
} |
436 |
|
result = passed_muons.getCount()==0; |
437 |
+ |
//cout << endl; |
438 |
|
return result; |
439 |
|
} |
440 |
|
|
445 |
|
double mRelIso, |
446 |
|
const edm::Event& iEvent){ |
447 |
|
bool result = false; |
448 |
< |
cout << "Cut Flow: passed stage 4: "; |
448 |
> |
//cout << "Cut Flow: passed stage 4: "; |
449 |
|
Handle< vector< pat::Electron > > electrons; |
450 |
|
iEvent . getByLabel( "selectedLayer1Electrons", electrons ); |
451 |
|
// |
464 |
|
_caloiso = e->dr03IsolationVariables().ecalRecHitSumEt + e->dr03IsolationVariables().hcalDepth1TowerSumEt + e->dr03IsolationVariables().hcalDepth2TowerSumEt; |
465 |
|
_reliso = (_trackiso + _caloiso)/_pt; |
466 |
|
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; |
467 |
|
if (_pt > mPt && |
468 |
|
_abseta < mEta && |
469 |
|
_reliso < mRelIso && |
470 |
|
_index != electron_index |
471 |
|
){ |
472 |
|
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; |
473 |
|
} |
474 |
|
} |
475 |
|
result = passed_electrons.getCount()==0; |
476 |
+ |
//cout << endl; |
477 |
+ |
return result; |
478 |
+ |
} |
479 |
+ |
|
480 |
+ |
|
481 |
+ |
bool CutFlow::has_electron(std::string mLabel, |
482 |
+ |
const edm::Event& iEvent){ |
483 |
+ |
bool result = false; |
484 |
+ |
Handle< vector< pat::Electron > > electrons; |
485 |
+ |
iEvent . getByLabel( mLabel, electrons ); |
486 |
+ |
result = electrons->size()>0; |
487 |
+ |
return result; |
488 |
+ |
} |
489 |
+ |
|
490 |
+ |
|
491 |
+ |
bool CutFlow::is_electron(std::string mLabel, |
492 |
+ |
double mPt, |
493 |
+ |
double mEta, |
494 |
+ |
double mD0, |
495 |
+ |
double mRelIso, |
496 |
+ |
const edm::Event& iEvent){ |
497 |
+ |
bool result = false; |
498 |
+ |
//cout << "Cut Flow: passed stage 1: "; |
499 |
+ |
Handle< vector< pat::Electron > > electrons; |
500 |
+ |
iEvent . getByLabel( "selectedLayer1Electrons", electrons ); |
501 |
+ |
Handle< reco::BeamSpot > beamSpotHandle; |
502 |
+ |
iEvent . getByLabel( "offlineBeamSpot", beamSpotHandle); |
503 |
+ |
// |
504 |
+ |
//_____ Beam spot _____________________________________________________ |
505 |
+ |
// |
506 |
+ |
reco::BeamSpot beamSpot; |
507 |
+ |
if ( beamSpotHandle.isValid() ){ |
508 |
+ |
beamSpot = *beamSpotHandle; |
509 |
+ |
} |
510 |
+ |
else{ |
511 |
+ |
edm::LogInfo("TtLJetsAnalyzer") |
512 |
+ |
<< "No beam spot available from EventSetup \n"; |
513 |
+ |
} |
514 |
+ |
const reco::BeamSpot::Point _bs(beamSpot.x0(), beamSpot.y0(),beamSpot.z0()); |
515 |
+ |
// |
516 |
+ |
//_____ loop over electrons _______________________________________________ |
517 |
+ |
// |
518 |
+ |
double _pt = 0.0; |
519 |
+ |
double _abseta = 0.0; |
520 |
+ |
double _d0 = 0.0; |
521 |
+ |
double _d0_pat = 0.0; |
522 |
+ |
double _trackiso = 10000.0; |
523 |
+ |
double _ecaloiso = 10000.0; |
524 |
+ |
double _ecaloiso2 = 10000.0; |
525 |
+ |
double _pat_ecaloiso = 10000.0; |
526 |
+ |
double _hcaloiso1 = 10000.0; |
527 |
+ |
double _hcaloiso2 = 10000.0; |
528 |
+ |
double _caloiso = 10000.0; |
529 |
+ |
double _reliso = 10000.0; |
530 |
+ |
MeanCounter passed_electrons(""); |
531 |
+ |
for ( vector<pat::Electron>::const_iterator e = electrons -> begin(); e != electrons -> end(); e++){ |
532 |
+ |
//_____ check that the electron is robust-tight |
533 |
+ |
if( !(e->electronID("eidRobustTight")) ) continue; |
534 |
+ |
_pt = e->pt(); |
535 |
+ |
_abseta = fabs(e->eta()); |
536 |
+ |
_d0_pat = e->dB(); |
537 |
+ |
_d0 = -(e->gsfTrack()->dxy(_bs)); |
538 |
+ |
_trackiso = e->dr03IsolationVariables().tkSumPt; |
539 |
+ |
_ecaloiso = e->dr04IsolationVariables().ecalRecHitSumEt; |
540 |
+ |
_ecaloiso2 = e->dr03IsolationVariables().ecalRecHitSumEt; |
541 |
+ |
//_pat_ecaloiso = e->isolation(pat::ECalIso); |
542 |
+ |
_hcaloiso1 = e->dr04IsolationVariables().hcalDepth1TowerSumEt; |
543 |
+ |
_hcaloiso2 = e->dr04IsolationVariables().hcalDepth2TowerSumEt; |
544 |
+ |
_caloiso = _ecaloiso + _hcaloiso1 + _hcaloiso2; |
545 |
+ |
//_caloiso = _pat_ecaloiso +_hcaloiso1 + _hcaloiso2; |
546 |
+ |
_reliso = (_trackiso + _caloiso)/_pt; |
547 |
+ |
if (_pt > mPt && |
548 |
+ |
_abseta < mEta && |
549 |
+ |
fabs(_d0) < mD0 && |
550 |
+ |
fabs(_reliso) < mRelIso |
551 |
+ |
){ |
552 |
+ |
passed_electrons.count(); |
553 |
+ |
electron_index = (int)(e - electrons->begin()); |
554 |
+ |
if (passed_electrons.getCount()==1){ |
555 |
+ |
cout << "pt=" << _pt << ", abseta="; |
556 |
+ |
cout << _abseta << ", d0="; |
557 |
+ |
cout << _d0 << ", trackiso="; |
558 |
+ |
cout << _trackiso << ", ecaloiso04="; |
559 |
+ |
cout << _ecaloiso << ", ecaloiso03="; |
560 |
+ |
cout << _ecaloiso2 << ", pat_ecaloiso="; |
561 |
+ |
cout << _pat_ecaloiso << ", hcaloiso1="; |
562 |
+ |
cout << _hcaloiso1 << ", hcaloiso2="; |
563 |
+ |
cout << _hcaloiso2 << ", caloiso04="; |
564 |
+ |
cout << _caloiso << ", reliso="; |
565 |
+ |
cout << _reliso; |
566 |
+ |
//cout << endl; |
567 |
+ |
} |
568 |
+ |
} |
569 |
+ |
} |
570 |
+ |
//cout << "Number of good electrons: " << passed_electrons.getCount(); |
571 |
+ |
result = passed_electrons.getCount()==1; |
572 |
|
return result; |
573 |
|
} |
574 |
+ |
|
575 |
|
|
576 |
+ |
int CutFlow::count_jets(std::string jLabel, |
577 |
+ |
double jPt, |
578 |
+ |
double jEta, |
579 |
+ |
std::string lLabel, |
580 |
+ |
double lPt, |
581 |
+ |
double lEta, |
582 |
+ |
double lD0, |
583 |
+ |
double lDR, |
584 |
+ |
const edm::Event & iEvent){ |
585 |
+ |
MeanCounter _njets(""); |
586 |
+ |
Handle< vector< pat::Jet > > jets; |
587 |
+ |
iEvent . getByLabel( jLabel, jets ); |
588 |
+ |
Handle< vector< pat::Electron > > electrons; |
589 |
+ |
iEvent . getByLabel( lLabel, electrons ); |
590 |
+ |
Handle< reco::BeamSpot > beamSpotHandle; |
591 |
+ |
iEvent . getByLabel( "offlineBeamSpot", beamSpotHandle); |
592 |
+ |
// |
593 |
+ |
//_____ Beam spot _____________________________________________________ |
594 |
+ |
// |
595 |
+ |
reco::BeamSpot beamSpot; |
596 |
+ |
if ( beamSpotHandle.isValid() ){ |
597 |
+ |
beamSpot = *beamSpotHandle; |
598 |
+ |
} |
599 |
+ |
else{ |
600 |
+ |
edm::LogInfo("TtLJetsAnalyzer") |
601 |
+ |
<< "No beam spot available from EventSetup \n"; |
602 |
+ |
} |
603 |
+ |
const reco::BeamSpot::Point _bs(beamSpot.x0(), beamSpot.y0(),beamSpot.z0()); |
604 |
+ |
// |
605 |
+ |
//_____ loop over jets _______________________________________________ |
606 |
+ |
// |
607 |
+ |
double j_pt = 0.0; |
608 |
+ |
double j_eta = 0.0; |
609 |
+ |
for ( vector<pat::Jet>::const_iterator jet = jets -> begin(); jet != jets -> end(); ++jet){ |
610 |
+ |
j_pt = jet->pt(); |
611 |
+ |
j_eta = jet->eta(); |
612 |
+ |
// |
613 |
+ |
//_____ loop over electrons _______________________________________________ |
614 |
+ |
// |
615 |
+ |
double e_pt = 0.0; |
616 |
+ |
double e_abseta = 0.0; |
617 |
+ |
double e_d0 = 0.0; |
618 |
+ |
double e_dr = 0.0; |
619 |
+ |
bool jet_removed = false; |
620 |
+ |
for ( vector<pat::Electron>::const_iterator e = electrons -> begin(); e != electrons -> end(); e++){ |
621 |
+ |
//_____ check that the electron is robust-tight |
622 |
+ |
if( !(e->electronID("eidRobustTight")) ) continue; |
623 |
+ |
e_pt = e->pt(); |
624 |
+ |
e_abseta = fabs(e->eta()); |
625 |
+ |
e_d0 = -(e->gsfTrack()->dxy(_bs)); |
626 |
+ |
e_dr = reco::deltaR(*jet, *e); |
627 |
+ |
if ( e_pt > lPt && e_abseta < lEta && fabs(e_d0)<lD0 && e_dr<lDR){ |
628 |
+ |
jet_removed = true; |
629 |
+ |
} |
630 |
+ |
} |
631 |
+ |
if (j_pt>jPt && fabs(j_eta)<jEta && !jet_removed) _njets.count(); |
632 |
+ |
} |
633 |
+ |
cout << "Number of jets after cleaning: " << _njets.getCount(); |
634 |
+ |
return _njets.getCount(); |
635 |
+ |
} |
636 |
|
|
637 |
|
//define this as a plug-in |
638 |
|
DEFINE_FWK_MODULE(CutFlow); |