-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeptonPlusFakeMLSelection.cc
More file actions
1437 lines (1153 loc) · 56.5 KB
/
LeptonPlusFakeMLSelection.cc
File metadata and controls
1437 lines (1153 loc) · 56.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <string>
#include <TTree.h>
#include "CommonTools/include/Counters.hh"
#include "CommonTools/include/Selection.hh"
#include "CommonTools/include/Utils.hh"
#include "HiggsAnalysisTools/include/LeptonPlusFakeMLSelection.hh"
#include "CommonTools/include/EfficiencyEvaluator.hh"
#include "CommonTools/include/LeptonIdBits.h"
#include "CommonTools/include/PUWeight.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <TTree.h>
using namespace bits;
LeptonPlusFakeMLSelection::LeptonPlusFakeMLSelection(TTree *tree)
: Higgs(tree) {
// choose the Higgs Mass
std::string higgsConfigDir;
std::string higgsConfigDirMass;
std::ifstream setfile("config/higgs/higgsMass.txt");
higgsConfigDir="config/higgs/";
if(!setfile.good()) {
std::cout << "Cannot read the higgsMass file to choose the selection: config/higgs/higgsMass.txt" << std::endl
<< "using default (160 GeV)" << std::endl;
higgsConfigDirMass="config/higgs/h160/";
}
else {
std::string var, massVal;
bool found=false;
while (1) {
setfile >> var >> massVal;
_massVal = atoi(massVal.c_str());
if(!setfile.good()) break;
if(var.compare("HiggsMass")==0) {
found=true;
higgsConfigDirMass="config/higgs/h" + massVal + "/";
std::cout << "Reading configuration for Higgs mass = " << massVal << " GeV/c^2" << std::endl;
break;
}
}
}
// selection efficiencies
std::string fileCutsEE = higgsConfigDirMass + "2e2nuCuts.txt";
std::string fileSwitchesEE = higgsConfigDir + "2l2nuSwitches.txt";
CutBasedHiggsSelectionEE.Configure(fileCutsEE.c_str(),fileSwitchesEE.c_str(),"FULL SELECTION EVENT COUNTER EE");
CutBasedHiggsErrorsSelectionEE.Configure(fileCutsEE.c_str(),fileSwitchesEE.c_str(),"FULL SELECTION ERRORS EE");
_selectionEE = CutBasedHiggsSelectionEE.GetSelection();
_selectionErrEE = CutBasedHiggsErrorsSelectionEE.GetSelection();
// extra selection efficiencies - to be put here not to pass the full list of leptons to the preselection class
_selectionEE->addCut("etaElectronAcc");
_selectionEE->addCut("ptElectronAcc");
_selectionEE->addCut("etaMuonAcc");
_selectionEE->addCut("ptMuonAcc");
_selectionEE->addCut("etUncorrJetAcc");
_selectionEE->addSwitch("apply_kFactor");
_selectionEE->addSwitch("isData");
_selectionEE->addSwitch("goodRunLS");
_selectionEE->addSwitch("asymmetricID");
_selectionEE->addStringParameter("electronIDType");
_selectionEE->addStringParameter("electronIDTypeLow");
// cut based electron id or likelihood
TString selectionString(_selectionEE->getStringParameter("electronIDType"));
if (!_selectionEE->getSwitch("asymmetricID"))
cout << "=== CONFIGURING " << selectionString << " CUT BASED SYMMETRIC ELECTRON ID ===" << endl;
EgammaCutBasedID.ConfigureNoClass("config/higgs/electronId/"+selectionString);
EgammaCutBasedID.ConfigureEcalCleaner("config/higgs/electronId/");
if (_selectionEE->getSwitch("asymmetricID")) {
TString selectionStringLow (_selectionEE->getStringParameter("electronIDTypeLow"));
cout << "=== CONFIGURING " << selectionStringLow << " and "
<< selectionString << " for CUT BASED ASYMMETRIC ELECTRON ID ===" << endl;
EgammaCutBasedIDLow.ConfigureNoClass("config/higgs/electronId/"+selectionStringLow);
EgammaCutBasedIDLow.ConfigureEcalCleaner("config/higgs/electronId/");
}
// configuring electron likelihood
TFile *fileLH = TFile::Open("pdfs_MC.root");
TDirectory *EB0lt15dir = fileLH->GetDirectory("/");
TDirectory *EB1lt15dir = fileLH->GetDirectory("/");
TDirectory *EElt15dir = fileLH->GetDirectory("/");
TDirectory *EB0gt15dir = fileLH->GetDirectory("/");
TDirectory *EB1gt15dir = fileLH->GetDirectory("/");
TDirectory *EEgt15dir = fileLH->GetDirectory("/");
LikelihoodSwitches defaultSwitches;
defaultSwitches.m_useFBrem = true;
defaultSwitches.m_useEoverP = false;
defaultSwitches.m_useSigmaPhiPhi = true;
defaultSwitches.m_useHoverE = false;
defaultSwitches.m_useOneOverEMinusOneOverP = true;
LH = new ElectronLikelihood(&(*EB0lt15dir), &(*EB1lt15dir), &(*EElt15dir), &(*EB0gt15dir), &(*EB1gt15dir), &(*EEgt15dir), defaultSwitches, std::string("class"),std::string("class"),true,true);
// Reading GoodRUN LS
std::cout << "[GoodRunLS]::goodRunLS is " << _selectionEE->getSwitch("goodRunLS") << " isData is " << _selectionEE->getSwitch("isData") << std::endl;
// To read good run list!
if (_selectionEE->getSwitch("goodRunLS") && _selectionEE->getSwitch("isData")) {
std::string goodRunJsonFile = "config/json/goodCollisions2011.json"; // chiara
setJsonGoodRunList(goodRunJsonFile);
fillRunLSMap();
}
// kinematics
for(int theChannel=0; theChannel<1; theChannel++) {
m_p4LeptonPlus[theChannel] = new TLorentzVector(0.,0.,0.,0.);
m_p4LeptonMinus[theChannel] = new TLorentzVector(0.,0.,0.,0.);
m_p3PFMET = new TVector3(0.,0.,0.);
m_p3TKMET = new TVector3(0.,0.,0.);
}
// b-veto event variables
m_maxDxyEvt = 0.0;
m_maxDszEvt = 0.0;
}
LeptonPlusFakeMLSelection::~LeptonPlusFakeMLSelection(){
for(int theChannel=0; theChannel<1; theChannel++) {
delete m_p4LeptonPlus[theChannel];
delete m_p4LeptonMinus[theChannel];
}
delete m_p3PFMET;
delete m_p3TKMET;
delete _selectionEE;
delete _selectionErrEE;
myOutTreeEE -> save();
}
void LeptonPlusFakeMLSelection::initialiseFakeRate() {
// binning
m_minFakePt[0] = 10.; m_maxFakePt[0] = 15.;
m_minFakePt[1] = 15.; m_maxFakePt[1] = 20.;
m_minFakePt[2] = 20.; m_maxFakePt[2] = 25.;
m_minFakePt[3] = 25.; m_maxFakePt[3] = 50.;
m_minFakePt[4] = 50.; m_maxFakePt[4] = 10000.;
/*
// fake in the barrel from QCD MC
m_fakeRateEB[0] = 0.31852;
m_fakeRateEB[1] = 0.0815463;
m_fakeRateEB[2] = 0.0707214;
m_fakeRateEB[3] = 0.0588124;
m_fakeRateEB[4] = 0.0458273;
m_fakeRateEB_err[0] = 0.00598496;
m_fakeRateEB_err[1] = 0.00467256;
m_fakeRateEB_err[2] = 0.00381354;
m_fakeRateEB_err[3] = 0.00335443;
m_fakeRateEB_err[4] = 0.0120015;
// fake in the endcap from QCD MC
m_fakeRateEE[0] = 0.208365;
m_fakeRateEE[1] = 0.0621581;
m_fakeRateEE[2] = 0.0546968;
m_fakeRateEE[3] = 0.0522816;
m_fakeRateEE[4] = 0.0515749;
m_fakeRateEE_err[0] = 0.00714442;
m_fakeRateEE_err[1] = 0.00411465;
m_fakeRateEE_err[2] = 0.00314477;
m_fakeRateEE_err[3] = 0.00299393;
m_fakeRateEE_err[4] = 0.0142672;
*/
/* // chiara
// fake in the barrel from data (jet:30)) - no EWK subtraction
m_fakeRateEB[0] = 0.170909;
m_fakeRateEB[1] = 0.127837;
m_fakeRateEB[2] = 0.0843061;
m_fakeRateEB[3] = 0.0857687;
m_fakeRateEB[4] = 0.116071;
m_fakeRateEB_err[0] = 0.00926705;
m_fakeRateEB_err[1] = 0.00918355;
m_fakeRateEB_err[2] = 0.00707559;
m_fakeRateEB_err[3] = 0.00705814;
m_fakeRateEB_err[4] = 0.0302665;
// fake in the endcap from data (jet:30) - no EWK subtraction
m_fakeRateEE[0] = 0.136997;
m_fakeRateEE[1] = 0.0632603;
m_fakeRateEE[2] = 0.0563645;
m_fakeRateEE[3] = 0.045511;
m_fakeRateEE[4] = 0.0300752;
m_fakeRateEE_err[0] = 0.009566;
m_fakeRateEE_err[1] = 0.00693256;
m_fakeRateEE_err[2] = 0.00499824;
m_fakeRateEE_err[3] = 0.00423941;
m_fakeRateEE_err[4] = 0.0148097;
*/
// fake in the barrel from data (jet:30)) - with EWK subtraction (apart from bin0, where no EWK removal)
m_fakeRateEB[0] = 0.170909;
m_fakeRateEB[1] = 0.126939;
m_fakeRateEB[2] = 0.0829306;
m_fakeRateEB[3] = 0.0804465;
m_fakeRateEB[4] = 0.0993018;
m_fakeRateEB_err[0] = 0.00926705;
m_fakeRateEB_err[1] = 0.00916318;
m_fakeRateEB_err[2] = 0.00703008;
m_fakeRateEB_err[3] = 0.00687927;
m_fakeRateEB_err[4] = 0.0285547;
// fake in the endcap from data (jet:30) - with EWK subtraction (apart from bin0, where no EWK removal)
m_fakeRateEE[0] = 0.136997;
m_fakeRateEE[1] = 0.0628376;
m_fakeRateEE[2] = 0.0559572;
m_fakeRateEE[3] = 0.0441833;
m_fakeRateEE[4] = 0.0255683;
m_fakeRateEE_err[0] = 0.009566;
m_fakeRateEE_err[1] = 0.00691408;
m_fakeRateEE_err[2] = 0.00498304;
m_fakeRateEE_err[3] = 0.00418404;
m_fakeRateEE_err[4] = 0.01372;
/*
// fake in the barrel from data (jet:15)) - no EWK subtraction
m_fakeRateEB[0] = 0.176334;
m_fakeRateEB[1] = 0.13883;
m_fakeRateEB[2] = 0.105588;
m_fakeRateEB[3] = 0.0916634;
m_fakeRateEB[4] = 0.114754;
m_fakeRateEB_err[0] = 0.00382773;
m_fakeRateEB_err[1] = 0.00532204;
m_fakeRateEB_err[2] = 0.00503719;
m_fakeRateEB_err[3] = 0.00573555;
m_fakeRateEB_err[4] = 0.028856;
// fake in the endcap from data (jet:15)
m_fakeRateEE[0] = 0.138302;
m_fakeRateEE[1] = 0.0695556;
m_fakeRateEE[2] = 0.0601607;
m_fakeRateEE[3] = 0.0486044;
m_fakeRateEE[4] = 0.0357143;
m_fakeRateEE_err[0] = 0.00379404;
m_fakeRateEE_err[1] = 0.00379232;
m_fakeRateEE_err[2] = 0.00310862;
m_fakeRateEE_err[3] = 0.00333565;
m_fakeRateEE_err[4] = 0.0156841;
*/
/*
// fake in the barrel from data (jet:50))
m_fakeRateEB[0] = 0.130682;
m_fakeRateEB[1] = 0.101523;
m_fakeRateEB[2] = 0.0920502;
m_fakeRateEB[3] = 0.0910973;
m_fakeRateEB[4] = 0.0804598;
m_fakeRateEB_err[0] = 0.0254063;
m_fakeRateEB_err[1] = 0.021518;
m_fakeRateEB_err[2] = 0.0187001;
m_fakeRateEB_err[3] = 0.013093;
m_fakeRateEB_err[4] = 0.0291619;
// fake in the endcap from data (jet:50)
m_fakeRateEE[0] = 0.104575;
m_fakeRateEE[1] = 0.0753425;
m_fakeRateEE[2] = 0.0536913;
m_fakeRateEE[3] = 0.0351438;
m_fakeRateEE[4] = 0.0222222;
m_fakeRateEE_err[0] = 0.0247391;
m_fakeRateEE_err[1] = 0.0218441;
m_fakeRateEE_err[2] = 0.0130575;
m_fakeRateEE_err[3] = 0.00735984;
m_fakeRateEE_err[4] = 0.0155379;
*/
}
void LeptonPlusFakeMLSelection::Loop() {
_verbose=false;
if(fChain == 0) return;
initialiseFakeRate();
// kinematics reduced tree
std::string reducedTreeNameEE = _datasetName+"-datasetEE.root";
myOutTreeEE = new RedHiggsTree(reducedTreeNameEE.c_str());
if ( _selectionEE->getSwitch("isData")) myOutTreeEE->addRunInfos();
myOutTreeEE->addMLVars();
myOutTreeEE->addLatinos();
unsigned int lastLumi=0;
unsigned int lastRun=0;
PUWeight* fPUWeight = new PUWeight();
Long64_t nbytes = 0, nb = 0;
Long64_t nentries = fChain->GetEntries();
std::cout << "Number of entries = " << nentries << std::endl;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
if (jentry%1000 == 0) std::cout << ">>> Processing event # " << jentry << std::endl;
resetKinematicsStart();
// weight for the PU observed in 2011 data
float tmpWeight = 1.;
if ( !_selectionEE->getSwitch("isData") ) tmpWeight *= fPUWeight->GetWeight(nPU);
// dummy MC truth
bool promptEE = true;
// Good Run selection
if (_selectionEE->getSwitch("isData") && _selectionEE->getSwitch("goodRunLS") && !isGoodRunLS()) {
if ( lastRun!= runNumber || lastLumi != lumiBlock) {
lastRun = runNumber;
lastLumi = lumiBlock;
std::cout << "[GoodRunLS]::Run " << lastRun << " LS " << lastLumi << " is rejected" << std::endl;
}
continue;
}
if (_selectionEE->getSwitch("isData") && _selectionEE->getSwitch("goodRunLS") && ( lastRun!= runNumber || lastLumi != lumiBlock) ) {
lastRun = runNumber;
lastLumi = lumiBlock;
std::cout << "[GoodRunLS]::Run " << lastRun << " LS " << lastLumi << " is OK" << std::endl;
}
// IMPORTANT: FOR DATA RELOAD THE TRIGGER MASK PER FILE WHICH IS SUPPOSED TO CONTAIN UNIFORM CONDITIONS X FILE
reloadTriggerMask();
bool passedHLT[1];
passedHLT[ee] = hasPassedHLT();
// ----------------------------------------------------------------------------
// get the best electrons and best muons ==> tu be used to select ALL the possible channels at the beginning only
std::pair<int,int> thePreElectrons = getBestElectronPair_acceptance();
thePreElectron = thePreElectrons.second;
thePrePositron = thePreElectrons.first;
// reconstructed channel
m_channel[ee] = false;
// at this level the SELECTED channel should have pT > 10 and > 20. So far, at least 2 leptons with pT >20 and 10 in the event
if (thePreElectron > -1 && thePrePositron > -1) {
float thisMaxPt = TMath::Max(GetPt(pxEle[thePreElectron],pyEle[thePreElectron]),GetPt(pxEle[thePrePositron],pyEle[thePrePositron]));
float thisMinPt = TMath::Min(GetPt(pxEle[thePreElectron],pyEle[thePreElectron]),GetPt(pxEle[thePrePositron],pyEle[thePrePositron]));
if (thisMaxPt>20 && thisMinPt>15) m_channel[ee] = true; // fixme: hardcoded
}
if (_verbose) {
std::cout << "nEle = " << nEle << "\tnMuon = " << nMuon << std::endl;
std::cout << "indices: " << thePreElectron << " " << thePrePositron << std::endl;
std::cout << "chargeEle = " << chargeEle[thePreElectron] << "\tchargePos = " << chargeEle[thePrePositron] << std::endl;
std::cout << "ee = " << m_channel[ee] << std::endl;
}
// -------------------------------------------------------------
// EE candidates: preparing vectors of candidates and selecting the two highest pT ele- and ele+ after each step - to check the 20 GeV cut after
// eleID, for electrons in acceptance
std::pair<int,int> theBestIdEle = getBestElectronPair_id(_acceptEleAll);
// isolation, for identified electrons
std::pair<int,int> theBestIsolEle = getBestElectronPair_isol(_idEleAll);
// conversion rejection, for isolated electrons
std::pair<int,int> theBestConvEle = getBestElectronPair_conv(_isolEleAll);
// transverse impact parameter, for electrons passing conversion rejection
std::pair<int,int> theBestIpEle = getBestElectronPair_ip(_convEleAll);
// the two highest pT electrons at this point are those I use for my analysis since the passed the full lepton selection
int thePositron = theBestIpEle.first;
int theElectron = theBestIpEle.second;
if (thePositron>-1 && theElectron>-1) {
float ptPositron = GetPt(pxEle[thePositron],pyEle[thePositron]);
float ptElectron = GetPt(pxEle[theElectron],pyEle[theElectron]);
if (ptPositron>ptElectron) theReal = thePositron;
else theReal = theElectron;
}
if (thePositron>-1 && theElectron<0) {
theReal = thePositron;
}
if (theElectron>-1 && thePositron<0) {
theReal = theElectron;
}
// consider all possible denominators different from the selected tight candidate and use the highest pT one as a fake
theFake = getBestDenominator(theReal);
// set of kinematics: : now I've all the final leptons
resetKinematics();
// MET is an event variable. Independent o the channel
m_p3PFMET->SetXYZ(pxPFMet[0],pyPFMet[0],pzPFMet[0]);
m_p3TKMET->SetXYZ(pxChMetPV[0],pyChMetPV[0],pzChMetPV[0]); // the one associated to the 0th vertex
m_theMET = m_p3PFMET->Pt();
setKinematicsEE(theReal, theFake);
// weight with the Fake -> L2 probability
float weight = 1.;
float weightError = 1.;
float theFakePt = GetPt(pxEle[theFake],pyEle[theFake]);
bool isFakeBarrel = false;
if ( fabs(etaEle[theFake])<1.476 ) isFakeBarrel = true;
if ( theFake>-1 ) {
float fakerate = getFakeRate( theFakePt, isFakeBarrel );
float fakerateErr = getFakeRateError( theFakePt, isFakeBarrel );
weight = tmpWeight * fakerate / (1. - fakerate);
weightError = tmpWeight * fakerateErr / ( (1. - fakerate)*(1. - fakerate) );
// weight = tmpWeight; // chiara: only to estimate real leptons contribution from MC
// weightError = tmpWeight; // chiara: only to estimate real leptons contribution from MC
} else {
weight = tmpWeight;
weightError = tmpWeight;
}
// -------------------------------------------------------------
// look for PV in the event (there is always at least 1 PV)
m_closestPV = getPV(); // fixme: si chiama closest ma e' quello a piu' alto pT.
int njets[1], nuncorrjets[1];
float dphiLLJ[1], btag[1];
int nsoftmu[1],nextraleptons[1];
for(int ichan=0; ichan<1; ichan++) {
// jet counter
njets[ichan] = numJets(eleCands[ichan],muCands[ichan],ichan);
nuncorrjets[ichan] = numUncorrJets(eleCands[ichan],muCands[ichan]);
// if 1-jet bin, use deltaphi(ll-jet)
dphiLLJ[ichan] = deltaPhiLLJet(ichan);
// b veto
btag[ichan] = bVetoJets(eleCands[ichan],muCands[ichan]);
// soft muon counter
nsoftmu[ichan] = numSoftMuons(muCands[ichan]);
// extra lepton counter
nextraleptons[ichan] = numExtraLeptons(eleCands[ichan],muCands[ichan]);
}
// ---------------------------------------
// filling counters for the different final states
// EE
CutBasedHiggsSelectionEE.SetWeight(weight);
CutBasedHiggsSelectionEE.SetMcTruth(promptEE);
CutBasedHiggsSelectionEE.SetHLT(passedHLT[ee]);
CutBasedHiggsSelectionEE.SetIsChannel(m_channel[ee]);
CutBasedHiggsSelectionEE.SetElectronId(theReal);
CutBasedHiggsSelectionEE.SetPositronId(theFake);
CutBasedHiggsSelectionEE.SetElectronIsolation(theReal);
CutBasedHiggsSelectionEE.SetPositronIsolation(theFake);
CutBasedHiggsSelectionEE.SetElectronConvRejection(theReal);
CutBasedHiggsSelectionEE.SetPositronConvRejection(theFake);
CutBasedHiggsSelectionEE.SetElectronIp(theReal);
CutBasedHiggsSelectionEE.SetPositronIp(theFake);
// checking if the highest pT electron at each step has pT>20
float thisMaxPtIpEE = TMath::Max(GetPt(pxEle[theReal],pyEle[theReal]),GetPt(pxEle[theFake],pyEle[theFake]));
if (thisMaxPtIpEE<20) {
CutBasedHiggsSelectionEE.SetElectronIp(-1);
CutBasedHiggsSelectionEE.SetPositronIp(-1);
}
CutBasedHiggsSelectionEE.SetHighElePt(hardestLeptonPt[ee]);
CutBasedHiggsSelectionEE.SetLowElePt(slowestLeptonPt[ee]);
CutBasedHiggsSelectionEE.SetExtraSlowLeptonPTCut(15.0); // enforce the min pT cut only on electrons
CutBasedHiggsSelectionEE.SetNJets(njets[ee]);
CutBasedHiggsSelectionEE.SetNUncorrJets(nuncorrjets[ee]);
CutBasedHiggsSelectionEE.SetBTagJets(btag[ee]);
CutBasedHiggsSelectionEE.SetNSoftMuons(nsoftmu[ee]);
CutBasedHiggsSelectionEE.SetNExtraLeptons(nextraleptons[ee]);
CutBasedHiggsSelectionEE.SetMet(m_theMET);
CutBasedHiggsSelectionEE.SetProjectedMet(m_projectedMet[ee]);
CutBasedHiggsSelectionEE.SetMetOverPtLL(m_metOptll[ee]);
CutBasedHiggsSelectionEE.SetDeltaPhiLLJet(dphiLLJ[ee]);
CutBasedHiggsSelectionEE.SetDeltaPhi(m_deltaPhi[ee]);
CutBasedHiggsSelectionEE.SetInvMass(m_mll[ee]);
CutBasedHiggsSelectionEE.SetDetaLeptons(m_deltaEtaLeptons[ee]);
CutBasedHiggsSelectionEE.SetWWInvMass(2.*m_transvMass[ee]/_massVal);
bool isSelectedEE = CutBasedHiggsSelectionEE.output();
bool selUpToFinalLeptonsEE = CutBasedHiggsSelectionEE.outputUpToFinalLeptons();
bool selUpToJetVetoEE = CutBasedHiggsSelectionEE.outputUpToJetVeto();
bool selUpToUncorrJetVetoEE = CutBasedHiggsSelectionEE.outputUpToUncorrJetVeto();
bool selPreDeltaPhiEE = CutBasedHiggsSelectionEE.outputPreDeltaPhi();
bool outputStep0 = CutBasedHiggsSelectionEE.outputStep0();
bool outputStep1 = CutBasedHiggsSelectionEE.outputStep1();
bool outputStep2 = CutBasedHiggsSelectionEE.outputStep2();
bool outputStep3 = CutBasedHiggsSelectionEE.outputStep3();
bool outputStep4 = CutBasedHiggsSelectionEE.outputStep4();
bool outputStep5 = CutBasedHiggsSelectionEE.outputStep5();
bool outputStep6 = CutBasedHiggsSelectionEE.outputStep6();
bool outputStep7 = CutBasedHiggsSelectionEE.outputStep7();
bool outputStep8 = CutBasedHiggsSelectionEE.outputStep8();
bool outputStep9 = CutBasedHiggsSelectionEE.outputStep9();
bool outputStep10 = CutBasedHiggsSelectionEE.outputStep10();
bool outputStep11 = CutBasedHiggsSelectionEE.outputStep11();
bool outputStep12 = CutBasedHiggsSelectionEE.outputStep12();
bool outputStep13 = CutBasedHiggsSelectionEE.outputStep13();
bool outputStep14 = CutBasedHiggsSelectionEE.outputStep14();
bool outputStep15 = CutBasedHiggsSelectionEE.outputStep15();
bool outputStep16 = CutBasedHiggsSelectionEE.outputStep16();
bool outputStep17 = CutBasedHiggsSelectionEE.outputStep17();
bool outputStep18 = CutBasedHiggsSelectionEE.outputStep18();
bool outputStep19 = CutBasedHiggsSelectionEE.outputStep19();
bool outputStep20 = CutBasedHiggsSelectionEE.outputStep20();
bool outputStep21 = CutBasedHiggsSelectionEE.outputStep21();
bool outputStep22 = CutBasedHiggsSelectionEE.outputStep22();
bool outputStep23 = CutBasedHiggsSelectionEE.outputStep23();
bool outputStep24 = CutBasedHiggsSelectionEE.outputStep24();
myOutTreeEE->fillRunInfos(runNumber, lumiBlock, eventNumber, weight);
myOutTreeEE -> fillAll(GetPt(pxTCMet[0],pyTCMet[0]), GetPt(pxPFMet[0],pyPFMet[0]), GetPt(pxMet[0],pyMet[0]),
m_projectedMet[ee], m_deltaPhi[ee], m_deltaErre[ee], m_transvMass[ee], m_mll[ee],
hardestLeptonPt[ee], slowestLeptonPt[ee], hardestLeptonEta[ee], slowestLeptonEta[ee],
m_deltaEtaLeptons[ee], nPV,
selUpToFinalLeptonsEE, selUpToJetVetoEE, selUpToUncorrJetVetoEE, selPreDeltaPhiEE, isSelectedEE);
myOutTreeEE -> fillMLVars(njets[ee], nuncorrjets[ee], m_maxDxyEvt, m_maxDszEvt, m_maxTrackCountingHighEffBJetTags, m_maxImpactParameterMVABJetTags, m_maxCombinedSecondaryVertexMVABJetTags);
myOutTreeEE -> fillLatinos( outputStep0, outputStep1, outputStep2, outputStep3, outputStep4, outputStep5, outputStep6, outputStep7, outputStep8, outputStep9, outputStep10, outputStep11, outputStep12, outputStep13, outputStep14, outputStep15, outputStep16, outputStep17, outputStep18, outputStep19, outputStep20, outputStep21, outputStep22, outputStep23, outputStep24 );
// dumping final tree, only if there are 2 leptons in the acceptance
if(outputStep1) myOutTreeEE -> store();
// for errors
CutBasedHiggsErrorsSelectionEE.SetWeight(weightError);
CutBasedHiggsErrorsSelectionEE.SetMcTruth(promptEE);
CutBasedHiggsErrorsSelectionEE.SetHLT(passedHLT[ee]);
CutBasedHiggsErrorsSelectionEE.SetIsChannel(m_channel[ee]);
CutBasedHiggsErrorsSelectionEE.SetElectronId(1);
CutBasedHiggsErrorsSelectionEE.SetPositronId(1);
CutBasedHiggsErrorsSelectionEE.SetElectronIsolation(1);
CutBasedHiggsErrorsSelectionEE.SetPositronIsolation(1);
CutBasedHiggsErrorsSelectionEE.SetElectronConvRejection(1);
CutBasedHiggsErrorsSelectionEE.SetPositronConvRejection(1);
CutBasedHiggsErrorsSelectionEE.SetElectronIp(theReal);
CutBasedHiggsErrorsSelectionEE.SetPositronIp(theFake);
if (thisMaxPtIpEE<20) {
CutBasedHiggsErrorsSelectionEE.SetElectronIp(-1);
CutBasedHiggsErrorsSelectionEE.SetPositronIp(-1);
}
CutBasedHiggsErrorsSelectionEE.SetHighElePt(hardestLeptonPt[ee]);
CutBasedHiggsErrorsSelectionEE.SetLowElePt(slowestLeptonPt[ee]);
CutBasedHiggsErrorsSelectionEE.SetNJets(njets[ee]);
CutBasedHiggsErrorsSelectionEE.SetNUncorrJets(nuncorrjets[ee]);
CutBasedHiggsErrorsSelectionEE.SetBTagJets(btag[ee]);
CutBasedHiggsErrorsSelectionEE.SetNSoftMuons(nsoftmu[ee]);
CutBasedHiggsErrorsSelectionEE.SetNExtraLeptons(nextraleptons[ee]);
CutBasedHiggsErrorsSelectionEE.SetMet(m_theMET);
CutBasedHiggsErrorsSelectionEE.SetProjectedMet(m_projectedMet[ee]);
CutBasedHiggsErrorsSelectionEE.SetMetOverPtLL(m_metOptll[ee]);
CutBasedHiggsErrorsSelectionEE.SetDeltaPhiLLJet(dphiLLJ[ee]);
CutBasedHiggsErrorsSelectionEE.SetDeltaPhi(m_deltaPhi[ee]);
CutBasedHiggsErrorsSelectionEE.SetInvMass(m_mll[ee]);
CutBasedHiggsErrorsSelectionEE.SetDetaLeptons(m_deltaEtaLeptons[ee]);
CutBasedHiggsErrorsSelectionEE.SetWWInvMass(2.*m_transvMass[ee]/_massVal);
bool isSelectedErrorEE = CutBasedHiggsErrorsSelectionEE.output();
}
}
void LeptonPlusFakeMLSelection::displayEfficiencies(std::string datasetName) {
std::string::size_type loc = datasetName.find_first_of(".",0);
if( loc != std::string::npos ) {
datasetName.erase(loc);
}
std::cout << "--------------------------------" << std::endl;
std::cout << "=== RATE ESTIMATED FROM FAKE RATE FOR EE SELECTION ===: " << std::endl;
CutBasedHiggsSelectionEE.displayEfficiencies(datasetName);
std::cout << "=== RATE UNCERTAINTY ESTIMATED FROM FAKE RATE FOR EE SELECTION ===" << std::endl;
CutBasedHiggsErrorsSelectionEE.displayEfficiencies(datasetName);
// simple cuts based or like based ele id
if (!_selectionEE->getSwitch("asymmetricID")) {
std::cout << "cut based symmetric ID: " << std::endl;
EgammaCutBasedID.displayEfficiencies();
} else {
std::cout << "cut based asymmetric ID: Low pT" << std::endl;
EgammaCutBasedIDLow.displayEfficiencies();
std::cout << "cut based asymmetric ID: High pT" << std::endl;
EgammaCutBasedID.displayEfficiencies();
}
}
std::pair<int,int> LeptonPlusFakeMLSelection::getBestElectronPair_acceptance() {
int theLep1 = -1;
int theLep2 = -1;
float maxPtLep1 = -1000.;
float maxPtLep2 = -1000.;
_acceptEleAll.clear();
for(int i=0;i<nEle;i++) {
TVector3 pLepton(pxEle[i],pyEle[i],pzEle[i]);
float thisPt=pLepton.Pt();
if(_selectionEE->getSwitch("etaElectronAcc") && !_selectionEE->passCut("etaElectronAcc",etaEle[i]) ) continue;
if(_selectionEE->getSwitch("ptElectronAcc") && !_selectionEE->passCut("ptElectronAcc",thisPt) ) continue;
float thisCharge = chargeEle[i];
if (thisCharge > 0 && thisPt> maxPtLep1){ maxPtLep1 = thisPt; theLep1 = i; }
if (thisCharge < 0 && thisPt> maxPtLep2){ maxPtLep2 = thisPt; theLep2 = i; }
_acceptEleAll.push_back(i);
}
_acceptEleAll = sortElectronsByPt(_acceptEleAll);
return make_pair(theLep1,theLep2);
}
std::pair<int,int> LeptonPlusFakeMLSelection::getBestElectronPair_id( std::vector<int> acceptEle ) {
int theLep1 = -1;
int theLep2 = -1;
float maxPtLep1 = -1000.;
float maxPtLep2 = -1000.;
_idEleAll.clear();
for (int iEle=0; iEle<acceptEle.size(); iEle++) {
int thisEle = acceptEle[iEle];
bool theElectronID, theElectronIsol, theElectronConvRej;
theElectronID = theElectronIsol = theElectronConvRej = true;
float thisPt = GetPt(pxEle[thisEle],pyEle[thisEle]);
if (!_selectionEE->getSwitch("asymmetricID")) isEleID(thisEle,&theElectronID,&theElectronIsol,&theElectronConvRej,&EgammaCutBasedID);
if ( _selectionEE->getSwitch("asymmetricID")) {
if (thisPt>=20) isEleID(thisEle,&theElectronID,&theElectronIsol,&theElectronConvRej,&EgammaCutBasedID);
if (thisPt<20) isEleID(thisEle,&theElectronID,&theElectronIsol,&theElectronConvRej,&EgammaCutBasedIDLow);
}
if (!theElectronID) continue;
float thisCharge = chargeEle[thisEle];
if (thisCharge > 0 && thisPt> maxPtLep1){ maxPtLep1 = thisPt; theLep1 = thisEle; }
if (thisCharge < 0 && thisPt> maxPtLep2){ maxPtLep2 = thisPt; theLep2 = thisEle; }
_idEleAll.push_back(thisEle);
}
_idEleAll = sortElectronsByPt(_idEleAll);
return make_pair(theLep1,theLep2);
}
std::pair<int,int> LeptonPlusFakeMLSelection::getBestElectronPair_isol( std::vector<int> idEle ) {
int theLep1 = -1;
int theLep2 = -1;
float maxPtLep1 = -1000.;
float maxPtLep2 = -1000.;
_isolEleAll.clear();
for (int iEle=0; iEle<idEle.size(); iEle++) {
int thisEle = idEle[iEle];
bool theElectronID, theElectronIsol, theElectronConvRej;
theElectronID = theElectronIsol = theElectronConvRej = true;
isEleID(thisEle,&theElectronID,&theElectronIsol,&theElectronConvRej,&EgammaCutBasedID);
if (!theElectronIsol) continue;
float thisPt = GetPt(pxEle[thisEle],pyEle[thisEle]);
float thisCharge = chargeEle[thisEle];
if (thisCharge > 0 && thisPt> maxPtLep1){ maxPtLep1 = thisPt; theLep1 = thisEle; }
if (thisCharge < 0 && thisPt> maxPtLep2){ maxPtLep2 = thisPt; theLep2 = thisEle; }
_isolEleAll.push_back(thisEle);
}
_isolEleAll = sortElectronsByPt(_isolEleAll);
return make_pair(theLep1,theLep2);
}
std::pair<int,int> LeptonPlusFakeMLSelection::getBestElectronPair_conv( std::vector<int> isolEle ) {
int theLep1 = -1;
int theLep2 = -1;
float maxPtLep1 = -1000.;
float maxPtLep2 = -1000.;
_convEleAll.clear();
for (int iEle=0; iEle<isolEle.size(); iEle++) {
int thisEle = isolEle[iEle];
bool theElectronID, theElectronIsol, theElectronConvRej;
theElectronID = theElectronIsol = theElectronConvRej = true;
isEleID(thisEle,&theElectronID,&theElectronIsol,&theElectronConvRej,&EgammaCutBasedID);
if (!theElectronConvRej) continue;
float thisPt = GetPt(pxEle[thisEle],pyEle[thisEle]);
float thisCharge = chargeEle[thisEle];
if (thisCharge > 0 && thisPt> maxPtLep1){ maxPtLep1 = thisPt; theLep1 = thisEle; }
if (thisCharge < 0 && thisPt> maxPtLep2){ maxPtLep2 = thisPt; theLep2 = thisEle; }
_convEleAll.push_back(thisEle);
}
_convEleAll = sortElectronsByPt(_convEleAll);
return make_pair(theLep1,theLep2);
}
std::pair<int,int> LeptonPlusFakeMLSelection::getBestElectronPair_ip( std::vector<int> convEle ) {
int theLep1 = -1;
int theLep2 = -1;
float maxPtLep1 = -1000.;
float maxPtLep2 = -1000.;
_ipEleAll.clear();
for (int iEle=0; iEle<convEle.size(); iEle++) {
int thisEle = convEle[iEle];
int gsfTrack = gsfTrackIndexEle[thisEle];
float d3dEle = impactPar3DGsfTrack[gsfTrack];
if (_selectionEE->getSwitch("electronIP") && (!_selectionEE->passCut("electronIP",d3dEle)) ) continue;
float thisPt = GetPt(pxEle[thisEle],pyEle[thisEle]);
float thisCharge = chargeEle[thisEle];
if (thisCharge > 0 && thisPt> maxPtLep1){ maxPtLep1 = thisPt; theLep1 = thisEle; }
if (thisCharge < 0 && thisPt> maxPtLep2){ maxPtLep2 = thisPt; theLep2 = thisEle; }
_ipEleAll.push_back(thisEle);
}
_ipEleAll = sortElectronsByPt(_ipEleAll);
return make_pair(theLep1,theLep2);
}
int LeptonPlusFakeMLSelection::getBestDenominator(int realEle) {
int theFake=-1;
float maxPtFake=-1000.;
for(int iele=0; iele<nEle; iele++) {
if (iele==realEle) continue;
if (chargeEle[iele]*chargeEle[realEle]>0) continue;
bool isGoodDenom = isDenomFake(iele);
if (!isGoodDenom) continue;
float thisElePt = GetPt(pxEle[iele],pyEle[iele]);
// removing candidates passing the tight selection
bool isTight = true;
bool theElectronID, theElectronIsol, theElectronConvRej;
theElectronID = theElectronIsol = theElectronConvRej = true;
if (!_selectionEE->getSwitch("asymmetricID")) isEleID(iele,&theElectronID,&theElectronIsol,&theElectronConvRej,&EgammaCutBasedID);
if ( _selectionEE->getSwitch("asymmetricID")) {
if (thisElePt>=20) isEleID(iele,&theElectronID,&theElectronIsol,&theElectronConvRej,&EgammaCutBasedID);
if (thisElePt<20) isEleID(iele,&theElectronID,&theElectronIsol,&theElectronConvRej,&EgammaCutBasedIDLow);
}
if (!theElectronID) isTight = false;
if (!theElectronIsol) isTight = false;
if (!theElectronConvRej) isTight = false;
int gsfTrack = gsfTrackIndexEle[iele];
float d3dEle = impactPar3DGsfTrack[gsfTrack];
if (_selectionEE->getSwitch("electronIP") && (!_selectionEE->passCut("electronIP",d3dEle)) ) isTight = false;
if (isTight) continue;
if( thisElePt > maxPtFake ) { maxPtFake = thisElePt; theFake=iele; }
}
return theFake;
}
bool LeptonPlusFakeMLSelection::isDenomFake(int theEle) {
Utils anaUtils;
bool isGoodDenom = true;
TVector3 p3Ele(pxEle[theEle], pyEle[theEle], pzEle[theEle]);
// acceptance
if( fabs(p3Ele.Eta()) > 2.5 ) isGoodDenom = false;
if( p3Ele.Pt() < 10. ) isGoodDenom = false;
// only ecal driven
bool ecalDriven = anaUtils.electronRecoType(recoFlagsEle[theEle], bits::isEcalDriven);
if(!ecalDriven) isGoodDenom = false;
// barrel or endcap
bool isEleEB = anaUtils.fiducialFlagECAL(fiducialFlagsEle[theEle], isEB);
// isolation
float combinedIso;
if (isEleEB) combinedIso = dr03TkSumPtEle[theEle] + TMath::Max(0.0,dr03EcalRecHitSumEtEle[theEle]-1.0) + dr03HcalTowerSumEtFullConeEle[theEle];
if (!isEleEB) combinedIso = dr03TkSumPtEle[theEle] + dr03EcalRecHitSumEtEle[theEle] + dr03HcalTowerSumEtFullConeEle[theEle];
float corrCombinedIso = (combinedIso - rhoFastjet*TMath::Pi()*0.3*0.3) / p3Ele.Pt();
if ( corrCombinedIso>0.15 ) isGoodDenom = false;
// H/E
bool isBarrelEle;
if ( fabs(etaEle[theEle]) < 1.479 ) isBarrelEle = true;
if ( fabs(etaEle[theEle]) >= 1.479 ) isBarrelEle = false;
if ( isBarrelEle && hOverEEle[theEle]>0.15) isGoodDenom = false;
if (!isBarrelEle && hOverEEle[theEle]>0.10) isGoodDenom = false;
// sigmaIetaIeta
bool isBarrelSc;
int sc = superClusterIndexEle[theEle];
if ( sc < 0 ) isGoodDenom = false;
if ( fabs(etaSC[sc]) < 1.479 ) isBarrelSc = true;
if ( fabs(etaSC[sc]) >= 1.479 ) isBarrelSc = false;
if ( isBarrelSc && sqrt(covIEtaIEtaSC[sc])>0.014 ) isGoodDenom = false;
if (!isBarrelSc && sqrt(covIEtaIEtaSC[sc])>0.035 ) isGoodDenom = false;
// spikes
float theE1 = eMaxSC[sc];
float theE4SwissCross = e4SwissCrossSC[sc];
float theSpikeSC = 1.0 - (theE4SwissCross/theE1);
if (theSpikeSC>0.95) isGoodDenom = false;
return isGoodDenom;
}
float LeptonPlusFakeMLSelection::getFakeRate( float fakePt, bool isFakeBarrel ) {
for (int theBin = 0; theBin<7; theBin++) {
if( fakePt >= m_minFakePt[theBin] && fakePt < m_maxFakePt[theBin] ) {
if (isFakeBarrel) return m_fakeRateEB[theBin];
if (!isFakeBarrel) return m_fakeRateEE[theBin];
}
}
std::cout << "BIG ERROR: fakePt = " << fakePt << endl;
return -1.;
}
float LeptonPlusFakeMLSelection::getFakeRateError( float fakePt, bool isFakeBarrel ) {
for (int theBin = 0; theBin < 7; theBin++) {
if( fakePt >= m_minFakePt[theBin] && fakePt < m_maxFakePt[theBin] ) {
if (isFakeBarrel) return m_fakeRateEB_err[theBin];
if (!isFakeBarrel) return m_fakeRateEE_err[theBin];
}
}
return -1.;
}
void LeptonPlusFakeMLSelection::setKinematicsEE(int myReal, int myFake) {
if (myFake > -1 && myReal > -1) {
eleCands[ee].push_back(myReal);
eleCands[ee].push_back(myFake);
hardestLeptonPt[ee] = TMath::Max(GetPt(pxEle[myReal],pyEle[myReal]),GetPt(pxEle[myFake],pyEle[myFake]));
slowestLeptonPt[ee] = TMath::Min(GetPt(pxEle[myReal],pyEle[myReal]),GetPt(pxEle[myFake],pyEle[myFake]));
hardestLeptonEta[ee] = etaEle[myReal];
slowestLeptonEta[ee] = etaEle[myFake];
m_p4LeptonMinus[ee] -> SetXYZT(pxEle[myReal], pyEle[myReal], pzEle[myReal], energyEle[myReal]);
m_p4LeptonPlus[ee] -> SetXYZT(pxEle[myFake],pyEle[myFake],pzEle[myFake],energyEle[myFake]);
m_mll[ee] = (*(m_p4LeptonMinus[ee]) + *(m_p4LeptonPlus[ee])).M();
m_deltaPhi[ee] = fabs(180./TMath::Pi() * m_p4LeptonMinus[ee]->Vect().DeltaPhi(m_p4LeptonPlus[ee]->Vect()));
m_deltaErre[ee] = m_p4LeptonMinus[ee]->Vect().DeltaR(m_p4LeptonPlus[ee]->Vect());
m_deltaEtaLeptons[ee] = etaEle[myReal]-etaEle[myFake];
m_dilepPt[ee].SetXYZ( m_p4LeptonMinus[ee]->Vect().X()+m_p4LeptonPlus[ee]->Vect().X(),m_p4LeptonMinus[ee]->Vect().Y()+m_p4LeptonPlus[ee]->Vect().Y(),0.0 );
m_transvMass[ee]=CalcGammaMRstar(*m_p4LeptonMinus[ee],*m_p4LeptonPlus[ee]);
m_metOptll[ee] = m_theMET / m_dilepPt[ee].Pt();
m_mT2[ee] = 0.;
// m_p4MET->SetXYZT(pxPFMet[0],pyPFMet[0],pzPFMet[0],energyPFMet[0]);
m_projectedMet[ee] = GetProjectedMet(m_p4LeptonMinus[ee]->Vect(),m_p4LeptonPlus[ee]->Vect());
}
}
void LeptonPlusFakeMLSelection::resetKinematicsStart() {
theReal = -1;
theFake = -1;
thePreElectron = -1;
thePrePositron = -1;
}
void LeptonPlusFakeMLSelection::resetKinematics() {
for(int theChannel=0; theChannel<1; theChannel++) {
eleCands[theChannel].clear();
muCands[theChannel].clear();
m_p4LeptonMinus[theChannel] -> SetXYZT(0,0,0,0);
m_p4LeptonPlus[theChannel] -> SetXYZT(0,0,0,0);
m_p3PFMET -> SetXYZ(0,0,0);
m_p3TKMET -> SetXYZ(0,0,0);
hardestLeptonPt[theChannel] = 0.;
slowestLeptonPt[theChannel] = 0.;
hardestLeptonEta[theChannel] = 0.;
slowestLeptonEta[theChannel] = 0.;
m_mll[theChannel] = 0.;
m_deltaPhi[theChannel] = 0.;
m_deltaErre[theChannel] = 0.;
m_deltaEtaLeptons[theChannel] = 0.;
m_dilepPt[theChannel] = 0.;
m_transvMass[theChannel] = 0.;
m_metOptll[theChannel] = 0.;
m_mT2[theChannel] = 0.;
m_projectedMet[theChannel] = 0.;
}
}
void LeptonPlusFakeMLSelection::isEleID(int eleIndex, bool *eleIdOutput, bool *isolOutput, bool *convRejOutput, CutBasedEleIDSelector *thisCutBasedID) {
*eleIdOutput = *isolOutput = *convRejOutput = false;
Utils anaUtils;
int gsf = gsfTrackIndexEle[eleIndex];
float pt = GetPt(pxEle[eleIndex],pyEle[eleIndex]);
// if is ECAL driven, take the electron ID variables from the standard electron
// above all, take the ECAL supercluster instead of PF super cluster
float HoE, s9s25, deta, dphiin, dphiout, fbrem, see, spp, eopout, eop;
float e1, e4SwissCross, fidFlagSC, seedRecHitFlag, seedTime, seedChi2;
bool ecaldriven = anaUtils.electronRecoType(recoFlagsEle[eleIndex], isEcalDriven);
HoE = hOverEEle[eleIndex];
deta = deltaEtaAtVtxEle[eleIndex];
dphiin = deltaPhiAtVtxEle[eleIndex];
dphiout = deltaPhiAtCaloEle[eleIndex];
fbrem = fbremEle[eleIndex];
eopout = eSeedOverPoutEle[eleIndex];
eop = eSuperClusterOverPEle[eleIndex];
if(ecaldriven) {
int sc = superClusterIndexEle[eleIndex];
s9s25 = e3x3SC[sc]/e5x5SC[sc];
see = sqrt(covIEtaIEtaSC[sc]);
spp = sqrt(covIPhiIPhiSC[sc]);
e1 = eMaxSC[sc];
e4SwissCross = e4SwissCrossSC[sc];
fidFlagSC = fiducialFlagsEle[eleIndex];
seedRecHitFlag = recoFlagSC[sc];
seedTime = timeSC[sc];
seedChi2 = chi2SC[sc];
} else {
int sc = PFsuperClusterIndexEle[eleIndex];
if(sc>-1) {
s9s25 = e3x3PFSC[sc]/e5x5PFSC[sc];
see = sqrt(covIEtaIEtaPFSC[sc]);
spp = sqrt(covIPhiIPhiPFSC[sc]);
e1 = eMaxSC[sc];
e4SwissCross = e4SwissCrossSC[sc];
fidFlagSC = fiducialFlagsEle[eleIndex];
seedRecHitFlag = recoFlagSC[sc];
seedTime = timeSC[sc];
seedChi2 = chi2SC[sc];
} else {
s9s25 = 999.;
see = 999.;
spp = 999.;
}
}
thisCutBasedID->SetEcalFiducialRegion( fiducialFlagsEle[eleIndex] );
thisCutBasedID->SetRecoFlag(recoFlagsEle[eleIndex]);
thisCutBasedID->applyElectronIDOnPFlowElectrons(true);
thisCutBasedID->SetHOverE( HoE );
thisCutBasedID->SetS9S25( s9s25 );