-
Notifications
You must be signed in to change notification settings - Fork 1
/
FinalSelection2D_relaxed.cc
1296 lines (1180 loc) · 64.9 KB
/
FinalSelection2D_relaxed.cc
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 <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TGraph.h>
#include <TGraphAsymmErrors.h>
#include "TMultiGraph.h"
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <stdio.h>
#include <TF1.h>
#include <TDirectoryFile.h>
#include <TRandom3.h>
#include "TLorentzVector.h"
#include "TString.h"
#include "TLegend.h"
#include "TH1F.h"
#include "TKey.h"
#include "THashList.h"
#include "THStack.h"
#include "TPaveLabel.h"
#include "TFile.h"
#include "myHelper.h"
#include "tr_Tree.h"
#include "ScaleFactor.h"
#include "ZmmSF.h"
#include "LumiReweightingStandAlone.h"
#include "btagSF.h"
#include "RooWorkspace.h"
#include "RooRealVar.h"
#include "RooFunctor.h"
using namespace std;
int main(int argc, char** argv) {
std::string input = *(argv + 1);
std::string output = *(argv + 2);
std::string sample = *(argv + 3);
std::string name = *(argv + 4);
float tes=0;
if (argc > 1) {
tes = atof(argv[5]);
}
TFile *f_Double = new TFile(input.c_str());
cout<<"XXXXXXXXXXXXX "<<input.c_str()<<" XXXXXXXXXXXX"<<endl;
TTree *arbre = (TTree*) f_Double->Get("mutau_tree");
TH1F* nbevt = (TH1F*) f_Double->Get("nevents");
float ngen = nbevt->GetBinContent(2);
TFile *f_Trk=new TFile("Tracking_EfficienciesAndSF_BCDEFGH.root");
TGraph *h_Trk=(TGraph*) f_Trk->Get("ratio_eff_eta3_dr030e030_corr");
reweight::LumiReWeighting* LumiWeights_12;
LumiWeights_12 = new reweight::LumiReWeighting("MC_Moriond17_PU25ns_V1.root", "Data_Pileup_2016_271036-284044_80bins.root", "pileup", "pileup");
//TFile *fZ=new TFile("zpt_weights_2016_BtoH.root");
TFile *fZ=new TFile("zpt_weights_btag.root");
TH2F *histZ=(TH2F*) fZ->Get("zptmass_histo");
TFile *fM=new TFile("mbtt_weights_2016_BtoH.root");
TH1F *histM=(TH1F*) fM->Get("mbtt_histo");
//TFile fw("htt_scalefactors_v16_3.root");
//RooWorkspace *w = (RooWorkspace*)fw.Get("w");
//fw.Close();
TFile fw2("htt_scalefactors_sm_moriond_v1.root");
RooWorkspace *w2 = (RooWorkspace*)fw2.Get("w");
fw2.Close();
float xs=1.0; float weight=1.0; float luminosity=35870.0;
if (sample=="ZL" or sample=="ZTT" or sample=="ZJ" or sample=="ZLL"){ xs=5765.4; weight=luminosity*xs/ngen;}
else if (sample=="DYlow") {xs=18610; weight=luminosity*xs/ngen;}
else if (sample=="DY1low") {xs=421.5; weight=luminosity*xs/ngen;}
else if (sample=="DY2low") {xs=184.3; weight=luminosity*xs/ngen;}
else if (sample=="TTL" or sample=="TT" or sample=="TTT" or sample=="TTJ") {xs=831.76; weight=luminosity*xs/ngen;}
else if (sample=="W") {xs=61526.7; weight=luminosity*xs/ngen;}
else if (sample=="QCD") {xs=720648000*0.00042; weight=luminosity*xs/ngen;}
else if (sample=="data_obs"){weight=1.0;}
else if (sample=="WZ1L1Nu2Q") {xs=10.71; weight=luminosity*xs/ngen;}
else if (sample=="WZ1L3Nu") {xs=3.05; weight=luminosity*xs/ngen;}
else if (sample=="WZJets") {xs=5.26; weight=luminosity*xs/ngen;}
else if (sample=="WZLLLNu") {xs=4.708; weight=luminosity*xs/ngen;}
else if (sample=="WZ2L2Q") {xs=5.595; weight=luminosity*xs/ngen;}
else if (sample=="WW1L1Nu2Q") {xs=49.997; weight=luminosity*xs/ngen;}
else if (sample=="ZZ4L") {xs=1.212; weight=luminosity*xs/ngen;}
else if (sample=="ZZ2L2Q") {xs=3.22; weight=luminosity*xs/ngen;}
else if (sample=="VV2L2Nu") {xs=11.95; weight=luminosity*xs/ngen;}
else if (sample=="ST_tW_antitop") {xs=35.6; weight=luminosity*xs/ngen;}
else if (sample=="ST_tW_top") {xs=35.6; weight=luminosity*xs/ngen;}
else if (sample=="ST_t_antitop") {xs=26.23; weight=luminosity*xs/ngen;}
else if (sample=="ST_t_top") {xs=44.07; weight=luminosity*xs/ngen;}
else if (sample=="ggh") {xs=48.58*0.0627; weight=luminosity*xs/ngen;}
else if (sample=="VBF") {xs=3.782*0.0627; weight=luminosity*xs/ngen;}
else if (sample=="bbtt15") {xs=0.01*48.58*0.1475; weight=luminosity*xs/ngen;}
else if (sample=="bbtt20") {xs=0.01*48.58*0.1426; weight=luminosity*xs/ngen;}
else if (sample=="bbtt25") {xs=0.01*48.58*0.1381; weight=luminosity*xs/ngen;}
else if (sample=="bbtt30") {xs=0.01*48.58*0.1358; weight=luminosity*xs/ngen;}
else if (sample=="bbtt35") {xs=0.01*48.58*0.1338; weight=luminosity*xs/ngen;}
else if (sample=="bbtt40") {xs=0.01*48.58*0.1322; weight=luminosity*xs/ngen;}
else if (sample=="bbtt45") {xs=0.01*48.58*0.1282; weight=luminosity*xs/ngen;}
else if (sample=="bbtt50") {xs=0.01*48.58*0.1232; weight=luminosity*xs/ngen;}
else if (sample=="bbtt55") {xs=0.01*48.58*0.1193; weight=luminosity*xs/ngen;}
else if (sample=="bbtt60") {xs=0.01*48.58*0.1133; weight=luminosity*xs/ngen;}
else if (sample=="VBFbbtt20") {xs=0.01*3.782*0.1983; weight=luminosity*xs/ngen;}
else if (sample=="VBFbbtt40") {xs=0.01*3.782*0.1908; weight=luminosity*xs/ngen;}
else if (sample=="VBFbbtt60") {xs=0.01*3.782*0.1799; weight=luminosity*xs/ngen;}
else if (sample=="WHbbtt40") {xs=0.01*(0.5328+0.840)*0.339; weight=luminosity*xs/ngen;}
else if (sample=="ZHbbtt40") {xs=0.01*0.8839*0.242; weight=luminosity*xs/ngen;}
else if (sample=="ggH125") {xs=48.58*0.0627; weight=luminosity*xs/ngen;}
else if (sample=="VBF125") {xs=3.782*0.0627; weight=luminosity*xs/ngen;}
else if (sample=="ggH120") {xs=52.22*0.0698; weight=luminosity*xs/ngen;}
else if (sample=="VBF120") {xs=3.935*0.0698; weight=luminosity*xs/ngen;}
else if (sample=="ggH130") {xs=45.31*0.0541; weight=luminosity*xs/ngen;}
else if (sample=="VBF130") {xs=3.637*0.0541; weight=luminosity*xs/ngen;}
else if (sample=="ggH110") {xs=57.90*0.0791; weight=luminosity*xs/ngen;}
else if (sample=="VBF110") {xs=4.434*0.0791; weight=luminosity*xs/ngen;}
else if (sample=="ggH140") {xs=36.0*0.0360; weight=luminosity*xs/ngen;}
else if (sample=="VBF140") {xs=3.492*0.0360; weight=luminosity*xs/ngen;}
else if (sample=="ggHWW125") {xs=48.58*0.2137*0.3258*0.3258; weight=luminosity*xs/ngen;}
else if (sample=="VBFWW125") {xs=3.782*0.2137*0.3258*0.3258; weight=luminosity*xs/ngen;}
else if (sample=="WplusH120") {xs=0.9558*0.0698; weight=luminosity*xs/ngen;}
else if (sample=="WplusH125") {xs=0.840*0.0627; weight=luminosity*xs/ngen;}
else if (sample=="WplusHWW125") {xs=0.840*0.2137*0.3258*0.3258; weight=luminosity*xs/ngen;}
else if (sample=="WplusH130") {xs=0.7414*0.0541; weight=luminosity*xs/ngen;}
else if (sample=="WplusH110") {xs=1.335*0.0791; weight=luminosity*xs/ngen;}
else if (sample=="WplusH140") {xs=0.6308*0.0360; weight=luminosity*xs/ngen;}
else if (sample=="WminusH120") {xs=0.6092*0.0698; weight=luminosity*xs/ngen;}
else if (sample=="WminusH125") {xs=0.5328*0.0627; weight=luminosity*xs/ngen;}
else if (sample=="WminusHWW125") {xs=0.5328*0.2137*0.3258*0.3258; weight=luminosity*xs/ngen;}
else if (sample=="WminusH130") {xs=0.4676*0.0541; weight=luminosity*xs/ngen;}
else if (sample=="WminusH110") {xs=0.8587*0.0791; weight=luminosity*xs/ngen;}
else if (sample=="WminusH140") {xs=0.394*0.0360; weight=luminosity*xs/ngen;}
else if (sample=="ZH120") {xs=0.9939*0.0698; weight=luminosity*xs/ngen;}
else if (sample=="ZH125") {xs=0.8839*0.0627; weight=luminosity*xs/ngen;}
else if (sample=="ZHWW125") {xs=0.8839*0.2137*0.3258*0.3258; weight=luminosity*xs/ngen;}
else if (sample=="ZH130") {xs=0.7899*0.0541; weight=luminosity*xs/ngen;}
else if (sample=="ZH110") {xs=1.309*0.0791; weight=luminosity*xs/ngen;}
else if (sample=="ZH140") {xs=0.6514*0.0360; weight=luminosity*xs/ngen;}
else if (sample=="ZH_LLBB") {xs=0.8839*0.10974*0.5824; weight=luminosity*xs/ngen;}
else if (sample=="WminusH_LBB") {xs=0.5328*3*0.108535*0.5824; weight=luminosity*xs/ngen;}
else if (sample=="WplusH_LBB") {xs=0.840*3*0.108535*0.5824; weight=luminosity*xs/ngen;}
else if (sample=="ttHnonbb") {xs=0.5085*(1-0.577); weight=luminosity*xs/ngen;}//FIXME
else if (sample=="WGLNu") {xs=489.0; weight=luminosity*xs/ngen;}
else if (sample=="WGstarMuMu") {xs=2.793; weight=luminosity*xs/ngen;}
else if (sample=="WGstarEE") {xs=3.526; weight=luminosity*xs/ngen;}
else if (sample=="EWKWminus") {xs=20.25; weight=luminosity*xs/ngen;}
else if (sample=="EWKWplus") {xs=25.62; weight=luminosity*xs/ngen;}
else if (sample=="EWKZLL" or sample=="EWKZLL_TT" or sample=="EWKZLL_J" or sample=="EWKZLL_L" or sample=="EWKZLL_LL") {xs=3.987; weight=luminosity*xs/ngen;}
else if (sample=="EWKZNuNu" or sample=="EWKZNuNu_TT" or sample=="EWKZNuNu_J" or sample=="EWKZNuNu_L" or sample=="EWKZNuNu_LL") {xs=10.01; weight=luminosity*xs/ngen;}
else cout<<"Attention!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
cout.setf(ios::fixed, ios::floatfield);
cout.precision(10);
arbre->SetBranchAddress("run", &run);
arbre->SetBranchAddress("lumi", &lumi);
arbre->SetBranchAddress("evt", &evt);
arbre->SetBranchAddress("npv", &npv);
arbre->SetBranchAddress("px_1", &px_1);
arbre->SetBranchAddress("py_1", &py_1);
arbre->SetBranchAddress("pz_1", &pz_1);
arbre->SetBranchAddress("pt_1", &pt_1);
arbre->SetBranchAddress("phi_1", &phi_1);
arbre->SetBranchAddress("eta_1", &eta_1);
arbre->SetBranchAddress("iso_1", &iso_1);
arbre->SetBranchAddress("m_1", &m_1);
arbre->SetBranchAddress("q_1", &q_1);
arbre->SetBranchAddress("id_m_medium_1", &id_m_medium_1);
arbre->SetBranchAddress("id_m_medium2016_1", &id_m_medium2016_1);
arbre->SetBranchAddress("nbtag", &nbtag);
arbre->SetBranchAddress("nbtag_JESDown", &nbtag_JESDown);
arbre->SetBranchAddress("nbtag_JESUp", &nbtag_JESUp);
arbre->SetBranchAddress("nbtagL", &nbtagL);
arbre->SetBranchAddress("nbtagT", &nbtagT);
arbre->SetBranchAddress("nbtag15", &nbtag15);
arbre->SetBranchAddress("nbtag15L", &nbtag15L);
arbre->SetBranchAddress("nbtag15T", &nbtag15T);
arbre->SetBranchAddress("bptL_1", &bptL_1);
arbre->SetBranchAddress("betaL_1", &betaL_1);
arbre->SetBranchAddress("bphiL_1", &bphiL_1);
arbre->SetBranchAddress("bptL_2", &bptL_2);
arbre->SetBranchAddress("betaL_2", &betaL_2);
arbre->SetBranchAddress("bphiL_2", &bphiL_2);
arbre->SetBranchAddress("bpt_1", &bpt_1);
arbre->SetBranchAddress("beta_1", &beta_1);
arbre->SetBranchAddress("bphi_1", &bphi_1);
arbre->SetBranchAddress("bpt_1_JESUp", &bpt_1_JESUp);
arbre->SetBranchAddress("beta_1_JESUp", &beta_1_JESUp);
arbre->SetBranchAddress("bphi_1_JESUp", &bphi_1_JESUp);
arbre->SetBranchAddress("bpt_1_JESDown", &bpt_1_JESDown);
arbre->SetBranchAddress("beta_1_JESDown", &beta_1_JESDown);
arbre->SetBranchAddress("bphi_1_JESDown", &bphi_1_JESDown);
arbre->SetBranchAddress("bpt_2", &bpt_2);
arbre->SetBranchAddress("beta_2", &beta_2);
arbre->SetBranchAddress("bphi_2", &bphi_2);
arbre->SetBranchAddress("q_2", &q_2);
arbre->SetBranchAddress("px_2", &px_2);
arbre->SetBranchAddress("py_2", &py_2);
arbre->SetBranchAddress("pz_2", &pz_2);
arbre->SetBranchAddress("pt_2", &pt_2);
arbre->SetBranchAddress("eta_2", &eta_2);
arbre->SetBranchAddress("m_2", &m_2);
arbre->SetBranchAddress("phi_2", &phi_2);
arbre->SetBranchAddress("met", &met);
arbre->SetBranchAddress("metphi", &metphi);
arbre->SetBranchAddress("njets", &njets);
arbre->SetBranchAddress("jpt_1", &jpt_1);
arbre->SetBranchAddress("amcatNLO_weight", &amcatNLO_weight);
arbre->SetBranchAddress("metphi_JESDown", &metphi_JESDown);
arbre->SetBranchAddress("metphi_JESUp", &metphi_JESUp);
arbre->SetBranchAddress("met_JESDown", &met_JESDown);
arbre->SetBranchAddress("met_JESUp", &met_JESUp);
arbre->SetBranchAddress("metphi_UESDown", &metphi_UESDown);
arbre->SetBranchAddress("metphi_UESUp", &metphi_UESUp);
arbre->SetBranchAddress("met_UESDown", &met_UESDown);
arbre->SetBranchAddress("met_UESUp", &met_UESUp);
arbre->SetBranchAddress("njets_JESDown", &njets_JESDown);
arbre->SetBranchAddress("njets_JESUp", &njets_JESUp);
arbre->SetBranchAddress("byVLooseIsolationMVArun2v1DBoldDMwLT_2",&byVLooseIsolationMVArun2v1DBoldDMwLT_2);
arbre->SetBranchAddress("byLooseIsolationMVArun2v1DBoldDMwLT_2",&byLooseIsolationMVArun2v1DBoldDMwLT_2);
arbre->SetBranchAddress("byMediumIsolationMVArun2v1DBoldDMwLT_2",&byMediumIsolationMVArun2v1DBoldDMwLT_2);
arbre->SetBranchAddress("byTightIsolationMVArun2v1DBoldDMwLT_2",&byTightIsolationMVArun2v1DBoldDMwLT_2);
arbre->SetBranchAddress("byVTightIsolationMVArun2v1DBoldDMwLT_2",&byVTightIsolationMVArun2v1DBoldDMwLT_2);
arbre->SetBranchAddress("byIsolationMVA3oldDMwLTraw_2",&byIsolationMVA3oldDMwLTraw_2);
arbre->SetBranchAddress("matchIsoMu22eta2p1_1", &matchIsoMu22eta2p1_1);
arbre->SetBranchAddress("matchIsoTkMu22eta2p1_1", &matchIsoTkMu22eta2p1_1);
arbre->SetBranchAddress("matchIsoMu22_1", &matchIsoMu22_1);
arbre->SetBranchAddress("matchIsoTkMu22_1", &matchIsoTkMu22_1);
arbre->SetBranchAddress("matchIsoMu24_1", &matchIsoMu24_1);
arbre->SetBranchAddress("matchIsoTkMu24_1", &matchIsoTkMu24_1);
arbre->SetBranchAddress("matchIsoMu19Tau20_1", &matchIsoMu19Tau20_1);
arbre->SetBranchAddress("matchIsoMu21Tau20_1", &matchIsoMu21Tau20_1);
arbre->SetBranchAddress("filterIsoMu22eta2p1_1", &filterIsoMu22eta2p1_1);
arbre->SetBranchAddress("filterIsoTkMu22eta2p1_1", &filterIsoTkMu22eta2p1_1);
arbre->SetBranchAddress("filterIsoMu22_1", &filterIsoMu22_1);
arbre->SetBranchAddress("filterIsoTkMu22_1", &filterIsoTkMu22_1);
arbre->SetBranchAddress("filterIsoMu24_1", &filterIsoMu24_1);
arbre->SetBranchAddress("filterIsoTkMu24_1", &filterIsoTkMu24_1);
arbre->SetBranchAddress("filterIsoMu19Tau20_1", &filterIsoMu19Tau20_1);
arbre->SetBranchAddress("filterIsoMu21Tau20_1", &filterIsoMu21Tau20_1);
arbre->SetBranchAddress("passIsoMu22eta2p1", &passIsoMu22eta2p1);
arbre->SetBranchAddress("passIsoTkMu22eta2p1", &passIsoTkMu22eta2p1);
arbre->SetBranchAddress("passIsoMu22", &passIsoMu22);
arbre->SetBranchAddress("passIsoTkMu22", &passIsoTkMu22);
arbre->SetBranchAddress("passIsoMu24", &passIsoMu24);
arbre->SetBranchAddress("passIsoTkMu24", &passIsoTkMu24);
arbre->SetBranchAddress("passIsoMu19Tau20", &passIsoMu19Tau20);
arbre->SetBranchAddress("passIsoMu21Tau20", &passIsoMu21Tau20);
arbre->SetBranchAddress("matchIsoMu19Tau20_2", &matchIsoMu19Tau20_2);
arbre->SetBranchAddress("matchIsoMu21Tau20_2", &matchIsoMu21Tau20_2);
arbre->SetBranchAddress("filterIsoMu19Tau20_2", &filterIsoMu19Tau20_2);
arbre->SetBranchAddress("filterIsoMu21Tau20_2", &filterIsoMu21Tau20_2);
arbre->SetBranchAddress("l2_decayMode",&l2_decayMode);
arbre->SetBranchAddress("againstElectronVLooseMVA6_2",&againstElectronVLooseMVA6_2);
arbre->SetBranchAddress("againstElectronLooseMVA6_2",&againstElectronLooseMVA6_2);
arbre->SetBranchAddress("againstElectronMediumMVA6_2",&againstElectronMediumMVA6_2);
arbre->SetBranchAddress("againstElectronTightMVA6_2",&againstElectronTightMVA6_2);
arbre->SetBranchAddress("againstElectronVTightMVA6_2",&againstElectronVTightMVA6_2);
arbre->SetBranchAddress("againstMuonLoose3_2",&againstMuonLoose3_2);
arbre->SetBranchAddress("againstMuonTight3_2",&againstMuonTight3_2);
arbre->SetBranchAddress("gen_match_1",&gen_match_1);
arbre->SetBranchAddress("gen_match_2",&gen_match_2);
arbre->SetBranchAddress("npu",&npu);
arbre->SetBranchAddress("genpT",&genpT);
arbre->SetBranchAddress("genM",&genM);
arbre->SetBranchAddress("genEta",&genEta);
arbre->SetBranchAddress("genPhi",&genPhi);
arbre->SetBranchAddress("pt_top1",&pt_top1);
arbre->SetBranchAddress("pt_top2",&pt_top2);
arbre->SetBranchAddress("genDR_2",&genDR_2);
arbre->SetBranchAddress("numGenJets",&numGenJets);
arbre->SetBranchAddress("bpt_1",&bpt_1);
arbre->SetBranchAddress("bpt_2",&bpt_2);
arbre->SetBranchAddress("bflavor_1",&bflavor_1);
arbre->SetBranchAddress("bflavor_1_JESDown",&bflavor_1_JESDown);
arbre->SetBranchAddress("bflavor_1_JESUp",&bflavor_1_JESUp);
arbre->SetBranchAddress("bflavor_2",&bflavor_2);
arbre->SetBranchAddress("bflavorL_1",&bflavorL_1);
arbre->SetBranchAddress("bflavorL_2",&bflavorL_2);
float bins0[] = {0,20,40,60,80,100,120,140,160,180,200}; //gt120
float bins1[] = {10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,115};//100-120
float bins2[] = {10,15,20,25,30,35,40,45,50,55,60,65,70,95};//80-100
float bins3[] = {10,15,20,25,30,35,40,45,50,55,75};//lt80
/* float bins0[] = {0,60,120,180}; //gt120
float bins1[] = {10,15,20,25,30,35,40,45,50,55,60,115};//100-120
float bins2[] = {10,15,20,25,30,35,40,45,50,55,60,95};//80-100
float bins3[] = {10,15,20,25,30,35,40,45,50,55,60,75};//lt80
*/
int binnum1 = sizeof(bins1)/sizeof(Float_t) - 1;
int binnum0 = sizeof(bins0)/sizeof(Float_t) - 1;
int binnum2 = sizeof(bins2)/sizeof(Float_t) - 1;
int binnum3 = sizeof(bins3)/sizeof(Float_t) - 1;
TH1F *hincl=new TH1F ("hincl", "hincl", 16,0,160); hincl->Sumw2();
TH1F *nlowhigh=new TH1F ("nlowhigh", "nlowhigh", 6,0,6);nlowhigh->Sumw2();
std::vector<TH1F*> n70;
std::vector<TH1F*> n70SS;
std::vector<TH1F*> h0_OS;
std::vector<TH1F*> h1_OS;
std::vector<TH1F*> h0_SS;
std::vector<TH1F*> h1_SS;
std::vector<TH1F*> h0_AI;
std::vector<TH1F*> h1_AI;
std::vector<TH1F*> h0_QCD;
std::vector<TH1F*> h1_QCD;
std::vector<TH1F*> h0_WOS;
std::vector<TH1F*> h1_WOS;
std::vector<TH1F*> h0_WSS;
std::vector<TH1F*> h1_WSS;
std::vector<TH1F*> h2_OS;
std::vector<TH1F*> h3_OS;
std::vector<TH1F*> h2_SS;
std::vector<TH1F*> h3_SS;
std::vector<TH1F*> h2_AI;
std::vector<TH1F*> h3_AI;
std::vector<TH1F*> h2_QCD;
std::vector<TH1F*> h3_QCD;
std::vector<TH1F*> h2_WOS;
std::vector<TH1F*> h3_WOS;
std::vector<TH1F*> h2_WSS;
std::vector<TH1F*> h3_WSS;
std::vector<TH1F*> h4_OS;
std::vector<TH1F*> h5_OS;
std::vector<TH1F*> h4_SS;
std::vector<TH1F*> h5_SS;
std::vector<TH1F*> h4_AI;
std::vector<TH1F*> h5_AI;
std::vector<TH1F*> h4_QCD;
std::vector<TH1F*> h5_QCD;
std::vector<TH1F*> h4_WOS;
std::vector<TH1F*> h5_WOS;
std::vector<TH1F*> h4_WSS;
std::vector<TH1F*> h5_WSS;
std::vector<TH1F*> h6_OS;
std::vector<TH1F*> h6_SS;
std::vector<TH1F*> h6_AI;
std::vector<TH1F*> h6_QCD;
std::vector<TH1F*> h6_WOS;
std::vector<TH1F*> h6_WSS;
int nbhist=1;
if (tes==100) nbhist=56;
if (tes==1) nbhist=18;
if (tes==16) nbhist=6;
if (tes==17) nbhist=2;
if (tes==18) nbhist=4;
if (tes==19) nbhist=6;
if (tes==30) nbhist=12;
for (int k=0; k<nbhist; ++k){
ostringstream HNn70; HNn70 << "n70" << k;
ostringstream HNn70SS; HNn70SS << "n70SS" << k;
n70.push_back(new TH1F (HNn70.str().c_str(),"InvMa",18,0,18)); n70[k]->Sumw2();
n70SS.push_back(new TH1F (HNn70SS.str().c_str(),"InvMa",18,0,18)); n70SS[k]->Sumw2();
}
for (int k=0; k<nbhist; ++k){
ostringstream HNS0OS; HNS0OS << "h0_OS" << k;
ostringstream HNS1OS; HNS1OS << "h1_OS" << k;
h0_OS.push_back(new TH1F (HNS0OS.str().c_str(),"InvMa",binnum0,bins0)); h0_OS[k]->Sumw2();
h1_OS.push_back(new TH1F (HNS1OS.str().c_str(),"InvMa",binnum1,bins1)); h1_OS[k]->Sumw2();
ostringstream HNS2OS; HNS2OS << "h2_OS" << k;
ostringstream HNS3OS; HNS3OS << "h3_OS" << k;
h2_OS.push_back(new TH1F (HNS2OS.str().c_str(),"InvMa",binnum0,bins0)); h2_OS[k]->Sumw2();
h3_OS.push_back(new TH1F (HNS3OS.str().c_str(),"InvMa",binnum1,bins1)); h3_OS[k]->Sumw2();
ostringstream HNS4OS; HNS4OS << "h4_OS" << k;
ostringstream HNS5OS; HNS5OS << "h5_OS" << k;
ostringstream HNS6OS; HNS6OS << "h6_OS" << k;
h4_OS.push_back(new TH1F (HNS4OS.str().c_str(),"InvMa",binnum3,bins3)); h4_OS[k]->Sumw2();
h5_OS.push_back(new TH1F (HNS5OS.str().c_str(),"InvMa",binnum2,bins2)); h5_OS[k]->Sumw2();
h6_OS.push_back(new TH1F (HNS6OS.str().c_str(),"InvMa",binnum1,bins1)); h6_OS[k]->Sumw2();
ostringstream HNS0SS; HNS0OS << "h0_SS" << k;
ostringstream HNS1SS; HNS1OS << "h1_SS" << k;
h0_SS.push_back(new TH1F (HNS0SS.str().c_str(),"InvMa",binnum0,bins0)); h0_SS[k]->Sumw2();
h1_SS.push_back(new TH1F (HNS1SS.str().c_str(),"InvMa",binnum1,bins1)); h1_SS[k]->Sumw2();
ostringstream HNS2SS; HNS2OS << "h2_SS" << k;
ostringstream HNS3SS; HNS3OS << "h3_SS" << k;
h2_SS.push_back(new TH1F (HNS2SS.str().c_str(),"InvMa",binnum0,bins0)); h2_SS[k]->Sumw2();
h3_SS.push_back(new TH1F (HNS3SS.str().c_str(),"InvMa",binnum1,bins1)); h3_SS[k]->Sumw2();
ostringstream HNS4SS; HNS4SS << "h4_SS" << k;
ostringstream HNS5SS; HNS5SS << "h5_SS" << k;
ostringstream HNS6SS; HNS6SS << "h6_SS" << k;
h4_SS.push_back(new TH1F (HNS4SS.str().c_str(),"InvMa",binnum3,bins3)); h4_SS[k]->Sumw2();
h5_SS.push_back(new TH1F (HNS5SS.str().c_str(),"InvMa",binnum2,bins2)); h5_SS[k]->Sumw2();
h6_SS.push_back(new TH1F (HNS6SS.str().c_str(),"InvMa",binnum1,bins1)); h6_SS[k]->Sumw2();
ostringstream HNS0AI; HNS0OS << "h0_AI" << k;
ostringstream HNS1AI; HNS1OS << "h1_AI" << k;
h0_AI.push_back(new TH1F (HNS0AI.str().c_str(),"InvMa",binnum0,bins0)); h0_AI[k]->Sumw2();
h1_AI.push_back(new TH1F (HNS1AI.str().c_str(),"InvMa",binnum1,bins1)); h1_AI[k]->Sumw2();
ostringstream HNS2AI; HNS2OS << "h2_AI" << k;
ostringstream HNS3AI; HNS3OS << "h3_AI" << k;
h2_AI.push_back(new TH1F (HNS2AI.str().c_str(),"InvMa",binnum0,bins0)); h2_AI[k]->Sumw2();
h3_AI.push_back(new TH1F (HNS3AI.str().c_str(),"InvMa",binnum1,bins1)); h3_AI[k]->Sumw2();
ostringstream HNS4AI; HNS4AI << "h4_AI" << k;
ostringstream HNS5AI; HNS5AI << "h5_AI" << k;
ostringstream HNS6AI; HNS6AI << "h6_AI" << k;
h4_AI.push_back(new TH1F (HNS4AI.str().c_str(),"InvMa",binnum3,bins3)); h4_AI[k]->Sumw2();
h5_AI.push_back(new TH1F (HNS5AI.str().c_str(),"InvMa",binnum2,bins2)); h5_AI[k]->Sumw2();
h6_AI.push_back(new TH1F (HNS6AI.str().c_str(),"InvMa",binnum1,bins1)); h6_AI[k]->Sumw2();
ostringstream HNS0QCD; HNS0QCD << "h0_QCD" << k;
ostringstream HNS1QCD; HNS1QCD << "h1_QCD" << k;
h0_QCD.push_back(new TH1F (HNS0QCD.str().c_str(),"InvMa",binnum0,bins0)); h0_QCD[k]->Sumw2();
h1_QCD.push_back(new TH1F (HNS1QCD.str().c_str(),"InvMa",binnum1,bins1)); h1_QCD[k]->Sumw2();
ostringstream HNS2QCD; HNS2QCD << "h2_QCD" << k;
ostringstream HNS3QCD; HNS3QCD << "h3_QCD" << k;
h2_QCD.push_back(new TH1F (HNS2QCD.str().c_str(),"InvMa",binnum0,bins0)); h2_QCD[k]->Sumw2();
h3_QCD.push_back(new TH1F (HNS3QCD.str().c_str(),"InvMa",binnum1,bins1)); h3_QCD[k]->Sumw2();
ostringstream HNS4QCD; HNS4QCD << "h4_QCD" << k;
ostringstream HNS5QCD; HNS5QCD << "h5_QCD" << k;
ostringstream HNS6QCD; HNS6QCD << "h6_QCD" << k;
h4_QCD.push_back(new TH1F (HNS4QCD.str().c_str(),"InvMa",binnum3,bins3)); h4_QCD[k]->Sumw2();
h5_QCD.push_back(new TH1F (HNS5QCD.str().c_str(),"InvMa",binnum2,bins2)); h5_QCD[k]->Sumw2();
h6_QCD.push_back(new TH1F (HNS6QCD.str().c_str(),"InvMa",binnum1,bins1)); h6_QCD[k]->Sumw2();
ostringstream HNS0WSS; HNS0WSS << "h0_WSS" << k;
ostringstream HNS1WSS; HNS1WSS << "h1_WSS" << k;
h0_WSS.push_back(new TH1F (HNS0WSS.str().c_str(),"InvMa",binnum0,bins0)); h0_WSS[k]->Sumw2();
h1_WSS.push_back(new TH1F (HNS1WSS.str().c_str(),"InvMa",binnum1,bins1));h1_WSS[k]->Sumw2();
ostringstream HNS2WSS; HNS2WSS << "h2_WSS" << k;
ostringstream HNS3WSS; HNS3WSS << "h3_WSS" << k;
h2_WSS.push_back(new TH1F (HNS2WSS.str().c_str(),"InvMa",binnum0,bins0)); h2_WSS[k]->Sumw2();
h3_WSS.push_back(new TH1F (HNS3WSS.str().c_str(),"InvMa",binnum1,bins1));h3_WSS[k]->Sumw2();
ostringstream HNS4WSS; HNS4WSS << "h4_WSS" << k;
ostringstream HNS5WSS; HNS5WSS << "h5_WSS" << k;
ostringstream HNS6WSS; HNS6WSS << "h6_WSS" << k;
h4_WSS.push_back(new TH1F (HNS4WSS.str().c_str(),"InvMa",binnum3,bins3)); h4_WSS[k]->Sumw2();
h5_WSS.push_back(new TH1F (HNS5WSS.str().c_str(),"InvMa",binnum2,bins2)); h5_WSS[k]->Sumw2();
h6_WSS.push_back(new TH1F (HNS6WSS.str().c_str(),"InvMa",binnum1,bins1)); h6_WSS[k]->Sumw2();
ostringstream HNS0WOS; HNS0WOS << "h0_WOS" << k;
ostringstream HNS1WOS; HNS1WOS << "h1_WOS" << k;
h0_WOS.push_back(new TH1F (HNS0WOS.str().c_str(),"InvMa",binnum0,bins0)); h0_WOS[k]->Sumw2();
h1_WOS.push_back(new TH1F (HNS1WOS.str().c_str(),"InvMa",binnum1,bins1)); h1_WOS[k]->Sumw2();
ostringstream HNS2WOS; HNS2WOS << "h2_WOS" << k;
ostringstream HNS3WOS; HNS3WOS << "h3_WOS" << k;
h2_WOS.push_back(new TH1F (HNS2WOS.str().c_str(),"InvMa",binnum0,bins0)); h2_WOS[k]->Sumw2();
h3_WOS.push_back(new TH1F (HNS3WOS.str().c_str(),"InvMa",binnum1,bins1)); h3_WOS[k]->Sumw2();
ostringstream HNS4WOS; HNS4WOS << "h4_WOS" << k;
ostringstream HNS5WOS; HNS5WOS << "h5_WOS" << k;
ostringstream HNS6WOS; HNS6WOS << "h6_WOS" << k;
h4_WOS.push_back(new TH1F (HNS4WOS.str().c_str(),"InvMa",binnum3,bins3)); h4_WOS[k]->Sumw2();
h5_WOS.push_back(new TH1F (HNS5WOS.str().c_str(),"InvMa",binnum2,bins2)); h5_WOS[k]->Sumw2();
h6_WOS.push_back(new TH1F (HNS6WOS.str().c_str(),"InvMa",binnum1,bins1)); h6_WOS[k]->Sumw2();
}
ScaleFactor * myScaleFactor_trgMu24 = new ScaleFactor();
myScaleFactor_trgMu24->init_ScaleFactor("LeptonEfficiencies/Muon/Run2016BtoH/Muon_IsoMu24_OR_TkIsoMu24_2016BtoH_eff.root");
ScaleFactor * myScaleFactor_trgMu19Leg = new ScaleFactor();
myScaleFactor_trgMu19Leg->init_ScaleFactor("LeptonEfficiencies/Muon/Run2016BtoH/Muon_Mu19leg_2016BtoH_eff.root");
ScaleFactor * myScaleFactor_trgMu22 = new ScaleFactor();
myScaleFactor_trgMu22->init_ScaleFactor("LeptonEfficiencies/Muon/Run2016BtoH/Muon_Mu22OR_eta2p1_eff.root");
ScaleFactor * myScaleFactor_trgMu19LegAnti = new ScaleFactor();
myScaleFactor_trgMu19LegAnti->init_ScaleFactor("LeptonEfficiencies/Muon/Run2016BtoH/Muon_Mu19leg_eta2p1_antiisolated_Iso0p15to0p3_eff_rb.root");
ScaleFactor * myScaleFactor_trgMu22Anti = new ScaleFactor();
myScaleFactor_trgMu22Anti->init_ScaleFactor("LeptonEfficiencies/Muon/Run2016BtoH/Muon_Mu22OR_eta2p1_antiisolated_Iso0p15to0p3_eff_rb.root");
ScaleFactor * myScaleFactor_id = new ScaleFactor();
myScaleFactor_id->init_ScaleFactor("LeptonEfficiencies/Muon/Run2016BtoH/Muon_IdIso_IsoLt0p15_2016BtoH_eff.root");
ScaleFactor * myScaleFactor_idAnti = new ScaleFactor();
myScaleFactor_idAnti->init_ScaleFactor("LeptonEfficiencies/Muon/Run2016BtoH/Muon_IdIso_antiisolated_Iso0p15to0p3_eff_rb.root");
TString postfixTES[18]={"_CMS_scale_t_13TeVDown","_CMS_scale_t_13TeVUp","_CMS_scale_t_1prong_13TeVDown","_CMS_scale_t_1prong_13TeVUp","_CMS_scale_t_1prong1pizero_13TeVDown","_CMS_scale_t_1prong1pizero_13TeVUp","_CMS_scale_t_3prong_13TeVDown","_CMS_scale_t_3prong_13TeVUp","_CMS_scale_m_13TeVUp","_CMS_scale_m_13TeVDown","_CMS_btag_heavy_13TeVUp","_CMS_btag_heavy_13TeVDown","_CMS_btag_light_13TeVUp","_CMS_btag_light_13TeVDown","_CMS_scale_met_unclustered_13TeVDown","_CMS_scale_met_unclustered_13TeVUp","_CMS_scale_j_13TeVDown","_CMS_scale_j_13TeVUp"};
TString postfixDM[6]={"_CMS_tauDMReco_1prong_13TeVUp","_CMS_tauDMReco_1prong_13TeVDown","_CMS_tauDMReco_1prong1pizero_13TeVUp","_CMS_tauDMReco_1prong1pizero_13TeVDown","_CMS_tauDMReco_3prong_13TeVUp","_CMS_tauDMReco_3prong_13TeVDown"};
TString postfixFakeDM[6]={"_CMS_jetToTauDMReco_1prong_13TeVUp","_CMS_jetToTauDMReco_1prong_13TeVDown","_CMS_jetToTauDMReco_1prong1pizero_13TeVUp","_CMS_jetToTauDMReco_1prong1pizero_13TeVDown","_CMS_jetToTauDMReco_3prong_13TeVUp","_CMS_jetToTauDMReco_3prong_13TeVDown"};
TString postfixZLshape[2]={"_CMS_htt_ZLShape_mt_13TeVUp","_CMS_htt_ZLShape_mt_13TeVDown"};
TString postfixZLnorm[4]={"_CMS_mFakeTau_1prong_13TeVUp","_CMS_mFakeTau_1prong_13TeVDown","_CMS_mFakeTau_1prong1pizero_13TeVUp","_CMS_mFakeTau_1prong1pizero_13TeVDown"};
TString postfixJES[56]={"_CMS_scale_j_13TeVDown","_CMS_scale_j_13TeVUp","_CMS_scale_j_AbsoluteFlavMap_13TeVDown","_CMS_scale_j_AbsoluteFlavMap_13TeVUp","_CMS_scale_j_AbsoluteMPFBias_13TeVDown","_CMS_scale_j_AbsoluteMPFBias_13TeVUp","_CMS_scale_j_AbsoluteScale_13TeVDown","_CMS_scale_j_AbsoluteScale_13TeVUp","_CMS_scale_j_AbsoluteStat_13TeVDown","_CMS_scale_j_AbsoluteStat_13TeVUp","_CMS_scale_j_FlavorQCD_13TeVDown","_CMS_scale_j_FlavorQCD_13TeVUp","_CMS_scale_j_Fragmentation_13TeVDown","_CMS_scale_j_Fragmentation_13TeVUp","_CMS_scale_j_PileUpDataMC_13TeVDown","_CMS_scale_j_PileUpDataMC_13TeVUp","_CMS_scale_j_PileUpPtBB_13TeVDown","_CMS_scale_j_PileUpPtBB_13TeVUp","_CMS_scale_j_PileUpPtEC1_13TeVDown","_CMS_scale_j_PileUpPtEC1_13TeVUp","_CMS_scale_j_PileUpPtEC2_13TeVDown","_CMS_scale_j_PileUpPtEC2_13TeVUp","_CMS_scale_j_PileUpPtHF_13TeVDown","_CMS_scale_j_PileUpPtHF_13TeVUp","_CMS_scale_j_PileUpPtRef_13TeVDown","_CMS_scale_j_PileUpPtRef_13TeVUp","_CMS_scale_j_RelativeBal_13TeVDown","_CMS_scale_j_RelativeBal_13TeVUp","_CMS_scale_j_RelativeFSR_13TeVDown","_CMS_scale_j_RelativeFSR_13TeVUp","_CMS_scale_j_RelativeJEREC1_13TeVDown","_CMS_scale_j_RelativeJEREC1_13TeVUp","_CMS_scale_j_RelativeJEREC2_13TeVDown","_CMS_scale_j_RelativeJEREC2_13TeVUp","_CMS_scale_j_RelativeJERHF_13TeVDown","_CMS_scale_j_RelativeJERHF_13TeVUp","_CMS_scale_j_RelativePtBB_13TeVDown","_CMS_scale_j_RelativePtBB_13TeVUp","_CMS_scale_j_RelativePtEC1_13TeVDown","_CMS_scale_j_RelativePtEC1_13TeVUp","_CMS_scale_j_RelativePtEC2_13TeVDown","_CMS_scale_j_RelativePtEC2_13TeVUp","_CMS_scale_j_RelativePtHF_13TeVDown","_CMS_scale_j_RelativePtHF_13TeVUp","_CMS_scale_j_RelativeStatEC_13TeVDown","_CMS_scale_j_RelativeStatEC_13TeVUp","_CMS_scale_j_RelativeStatFSR_13TeVDown","_CMS_scale_j_RelativeStatFSR_13TeVUp","_CMS_scale_j_RelativeStatHF_13TeVDown","_CMS_scale_j_RelativeStatHF_13TeVUp","_CMS_scale_j_SinglePionECAL_13TeVDown","_CMS_scale_j_SinglePionECAL_13TeVUp","_CMS_scale_j_SinglePionHCAL_13TeVDown","_CMS_scale_j_SinglePionHCAL_13TeVUp","_CMS_scale_j_TimePtEta_13TeVDown","_CMS_scale_j_TimePtEta_13TeVUp"};
TString postfixFake[12]={"_CMS_fakeRate10_var1_13TeVUp","_CMS_fakeRate10_var1_13TeVDown","_CMS_fakeRate10_var2_13TeVUp","_CMS_fakeRate10_var2_13TeVDown","_CMS_fakeRate1_var1_13TeVUp","_CMS_fakeRate1_var1_13TeVDown","_CMS_fakeRate1_var2_13TeVUp","_CMS_fakeRate1_var2_13TeVDown","_CMS_fakeRate0_var1_13TeVUp","_CMS_fakeRate0_var1_13TeVDown","_CMS_fakeRate0_var2_13TeVUp","_CMS_fakeRate0_var2_13TeVDown"};
Int_t nentries_wtn = (Int_t) arbre->GetEntries();
for (Int_t i = 0; i < nentries_wtn; i++) {
arbre->GetEntry(i);
if (i % 10000 == 0) fprintf(stdout, "\r Processed events: %8d of %8d ", i, nentries_wtn);
fflush(stdout);
bool isSingleLep = (passIsoMu22 && matchIsoMu22_1 && filterIsoMu22_1) or (passIsoTkMu22 && matchIsoTkMu22_1 && filterIsoTkMu22_1) or (passIsoMu22eta2p1 && matchIsoMu22eta2p1_1 && filterIsoMu22eta2p1_1) or (passIsoTkMu22eta2p1 && matchIsoTkMu22eta2p1_1 && filterIsoTkMu22eta2p1_1);
bool isCrossTrigger = (passIsoMu19Tau20 && matchIsoMu19Tau20_1 && filterIsoMu19Tau20_1 && matchIsoMu19Tau20_2 && filterIsoMu19Tau20_2);
if (sample=="data_obs" && run<278820 && !id_m_medium2016_1) continue;
if (sample=="data_obs" && run>=278820 && !id_m_medium_1) continue;
if (pt_1<19.8) continue;
if (fabs(eta_1)>2.1) continue;
if (!isSingleLep && !isCrossTrigger) continue;
if (!((isSingleLep && pt_1>23) or (isCrossTrigger && (pt_1<=23 or pt_2<22)))) continue;
//if (!againstElectronVLooseMVA6_2 or !againstMuonLoose3_2) continue; //deja coupe dans le skim
float sf_trg=1.0;
float sf_id=1.0;
float sf_id_anti=1.0;
float sf_trg_anti=1.0;
float eff_tau=1.0;
float eff_tau_anti=1.0;
if (sample!="data_obs"){
sf_id=myScaleFactor_id->get_ScaleFactor(pt_1,eta_1);
}
float signalRegion=(byTightIsolationMVArun2v1DBoldDMwLT_2 && iso_1<0.15);
float aiRegion=(byVLooseIsolationMVArun2v1DBoldDMwLT_2 && !byTightIsolationMVArun2v1DBoldDMwLT_2 && iso_1<0.15);
float qcdRegion=(byLooseIsolationMVArun2v1DBoldDMwLT_2 && iso_1<0.30);
float wRegion=(byMediumIsolationMVArun2v1DBoldDMwLT_2 && iso_1<0.30);
float wsfRegion=(byMediumIsolationMVArun2v1DBoldDMwLT_2 && iso_1<0.15);
float qcdCR=(byMediumIsolationMVArun2v1DBoldDMwLT_2 && iso_1<0.30 && iso_1>0.15);
TLorentzVector mytau;
mytau.SetPtEtaPhiM(pt_2,eta_2,phi_2,m_2);
TLorentzVector mymu;
mymu.SetPtEtaPhiM(pt_1,eta_1,phi_1,m_1);
TLorentzVector mybjet1L;
mybjet1L.SetPtEtaPhiM(bptL_1,betaL_1,bphiL_1,0);
TLorentzVector mybjet2L;
mybjet2L.SetPtEtaPhiM(bptL_2,betaL_2,bphiL_2,0);
TLorentzVector mybjet1T;
mybjet1T.SetPtEtaPhiM(bptT_1,betaT_1,bphiT_1,0);
TLorentzVector mybjet2T;
mybjet2T.SetPtEtaPhiM(bptT_2,betaT_2,bphiT_2,0);
TLorentzVector mybjet1;
mybjet1.SetPtEtaPhiM(bpt_1,beta_1,bphi_1,0);
TLorentzVector mybjet2;
mybjet2.SetPtEtaPhiM(bpt_2,beta_2,bphi_2,0);
//***************** Weights **************
if (sample=="W"){
weight=25.446;
if (numGenJets==1) weight=6.8176;
else if (numGenJets==2) weight=2.1038;
else if (numGenJets==3) weight=0.6889;
else if (numGenJets==4) weight=0.6900;
}
if (sample=="ZTT" or sample=="ZLL" or sample=="ZL" or sample=="ZJ"){
weight=1.4184;
if (numGenJets==1)
weight=0.45729;
else if (numGenJets==2)
weight=0.4668;
else if (numGenJets==3)
weight=0.47995;
else if (numGenJets==4)
weight=0.39349;
}
if (sample=="DYlow" or sample=="DYlowll" or sample=="DY1low" or sample=="DY1lowll" or sample=="DY2low" or sample=="DY2lowll"){
weight=0.0;
if (numGenJets==1) weight=0.74;
else if (numGenJets==2) weight=0.823;
}
float correction=sf_id;
if (sample!="data_obs") correction=correction*LumiWeights_12->weight(npu);
float aweight=amcatNLO_weight*weight*correction;
if (sample!="data_obs"){
if (gen_match_2==5) aweight=aweight*0.95; //Tau ID SF
else if (gen_match_2==2 or gen_match_2==4){
if (fabs(mytau.Eta())<0.4) aweight=aweight*1.012;
else if (fabs(mytau.Eta())<0.8) aweight=aweight*1.007;
else if (fabs(mytau.Eta())<1.2) aweight=aweight*0.870;
else if (fabs(mytau.Eta())<1.7) aweight=aweight*1.154;
else aweight=aweight*2.281;
}
else if (gen_match_2==1 or gen_match_2==3){//Yiwen
if (fabs(eta_2)<1.460) aweight=aweight*1.213;
else if (fabs(eta_2)>1.558) aweight=aweight*1.375;
}
aweight=aweight*h_Trk->Eval(eta_1);
}
if (sample=="ZTT" or sample=="ZLL" or sample=="ZL" or sample=="ZJ" or sample=="DYlow" or sample=="DY1low" or sample=="DY2low"){
//float zpt_corr=histZ->GetBinContent(histZ->GetXaxis()->FindBin(genM),histZ->GetYaxis()->FindBin(genpT));
float zpt_corr=histZ->GetBinContent(histZ->GetXaxis()->FindBin(90),histZ->GetYaxis()->FindBin(genpT));
if (fabs(tes)!=10) //nominal
aweight=aweight*zpt_corr;
else if (tes==10) // up
aweight=aweight*(1+1.10*(zpt_corr-1));
else if (tes==-10) // down
aweight=aweight*(1+0.90*(zpt_corr-1));
}
//************************ Jet to tau FR shape **************************
if (tes==14 && (sample=="TTJ" or sample=="ZJ" or sample=="W") && gen_match_2==6){
float jtotau=1-(0.2*mytau.Pt()/100);
if (mytau.Pt()>200) jtotau=1-(0.2*200.0/100);
aweight=aweight*jtotau;
}
if (tes==-14 && (sample=="TTJ" or sample=="ZJ" or sample=="W") && gen_match_2==6){
float jtotau=1+(0.2*mytau.Pt()/100);
if (mytau.Pt()>200) jtotau=1+(0.2*200.0/100);
aweight=aweight*jtotau;
}
// ###########################################################
// ######## Separation between L, T and J ####################
// ###########################################################
if (sample=="ZL" && gen_match_2>4) continue;
if (sample=="ZTT" && gen_match_2!=5) continue;
if (sample=="ZJ" && gen_match_2!=6) continue;
if (sample=="TTJ" && gen_match_2!=6) continue;
//if (sample=="TTT" && gen_match_2==6) continue;
if (sample=="TTT" && gen_match_2!=5) continue;
if (sample=="TTL" && gen_match_2>4) continue;
if (name=="VV" && gen_match_2==6) continue;
if (name=="ST" && gen_match_2==6) continue;
// #############################################################
// ################### Top pT reweighting ######################
// #############################################################
float pttop1=pt_top1;
if (pttop1>400) pttop1=400;
float pttop2=pt_top2;
if (pttop2>400) pttop2=400;
if ((sample=="TTJ" or sample=="TTT" or sample=="TT" or sample=="TTL") && fabs(tes)!=11) aweight*=sqrt(exp(0.0615-0.0005*pttop1)*exp(0.0615-0.0005*pttop2));
if ((sample=="TTJ" or sample=="TTT" or sample=="TT" or sample=="TTL") && tes==11) aweight*=(1+2*(sqrt(exp(0.0615-0.0005*pttop1)*exp(0.0615-0.0005*pttop2))-1));
if (sample=="data_obs") aweight=1.0;
float weight_btag_1b=1.0;
if (sample!="data_obs"){
weight_btag_1b=GetSF_M(1,bpt_1,bflavor_1,0);
}
// ############################################################
// ############### Loop over JES sources ######################
// ############################################################
//
TLorentzVector myrawmet;
myrawmet.SetPtEtaPhiM(met,0,metphi,0);
TLorentzVector myrawtau=mytau;
TLorentzVector myrawmu=mymu;
TLorentzVector myrawbjet1=mybjet1;
for (int k=0; k<nbhist; ++k){
float weight2=1.0;
TLorentzVector mymet=myrawmet;
mytau=myrawtau;
mymu=myrawmu;
mybjet1=myrawbjet1;
if (sample!="data_obs"){
weight_btag_1b=GetSF_M(1,bpt_1,bflavor_1,0);
}
if (tes==1 && gen_match_2==5){
if (k==0){ mytau*=0.988; mymet=mymet+(0.012/0.988)*mytau;}
else if (k==1){ mytau*=1.012; mymet=mymet-(0.012/1.012)*mytau;}
else if (k==2 && l2_decayMode==0){ mytau*=0.988; mymet=mymet+(0.012/0.988)*mytau;}
else if (k==3 && l2_decayMode==0){ mytau*=1.012; mymet=mymet-(0.012/1.012)*mytau;}
else if (k==4 && l2_decayMode==1){ mytau*=0.988; mymet=mymet+(0.012/0.988)*mytau;}
else if (k==5 && l2_decayMode==1){ mytau*=1.012; mymet=mymet-(0.012/1.012)*mytau;}
else if (k==6 && l2_decayMode==10){ mytau*=0.988; mymet=mymet+(0.012/0.988)*mytau;}
else if (k==7 && l2_decayMode==10){ mytau*=1.012; mymet=mymet-(0.012/1.012)*mytau;}
}
if (tes==1){
if (k==8){ mymu*1.002; mymet=mymet-(0.002/1.002)*mymu;}
else if (k==9){ mymu*0.998; mymet=mymet+(0.002/0.998)*mymu;}
else if (k==14){ mymet.SetPtEtaPhiM(met_UESDown,0,metphi_UESDown,0);}
else if (k==15){ mymet.SetPtEtaPhiM(met_UESUp,0,metphi_UESUp,0);}
else if (k==16){ mymet.SetPtEtaPhiM(met_JESDown,0,metphi_JESDown,0);}
else if (k==17){ mymet.SetPtEtaPhiM(met_JESUp,0,metphi_JESUp,0);}
}
if (tes==1){
if (k==10 && bflavor_1>4) weight_btag_1b=GetSF_M(1,bpt_1,bflavor_1,1);
if (k==11 && bflavor_1>4) weight_btag_1b=GetSF_M(1,bpt_1,bflavor_1,-1);
if (k==12 && bflavor_1<5) weight_btag_1b=GetSF_M(1,bpt_1,bflavor_1,1);
if (k==13 && bflavor_1<5) weight_btag_1b=GetSF_M(1,bpt_1,bflavor_1,-1);
}
bool has_1b=nbtag>=1;//FIXME
if (tes==1 and k==16) {has_1b=nbtag_JESDown>=1; mybjet1.SetPtEtaPhiM(bpt_1_JESDown,beta_1_JESDown,bphi_1_JESDown,0); weight_btag_1b=GetSF_M(1,bpt_1_JESDown,bflavor_1_JESDown,0);}
if (tes==1 and k==17) {has_1b=nbtag_JESUp>=1; mybjet1.SetPtEtaPhiM(bpt_1_JESUp,beta_1_JESUp,bphi_1_JESUp,0); weight_btag_1b=GetSF_M(1,bpt_1_JESUp,bflavor_1_JESUp,0);}
float dm_weight=1.0;
if (tes==17 && sample=="ZL"){
if (k==0){
mytau*=1.015;
mymet=mymet-(0.015/1.015)*mytau;
}
else if (k==1) {
mytau*=0.985;
mymet=mymet+(0.015/0.985)*mytau;
}
}
if (mytau.Pt()<25.0) continue;
if (mymu.Pt()<20.0) continue;
float norm_zeta=norm_F(mymu.Px()/mymu.Pt()+mytau.Px()/mytau.Pt(),mymu.Py()/mymu.Pt()+mytau.Py()/mytau.Pt());
float x_zeta= (mymu.Px()/mymu.Pt()+mytau.Px()/mytau.Pt())/norm_zeta;
float y_zeta= (mymu.Py()/mymu.Pt()+mytau.Py()/mytau.Pt())/norm_zeta;
float p_zeta_mis=mymet.Px()*x_zeta+mymet.Py()*y_zeta;
float pzeta_vis=(mymu.Px()+mytau.Px())*x_zeta+(mymu.Py()+mytau.Py())*y_zeta;
float pzeta=p_zeta_mis-0.85*pzeta_vis;
float mt1=TMass_F(mymu.Pt(),mymet.Pt(),mymu.Px(),mymet.Px(),mymu.Py(),mymet.Py());
float mt2=TMass_F(mytau.Pt(),mymet.Pt(),mytau.Px(),mymet.Px(),mytau.Py(),mymet.Py());
float mt12=TMass_F((mytau+mymu).Pt(),mymet.Pt(),(mytau+mymu).Px(),mymet.Px(),(mytau+mymu).Py(),mymet.Py());
float mbbtt=(mymu+mytau+mybjet1L+mybjet2L).M();
float mbtt=(mymu+mytau+mybjet1).M();
float mtt=(mymu+mytau).M();
float var_1b=mtt;
float var_2b=mtt;
if (sample=="ZTT" or sample=="ZLL" or sample=="ZL" or sample=="ZJ" or sample=="DYlow" or sample=="DY1low" or sample=="DY2low"){
TLorentzVector genZ;
genZ.SetPtEtaPhiM(genpT,genEta,genPhi,genM);
float genmbtt=(genZ+mybjet1).M();
if (genmbtt<40) genmbtt=40;
if (genmbtt>600) genmbtt=600;
float mbtt_corr=histM->GetBinContent(histM->GetXaxis()->FindBin(genmbtt));
if (mbtt_corr<0.5) mbtt_corr=1.0;
if (fabs(tes)!=8) weight2=weight2*mbtt_corr;
if (tes==8) // up
weight2=weight2*(1+2.00*(mbtt_corr-1));
if (tes==-8) // down
weight2=weight2*(1+0.00*(mbtt_corr-1));
}
if (sample!="data_obs"){
if (mymu.Pt()<23){
w2->var("t_pt")->setVal(mytau.Pt());
w2->var("t_eta")->setVal(mytau.Eta());
w2->var("t_dm")->setVal(l2_decayMode);
float eff_tau_ratio = w2->function("t_genuine_TightIso_mt_ratio")->getVal();
sf_trg=myScaleFactor_trgMu19Leg->get_ScaleFactor(pt_1,eta_1)*eff_tau_ratio;
}
else{
sf_trg=myScaleFactor_trgMu22->get_ScaleFactor(pt_1,eta_1);
}
}
if (sample=="data_obs") {aweight=1.0; weight2=1.0;}
weight2=weight2*sf_trg*dm_weight;
float fr=1.0;
/*float p0_dm0_B=0.218512;
float p1_dm0_B=0.000337089;
float p0_dm1_B=0.230227;
float p1_dm1_B=0.000786509;
float p0_dm10_B=0.172631;
float p1_dm10_B=0.0000840138;
float p0_dm0_E=0.270796;
float p1_dm0_E=0.000821388;
float p0_dm1_E=0.244202;
float p1_dm1_E=0.000882359;
float p0_dm10_E=0.214062;
float p1_dm10_E=0.000896065;
if (l2_decayMode==0) fr=p0_dm0_B-p1_dm0_B*pt_2;
else if (l2_decayMode==1) fr=p0_dm1_B-p1_dm1_B*pt_2;
else if (l2_decayMode==10) fr=p0_dm10_B-p1_dm10_B*pt_2;
if (fabs(eta_2)>1.479){
if (l2_decayMode==0) fr=p0_dm0_E-p1_dm0_E*pt_2;
else if (l2_decayMode==1) fr=p0_dm1_E-p1_dm1_E*pt_2;
else if (l2_decayMode==10) fr=p0_dm10_E-p1_dm10_E*pt_2;
}*/
//Tight
/*if (l2_decayMode==0) fr= 0.2401 - 0.000614282 * (mytau.Pt()-40);
if (l2_decayMode==1) fr= 0.230823 - 0.000918427 * (mytau.Pt()-40);
if (l2_decayMode==10) fr= 0.17867 + 0.000316496 * (mytau.Pt()-40);
if (tes==30 && l2_decayMode==10){//FIXME
if (k==0) fr= 0.18166+0.000239627 * (mytau.Pt()-40);
if (k==1) fr= 0.175687 + 0.000393365 * (mytau.Pt()-40);
if (k==2) fr= 0.178668 +0.000523315 * (mytau.Pt()-40);
if (k==3) fr= 0.178679 +0.000109677 * (mytau.Pt()-40);
}
if (tes==30 && l2_decayMode==1){
if (k==4) fr= 0.234162 -0.000943962 * (mytau.Pt()-40);
if (k==5) fr= 0.227485 -0.000892892 * (mytau.Pt()-40);
if (k==6) fr= 0.230822 -0.000712327 * (mytau.Pt()-40);
if (k==7) fr= 0.230825 -0.00112453 * (mytau.Pt()-40);
}
if (tes==30 && l2_decayMode==0){
if (k==8) fr= 0.246021 -0.000686205 * (mytau.Pt()-40);
if (k==9) fr= 0.234195 -0.00054236 * (mytau.Pt()-40);
if (k==10) fr= 0.240103 -0.00024351 * (mytau.Pt()-40);
if (k==11) fr= 0.240112 -0.000985054 * (mytau.Pt()-40);
}*/
if (l2_decayMode==0) fr= 2.20179e-01 + 3.17084e-01*(TMath::Landau(mytau.Pt(),2.30233e+01,2.62218e+00,0));
if (l2_decayMode==1) fr= 1.83924e-01 + 8.66271e+00*(TMath::Landau(mytau.Pt(),-2.56076e+01,4.12774e+00,0));
if (l2_decayMode==10) fr= 6.27144e-02 + 7.25830e-01*(TMath::Landau(mytau.Pt(),6.37171e+01,3.38631e+01,0));
/*//Medium
if (l2_decayMode==0) fr= 0.3696 - 0.0009 * (pt_2-40);
if (l2_decayMode==1) fr= 0.3608 - 0.0012 * (pt_2-40);
if (l2_decayMode==10) fr= 0.2865 + 0.0001 * (pt_2-40);*/
//Very tight
/*if (l2_decayMode==0) fr= 0.1537 - 0.0005 * (pt_2-40);
if (l2_decayMode==1) fr= 0.1433 - 0.0007 * (pt_2-40);
if (l2_decayMode==10) fr= 0.1124 + 0.0003 * (pt_2-40);*/
bool selection_1b =(mt1<50 and mt2<60); // (mt1<40 and mt2<50);//FIXME
//selection_1b=true;
//selection_1b=mt1<50 and mt2<60;//true;
//selection_1b = (mt1+mt2<80);
//bool selection_1b = (mt1<60 and mt12<70 and mt2<80 and pzeta>-90);
bool selection_2b = (mymet.Pt()<75 and mt1<50 and mt12<60 and mt2<60 and pzeta>-70);
//selection_1b=true;
bool is_incl_2b=mbbtt>=160 and nbtagL>=2 and selection_2b;//160
bool is_2b=mbbtt<160 and nbtagL>=2 and selection_2b;//160
//
//cout<<njets<<" "<<mjj<<endl;
//bool is_incl_2b=mbtt>=90 and nbtag>=1 and nbtagL<200 and selection_1b and njets>=2 and mjj>500;
//bool is_2b=mbtt<90 and nbtagL<200 and nbtag>=1 and selection_1b and njets>=2 and mjj>500;
bool is_incl_1b=mbtt>=90 and has_1b and nbtagL<2 and selection_1b;//90
bool is_1b=mbtt<90 and nbtagL<2 and has_1b and selection_1b;//90
bool is_1b_lt80=mbtt<75 and has_1b and selection_1b;
bool is_1b_80to100=mbtt>=75 and mbtt<95 and has_1b and selection_1b;
bool is_1b_100to120=mbtt>=95 and mbtt<115 and has_1b and selection_1b;
bool is_1b_gt120=mbtt>=115 and has_1b and selection_1b;
float wfr=fr/(1-fr);
float weight_btag_2b=1.0;
//var_1b=TMass_F((mytau+mymu).Pt(),mymet.Pt(),(mytau+mymu).Px(),mymet.Px(),(mytau+mymu).Py(),mymet.Py());
//cout<<gen_match_2<<endl;
//************************* Fill histograms **********************
if (is_incl_2b){
if (signalRegion && q_1*q_2<0){
h0_OS[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
}
if (aiRegion && q_1*q_2<0 && (sample=="data_obs" or gen_match_2<=5)){
h0_AI[k]->Fill(var_2b,weight2*aweight*weight_btag_2b*wfr);
}
if (signalRegion && q_1*q_2>0)
h0_SS[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
if (wRegion && q_1*q_2<0)
h0_WOS[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
if (wRegion && q_1*q_2>0)
h0_WSS[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
if (qcdRegion && q_1*q_2>0)
h0_QCD[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
}
if (is_2b){
if (signalRegion && q_1*q_2<0){
h1_OS[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
}
if (aiRegion && q_1*q_2<0 && (sample=="data_obs" or gen_match_2<=5)){
h1_AI[k]->Fill(var_2b,weight2*aweight*weight_btag_2b*wfr);
}
if (signalRegion && q_1*q_2>0)
h1_SS[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
if (wRegion && q_1*q_2<0)
h1_WOS[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
if (wRegion && q_1*q_2>0)
h1_WSS[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
if (qcdRegion && q_1*q_2>0)
h1_QCD[k]->Fill(var_2b,weight2*aweight*weight_btag_2b);
}
if (is_1b_gt120 && mt1<40){
if (signalRegion && q_1*q_2<0){
h2_OS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
if (aiRegion && q_1*q_2<0 && (sample=="data_obs" or gen_match_2<=5)){
h2_AI[k]->Fill(var_1b,weight2*aweight*weight_btag_1b*wfr);
}
if (signalRegion && q_1*q_2>0)
h2_SS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2<0)
h2_WOS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2>0)
h2_WSS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (qcdRegion && q_1*q_2>0)
h2_QCD[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
if (is_1b && mt1<40){
if (signalRegion && q_1*q_2<0){
h3_OS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
if (aiRegion && q_1*q_2<0 && (sample=="data_obs" or gen_match_2<=5)){
h3_AI[k]->Fill(var_1b,weight2*aweight*weight_btag_1b*wfr);
}
if (signalRegion && q_1*q_2>0)
h3_SS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2<0)
h3_WOS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2>0)
h3_WSS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (qcdRegion && q_1*q_2>0)
h3_QCD[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
if (is_1b_lt80 and mt1<40){
if (signalRegion && q_1*q_2<0){
h4_OS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
//cout<<var_1b<<" "<<nbtagT<<" "<<byVTightIsolationMVArun2v1DBoldDMwLT_2<<endl;
}
if (aiRegion && q_1*q_2<0 && (sample=="data_obs" or gen_match_2<=5)){
h4_AI[k]->Fill(var_1b,weight2*aweight*weight_btag_1b*wfr);
}
if (signalRegion && q_1*q_2>0)
h4_SS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2<0)
h4_WOS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2>0)
h4_WSS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (qcdRegion && q_1*q_2>0)
h4_QCD[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
if (is_1b_80to100 && pzeta<0 && mt1<50){
if (signalRegion && q_1*q_2<0){
h5_OS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
if (aiRegion && q_1*q_2<0 && (sample=="data_obs" or gen_match_2<=5)){
h5_AI[k]->Fill(var_1b,weight2*aweight*weight_btag_1b*wfr);
}
if (signalRegion && q_1*q_2>0)
h5_SS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2<0)
h5_WOS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2>0)
h5_WSS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (qcdRegion && q_1*q_2>0)
h5_QCD[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
if (is_1b_100to120){
if (signalRegion && q_1*q_2<0){
h6_OS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
if (aiRegion && q_1*q_2<0 && (sample=="data_obs" or gen_match_2<=5)){
h6_AI[k]->Fill(var_1b,weight2*aweight*weight_btag_1b*wfr);
}
if (signalRegion && q_1*q_2>0)
h6_SS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2<0)
h6_WOS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (wRegion && q_1*q_2>0)
h6_WSS[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
if (qcdRegion && q_1*q_2>0)
h6_QCD[k]->Fill(var_1b,weight2*aweight*weight_btag_1b);
}
}
} // end of loop over events
for (int k=0; k<nbhist; ++k){
h0_WOS[k]->Scale(h0_OS[k]->Integral()/h0_WOS[k]->Integral());
h1_WOS[k]->Scale(h1_OS[k]->Integral()/h1_WOS[k]->Integral());
h0_WSS[k]->Scale(h0_SS[k]->Integral()/h0_WSS[k]->Integral());
h1_WSS[k]->Scale(h1_SS[k]->Integral()/h1_WSS[k]->Integral());
h2_WOS[k]->Scale(h2_OS[k]->Integral()/h2_WOS[k]->Integral());
h3_WOS[k]->Scale(h3_OS[k]->Integral()/h3_WOS[k]->Integral());
h2_WSS[k]->Scale(h2_SS[k]->Integral()/h2_WSS[k]->Integral());
h3_WSS[k]->Scale(h3_SS[k]->Integral()/h3_WSS[k]->Integral());
h4_WOS[k]->Scale(h4_OS[k]->Integral()/h4_WOS[k]->Integral());
h5_WOS[k]->Scale(h5_OS[k]->Integral()/h5_WOS[k]->Integral());
h6_WOS[k]->Scale(h6_OS[k]->Integral()/h6_WOS[k]->Integral());
h4_WSS[k]->Scale(h4_SS[k]->Integral()/h4_WSS[k]->Integral());
h5_WSS[k]->Scale(h5_SS[k]->Integral()/h5_WSS[k]->Integral());
h6_WSS[k]->Scale(h6_SS[k]->Integral()/h6_WSS[k]->Integral());
}
TFile *fout = TFile::Open(output.c_str(), "RECREATE");
fout->cd();
hincl->Write();
TString postfix="";
if (tes==1)
postfix="_CMS_scale_t_mt_13TeVUp";
if (tes==-1)
postfix="_CMS_scale_t_mt_13TeVDown";
if (tes==15)