-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreselection_UL.h
2015 lines (1725 loc) · 102 KB
/
preselection_UL.h
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
/// Header file with functions needed to execute the Python version
/// preselection step of the analysis. The header is declared to the
/// ROOT C++ interpreter prior to the start of the analysis via the
/// `ROOT.gInterpreter.Declare()` function.
///
/// Header file with functions needed to execute the Python version
/// preselection step of the analysis. The header is declared to the
/// ROOT C++ interpreter prior to the start of the analysis via the
/// `ROOT.gInterpreter.Declare()` function.
///
#ifndef PRE_H
#define PRE_H
#include "ROOT/RDataFrame.hxx"
#include "ROOT/RVec.hxx"
#include "TCanvas.h"
#include "TH1D.h"
#include "TFile.h"
#include "TH2D.h"
#include "TH2F.h"
#include "TLatex.h"
#include "Math/Vector4D.h"
#include "TStyle.h"
#include <map>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <TH1.h>
#include <TH2.h>
#include <TH2F.h>
#include <cmath>
//#include <curl/curl.h>
#include <stdio.h>
#include "TDavixFile.h"
using namespace ROOT::VecOps;
using RNode = ROOT::RDF::RNode;
using rvec_f = const RVec<float> &;
using rvec_i = const RVec<int> &;
using rvec_b = const RVec<bool> &;
const string remote_storage = "https://vbs-pg-support.web.cern.ch/nanoAOD-tools/";
//cout<<"ciao"<<endl;
bool Pass_min_req(rvec_b Muon_looseId, rvec_f Muon_pt, rvec_f Muon_pfRelIso04_all, rvec_f Muon_eta, rvec_b Electron_mvaFall17V2Iso_WPL, rvec_f Electron_jetRelIso, rvec_f Electron_pt, rvec_f Electron_eta, rvec_i Tau_idDeepTau2017v2p1VSjet, rvec_i Tau_idDeepTau2017v2p1VSe, rvec_i Tau_idDeepTau2017v2p1VSmu, rvec_f Tau_pt, rvec_f Tau_eta, rvec_f Jet_pt, rvec_f Jet_eta, rvec_i Jet_puId)
{
bool loose_muon = false;
bool loose_ele = false;
bool loose_tau = false;
bool loose_jet = false;
for(int i = 0; i < Muon_pt.size(); i++){
if(Muon_looseId[i] && Muon_pt[i] > 30. && Muon_pfRelIso04_all[i] < 1. && Muon_pfRelIso04_all[i] >=0. && abs(Muon_eta[i]) < 2.4){
loose_muon = true;
break;
}
}
if(loose_muon == false){
for(int i = 0; i < Electron_pt.size(); i++){
if(Electron_mvaFall17V2Iso_WPL[i] && Electron_jetRelIso[i] < 1. && Electron_jetRelIso[i] >= 0. && Electron_pt[i] > 30. && ((abs(Electron_eta[i]) < 1.4442) || (abs(Electron_eta[i]) > 1.566 && abs(Electron_eta[i])< 2.5))){
loose_ele = true;
break;
}
}
}
if(loose_muon || loose_ele){
for(int i = 0; i < Tau_pt.size(); i++){
if(Tau_idDeepTau2017v2p1VSjet[i] >= 2 && Tau_idDeepTau2017v2p1VSe[i] >= 4 && Tau_idDeepTau2017v2p1VSmu[i] >= 8 && Tau_pt[i] > 30. && abs(Tau_eta[i]) < 2.3){
loose_tau = true;
break;
}
}
}
if((loose_muon || loose_ele) && loose_tau){
for(int i = 0; i < Jet_pt.size(); i++){
if(Jet_pt[i] > 30 and abs(Jet_eta[i]) < 5. && Jet_pt[i] > 30. && (Jet_pt[i] >= 50. || (Jet_pt[i] < 50. and Jet_puId[i] >= 7))){
loose_jet = true;
break;
}
}
}
return (loose_muon || loose_ele) && loose_tau && loose_jet;
}
RVec<float> MHT_pt_phi(rvec_f Electron_pt, rvec_f Electron_eta, rvec_f Electron_phi, rvec_f Electron_mass, rvec_f Electron_miniPFRelIso_all, rvec_f Muon_pt, rvec_f Muon_eta, rvec_f Muon_phi, rvec_f Muon_mass, rvec_f Muon_miniPFRelIso_all, rvec_f Jet_pt, rvec_f Jet_eta, rvec_f Jet_phi, rvec_f Jet_mass, rvec_i Jet_muonIdx1, rvec_i Jet_muonIdx2, rvec_i Jet_electronIdx1, rvec_i Jet_electronIdx2, int nJet){
RVec<float> MHT_pt_phi(2);
ROOT::Math::PtEtaPhiMVector mht;
for (size_t j = 0; j < Muon_pt.size(); j++){
if (Muon_pt[j] > 20 && Muon_miniPFRelIso_all[j] < 0.2){
ROOT::Math::PtEtaPhiMVector p(Muon_pt[j], Muon_eta[j], Muon_phi[j], Muon_mass[j]);
mht = mht + p;
}
}
for (size_t j = 0; j < Electron_pt.size(); j++){
if (Electron_pt[j] > 20 && Electron_miniPFRelIso_all[j] < 0.2){
ROOT::Math::PtEtaPhiMVector p(Electron_pt[j], Electron_eta[j], Electron_phi[j], Electron_mass[j]);
mht = mht + p;
}
}
//RVec<int> goodjets(nJets)
for (size_t i = 0; i < Jet_pt.size(); i++) {
//if (Jet_pt[i] > 40) continue;
if (Jet_pt[i] < 40) continue;
if (Jet_muonIdx1[i] != -1 and Jet_muonIdx1[i] < nJet){
if (Muon_pt[Jet_muonIdx1[i]] > 20 && Muon_miniPFRelIso_all[Jet_muonIdx1[i]] < 0.2) continue; //prefer the muon
}
if (Jet_muonIdx2[i] != -1 and Jet_muonIdx2[i] < nJet){
if (Muon_pt[Jet_muonIdx2[i]] > 20 && Muon_miniPFRelIso_all[Jet_muonIdx2[i]] < 0.2) continue; //prefer the muon
}
if (Jet_electronIdx1[i] != -1 and Jet_electronIdx1[i] < nJet){
if (Electron_pt[Jet_electronIdx1[i]] > 20 && Electron_miniPFRelIso_all[Jet_electronIdx1[i]] < 0.2) continue; //prefer the electron
}
if (Jet_electronIdx2[i] != -1 and Jet_electronIdx2[i] < nJet){
if (Electron_pt[Jet_electronIdx2[i]] > 20 && Electron_miniPFRelIso_all[Jet_electronIdx2[i]] < 0.2) continue; //prefer the electron
}
//goodjets[i] = 1;
ROOT::Math::PtEtaPhiMVector p(Jet_pt[i], Jet_eta[i], Jet_phi[i], Jet_mass[i]);
mht = mht + p;
}
MHT_pt_phi[0] = mht.Pt();
MHT_pt_phi[1] = -mht.Phi();
return MHT_pt_phi;
}
float getFirst(rvec_f a){
return a[0];
}
float getSecond(rvec_f a){
return a[1];
}
//float GetYear(unsigned int slot, const ROOT::RDF::RSampleInfo &id){
// Int_t year;
// if (id.Contains("RunIISummer16NanoAODv7")){
// year = 2016;
// } else if (id.Contains("RunIIFall17NanoAODv7")){
// year = 2017;
// } else if (id.Contains("RunIIAutumn18NanoAODv7")){
// year = 2018;
// }
// return year;
//}
string GetYear(unsigned int slot, const ROOT::RDF::RSampleInfo &id){
string year="2017";
if (id.Contains("RunIISummer16NanoAODv7")){
year = "2016";
} else if (id.Contains("RunIIFall17NanoAODv7")){
year = "2017";
} else if (id.Contains("RunIIAutumn18NanoAODv7")){
year = "2018";
}
return year;
}
map<string, int> dataset_map = {{"/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL16NanoAODAPVv2-106X_mcRun2_asymptotic_preVFP_v9-v1/NANOAODSIM", 25}, {"/WGToLNuG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 26}, {"/TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 18}, {"/TTZToQQ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 19}, {"/TTZToLLNuNu_M-10_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 20}, {"/TTWJetsToQQ_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL16NanoAODAPVv2-106X_mcRun2_asymptotic_preVFP_v9-v1/NANOAODSIM", 21}, {"/TTWJetsToLNu_TuneCP5down_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL16NanoAODAPVv2-106X_mcRun2_asymptotic_preVFP_v9-v1/NANOAODSIM", 22}, {"/tZq_ll_4f_ckm_NLO_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 23}, {"/WWTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 28}, {"/WWW_4F_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11_ext1-v1/NANOAODSIM", 50}, {"/WWZ_4F_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11_ext1-v1/NANOAODSIM", 51}, {"/WZZ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11_ext1-v1/NANOAODSIM", 52}, {"/ZZZ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11_ext1-v1/NANOAODSIM", 53}, {"/WWG_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 54}, {"/TTTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 15}, {"/WZ_TuneCP5_13TeV-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 64}, {"/DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 67}, {"/GluGluToWWToENEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 29}, {"/GluGluToWWToENMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 30}, {"/GluGluToWWToENTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 31}, {"/GluGluToWWToMNEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 32}, {"/GluGluToWWToMNMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 33}, {"/GluGluToWWToMNTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 34}, {"/GluGluToWWToTNEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 35}, {"/GluGluToWWToTNMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 36}, {"/GluGluToWWToTNTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 37}, {"/ST_tW_top_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 38}, {"/GluGluHToWWTo2L2Nu_M125_TuneCP5_PSw_13TeV-powheg2-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 40}, {"/GluGluHToZZTo4L_M125_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 42}, {"/GluGluHToTauTau_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 43}, {"/VBFHToWWTo2L2Nu_M-125_TuneCP5_13TeV-powheg-jhugen727-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 44}, {"/VBFHToTauTau_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODAPVv2-106X_mcRun2_asymptotic_preVFP_v9-v1/NANOAODSIM", 45}, {"/ttHToNonbb_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 46}, {"/VHToNonbb_M125_TuneCP5_13TeV-amcatnloFXFX_madspin_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 47}, {"/ZZTo2L2Nu_TuneCP5_13TeV_powheg_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 1}, {"/ZZTo4L_M-1toInf_TuneCP5_13TeV_powheg_pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 2}, {"/GluGluToContinToZZTo2e2nu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODAPVv2-106X_mcRun2_asymptotic_preVFP_v9-v1/NANOAODSIM", 11}, {"/GluGluToContinToZZTo2e2mu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 4}, {"/GluGluToContinToZZTo2e2tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 5}, {"/GluGluToContinToZZTo2mu2nu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 6}, {"/GluGluToContinToZZTo2mu2tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 8}, {"/GluGluToContinToZZTo4e_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 3}, {"/GluGluToContinToZZTo4mu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODAPVv2-106X_mcRun2_asymptotic_preVFP_v9-v1/NANOAODSIM", 7}, {"/GluGluToContinToZZTo4tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 10}, {"/VBS_SSWW_LL_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v2/NANOAODSIM", 71}, {"/VBS_SSWW_TL_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL16NanoAODAPVv9-106X_mcRun2_asymptotic_preVFP_v11-v1/NANOAODSIM", 72}, {"/VBS_SSWW_TT_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL16NanoAODAPVv2-106X_mcRun2_asymptotic_preVFP_v9-v1/NANOAODSIM", 73}, {"/SingleElectron/Run2016B-ver2_HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 363}, {"/SingleElectron/Run2016C-HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 364}, {"/SingleElectron/Run2016D-HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 365}, {"/SingleElectron/Run2016E-HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 366}, {"/SingleElectron/Run2016F-HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 367}, {"/SingleMuon/Run2016B-ver2_HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 341}, {"/SingleMuon/Run2016C-HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 342}, {"/SingleMuon/Run2016D-HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 343}, {"/SingleMuon/Run2016E-HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 344}, {"/SingleMuon/Run2016F-HIPM_UL2016_MiniAODv2_NanoAODv9-v2/NANOAOD", 345}, {"/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 110}, {"/WGToLNuG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 111}, {"/TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 103}, {"/TTZToQQ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 104}, {"/TTZToLLNuNu_M-10_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 105}, {"/TTWJetsToQQ_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 106}, {"/TTWJetsToLNu_TuneCP5down_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL16NanoAODAPVv2-106X_mcRun2_asymptotic_preVFP_v9-v1/NANOAODSIM", 107}, {"/tZq_ll_4f_ckm_NLO_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 108}, {"/WWTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 113}, {"/WWW_4F_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17_ext1-v1/NANOAODSIM", 134}, {"/WWZ_4F_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17_ext1-v1/NANOAODSIM", 135}, {"/WZZ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17_ext1-v1/NANOAODSIM", 136}, {"/ZZZ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17_ext1-v1/NANOAODSIM", 137}, {"/WWG_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 138}, {"/TTTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 100}, {"/WZ_TuneCP5_13TeV-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 148}, {"/DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 151}, {"/GluGluToWWToENEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 114}, {"/GluGluToWWToENMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 115}, {"/GluGluToWWToENTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 116}, {"/GluGluToWWToMNEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 117}, {"/GluGluToWWToMNMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 118}, {"/GluGluToWWToMNTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 119}, {"/GluGluToWWToTNEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 120}, {"/GluGluToWWToTNMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 121}, {"/GluGluToWWToTNTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 122}, {"/ST_tW_top_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 123}, {"/GluGluHToWWTo2L2Nu_M125_TuneCP5_PSw_13TeV-powheg2-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 125}, {"/GluGluHToZZTo4L_M125_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 127}, {"/GluGluHToTauTau_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODv2-106X_mcRun2_asymptotic_v15-v1/NANOAODSIM", 128}, {"/VBFHToWWTo2L2Nu_M-125_TuneCP5_13TeV-powheg-jhugen727-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 129}, {"/VBFHToTauTau_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 130}, {"/ttHToNonbb_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 131}, {"/VHToNonbb_M125_TuneCP5_13TeV-amcatnloFXFX_madspin_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 132}, {"/ZZTo2L2Nu_TuneCP5_13TeV_powheg_pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 86}, {"/ZZTo2L2Nu_TuneCP5_13TeV_powheg_pythia8/RunIISummer20UL16NanoAODv9-20UL16JMENano_106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 87}, {"/GluGluToContinToZZTo2e2nu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 96}, {"/GluGluToContinToZZTo2e2mu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 89}, {"/GluGluToContinToZZTo2e2tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 90}, {"/GluGluToContinToZZTo2mu2nu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 91}, {"/GluGluToContinToZZTo2mu2tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 93}, {"/GluGluToContinToZZTo4e_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 88}, {"/GluGluToContinToZZTo4mu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 92}, {"/GluGluToContinToZZTo4tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 95}, {"/VBS_SSWW_LL_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 155}, {"/VBS_SSWW_TL_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v2/NANOAODSIM", 156}, {"/VBS_SSWW_TT_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL16NanoAODv9-106X_mcRun2_asymptotic_v17-v1/NANOAODSIM", 157}, {"/SingleElectron/Run2016F-UL2016_MiniAODv2_NanoAODv9-v1/NANOAOD", 369}, {"/SingleElectron/Run2016G-UL2016_MiniAODv2_NanoAODv9-v1/NANOAOD", 370}, {"/SingleElectron/Run2016H-UL2016_MiniAODv2_NanoAODv9-v1/NANOAOD", 371}, {"/SingleMuon/Run2016F-UL2016_MiniAODv2_NanoAODv9-v1/NANOAOD", 347}, {"/SingleMuon/Run2016G-UL2016_MiniAODv2_NanoAODv9-v1/NANOAOD", 348}, {"/SingleMuon/Run2016H-UL2016_MiniAODv2_NanoAODv9-v1/NANOAOD", 349}, {"/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 194}, {"/WGToLNuG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 195}, {"/TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 187}, {"/TTZToQQ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 188}, {"/TTZToLLNuNu_M-10_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 189}, {"/TTWJetsToQQ_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 190}, {"/TTWJetsToLNu_TuneCP5down_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 191}, {"/tZq_ll_4f_ckm_NLO_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 192}, {"/WWTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 197}, {"/WWW_4F_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9_ext1-v2/NANOAODSIM", 219}, {"/WWZ_4F_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 220}, {"/WZZ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9_ext1-v2/NANOAODSIM", 221}, {"/ZZZ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9_ext1-v2/NANOAODSIM", 222}, {"/WWG_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 223}, {"/TTTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 184}, {"/WZ_TuneCP5_13TeV-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 233}, {"/DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 236}, {"/GluGluToWWToENEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 198}, {"/GluGluToWWToENMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 199}, {"/GluGluToWWToENTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 200}, {"/GluGluToWWToMNEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 201}, {"/GluGluToWWToMNMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 202}, {"/GluGluToWWToMNTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 203}, {"/GluGluToWWToTNEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 204}, {"/GluGluToWWToTNMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv2-106X_mc2017_realistic_v8-v1/NANOAODSIM", 205}, {"/GluGluToWWToTNTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 206}, {"/ST_tW_top_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 207}, {"/GluGluHToWWTo2L2Nu_M125_TuneCP5_PSw_13TeV-powheg2-pythia8/RunIISummer20UL17NanoAODv2-106X_mc2017_realistic_v8-v1/NANOAODSIM", 209}, {"/GluGluHToZZTo4L_M125_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 211}, {"/GluGluHToTauTau_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 212}, {"/VBFHToWWTo2L2Nu_M-125_TuneCP5_13TeV-powheg-jhugen727-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 213}, {"/VBFHToTauTau_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 214}, {"/ttHToNonbb_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 215}, {"/VHToNonbb_M125_TuneCP5_13TeV-amcatnloFXFX_madspin_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 216}, {"/ZZTo2L2Nu_TuneCP5_13TeV_powheg_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 170}, {"/ZZTo4L_M-1toInf_TuneCP5_13TeV_powheg_pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 171}, {"/GluGluToContinToZZTo2e2nu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 180}, {"/GluGluToContinToZZTo2e2mu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 173}, {"/GluGluToContinToZZTo2e2tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 174}, {"/GluGluToContinToZZTo2mu2nu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 175}, {"/GluGluToContinToZZTo2mu2tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 177}, {"/GluGluToContinToZZTo4e_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 172}, {"/GluGluToContinToZZTo4mu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 176}, {"/GluGluToContinToZZTo4tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 179}, {"/VBS_SSWW_LL_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 240}, {"/VBS_SSWW_TL_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 241}, {"/VBS_SSWW_TT_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v1/NANOAODSIM", 242}, {"/SingleElectron/Run2017B-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 373}, {"/SingleElectron/Run2017C-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 374}, {"/SingleElectron/Run2017D-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 375}, {"/SingleElectron/Run2017E-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 376}, {"/SingleElectron/Run2017F-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 377}, {"/SingleMuon/Run2017B-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 351}, {"/SingleMuon/Run2017C-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 352}, {"/SingleMuon/Run2017D-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 353}, {"/SingleMuon/Run2017E-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 354}, {"/SingleMuon/Run2017F-UL2017_MiniAODv2_NanoAODv9-v1/NANOAOD", 355}, {"/ZGToLLG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 279}, {"/WGToLNuG_01J_5f_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 280}, {"/TTGJets_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 272}, {"/TTZToQQ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 273}, {"/TTZToLLNuNu_M-10_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 274}, {"/TTWJetsToQQ_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 275}, {"/TTWJetsToLNu_TuneCP5_13TeV-amcatnloFXFX-madspin-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 276}, {"/tZq_ll_4f_ckm_NLO_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL18NanoAODv2-106X_upgrade2018_realistic_v15_L1v1-v1/NANOAODSIM", 277}, {"/WWTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 282}, {"/WWW_4F_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1_ext1-v2/NANOAODSIM", 304}, {"/WWZ_4F_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1_ext1-v2/NANOAODSIM", 305}, {"/WZZ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1_ext1-v2/NANOAODSIM", 306}, {"/ZZZ_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1_ext1-v2/NANOAODSIM", 307}, {"/WWG_TuneCP5_13TeV-amcatnlo-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 308}, {"/TTTo2L2Nu_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 269}, {"/WZ_TuneCP5_13TeV-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 318}, {"/DYJetsToLL_M-50_TuneCP5_13TeV-amcatnloFXFX-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 321}, {"/GluGluToWWToENEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 283}, {"/GluGluToWWToENMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 284}, {"/GluGluToWWToENTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 285}, {"/GluGluToWWToMNEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 286}, {"/GluGluToWWToMNMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 287}, {"/GluGluToWWToMNTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 288}, {"/GluGluToWWToTNEN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 289}, {"/GluGluToWWToTNMN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 290}, {"/GluGluToWWToTNTN_TuneCP5_13TeV_MCFM701_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 291}, {"/ST_tW_top_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 292}, {"/GluGluHToWWTo2L2Nu_M125_TuneCP5_PSw_13TeV-powheg2-pythia8/RunIISummer20UL18NanoAODv2-106X_upgrade2018_realistic_v15_L1v1-v1/NANOAODSIM", 294}, {"/GluGluHToZZTo4L_M125_TuneCP5_13TeV_powheg2_JHUGenV7011_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 296}, {"/GluGluHToTauTau_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 297}, {"/VBFHToWWTo2L2Nu_M-125_TuneCP5_13TeV-powheg-jhugen727-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 298}, {"/VBFHToTauTau_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 299}, {"/ttHToNonbb_M125_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 300}, {"/VHToNonbb_M125_TuneCP5_13TeV-amcatnloFXFX_madspin_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 301}, {"/ZZTo2L2Nu_TuneCP5_13TeV_powheg_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 255}, {"/ZZTo4L_M-1toInf_TuneCP5_13TeV_powheg_pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 256}, {"/GluGluToContinToZZTo2e2nu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 265}, {"/GluGluToContinToZZTo2e2mu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 258}, {"/GluGluToContinToZZTo2e2tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 259}, {"/GluGluToContinToZZTo2mu2nu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 260}, {"/GluGluToContinToZZTo2mu2tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 262}, {"/GluGluToContinToZZTo4e_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 257}, {"/GluGluToContinToZZTo4mu_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL18NanoAODv2-106X_upgrade2018_realistic_v15_L1v1-v1/NANOAODSIM", 261}, {"/GluGluToContinToZZTo4tau_TuneCP5_13TeV-mcfm701-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v2/NANOAODSIM", 264}, {"/VBS_SSWW_LL_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL18NanoAODv9-106X_upgrade2018_realistic_v16_L1v1-v1/NANOAODSIM", 325}, {"/VBS_SSWW_TL_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL18NanoAODv2-106X_upgrade2018_realistic_v15_L1v1-v1/NANOAODSIM", 326}, {"/VBS_SSWW_TT_polarization_TuneCP5_13TeV-madgraph-pythia8/RunIISummer20UL18NanoAODv2-106X_upgrade2018_realistic_v15_L1v1-v1/NANOAODSIM", 327}, {"/EGamma/Run2018A-UL2018_MiniAODv2_NanoAODv9-v1/NANOAOD", 379}, {"/EGamma/Run2018B-UL2018_MiniAODv2_NanoAODv9-v1/NANOAOD", 380}, {"/EGamma/Run2018C-UL2018_MiniAODv2_NanoAODv9-v1/NANOAOD", 381}, {"/EGamma/Run2018D-UL2018_MiniAODv2_NanoAODv9-v3/NANOAOD", 382}, {"/SingleMuon/Run2018A-UL2018_MiniAODv2_NanoAODv9-v2/NANOAOD", 357}, {"/SingleMuon/Run2018B-UL2018_MiniAODv2_NanoAODv9-v2/NANOAOD", 358}, {"/SingleMuon/Run2018C-UL2018_MiniAODv2_NanoAODv9-v2/NANOAOD", 359}, {"/SingleMuon/Run2018D-UL2018_MiniAODv2_NanoAODv9-v1/NANOAOD", 360}, {"/ST_tW_antitop_5f_inclusiveDecays_TuneCP5_13TeV-powheg-pythia8/RunIISummer20UL17NanoAODv9-106X_mc2017_realistic_v9-v2/NANOAODSIM", 208}};
string tokenize(string s, string del = " ")
{
int start = 0;
int end = s.find(del);
int i = 0;
int start_ = 0;
int end_ = 0;
string string1, string2, string3, string4;
while (end != -1) {
//cout << s.substr(start, end - start) << endl;
start = end + del.size();
end = s.find(del, start);
if (i == 5) string1 = s.substr(start, end - start);
else if (i==6) string2 = s.substr(start, end - start);
else if (i==7) string3 = s.substr(start, end - start);
else if (i==8) string4 = s.substr(start, end - start);
//cout<<i<<" "<<s.substr(start, end - start)<<endl;
i++;
}
string result;
result += string("/") + string2 + string("/") + string1 + string("-") + string4 + string("/") + string3;
return result;
}
int GetSample(unsigned int slot, const ROOT::RDF::RSampleInfo &id){
return dataset_map[tokenize(id.AsString(), "/")];
}
bool MET_HLT_Filter_UL2017(string Year, Bool_t Flag_goodVertices, Bool_t Flag_HBHENoiseFilter, Bool_t Flag_HBHENoiseIsoFilter, Bool_t Flag_EcalDeadCellTriggerPrimitiveFilter, Bool_t Flag_BadPFMuonFilter, Bool_t Flag_globalSuperTightHalo2016Filter, Bool_t HLT_IsoMu27, Bool_t HLT_Mu50, Bool_t HLT_OldMu100, Bool_t HLT_TkMu100, Bool_t HLT_Ele35_WPTight_Gsf, Bool_t HLT_Ele32_WPTight_Gsf_L1DoubleEG, Bool_t HLT_Photon200, Bool_t Flag_ecalBadCalibFilter, Bool_t Flag_BadPFMuonDzFilter, Bool_t L1_SingleIsoEG30er2p1, Bool_t L1_SingleIsoEG32, Bool_t L1_SingleEG40, Bool_t Flag_eeBadScFilter){
bool good_MET = Flag_goodVertices && Flag_globalSuperTightHalo2016Filter && Flag_HBHENoiseFilter && Flag_HBHENoiseIsoFilter && Flag_EcalDeadCellTriggerPrimitiveFilter && Flag_BadPFMuonFilter && Flag_eeBadScFilter && Flag_ecalBadCalibFilter && Flag_BadPFMuonDzFilter;
//bool good_HLT = HLT_IsoMu27 || HLT_Mu50 || HLT_OldMu100 || HLT_TkMu100 || HLT_Ele35_WPTight_Gsf || (HLT_Ele32_WPTight_Gsf_L1DoubleEG && (L1_SingleIsoEG30er2p1 || L1_SingleIsoEG32 || L1_SingleEG40)) || HLT_Photon200; OLD
//bool good_HLT = HLT_IsoMu27 || HLT_Mu50 || HLT_OldMu100 || HLT_TkMu100 || HLT_Ele35_WPTight_Gsf || HLT_Ele32_WPTight_Gsf_L1DoubleEG;
bool good_HLT = HLT_IsoMu27 || HLT_Mu50 || HLT_Ele35_WPTight_Gsf || HLT_Ele32_WPTight_Gsf_L1DoubleEG;
return good_MET && good_HLT;
}
bool MET_HLT_Filter_UL2017_nodz(string Year, Bool_t Flag_goodVertices, Bool_t Flag_HBHENoiseFilter, Bool_t Flag_HBHENoiseIsoFilter, Bool_t Flag_EcalDeadCellTriggerPrimitiveFilter, Bool_t Flag_BadPFMuonFilter, Bool_t Flag_globalSuperTightHalo2016Filter, Bool_t HLT_IsoMu27, Bool_t HLT_Mu50, Bool_t HLT_OldMu100, Bool_t HLT_TkMu100, Bool_t HLT_Ele35_WPTight_Gsf, Bool_t HLT_Ele32_WPTight_Gsf_L1DoubleEG, Bool_t HLT_Photon200, Bool_t Flag_ecalBadCalibFilter, Bool_t L1_SingleIsoEG30er2p1, Bool_t L1_SingleIsoEG32, Bool_t L1_SingleEG40, Bool_t Flag_eeBadScFilter){
bool good_MET = Flag_goodVertices && Flag_globalSuperTightHalo2016Filter && Flag_HBHENoiseFilter && Flag_HBHENoiseIsoFilter && Flag_EcalDeadCellTriggerPrimitiveFilter && Flag_BadPFMuonFilter && Flag_eeBadScFilter && Flag_ecalBadCalibFilter;
//bool good_HLT = HLT_IsoMu27 || HLT_Mu50 || HLT_OldMu100 || HLT_TkMu100 || HLT_Ele35_WPTight_Gsf || (HLT_Ele32_WPTight_Gsf_L1DoubleEG && (L1_SingleIsoEG30er2p1 || L1_SingleIsoEG32 || L1_SingleEG40)) || HLT_Photon200;
//bool good_HLT = HLT_IsoMu27 || HLT_Mu50 || HLT_OldMu100 || HLT_TkMu100 || HLT_Ele35_WPTight_Gsf || HLT_Ele32_WPTight_Gsf_L1DoubleEG;
bool good_HLT = HLT_IsoMu27 || HLT_Mu50 || HLT_Ele35_WPTight_Gsf || HLT_Ele32_WPTight_Gsf_L1DoubleEG;
return good_MET && good_HLT;
}
/*
float MET_HLT_Filter(string Year, Bool_t Flag_goodVertices, Bool_t Flag_HBHENoiseFilter, Bool_t Flag_HBHENoiseIsoFilter, Bool_t Flag_EcalDeadCellTriggerPrimitiveFilter, Bool_t Flag_BadPFMuonFilter, Bool_t Flag_globalSuperTightHalo2016Filter, Bool_t HLT_Ele27_WPTight_Gsf, Bool_t HLT_Ele32_WPTight_Gsf, Bool_t HLT_IsoMu24, Bool_t HLT_IsoMu27, Bool_t HLT_Mu50, Bool_t HLT_Ele35_WPTight_Gsf, Bool_t HLT_Ele32_WPTight_Gsf_L1DoubleEG, Bool_t HLT_Photon200){
bool good_MET = Flag_goodVertices && Flag_HBHENoiseFilter && Flag_HBHENoiseIsoFilter && Flag_EcalDeadCellTriggerPrimitiveFilter && Flag_BadPFMuonFilter;
bool good_HLT;
bool HLT_IsoTkMu24 = true;
if (Year == "2016"){
good_HLT = (HLT_Ele27_WPTight_Gsf || HLT_Ele32_WPTight_Gsf || HLT_IsoMu24 || HLT_IsoTkMu24) && Flag_globalSuperTightHalo2016Filter;
} else if (Year == "2017"){
good_HLT = (HLT_IsoMu27 || HLT_Mu50 || HLT_Ele35_WPTight_Gsf || HLT_Ele32_WPTight_Gsf_L1DoubleEG || HLT_Photon200); // or HLT.PFHT250 or HLT.PFHT350)
} else if (Year == "2018"){
good_HLT = (HLT_IsoMu27 || HLT_Mu50 || HLT_Ele35_WPTight_Gsf || HLT_Ele32_WPTight_Gsf_L1DoubleEG || HLT_Photon200); // or HLT.PFHT250 or HLT.PFHT350)
}
return good_MET && good_HLT;
}
*/
float GetEventHT(rvec_f Jet_pt, rvec_f Jet_eta, rvec_f Jet_phi, rvec_f Jet_mass){
ROOT::Math::PtEtaPhiMVector eventSum;
for (size_t i = 0; i < Jet_pt.size(); i++) {
ROOT::Math::PtEtaPhiMVector p(Jet_pt[i], Jet_eta[i], Jet_phi[i], Jet_mass[i]);
eventSum = eventSum + p;
}
return eventSum.Pt();
}
class WeightCalculatorFromHistogram {
public:
WeightCalculatorFromHistogram() {}
// get the weight from the bin content of the passed histogram
WeightCalculatorFromHistogram(TH1 *histogram, bool verbose=false) : histogram_(histogram), verbose_(verbose) {}
// get the weight from the bin content of the ratio hist/targethist
WeightCalculatorFromHistogram(TH1 *hist, TH1* targethist, bool norm=true, bool fixLargeWeights=true, bool verbose=false);
~WeightCalculatorFromHistogram() {}
float getWeight(float x, float y=0) const;
float getWeightErr(float x, float y=0) const;
private:
std::vector<float> loadVals(TH1 *hist, bool norm=true);
TH1* ratio(TH1 *hist, TH1* targethist, bool fixLargeWgts);
void fixLargeWeights(std::vector<float> &weights, float maxshift=0.0025,float hardmax=3);
float checkIntegral(std::vector<float> wgt1, std::vector<float> wgt2);
TH1* histogram_;
std::vector<float> refvals_,targetvals_;
bool verbose_;
bool norm_;
};
WeightCalculatorFromHistogram::WeightCalculatorFromHistogram(TH1 *hist, TH1* targethist, bool norm, bool fixLargeWeights, bool verbose) {
norm_ = norm;
verbose_ = verbose;
if(hist->GetNcells()!=targethist->GetNcells()) {
std::cout << "ERROR! Numerator and denominator histograms have different number of bins!" << std::endl;
histogram_=0;
} else {
for(int i=0; i<(int)hist->GetNcells(); ++i) {
refvals_.push_back(hist->GetBinContent(i));
targetvals_.push_back(targethist->GetBinContent(i));
}
histogram_ = ratio(hist,targethist,fixLargeWeights);
}
}
float WeightCalculatorFromHistogram::getWeight(float x, float y) const {
if(histogram_==NULL) {
std::cout << "ERROR! The weights input histogram is not loaded. Returning weight 0!" << std::endl;
return 0.;
}
if(!histogram_->InheritsFrom("TH2")) {
int bin = std::max(1, std::min(histogram_->GetNbinsX(), histogram_->GetXaxis()->FindBin(x)));
return histogram_->GetBinContent(bin);
} else {
int binx = std::max(1, std::min(histogram_->GetNbinsX(), histogram_->GetXaxis()->FindBin(x)));
int biny = std::max(1, std::min(histogram_->GetNbinsY(), histogram_->GetYaxis()->FindBin(y)));
return histogram_->GetBinContent(binx,biny);
}
}
float WeightCalculatorFromHistogram::getWeightErr(float x, float y) const {
if(histogram_==NULL) {
std::cout << "ERROR! The weights input histogram is not loaded. Returning weight error 1!" << std::endl;
return 1.;
}
if(!histogram_->InheritsFrom("TH2")) {
int bin = std::max(1, std::min(histogram_->GetNbinsX(), histogram_->GetXaxis()->FindBin(x)));
return histogram_->GetBinError(bin);
} else {
int binx = std::max(1, std::min(histogram_->GetNbinsX(), histogram_->GetXaxis()->FindBin(x)));
int biny = std::max(1, std::min(histogram_->GetNbinsY(), histogram_->GetYaxis()->FindBin(y)));
return histogram_->GetBinError(binx,biny);
}
}
std::vector<float> WeightCalculatorFromHistogram::loadVals(TH1 *hist, bool norm) {
int nbins=hist->GetNcells();
std::vector<float> vals;
for(int i=0; i<nbins; ++i) {
double bc=hist->GetBinContent(i);
//double val = (i>0 && bc==0 && hist->GetBinContent(i-1)>0 && hist->GetBinContent(i+1)>0) ? 0.5*(hist->GetBinContent(i-1)+hist->GetBinContent(i+1)) : bc;
vals.push_back(std::max(bc,0.));
}
if(verbose_) std::cout << "Normalization of " << hist->GetName() << ": " << hist->Integral() << std::endl;
if(norm) {
float scale = 1.0/hist->Integral();
for(int i=0; i<nbins; ++i) vals[i] *= scale;
}
return vals;
}
TH1* WeightCalculatorFromHistogram::ratio(TH1 *hist, TH1* targethist, bool fixLargeWgts) {
TH1 *ret = (TH1*)hist->Clone("hweights");
ret->SetDirectory(0);
std::vector<float> vals = loadVals(hist,norm_);
std::vector<float> targetvals = loadVals(targethist,norm_);
std::vector<float> weights;
int nbins = vals.size();
if(verbose_) std::cout << "Weights for variable " << hist->GetName() << " with a number of bins equal to " << nbins << ":" << std::endl;
for(int i=0; i<nbins; ++i) {
float weight = vals[i] !=0 ? targetvals[i]/vals[i] : 1.;
if(verbose_) std::cout << std::setprecision(3) << weight << " ";
weights.push_back(weight);
}
if(verbose_) std::cout << "." << std::endl;
if(fixLargeWgts) fixLargeWeights(weights);
if(verbose_) std::cout << "Final weights: " << std::endl;
for(int i=0; i<(int)weights.size(); ++i) {
ret->SetBinContent(i,weights[i]);
if(verbose_) std::cout << std::setprecision(3) << weights[i] << " ";
}
if(verbose_) std::cout << "." << std::endl;
return ret;
}
float WeightCalculatorFromHistogram::checkIntegral(std::vector<float> wgt1, std::vector<float> wgt2) {
float myint=0;
float refint=0;
for(int i=0; i<(int)wgt1.size(); ++i) {
myint += wgt1[i]*refvals_[i];
refint += wgt2[i]*refvals_[i];
}
return (myint-refint)/refint;
}
void WeightCalculatorFromHistogram::fixLargeWeights(std::vector<float> &weights, float maxshift,float hardmax) {
float maxw = std::min(*(std::max_element(weights.begin(),weights.end())),float(5.));
std::vector<float> cropped;
while (maxw > hardmax) {
cropped.clear();
for(int i=0; i<(int)weights.size(); ++i) cropped.push_back(std::min(maxw,weights[i]));
float shift = checkIntegral(cropped,weights);
if(verbose_) std::cout << "For maximum weight " << maxw << ": integral relative change: " << shift << std::endl;
if(fabs(shift) > maxshift) break;
maxw *= 0.95;
}
maxw /= 0.95;
if (cropped.size()>0) {
for(int i=0; i<(int)weights.size(); ++i) cropped[i] = std::min(maxw,weights[i]);
float normshift = checkIntegral(cropped,weights);
for(int i=0; i<(int)weights.size(); ++i) weights[i] = cropped[i]*(1-normshift);
}
}
class LeptonEfficiencyCorrector {
public:
LeptonEfficiencyCorrector() {effmaps_.clear();}
LeptonEfficiencyCorrector(std::vector<std::string> files, std::vector<std::string> histos);
~LeptonEfficiencyCorrector() {}
void setLeptons(int nLep, int *lepPdgId, float *lepPt, float *lepEta);
float getSF(int pdgid, float pt, float eta);
float getSFErr(int pdgid, float pt, float eta);
const std::vector<float> & run();
private:
std::vector<TH2F *> effmaps_;
std::vector<float> ret_;
int nLep_;
float *Lep_eta_, *Lep_pt_;
int *Lep_pdgId_;
};
LeptonEfficiencyCorrector:: LeptonEfficiencyCorrector(std::vector<std::string> files, std::vector<std::string> histos) {
effmaps_.clear();
if(files.size()!=histos.size()) {
std::cout << "ERROR! There should be one histogram per input file! Returning 0 as SF." << std::endl;
return;
}
for(int i=0; i<(int)files.size();++i) {
TFile *f = TFile::Open(files[i].c_str(),"read");
if(!f) {
std::cout << "WARNING! File " << files[i] << " cannot be opened. Skipping this scale factor " << std::endl;
continue;
}
TH2F *hist = (TH2F*)(f->Get(histos[i].c_str()))->Clone(("eff_"+histos[i]).c_str());
hist->SetDirectory(0);
if(!hist) {
std::cout << "ERROR! Histogram " << histos[i] << " not in file " << files[i] << ". Not considering this SF. " << std::endl;
continue;
} else {
std::cout << "Loading histogram " << histos[i] << " from file " << files[i] << "... " << std::endl;
}
effmaps_.push_back(hist);
f->Close();
}
}
void LeptonEfficiencyCorrector::setLeptons(int nLep, int *lepPdgId, float *lepPt, float *lepEta) {
nLep_ = nLep; Lep_pdgId_ = lepPdgId; Lep_pt_ = lepPt; Lep_eta_ = lepEta;
}
float LeptonEfficiencyCorrector::getSF(int pdgid, float pt, float eta) {
float out=1.;
//float x = abs(pdgid)==13 ? pt : eta;
//float y = abs(pdgid)==13 ? fabs(eta) : pt;
float x = abs(pdgid)==13 ? fabs(eta) : eta;
float y = abs(pdgid)==13 ? pt : pt;
//float x = abs(pdgid)==13 ? pt : eta; #LEGACY
//float y = abs(pdgid)==13 ? fabs(eta) : pt; #LEGACY
for(std::vector<TH2F*>::iterator hist=effmaps_.begin(); hist<effmaps_.end(); ++hist) {
WeightCalculatorFromHistogram wc(*hist);
out *= wc.getWeight(x,y);
}
return out;
}
float LeptonEfficiencyCorrector::getSFErr(int pdgid, float pt, float eta) {
float out=1.;
//float x = abs(pdgid)==13 ? pt : eta;
//float y = abs(pdgid)==13 ? fabs(eta) : pt;
float x = abs(pdgid)==13 ? fabs(eta) : eta;
float y = abs(pdgid)==13 ? pt : pt;
//float x = pt; #LEGACY
//float y = abs(pdgid)==13 ? fabs(eta) : eta; #LEGACY
for(std::vector<TH2F*>::iterator hist=effmaps_.begin(); hist<effmaps_.end(); ++hist) {
WeightCalculatorFromHistogram wc(*hist);
out *= wc.getWeightErr(x,y);
}
return out;
}
const std::vector<float> & LeptonEfficiencyCorrector::run() {
ret_.clear();
for (int iL = 0, nL = nLep_; iL < nL; ++iL) {
ret_.push_back(getSF((Lep_pdgId_)[iL], (Lep_pt_)[iL], (Lep_eta_)[iL]));
}
return ret_;
}
//string path = "https://ttedesch.web.cern.ch/ttedesch/nanoAOD-tools/python/postprocessing/data/leptonSF/";
string path = "python/postprocessing/data/leptonSF/";
/*
std::vector<std::string> mu_f_2016{remote_storage + path + "Mu_RunBCDEFGH_SF_ID_2016_syst.root"};
std::vector<std::string> el_f_2016{remote_storage + path + "EGM2D_RECO_SF_2016.root", remote_storage + path + "2016LegacyReReco_ElectronMVA90noiso_Fall17V2.root"};
std::vector<std::string> mu_h_2016{"NUM_TightID_DEN_genTracks_eta_pt"};
std::vector<std::string> el_h_2016{"EGamma_SF2D", "EGamma_SF2D"};
std::vector<std::string> mu_f_2017{remote_storage + path + "Muon_RunBCDEF_SF_ID_2017.root", remote_storage + path + "Muon_RunBCDEF_SF_ISO_2017.root"};
std::vector<std::string> el_f_2017{remote_storage + path + "EGM2D_2017_passingRECO_highEt.root", remote_storage + path + "Electron_MVA90_2017.root"};
std::vector<std::string> mu_h_2017{"NUM_TightID_DEN_genTracks_pt_abseta", "NUM_TightRelIso_DEN_TightIDandIPCut_pt_abseta"};
std::vector<std::string> el_h_2017{"EGamma_SF2D", "EGamma_SF2D"};
std::vector<std::string> mu_f_2018{remote_storage + path + "Muon_RunBCDEF_SF_ID_2018.root", remote_storage + path + "Muon_RunBCDEF_SF_ISO_2018.root"};
std::vector<std::string> el_f_2018{remote_storage + path + "EGM2D_passingRECO_2018All.root", remote_storage + path + "2018_ElectronMVA90Iso.root"};
std::vector<std::string> mu_h_2018{"NUM_TightID_DEN_TrackerMuons_pt_abseta", "NUM_TightRelIso_DEN_TightIDandIPCut_pt_abseta"};
std::vector<std::string> el_h_2018{"EGamma_SF2D", "EGamma_SF2D"};
*/
std::vector<std::string> mu_f_2017{remote_storage + path + "MuID_Tight_UL2017.root", remote_storage + path + "MuTRIG_UL2017.root", remote_storage + path + "MuISO_Tight_UL2017.root", remote_storage + path + "MuRECO_UL2017.root"};
std::vector<std::string> el_f_2017{remote_storage + path + "EleRECO_UL2017_EGM2D.root", remote_storage + path + "EleID_WP90Iso_UL2017_EGM2D.root"};
std::vector<std::string> mu_h_2017{"NUM_TightID_DEN_TrackerMuons_abseta_pt", "NUM_IsoMu27_DEN_CutBasedIdTight_and_PFIsoTight_abseta_pt", "NUM_TightRelIso_DEN_TightIDandIPCut_abseta_pt", "NUM_TrackerMuons_DEN_genTracks"};
std::vector<std::string> el_h_2017{"EGamma_SF2D", "EGamma_SF2D"};
//LeptonEfficiencyCorrector worker_mu_2016(mu_f_2016, mu_h_2016);
//LeptonEfficiencyCorrector worker_el_2016(el_f_2016, el_h_2016);
LeptonEfficiencyCorrector worker_mu_2017(mu_f_2017, mu_h_2017);
LeptonEfficiencyCorrector worker_el_2017(el_f_2017, el_h_2017);
//LeptonEfficiencyCorrector worker_mu_2018(mu_f_2018, mu_h_2018);
//LeptonEfficiencyCorrector worker_el_2018(el_f_2018, el_h_2018);
RVec<float> ElectronSFs(rvec_f Electron_pt, rvec_f Electron_eta, rvec_i Electron_pdgId, string Year){
//LeptonEfficiencyCorrector worker_el;
//if (Year == "2016") {
// worker_el = worker_el_2016;
//}
//if (Year == "2017"){
// worker_el = worker_el_2017;
//}
//if (Year == "2018"){
// worker_el = worker_el_2018;
//}
RVec<float> sf_el(Electron_pt.size());
RVec<float> sferr_el(Electron_pt.size());
/*
for (size_t j = 0; j < Electron_pt.size(); j++) sf_el[j] = worker_el.getSF(Electron_pdgId[j], Electron_pt[j], Electron_eta[j]);
for (size_t j = 0; j < Electron_pt.size(); j++) sferr_el[j] = worker_el.getSFErr(Electron_pdgId[j], Electron_pt[j], Electron_eta[j]);
*/
for (size_t j = 0; j < Electron_pt.size(); j++) sf_el[j] = worker_el_2017.getSF(Electron_pdgId[j], Electron_pt[j], Electron_eta[j]);
for (size_t j = 0; j < Electron_pt.size(); j++) sferr_el[j] = worker_el_2017.getSFErr(Electron_pdgId[j], Electron_pt[j], Electron_eta[j]);
RVec<float> Electron_effSF_errUp(Electron_pt.size());
for (size_t j = 0; j < Electron_pt.size(); j++) Electron_effSF_errUp[j] = sferr_el[j] + sf_el[j];
RVec<float> Electron_effSF_errDown(Electron_pt.size());
for (size_t j = 0; j < Electron_pt.size(); j++) Electron_effSF_errDown[j] = sferr_el[j] - sf_el[j];
RVec<float> result;
for (int j = 0; j < Electron_pt.size(); j++){
result.emplace_back(sf_el[j]);
result.emplace_back(Electron_effSF_errUp[j]);
result.emplace_back(Electron_effSF_errDown[j]);
}
return result;
}
RVec<float> MuonSFs(rvec_f Muon_pt, rvec_f Muon_eta, rvec_i Muon_pdgId, string Year){
//LeptonEfficiencyCorrector worker_mu;
//if (Year == "2016") {
// worker_mu = worker_mu_2016;
//}
//if (Year == "2017"){
// worker_mu = worker_mu_2017;
//}
//if (Year == "2018"){
// worker_mu = worker_mu_2018;
//}
RVec<float> sf_mu(Muon_pt.size());
RVec<float> sferr_mu(Muon_pt.size());
/*
for (size_t j = 0; j < Muon_pt.size(); j++) sf_mu[j] = worker_mu.getSF(Muon_pdgId[j], Muon_pt[j], Muon_eta[j]);
for (size_t j = 0; j < Muon_pt.size(); j++) sferr_mu[j] = worker_mu.getSFErr(Muon_pdgId[j], Muon_pt[j], Muon_eta[j]);
*/
for (size_t j = 0; j < Muon_pt.size(); j++) sf_mu[j] = worker_mu_2017.getSF(Muon_pdgId[j], Muon_pt[j], Muon_eta[j]);
for (size_t j = 0; j < Muon_pt.size(); j++) sferr_mu[j] = worker_mu_2017.getSFErr(Muon_pdgId[j], Muon_pt[j], Muon_eta[j]);
RVec<float> Muon_effSF_errUp(Muon_pt.size());
for (size_t j = 0; j < Muon_pt.size(); j++) Muon_effSF_errUp[j] = sferr_mu[j] + sf_mu[j];
RVec<float> Muon_effSF_errDown(Muon_pt.size());
for (size_t j = 0; j < Muon_pt.size(); j++) Muon_effSF_errDown[j] = sferr_mu[j] - sf_mu[j];
RVec<float> result;
for (int j = 0; j < Muon_pt.size(); j++){
result.emplace_back(sf_mu[j]);
result.emplace_back(Muon_effSF_errUp[j]);
result.emplace_back(Muon_effSF_errDown[j]);
}
return result;
}
//string remote_storage = "https://ttedesch.web.cern.ch/ttedesch/nanoAOD-tools/python/postprocessing/data/";
string path_pu = "python/postprocessing/data/pileup/";
void set_null_directory(TH2F *histo){
histo->SetDirectory(NULL);
}
/*
TFile *pufile_data2016 = TFile::Open(TString(remote_storage) + TString(path_pu) + TString("PileupData_GoldenJSON_Full2016.root"));
TH1 *histo_target_2016 = (TH1*)pufile_data2016->Get("pileup");
TH1 *histo_target_2016_plus = (TH1*)pufile_data2016->Get("pileup_plus");
TH1 *histo_target_2016_minus = (TH1*)pufile_data2016->Get("pileup_minus");
TFile *pufile_mc2016 = TFile::Open(TString(remote_storage) + TString(path_pu) + TString("pileup_profile_Summer16.root"));
TH1 *histo_2016 = (TH1*)pufile_mc2016->Get("pu_mc");
*/
TFile *pufile_data2017 = TFile::Open(TString(remote_storage) + TString(path_pu) + TString("PileupHistogram-goldenJSON-13tev-2017-99bins_withVar.root"));
TH1 *histo_target_2017 = (TH1*)pufile_data2017->Get("pileup");
TH1 *histo_target_2017_plus = (TH1*)pufile_data2017->Get("pileup_plus");
TH1 *histo_target_2017_minus = (TH1*)pufile_data2017->Get("pileup_minus");
TFile *pufile_mc2017 = TFile::Open(TString(remote_storage) + TString(path_pu) + TString("mcPileup2017.root"));
TH1 *histo_2017 = (TH1*)pufile_mc2017->Get("pu_mc");
/*
TFile *pufile_data2018 = TFile::Open(TString(remote_storage) + TString(path_pu) + TString("PileupHistogram-goldenJSON-13tev-2018-100bins_withVar.root"));
TH1 *histo_target_2018 = (TH1*)pufile_data2018->Get("pileup");
TH1 *histo_target_2018_plus = (TH1*)pufile_data2018->Get("pileup_plus");
TH1 *histo_target_2018_minus = (TH1*)pufile_data2018->Get("pileup_minus");
TFile *pufile_mc2018 = TFile::Open(TString(remote_storage) + TString(path_pu) + TString("mcPileup2018.root"));
TH1 *histo_2018 = (TH1*)pufile_mc2018->Get("pu_mc");
//close files??
*/
/*
RVec<float> puWeight(string Year, int Pileup_nTrueInt){
RVec<float> result(3);
if (Year == "2016"){
WeightCalculatorFromHistogram worker_2016(histo_2016, histo_target_2016, true, true, false);
WeightCalculatorFromHistogram worker_2016_plus(histo_2016, histo_target_2016_plus, true, true, false);
WeightCalculatorFromHistogram worker_2016_minus(histo_2016, histo_target_2016_minus, true, true, false);
if(Pileup_nTrueInt < histo_2016->GetNbinsX()) result[0] = worker_2016.getWeight(Pileup_nTrueInt);
else result[0] = 1;
if(Pileup_nTrueInt < histo_2016->GetNbinsX()) result[1] = worker_2016_plus.getWeight(Pileup_nTrueInt);
else result[1] = 1;
if(Pileup_nTrueInt < histo_2016->GetNbinsX()) result[2] = worker_2016_minus.getWeight(Pileup_nTrueInt);
else result[2] = 1;
}
else if (Year == "2017"){
WeightCalculatorFromHistogram worker_2017(histo_2017, histo_target_2017, true, true, false);
WeightCalculatorFromHistogram worker_2017_plus(histo_2017, histo_target_2017_plus, true, true, false);
WeightCalculatorFromHistogram worker_2017_minus(histo_2017, histo_target_2017_minus, true, true, false);
if(Pileup_nTrueInt < histo_2017->GetNbinsX()) result[0] = worker_2017.getWeight(Pileup_nTrueInt);
else result[0] = 1;
if(Pileup_nTrueInt < histo_2017->GetNbinsX()) result[1] = worker_2017_plus.getWeight(Pileup_nTrueInt);
else result[1] = 1;
if(Pileup_nTrueInt < histo_2017->GetNbinsX()) result[2] = worker_2017_minus.getWeight(Pileup_nTrueInt);
else result[2] = 1;
}
else if (Year == "2018"){
WeightCalculatorFromHistogram worker_2018(histo_2018, histo_target_2018, true, true, false);
WeightCalculatorFromHistogram worker_2018_plus(histo_2018, histo_target_2018_plus, true, true, false);
WeightCalculatorFromHistogram worker_2018_minus(histo_2018, histo_target_2018_minus, true, true, false);
if(Pileup_nTrueInt < histo_2018->GetNbinsX()) result[0] = worker_2018.getWeight(Pileup_nTrueInt);
else result[0] = 1;
if(Pileup_nTrueInt < histo_2018->GetNbinsX()) result[1] = worker_2018_plus.getWeight(Pileup_nTrueInt);
else result[1] = 1;
if(Pileup_nTrueInt < histo_2018->GetNbinsX()) result[2] = worker_2018_minus.getWeight(Pileup_nTrueInt);
else result[2] = 1;
}
return result;
}
*/
WeightCalculatorFromHistogram worker_2017(histo_2017, histo_target_2017, true, true, false);
WeightCalculatorFromHistogram worker_2017_plus(histo_2017, histo_target_2017_plus, true, true, false);
WeightCalculatorFromHistogram worker_2017_minus(histo_2017, histo_target_2017_minus, true, true, false);
RVec<float> puWeight(string Year, int Pileup_nTrueInt){
RVec<float> result(3);
if(Pileup_nTrueInt < histo_2017->GetNbinsX()) result[0] = worker_2017.getWeight(Pileup_nTrueInt);
else result[0] = 1;
if(Pileup_nTrueInt < histo_2017->GetNbinsX()) result[1] = worker_2017_plus.getWeight(Pileup_nTrueInt);
else result[1] = 1;
if(Pileup_nTrueInt < histo_2017->GetNbinsX()) result[2] = worker_2017_minus.getWeight(Pileup_nTrueInt);
else result[2] = 1;
return result;
}
//string remote_storage = "https://ttedesch.web.cern.ch/ttedesch/nanoAOD-tools/";
//string remote_storage_ = "https://ttedesch.web.cern.ch/ttedesch/nanoAOD-tools/";
string path_pf = "data/prefire_maps/";
//TFile *L1PrefiringMaps = TFile::Open(TString(remote_storage) + TString(path_pf) + TString("L1PrefiringMaps.root"));
//TH2F * L1prefiring_jetptvseta_2017BtoF = (TH2F *) L1PrefiringMaps->Get("L1prefiring_jetptvseta_2017BtoF");
//TH2F * L1prefiring_photonptvseta_2017BtoF = (TH2F *) L1PrefiringMaps->Get("L1prefiring_photonptvseta_2017BtoF");
TFile *L1PrefiringMaps = TFile::Open(TString(remote_storage) + TString(path_pf) + TString("L1PrefiringMaps.root"));
TH2F * L1prefiring_jetptvseta_2017BtoF = (TH2F *) L1PrefiringMaps->Get("L1prefiring_jetptvseta_UL2017BtoF");
TH2F * L1prefiring_photonptvseta_2017BtoF = (TH2F *) L1PrefiringMaps->Get("L1prefiring_photonptvseta_UL2017BtoF");
//TH2F * L1prefiring_jetptvseta_UL2017BtoF = (TH2F *) L1PrefiringMaps->Get("L1prefiring_jetptvseta_UL2017BtoF");
//TH2F * L1prefiring_photonptvseta_UL2017BtoF = (TH2F *) L1PrefiringMaps->Get("L1prefiring_photonptvseta_UL2017BtoF");
float GetPrefireProbability(TH2F *Map, float eta, float pt, float maxpt, int variation){
float x = maxpt - 0.01;
int bin = Map->FindBin(eta, min(pt, x));
float pref_prob = Map->GetBinContent(bin);
float stat = Map->GetBinError(bin); //bin statistical uncertainty
float syst = 0.2 * pref_prob; //20% of prefire rate
float r = sqrt(stat * stat + syst * syst);
float y = pref_prob + r;
float z = pref_prob - r;
if (variation == 1) pref_prob = min(y , float(1.0));
else if (variation == -1) pref_prob = max(z , float(0.0));
return pref_prob;
}
float EGvalue(rvec_f Photon_pt, rvec_f Photon_eta, rvec_i Photon_jetIdx, rvec_i Photon_electronIdx, rvec_f Electron_pt, rvec_f Electron_eta, rvec_i Electron_jetIdx, rvec_i Electron_photonIdx, int jid, int s){
float phopf = 1.0;
vector<int> PhotonInJet;
float JetMinPt = 20; //Min/Max Values may need to be fixed for new maps
float JetMaxPt = 500;
float JetMinEta = 2.0;
float JetMaxEta = 3.0;
float PhotonMinPt = 20;
float PhotonMaxPt = 500;
float PhotonMinEta = 2.0;
float PhotonMaxEta = 3.0;
TH2F *photon_map = L1prefiring_photonptvseta_2017BtoF;
for(int i = 0; i < Photon_pt.size(); i++){
if (Photon_jetIdx[i] == jid){
if (Photon_pt[i] >= PhotonMinPt && abs(Photon_eta[i]) <= PhotonMaxEta && abs(Photon_eta[i]) >= PhotonMinEta){
float phopf_temp = 1 - GetPrefireProbability(photon_map, Photon_eta[i], Photon_pt[i], PhotonMaxPt, s);
float elepf_temp = 1.0;
if (Photon_electronIdx[i] > -1){
if (Electron_pt[Photon_electronIdx[i]] >= PhotonMinPt && abs(Electron_eta[Photon_electronIdx[i]]) <= PhotonMaxEta and abs(Electron_eta[Photon_electronIdx[i]]) >= PhotonMinEta) elepf_temp = 1 - GetPrefireProbability(photon_map, Electron_eta[Photon_electronIdx[i]], Electron_pt[Photon_electronIdx[i]], PhotonMaxPt, s);
}
phopf = phopf * min(phopf_temp, elepf_temp);
PhotonInJet.push_back(i);
}
}
}
for(int i = 0; i < Electron_pt.size(); i++){
if (Electron_jetIdx[i] == jid && find(PhotonInJet.begin(), PhotonInJet.end(), Electron_photonIdx[i]) == PhotonInJet.end()){
if (Electron_pt[i] >= PhotonMinPt && abs(Electron_eta[i]) <= PhotonMaxEta && abs(Electron_eta[i]) >= PhotonMinEta) phopf = phopf * ( 1 - GetPrefireProbability(photon_map, Electron_eta[i], Electron_pt[i], PhotonMaxPt, s));
}
}
return phopf;
}
RVec<float> PrefCorr(rvec_f Photon_pt, rvec_f Photon_eta, rvec_i Photon_jetIdx, rvec_i Photon_electronIdx, rvec_f Electron_pt, rvec_f Electron_eta, rvec_i Electron_jetIdx, rvec_i Electron_photonIdx, rvec_f Jet_pt, rvec_f Jet_eta){
RVec<float> result(3);
float JetMinPt = 20; //Min/Max Values may need to be fixed for new maps
float JetMaxPt = 500;
float JetMinEta = 2.0;
float JetMaxEta = 3.0;
float PhotonMinPt = 20;
float PhotonMaxPt = 500;
float PhotonMinEta = 2.0;
float PhotonMaxEta = 3.0;
TH2F *jet_map = L1prefiring_jetptvseta_2017BtoF;
float prefw = 1.0;
vector<int> v{0,1,-1};
for (int j = 0; j < v.size(); j++){
prefw = 1.0; // new
int s = v[j];
for(int i = 0; i < Jet_pt.size(); i++){
float jetpf = 1.0;
//PhotonInJet = []
if(Jet_pt[i] >= JetMinPt && abs(Jet_eta[i]) <= JetMaxEta && abs(Jet_eta[i]) >= JetMinEta){
jetpf = jetpf * ( 1 - GetPrefireProbability(jet_map, Jet_eta[i], Jet_pt[i], JetMaxPt, s));
}
float phopf = EGvalue(Photon_pt, Photon_eta, Photon_jetIdx, Photon_electronIdx, Electron_pt, Electron_eta, Electron_jetIdx, Electron_photonIdx, i, s);
prefw = prefw * min(jetpf, phopf);
}
//Then loop over all photons/electrons not associated to jets
prefw = prefw * EGvalue(Photon_pt, Photon_eta, Photon_jetIdx, Photon_electronIdx, Electron_pt, Electron_eta, Electron_jetIdx, Electron_photonIdx, -1, s);
result[j] = prefw;
}
return result;
}
/*
def mk_safe(fct, *args):
try:
return fct(*args)
except Exception as e:
if any('Error in function boost::math::erf_inv' in arg for arg in e.args):
print('WARNING: catching exception and returning -1. Exception arguments: %s' % e.args)
return -1.
else:
raise e
*/
//RoccoR roccor_2016("RoccoR2016.txt");
//RoccoR roccor_2017("RoccoR2017.txt");
//RoccoR roccor_2018("RoccoR2018.txt");
//RoccoR roccor_2016aUL("RoccoR2016aUL.txt");
//RoccoR roccor_2016bUL("RoccoR2016bUL.txt");
//RoccoR roccor_2017UL("RoccoR2017UL.txt");
//RoccoR roccor_2018UL("RoccoR2018UL.txt");
RoccoR roccor("RoccoR2017UL.txt");
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<> dis(0, 1);//uniform distribution between 0 and 1
RVec<float> muonScaleRes(rvec_f Muon_pt, rvec_f Muon_eta, rvec_f Muon_phi, rvec_i Muon_charge, rvec_i Muon_nTrackerLayers, rvec_i Muon_genPartIdx, rvec_f GenPart_pt, string era){
RVec<float> result;
RVec<float> pt_corr, pt_err;
//RoccoR roccor;
//if (era == "2016") roccor = roccor_2016;
//else if (era == "2017") roccor = roccor_2017;
//else if (era == "2018") roccor = roccor_2018;
//if (era == "2016aUL") roccor = roccor_2016aUL;
//else if (era == "2016bUL") roccor = roccor_2016bUL;
//else if (era == "2017UL") roccor = roccor_2017UL;
//else roccor = roccor_2018UL;
bool isMC = true;
if (isMC == true){
for (int j = 0; j < Muon_pt.size(); j++){
int genIdx = Muon_genPartIdx[j];
if(genIdx >= 0 && genIdx < GenPart_pt.size()){
//pt_corr.emplace_back(Muon_pt[j] * mk_safe(roccor.kSpreadMC, Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j], GenPart_pt[genIdx]));
pt_corr.emplace_back(Muon_pt[j] * roccor.kSpreadMC(Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j], GenPart_pt[genIdx]));
//pt_err.emplace_back(Muon_pt[j] * mk_safe(roccor.kSpreadMCerror, Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j], GenPart_pt[genIdx]));
pt_err.emplace_back(Muon_pt[j] * roccor.kSpreadMCerror(Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j], GenPart_pt[genIdx]));
}
else{
float u1 = dis(gen);
//pt_corr.emplace_back(Muon_pt[j] * mk_safe(roccor.kSmearMC, Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j], Muon_nTrackerLayers[j], u1));
pt_corr.emplace_back(Muon_pt[j] * roccor.kSmearMC(Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j], Muon_nTrackerLayers[j], u1));
//pt_err.emplace_back(Muon_pt[j] * mk_safe(roccor.kSmearMCerror, Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j], Muon_nTrackerLayers[j], u1));
pt_err.emplace_back(Muon_pt[j] * roccor.kSmearMCerror(Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j], Muon_nTrackerLayers[j], u1));
}
}
}
else{
for (int j = 0; j < Muon_pt.size(); j++){
//pt_corr.emplace_back(Muon_pt[j] * mk_safe(roccor.kScaleDT, Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j]));
pt_corr.emplace_back(Muon_pt[j] * roccor.kScaleDT(Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j]));
//pt_err.emplace_back(Muon_pt[j] * mk_safe(roccor.kScaleDTerror, Muon_charge[j], Muon_pt[j], Muonu_eta[j], Muon_phi[j]));
pt_err.emplace_back(Muon_pt[j] * roccor.kScaleDTerror(Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j]));
}
}
RVec<float> pt_corr_up, pt_corr_down;
for (int j = 0; j < Muon_pt.size(); j++){
pt_corr_up.emplace_back(max(pt_corr[j] + pt_err[j], float(0.0)));
pt_corr_down.emplace_back(max(pt_corr[j] - pt_err[j], float(0.0)));
}
for (int j = 0; j < Muon_pt.size(); j++){
result.emplace_back(pt_corr[j]);
result.emplace_back(pt_corr_up[j]);
result.emplace_back(pt_corr_down[j]);
}
return result;
}
RVec<float> muonScaleRes_data(rvec_f Muon_pt, rvec_f Muon_eta, rvec_f Muon_phi, rvec_i Muon_charge, string era){
RVec<float> result;
RVec<float> pt_corr, pt_err;
//RoccoR roccor;
//if (era == "2016") roccor = roccor_2016;
//else if (era == "2017") roccor = roccor_2017;
//else if (era == "2018") roccor = roccor_2018;
//if (era == "2016aUL") roccor = roccor_2016aUL;
//else if (era == "2016bUL") roccor = roccor_2016bUL;
//else if (era == "2017UL") roccor = roccor_2017UL;
//else roccor = roccor_2018UL;
for (int j = 0; j < Muon_pt.size(); j++){
//pt_corr.emplace_back(Muon_pt[j] * mk_safe(roccor.kScaleDT, Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j]));
pt_corr.emplace_back(Muon_pt[j] * roccor.kScaleDT(Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j]));
//pt_err.emplace_back(Muon_pt[j] * mk_safe(roccor.kScaleDTerror, Muon_charge[j], Muon_pt[j], Muonu_eta[j], Muon_phi[j]));
pt_err.emplace_back(Muon_pt[j] * roccor.kScaleDTerror(Muon_charge[j], Muon_pt[j], Muon_eta[j], Muon_phi[j]));
}
RVec<float> pt_corr_up, pt_corr_down;
for (int j = 0; j < Muon_pt.size(); j++){
pt_corr_up.emplace_back(max(pt_corr[j] + pt_err[j], float(0.0)));
pt_corr_down.emplace_back(max(pt_corr[j] - pt_err[j], float(0.0)));
}
for (int j = 0; j < Muon_pt.size(); j++){
result.emplace_back(pt_corr[j]);
result.emplace_back(pt_corr_up[j]);
result.emplace_back(pt_corr_down[j]);
}
return result;
}
RVec<float> getMatrixColumn(const RVec<RVec<float>> & matrix, int column_index){
RVec<float> result;
for (int i = 0; i < matrix.size(); i++) result.emplace_back(matrix[i][column_index]);
return result;
}
RVec<float> getFlattenedMatrixColumn(rvec_f flattened_matrix, int nColumns, int column_index){
RVec<float> result;
for (int i = 0; i < flattened_matrix.size()/nColumns; i++) result.emplace_back(flattened_matrix[column_index + i*nColumns]);
return result;
}
float htProducer(int nJet, rvec_f Jet_pt){
float ht(0.0);
for (unsigned i=0; i<nJet; i++){
ht += Jet_pt[i];
}
return ht;
}
///////////////////////////////////////////////////////////////////////////////////////////////BTAG utils//////////////////////////////////////////////777
#ifndef BTagEntry_H
#define BTagEntry_H
/**
*
* BTagEntry
*
* Represents one pt- or discriminator-dependent calibration function.
*
* measurement_type: e.g. comb, ttbar, di-mu, boosted, ...
* sys_type: e.g. central, plus, minus, plus_JEC, plus_JER, ...
*
* Everything is converted into a function, as it is easiest to store it in a
* txt or json file.
*
************************************************************/
#include <string>
#include <TF1.h>
#include <TH1.h>
class BTagEntry
{
public:
enum OperatingPoint {
OP_LOOSE=0,
OP_MEDIUM=1,
OP_TIGHT=2,
OP_RESHAPING=3,
};
enum JetFlavor {
FLAV_B=0,
FLAV_C=1,
FLAV_UDSG=2,
};
struct Parameters {
OperatingPoint operatingPoint;
std::string measurementType;
std::string sysType;
JetFlavor jetFlavor;
float etaMin;
float etaMax;
float ptMin;
float ptMax;
float discrMin;
float discrMax;
// default constructor
Parameters(
OperatingPoint op=OP_TIGHT,
std::string measurement_type="comb",
std::string sys_type="central",
JetFlavor jf=FLAV_B,
float eta_min=-99999.,
float eta_max=99999.,
float pt_min=0.,
float pt_max=99999.,
float discr_min=0.,
float discr_max=99999.
);
};
BTagEntry() {}
BTagEntry(const std::string &csvLine);
BTagEntry(const std::string &func, Parameters p);
BTagEntry(const TF1* func, Parameters p);
BTagEntry(const TH1* histo, Parameters p);
~BTagEntry() {}
static std::string makeCSVHeader();