-
Notifications
You must be signed in to change notification settings - Fork 1
/
DrawCommPlot.C
3966 lines (3229 loc) · 132 KB
/
DrawCommPlot.C
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 "tdrstyle.C"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include "TH1D.h"
#include "TMultiGraph.h"
#include "TGraph.h"
#include "TCanvas.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include "THStack.h"
#include "TFile.h"
#include "TROOT.h"
#include "TColor.h"
#include "TF1.h"
#include "TMath.h"
#include <TLegend.h>
#include <TProfile.h>
#include <TLatex.h>
#include <TAxis.h>
#include <TProfile.h>
#include <TString.h>
using namespace std;
/*
TString filenameMC = "inclmc_2016_trig40_50_250_pvweight.root";
TString filename1 = "jetht_2016_tot_trig40_50_250_pvweight.root";
TString filename2 = "jetht_2016_runb2f_trig40_50_250.root";
TString filename3 = "jetht_2016_rung2h_trig40_50_250.root";
TString dir4plots="plots/";
TString jettype="AK4 jets (50 <p_{T}< 250 GeV)" ;
bool btag = false;
*/
/*
TString filenameMC = "muemc_2016_trig170_200_450_pseudopvweight.root";
TString filename1 = "btag_2016_tot_trig170_200_450.root";
TString filename2 = "btag_2016_runb2f_trig170_200_450.root";
TString filename3 = "btag_2016_rung2h_trig170_200_450.root";
TString dir4plots="plots/";
TString jettype="AK4 jets (200 <p_{T}< 450 GeV)" ;
bool btag = true;
*/
TString filenameMC = "muemc_2016_trig40_50_250_pseudopvweight.root";
TString filename3 = "btag_2016_rung2h_trig40_50_250.root";
bool btag = false;
TString filename4 = "btag_2018_v3.root";
TString filename5 = "btag_2018_v2.root";
TString filename6 = "plot_v1/btag_2018.root";
TString filename7 = "incl_rune_304672.root";
TString filename8 = "pfjet40_50_250_297425.root";
TString qwname3="2016 (runG-runH)";
TString qwname4="2018 315802-316271";
TString qwname5="2018 315489-315801";
TString qwname6="2018 314472-315490";
TString qwname7="RunE (after 304671)";
TString qwname8="P 297425-488";
// comparaison dans Drawdata
//TString filename1b = "jetht500_repair_off.root";
//TString filename2b = "jetht500_repair_on.root";
TString filename1b = "jetht40_repair_off.root";
TString filename2b = "jetht40_repair_on.root";
TString filename1 = filename1b;
TString filename2 = filename2b;
/*
//TString dir4plots="plots_jetht500/";
TString dir4plots="plots_jetht40/";
TString qwname1="off" ;
TString qwname2="on ";
TString jettype="AK4 jets (50 <p_{T}< 250 GeV)" ;
//TString jettype="AK4 jets (525 <p_{T}< 1000 GeV)" ;
*/
//
//
//
// comparaison dans DrawMCCompare
//
/*
//TString filename_1 = "ttbar_nopu_repair_off.root";
//TString filename_2 = "ttbar_nopu_repair_on.root";
TString filename_1 = "ttbar_pu_repair_off.root";
TString filename_2 = "ttbar_pu_repair_on.root";
TString qwname1="off" ;
TString qwname2="on ";
TString labelfile1="repair off";
TString labelfile2="repair on";
//TString dir4plots="plots_ttbar_nopu/";
//TString jettype="ttbar noPU (20 <p_{T}< 500 GeV)" ;
TString dir4plots="plots_ttbar_pu/";
TString jettype="ttbar PU (20 <p_{T}< 500 GeV)" ;
*/
TString filename_1 = "qcd500_repair_off.root";
TString filename_2 = "qcd500_repair_on.root";
//TString filename_1 = "qcd40_repair_off.root";
//TString filename_2 = "qcd40_repair_on.root";
TString labelfile1="repair off";
TString labelfile2="repair on";
TString qwname1="off" ;
TString qwname2="on ";
//TString dir4plots="plots_qcd40/";
//TString jettype="QCD (50 <p_{T}< 250 GeV)" ;
TString dir4plots="plots_qcd500/";
TString jettype="QCD (525 <p_{T}< 1000 GeV)" ;
TString filename = "incl_ctag_full.root";
TString filename2D = "test_2d_rund_mc.root";
bool booname2=true;
bool booname3=false;
bool booname4=false;
bool booname5=false;
bool booname6=false;
bool booname7=false;
bool booname8=false;
TString datacaption="297099-297101";
TString adddir = "./";
bool boolfile3=false;
TString filename_3=adddir+"QCD_8P6NoPU.root";
TString labelfile3="QCD 8TeV Pyth6 No PU";
bool boolfile4=false;
TString filename_4=adddir+"QCD_8P6wPU.root";
TString labelfile4="QCD 8TeV Pyth6 w/ PU";
bool boolfile5=false;
TString filename_5=adddir+"QCD_13P8NoPU.root";
TString labelfile5="QCD 13TeV Pyth8 No PU";
bool boolfile6=false;
TString filename_6=adddir+"QCD_13P8wPU.root";
TString labelfile6="QCD 13TeV Pyth8 w/ PU";
bool displayRatio = false;
TString PU = "";
TString title = "CMS Preliminary";
//TString format=".gif"; // .png or .pdf or .gif
TString format=".pdf"; // .png or .pdf or .gif
bool bOverflow=true;
bool web = false;
void Draw(TString name, TString histotitle, bool log, float miny=-1);
void Draw(TString name, TString ytitle, TString histotitle, bool log, float miny=-1);
void Draw2017(TString name, TString ytitle, TString histotitle, bool log, float miny=-1);
void Drawdata(TString name, TString ytitle, TString histotitle, bool log, float miny=-1);
void Drawdata2(TString name, TString ytitle, TString histotitle, bool log, float miny=-1);
void DrawMC(TString name, TString histotitle, bool log);
void DrawMCCompare(TString name, TString histotitle, bool log);
void DrawMCCompare(TString name, TString ytitle, TString histotitle, bool log, float miny=-1);
void DrawMCgen(TString name, TString histotitle, bool log);
void DrawTagRate(TString name, TString histotitle, bool log);
void Draw2DPlot(TString name, TString histotitle, TString titleX, TString titleY, bool log);
void OverFlowBinFix(TH1D* );
void ModifyBinning(TH1D* histo, int imax);
void DefineHstack(TString filename_x, TString name, TH1D*& hist_fill, THStack * & hs_fill, TH1D* & hist_fill_b, TH1D* & hist_fill_c, TH1D* & hist_fill_l, TH1D* & hist_fill_g, TH1D* & hist_fill_bfromg, TH1D* & hist_fill_cfromg, TH1D* & hist_fill_puu );
void DefineHline(TString filename_x, TString name, TH1D* & hist_line, int iMcolor, float xMsize, int iMstyle, int iLwidth);
void DefineHratio(TString nameRatio, TH1D* & histo_ratio1, TH1D* hnum, TH1D* hdenum, int iMcolor, float xMsize, int iMstyle, int iLwidth );
void DefineHgen(TString filename_x, TString name, TH1D* & hist_fill, int iColor);
void PrintEff(TString name);
void anplot();
void anplot2();
//--------
void DrawCommPlot(bool Draw_track_plots, bool Draw_Nminus1_plots, bool Draw_sv_plots, bool Draw_muons_plots, bool Draw_discriminator_plots ,
bool Draw_newdiscriminator_plots, bool Draw_tagRate_plots, bool Draw_2D_plots, bool Draw_pflepton){
TString action = "mkdir "+dir4plots+"/";
system(action);
//cout << "Drawing pt, eta, phi plots\n";
//Draw("jet_multi" ,"number of jets",1);
DrawMCCompare("jet_pt_all" ,"pT of all jets",1);
DrawMCCompare("jet_eta" ,"eta of all jets", 0);
DrawMCCompare("jet_phi" ,"phi of all jets",0);
DrawMCCompare("track_multi" ,"number of tracks in the jets", 0);
//DrawMC("nPV" ,"# of PV",0);
//cout << "Drawing tack plots\n";
if (Draw_track_plots){
DrawMCCompare("track_multi" , "number of tracks in the jets",0);
DrawMCCompare("trk_multi_sel" , "number of selected tracks in the jets",0);
DrawMCCompare("track_chi2" , "normalized #chi^{2} of the tracks" ,1);
DrawMCCompare("track_nHit" , "number of hits",1);
DrawMCCompare("track_HPix" , "number of hits in the Pixel",1);
DrawMCCompare("track_len" , "Track decay length",1);
DrawMCCompare("track_dist" , "Track distance to the jet axis" ,1);
DrawMCCompare("track_dz" , "Track IP_dz",1);
DrawMCCompare("track_pt" , "pT of all the tracks",1);
DrawMCCompare("track_pt15" , "pT of all the tracks",1);
//Draw("track_isfromSV", "Track is from SV",1);
DrawMCCompare("track_IPs" , "3D IP significance of all tracks",1);
DrawMCCompare("track_IPs1tr" , "3D IP significance of the first track",1);
DrawMCCompare("track_IPs2tr" , "3D IP significance of the second track",1);
DrawMCCompare("track_IPs3tr" , "3D IP significance of the third track",1);
DrawMCCompare("track_IP" , "3D IP of all tracks",1);
DrawMCCompare("track_IP1tr" , "3D IP of the first track" ,1);
DrawMCCompare("track_IP2tr" , "3D IP of the second track",1);
DrawMCCompare("track_IP3tr" , "3D IP of the third track" ,1);
DrawMCCompare("track_IP2Ds" , "2D IP significance of all tracks" ,1);
DrawMCCompare("track_IP2Ds1tr" , "2D IP significance of the first track",1);
DrawMCCompare("track_IP2Ds2tr" , "2D IP significance of the second track" ,1);
DrawMCCompare("track_IP2Ds3tr" , "2D IP significance of the third track" ,1);
DrawMCCompare("track_IP2D" , "2D IP of all tracks",1);
DrawMCCompare("track_IP2D1tr" , "2D IP of the first track" ,1);
DrawMCCompare("track_IP2D2tr" , "2D IP of the second track",1);
DrawMCCompare("track_IP2D3tr" , "2D IP of the third track" ,1);
DrawMCCompare("track_IP2Derr" , "2D IP error of all tracks",1);
DrawMCCompare("track_IP2Derr1tr" , "2D IP error of the first track",1);
DrawMCCompare("track_IP2Derr2tr" , "2D IP error of the second track" ,1);
DrawMCCompare("track_IP2Derr3tr" , "2D IP error of the third track",1);
DrawMCCompare("track_IPerr" , "3D IP error of all tracks",1);
DrawMCCompare("track_IPerr1tr" , "3D IP error of the first track" ,1);
DrawMCCompare("track_IPerr2tr" , "3D IP error of the second track" ,1);
DrawMCCompare("track_IPerr3tr" , "3D IP error of the third track" ,1);
}
if (Draw_Nminus1_plots){
DrawMCCompare("track_chi2_cut" ,"Normalized #chi^{2} @N-1 step",1);
DrawMCCompare("track_nHit_cut" ," Number of hits @N-1 step",1);
DrawMCCompare("track_HPix_cut" ,"Number of hits in the Pixel @N-1 step",1);
DrawMCCompare("track_len_cut" ,"Decay length @N-1 step",1);
DrawMCCompare("track_dist_cut" ,"Distance to the jet axis @N-1 step" ,1);
DrawMCCompare("track_dz_cut" , "Transverse IP @N-1 step",1);
DrawMCCompare("track_pt_cut" ,"Track pT @N-1 step",1);
DrawMCCompare("track_pt15_cut" ,"Track pT @N-1 step",1);
}
if (Draw_sv_plots){
DrawMCCompare("jet_pt_sv" ,"pT of jets containing a SV",1);
DrawMCCompare("sv_multi_0","nr. of SV including bin 0",1);
DrawMCCompare("sv_multi","nr. of SV",1);
DrawMCCompare("sv_mass","SV mass",0);
DrawMCCompare("sv_mass_3trk","SV mass if #tracks@SV >=3",0);
DrawMCCompare("sv_chi2norm","SV norm. #chi^{2}",1);
DrawMCCompare("sv_deltaR_jet","Delta R between the jet and the SV direction.",0);
DrawMCCompare("sv_deltaR_sumJet","#Delta R between the jet and the SV {p}",0);
DrawMCCompare("sv_deltaR_sumDir","#Delta R between the SV direction and the SV {p}",0);
DrawMCCompare("sv_en_ratio","SV energy ratio",0);
DrawMCCompare("sv_aboveC","IP2D of the first track above the charm threshold",1);
DrawMCCompare("sv_pt","SV p_{T}",1);
DrawMCCompare("sv_eta","SV #eta",0);
DrawMCCompare("sv_phi","SV #phi",0);
DrawMCCompare("sv_flight3D","SV 3D flight distance",1);
DrawMCCompare("sv_flight2D","SV 2D flight distance",1);
DrawMCCompare("sv_flight2D_3trk","SV 2D flight dist. if #tracks@SV >=3",1);
DrawMCCompare("sv_flight2DSig_3trk","SV 2D flight dist. sig. if #tracks@SV >=3",1);
DrawMCCompare("sv_flight3DSig","SV 3D flight distance significance",1);
DrawMCCompare("sv_flightSig2D","SV 2D flight distance significance",1);
DrawMCCompare("sv_flight3Derr","SV 3D flight distance error",1);
DrawMCCompare("sv_flight2Derr","SV 2D flight distance error",1);
DrawMCCompare("svnTrk","nr. of tracks from a SV",1);
DrawMCCompare("svnTrk_firstVxt","nr. of tracks from the first SV",1);
}
if (Draw_muons_plots){
DrawMCCompare("muon_multi" , "number of muons", 1);
DrawMCCompare("muon_multi_sel" , "number of selected muons",1);
DrawMCCompare("mu_ptrel" , "p_{T} rel. of the muon",0);
DrawMCCompare("mu_chi2" , "norm. #chi^{2} of the muon", 1);
DrawMCCompare("muon_Pt", "Muon p_{T}",1);
DrawMCCompare("muon_eta", "Muon #eta",0);
DrawMCCompare("muon_phi", "Muon #phi",0);
DrawMCCompare("muon_Ip3d", "Muon 3D IP",1);
DrawMCCompare("muon_Ip2d", "Muon 2D IP",1);
DrawMCCompare("muon_Sip3d", "Muon 3D IP significance",1);
DrawMCCompare("muon_Sip2d", "Muon 2D IP significance",1);
DrawMCCompare("muon_DeltaR", "Muon1 #Delta R",0);
}
if (Draw_discriminator_plots){
DrawMCCompare("TCHE_extended1" ,"TCHE (extended)",1);
DrawMCCompare("TCHP_extended1" ,"TCHP (extended)",1);
DrawMCCompare("discri_ssche0", "SSVHE Discriminator", 1);
DrawMCCompare("discri_sschp0", "SSVHP Discriminator", 1);
DrawMCCompare("TCHE" ,"TCHE Discriminator", 1);
DrawMCCompare("TCHP" ,"TCHP Discriminator",1);
DrawMCCompare("JP" ,"JP Discriminator",1);
DrawMCCompare("JBP" ,"JBP Discriminator",1);
DrawMCCompare("SSV" ,"SSVHE Discriminator",0);
DrawMCCompare("SSVHP" ,"SSVHP Discriminator",0);
DrawMCCompare("CSV" ,"CSV Discriminator",1);
}
if (Draw_newdiscriminator_plots) {
DrawMCCompare("RetCombSvx" ,"CSV_v1 Discriminator",1);
DrawMCCompare("RetCombSvx" ,"CSV_v1 Discriminator",0);
DrawMCCompare("CombCSVJP" ,"CSVJP Discriminator",1);
DrawMCCompare("CombCSVSL" ,"CSVSL_v1 Discriminator",1);
DrawMCCompare("CombCSVJPSL" ,"CSVJPSL Discriminator",1);
DrawMCCompare("SoftMu" ,"Soft Muon Discriminator",1);
DrawMCCompare("SoftMu" ,"Soft Muon Discriminator",0);
DrawMCCompare("SoftEl" ,"Soft Electron Discriminator",1);
}
if (Draw_tagRate_plots){
DrawTagRate("TCHE_extended1","TCHE (extended)", 1);
DrawTagRate("TCHP_extended1"," TCHP (extended)", 1);
DrawTagRate("discri_ssche0","SSVHE (extended)", 1);
DrawTagRate("discri_sschp0","SSVHP (extended)", 1);
DrawTagRate("TCHE" ,"TCHE Discriminator", 1);
DrawTagRate("TCHP" ,"TCHP Discriminator", 1);
DrawTagRate("JP" ,"JP Discriminator", 1);
DrawTagRate("JBP" ,"JBP Discriminator", 1);
DrawTagRate("SSV" ,"SSVHE Discriminator", 0);
DrawTagRate("SSVHP" ,"SSVHP Discriminator", 0);
DrawTagRate("CSV" ,"CSV Discriminator", 1);
}
if (Draw_2D_plots){
Draw2DPlot("seltrack_vs_jetpt", "nr. of selected tracks as a function of the jet p_{T}", "jet p_{T}","nr. of selected tracks",0);
Draw2DPlot("sv_mass_vs_flightDist3D", " SV mass as a function of the SV 3D flight distance ","SV 3D flight distance","SV mass", 0);
Draw2DPlot("avg_sv_mass_vs_jetpt","Avg SV mass as a function of the jet p_{T}","jet p_{T}","Avg SV mass", 0);
Draw2DPlot("sv_deltar_jet_vs_jetpt","#Delta R between the SV and the jet as a function of the jet p_{T}","jet p_{T}","#Delta R between the SV and the jet", 0);
Draw2DPlot("sv_deltar_sum_jet_vs_jetpt","#Delta R between the SV and the jet sum as a function of the jet p_{T}","jet p_{T}","#Delta R between the SV and the jet sum", 0);
Draw2DPlot("sv_deltar_sum_dir_vs_jetpt","#Delta R between the SV and the jet direction as a function of the jet p_{T}", "jet p_{T}","#Delta R between the SV and the jet direction", 0);
Draw2DPlot("muon_ptrel_vs_jetpt","Muon_p{T}^{rel} as a function of the jet p_{T}","jet p_{T}","Muon_p{T}^{rel}", 0);
Draw2DPlot("muon_DeltaR_vs_jetpt","Muon #Delta R as a function of the jet p_{T}","jet p_{T}","Muon #Delta R", 0);
}
if (Draw_pflepton) {
DrawMCCompare("pfelectron_multi","number of pfelectron",1);
DrawMCCompare("pfelectron_pt","pfelectron p_{T}",1);
DrawMCCompare("pfelectron_eta","pfelectron #eta",0);
DrawMCCompare("pfelectron_phi","pfelectron #phi", 0);
DrawMCCompare("pfelectron_Sip","3D IP significance of pfelectron",1);
DrawMCCompare("pfelectron_ptrel","pT rel. of the pfelectron",0);
DrawMCCompare("pfelectron_ratio","ratio of pfelectron", 1);
DrawMCCompare("pfelectron_ratiorel", "ratioRel of pfelectron",1);
DrawMCCompare("pfelectron_deltar", "#DeltaR(pfelectron,jet)",0);
DrawMCCompare("pfmuon_multi","number of pfmuon",1);
DrawMCCompare("pfmuon_goodquality","quality of pfmuons",0);
DrawMCCompare("pfmuon_pt","pfmuon p_{T}",1);
DrawMCCompare("pfmuon_eta","pfmuon #eta",0);
DrawMCCompare("pfmuon_phi","pfmuon #phi", 0);
DrawMCCompare("pfmuon_Sip","3D IP significance of pfmuon",1);
DrawMCCompare("pfmuon_ptrel","pT rel. of the pfmuon",0);
DrawMCCompare("pfmuon_ratio","ratio of pfmuon", 1);
DrawMCCompare("pfmuon_ratiorel", "ratioRel of pfmuon",1);
DrawMCCompare("pfmuon_deltar", "#DeltaR(pfmuon,jet)",0);
}
}
void anplot() {
TString action = "mkdir "+dir4plots+"/";
system(action);
DrawMCCompare("jet_pt_all" ,"pT of all jets",1);
DrawMCCompare("track_IPs" , "3D IP significance of all tracks",1);
DrawMCCompare("track_IP" , "3D IP of all tracks",1);
DrawMCCompare("track_IPerr" , "3D IP error of all tracks",1);
DrawMCCompare("track_chi2_cut" ,"Normalized #chi^{2} @N-1 step",1);
DrawMCCompare("track_nHit_cut" ," Number of hits @N-1 step",1);
DrawMCCompare("track_HPix_cut" ,"Number of hits in the Pixel @N-1 step",1);
DrawMCCompare("track_len_cut" ,"Decay length @N-1 step",1);
DrawMCCompare("track_dist_cut" ,"Distance to the jet axis @N-1 step" ,1);
DrawMCCompare("track_dz_cut" , "IP_dz @N-1 step",1);
DrawMCCompare("track_pt_cut" ,"Track pT @N-1 step",1);
DrawMCCompare("track_pt15_cut" ,"Track pT @N-1 step",1);
DrawMCCompare("track_IP2D_cut" ,"IP2D @N-1 step",1);
/*
DrawMCCompare("sv_multi_0","nr. of SV including bin 0",1);
DrawMCCompare("sv_mass","SV mass",0);
DrawMCCompare("sv_deltaR_jet","Delta R between the jet and the SV direction.",0);
DrawMCCompare("sv_pt","SV p_{T}",1);
DrawMCCompare("mu_ptrel" , "p_{T} rel. of the muon",0);
DrawMCCompare("muon_Pt", "Muon p_{T}",1);
DrawMCCompare("muon_Sip3d", "Muon 3D IP significance",1);
DrawMCCompare("muon_DeltaR", "Muon1 #Delta R",0);
DrawMCCompare("discri_ssche0", "SSVHE Discriminator", 1);
DrawMCCompare("discri_sschp0", "SSVHP Discriminator", 1);
DrawMCCompare("TCHE" ,"TCHE Discriminator", 1);
DrawMCCompare("TCHP" ,"TCHP Discriminator",1);
DrawMCCompare("JP" ,"JP Discriminator",1);
DrawMCCompare("JBP" ,"JBP Discriminator",1);
DrawMCCompare("CSV" ,"CSV Discriminator",1);
*/
}
void anplot2() {
TString action = "mkdir "+dir4plots+"/";
system(action);
DrawMCCompare("CSV" ,"CSV Discriminator",1);
DrawMCCompare("CombCSVSL" ,"CSVSL_v1 Discriminator",1);
/*
DrawMCCompare("RetCombSvx" ,"CSV_v1 Discriminator",1);
DrawMCCompare("RetCombSvx" ,"CSV_v1 Discriminator",0);
DrawMCCompare("CombCSVJP" ,"CSVJP Discriminator",1);
DrawMCCompare("CombCSVJPSL" ,"CSVJPSL Discriminator",1);
DrawMCCompare("SoftMu" ,"Soft Muon Discriminator",1);
DrawMCCompare("SoftEl" ,"Soft Electron Discriminator",1);
*/
}
//--------------------------
void Draw(TString name, TString histotitle, bool log, float miny)
{
Draw(name, "Entries", histotitle, log, miny);
}
//// Commissioning50ns
void Draw(TString name, TString ytitle, TString histotitle, bool log, float miny)
{
cout << " name " << name << " ytitle " << ytitle << " histotitle " << histotitle << endl;
cout << " log " << log << " miny " << miny << endl;
TH1D* hist_b;
TH1D* hist_bfromg;
TH1D* hist_c;
TH1D* hist_l;
TH1D* hist_g;
TH1D* hist_cfromg;
TH1D* hist_puu;
TH1D* hist_data;
TH1D* hist_data1;
TH1D* hist_data2;
TH1D* hist_data3;
TH1D* hist_data4;
TH1D* hist_data5;
TH1D* hist_data6;
TH1D* hist_data7;
TH1D* hist_data8;
TFile *myFile = new TFile(filenameMC);
myFile->cd();
hist_b = (TH1D*)gROOT->FindObject(name+"_b");
hist_c = (TH1D*)gROOT->FindObject(name+"_c");
hist_bfromg = (TH1D*)gROOT->FindObject(name+"_bfromg");
hist_l = (TH1D*)gROOT->FindObject(name+"_l");
hist_g = (TH1D*)gROOT->FindObject(name+"_g");
hist_cfromg = (TH1D*)gROOT->FindObject(name+"_cfromg");
hist_puu = (TH1D*)gROOT->FindObject(name+"_puu");
TFile *myFile1 = new TFile(filename1);
myFile1->cd();
hist_data1 = (TH1D*)gROOT->FindObject(name+"_data");
if (btag) hist_l->Scale(1.27);
if (btag) hist_g->Scale(1.27);
cout << " btag rewighting for hist_l and hist_g " << endl;
/*
if (btag) hist_l->Scale(1./0.93);
if (btag) hist_g->Scale(1./0.93);
*/
/*
//test caro
float xval;
float xval2;
// xval=1.;
cout << " quelle valeur pour le reweighting des light? "<< endl;
cin >> xval;
hist_l->Scale(xval);
hist_g->Scale(xval);
cout << " quelle valeur pour le reweighting des c? "<< endl;
cin >> xval2;
// xval2=1.5;
hist_c->Scale(xval2);
hist_cfromg->Scale(xval2);
*/
if(booname2) {
TFile *myFile2 = new TFile(filename2);
myFile2->cd();
hist_data2 = (TH1D*)gROOT->FindObject(name+"_data");
}
else { hist_data2 = (TH1D*)hist_data1->Clone(); }
if(booname3) {
TFile *myFile3 = new TFile(filename3);
myFile3->cd();
hist_data3 = (TH1D*)gROOT->FindObject(name+"_data");
}
if(booname4) {
TFile *myFile4 = new TFile(filename4);
myFile4->cd();
hist_data4 = (TH1D*)gROOT->FindObject(name+"_data");
}
if(booname5) {
TFile *myFile5 = new TFile(filename5);
myFile5->cd();
hist_data5 = (TH1D*)gROOT->FindObject(name+"_data");
}
if(booname6) {
TFile *myFile6 = new TFile(filename6);
myFile6->cd();
hist_data6 = (TH1D*)gROOT->FindObject(name+"_data");
}
if(booname7) {
TFile *myFile7 = new TFile(filename7);
myFile7->cd();
hist_data7 = (TH1D*)gROOT->FindObject(name+"_data");
}
if(booname8) {
TFile *myFile8 = new TFile(filename8);
myFile8->cd();
hist_data8 = (TH1D*)gROOT->FindObject(name+"_data");
}
bool ovbin = true;
for (int i=1;i<10;i++) {
char ccc[20];
sprintf(ccc,"bin%d",i);
TString biccc = ccc;
if (name==biccc+"_SVmass" ||
name==biccc+"_sv_flight3DSig" ||
name==biccc+"_sv_pt" ||
name==biccc+"_sv_deltaR_jet" ) ovbin= false;
}
/*
int imax=16; // 21
if (name=="trk_multi_sel") {
ModifyBinning(hist_b,imax);
ModifyBinning(hist_c,imax);
ModifyBinning(hist_bfromg,imax);
ModifyBinning(hist_l,imax);
ModifyBinning(hist_data,imax);
ModifyBinning(hist_g,imax);
ModifyBinning(hist_cfromg,imax);
ModifyBinning(hist_puu,imax);
}
*/
if (name=="pfmuonqual_multi") ovbin= false;
if (bOverflow && name!="SSV" && name!="SSVHP" && name!="sv_mass"
&& name!="sv_mass_3trk" && ovbin) {
OverFlowBinFix(hist_b);
OverFlowBinFix(hist_c);
OverFlowBinFix(hist_bfromg);
OverFlowBinFix(hist_l);
// OverFlowBinFix(hist_data);
OverFlowBinFix(hist_g);
OverFlowBinFix(hist_cfromg);
OverFlowBinFix(hist_puu);
OverFlowBinFix(hist_data1);
if (booname2) OverFlowBinFix(hist_data2);
if (booname3) OverFlowBinFix(hist_data3);
if (booname4) OverFlowBinFix(hist_data4);
if (booname5) OverFlowBinFix(hist_data5);
if (booname6) OverFlowBinFix(hist_data6);
if (booname7) OverFlowBinFix(hist_data7);
if (booname8) OverFlowBinFix(hist_data8);
}
TH1D* histo_tot = (TH1D*) hist_b->Clone();
histo_tot->Sumw2();
histo_tot ->Add(hist_c);
histo_tot ->Add(hist_bfromg);
histo_tot ->Add(hist_l);
histo_tot ->Add(hist_g);
histo_tot ->Add(hist_cfromg);
histo_tot ->Add(hist_puu);
float scale_f = (hist_data1->Integral())/(hist_b->Integral() + hist_c ->Integral()+ hist_bfromg->Integral() + hist_l->Integral() + hist_g->Integral() + hist_cfromg->Integral() + hist_puu->Integral());
hist_b ->Scale(scale_f);
hist_c ->Scale(scale_f);
hist_bfromg ->Scale(scale_f);
hist_l ->Scale(scale_f);
hist_g ->Scale(scale_f);
hist_cfromg ->Scale(scale_f);
hist_puu ->Scale(scale_f);
histo_tot ->Scale(scale_f);
if (name!="prob_DeepFlavourUDS" && name!="prob_DeepFlavourG") {
hist_l ->Add(hist_g);
}
hist_c ->Add(hist_cfromg);
float scale_f2 =1;
if (booname2) { scale_f2= (hist_data1->Integral())/(hist_data2->Integral()); hist_data2 ->Scale(scale_f2);}
float scale_f3 =1;
float scale_f4 =1;
float scale_f5 =1;
float scale_f6 =1;
float scale_f7 =1;
float scale_f8 =1;
if (booname3) { scale_f3 = (hist_data1->Integral())/(hist_data3->Integral()); hist_data3 ->Scale(scale_f3); }
if (booname4) { scale_f4 = (hist_data1->Integral())/(hist_data4->Integral()); hist_data4 ->Scale(scale_f4); }
if (booname5) { scale_f5 = (hist_data1->Integral())/(hist_data5->Integral()); hist_data5 ->Scale(scale_f5); }
if (booname6) { scale_f6 = (hist_data1->Integral())/(hist_data6->Integral()); hist_data6 ->Scale(scale_f6); }
if (booname7) { scale_f7 = (hist_data1->Integral())/(hist_data7->Integral()); hist_data7 ->Scale(scale_f7); }
if (booname8) { scale_f8 = (hist_data1->Integral())/(hist_data8->Integral()); hist_data8 ->Scale(scale_f8); }
TH1D* histo_ratio;
histo_ratio = (TH1D*) hist_data1->Clone();
histo_ratio->SetName("histo_ratio");
histo_ratio->SetTitle("");
histo_ratio->Divide(histo_tot);
hist_data1 ->SetLineWidth(2);
hist_data1 ->SetMarkerStyle(20);
hist_data1 ->SetMarkerSize(0.75);
/*
if (booname2 || booname3 || booname4 || booname5 || booname6) {
hist_c ->SetFillStyle(3001);
hist_cfromg ->SetFillStyle(3001);
hist_b ->SetFillStyle(3001);
hist_bfromg ->SetFillStyle(3001);
hist_l ->SetFillStyle(3001);
hist_g ->SetFillStyle(3001);
hist_puu ->SetFillStyle(3001);
}
*/
hist_c ->SetFillColor(8);
hist_b ->SetFillColor(kRed);
hist_bfromg->SetFillColor(7); //Pour merger les contributions --> kRed
hist_l ->SetFillColor(kBlue);
if (name=="prob_DeepFlavourUDS" || name=="prob_DeepFlavourG") {
hist_g ->SetFillColor(kBlue-9);
}
else {
hist_g ->SetFillColor(kBlue);
}
hist_cfromg ->SetFillColor(8);
hist_puu ->SetFillColor(kYellow);
hist_c ->SetLineColor(1);
hist_b ->SetLineColor(1);
hist_bfromg->SetLineColor(1); //Pour merger les contributions --> kRed
hist_l ->SetLineColor(1);
if (name=="prob_DeepFlavourUDS" || name=="prob_DeepFlavourG") {
hist_g ->SetLineColor(1);
}
else {
hist_g ->SetLineColor(kBlue);
}
hist_cfromg ->SetLineColor(8);
hist_puu ->SetLineColor(1);
histo_tot ->SetLineColor(1);
THStack *stack = new THStack("stack","stack");
stack ->Add(hist_b);
stack ->Add(hist_bfromg);
// stack ->Add(hist_cfromg);
stack ->Add(hist_c);
stack ->Add(hist_puu);
if (name=="prob_DeepFlavourUDS" || name=="prob_DeepFlavourG") {
stack ->Add(hist_g);
}
// otherwise is added in hist_l before
stack ->Add(hist_l);
TH1D* histo_ratio2;
TH1D* histo_ratio3;
TH1D* histo_ratio4;
TH1D* histo_ratio5;
TH1D* histo_ratio6;
TH1D* histo_ratio7;
TH1D* histo_ratio8;
if(booname2) {histo_ratio2 = (TH1D*) hist_data2->Clone();
histo_ratio2->SetName("histo_ratio2");
histo_ratio2->SetTitle("");
// histo_ratio2->Divide(hist_data1);
histo_ratio2->Divide(histo_tot);
}
if (booname3) histo_ratio3 = (TH1D*) hist_data3->Clone();
if (booname4) histo_ratio4 = (TH1D*) hist_data4->Clone();
if (booname5) histo_ratio5 = (TH1D*) hist_data5->Clone();
if (booname6) histo_ratio6 = (TH1D*) hist_data6->Clone();
if (booname7) histo_ratio7 = (TH1D*) hist_data7->Clone();
if (booname8) histo_ratio8 = (TH1D*) hist_data8->Clone();
if (booname3) histo_ratio3->Divide(histo_tot);
if (booname4) histo_ratio4->Divide(histo_tot);
if (booname5) histo_ratio5->Divide(histo_tot);
if (booname6) histo_ratio6->Divide(histo_tot);
if (booname7) histo_ratio7->Divide(histo_tot);
/*
if (booname3) histo_ratio3->Divide(hist_data1);
if (booname4) histo_ratio4->Divide(hist_data1);
if (booname5) histo_ratio5->Divide(hist_data1);
if (booname6) histo_ratio6->Divide(hist_data1);
if (booname7) histo_ratio7->Divide(hist_data1);
if (booname8) histo_ratio8->Divide(hist_data1);
*/
if(booname2) {
hist_data2 ->SetMarkerStyle(20); //Caro 24
hist_data2 ->SetMarkerSize(0.75);
// hist_data2 ->SetLineColor(2);
// hist_data2 ->SetMarkerColor(2);
hist_data2 ->SetLineColor(kPink+6);
hist_data2 ->SetMarkerColor(kPink+6);
histo_ratio2->SetMarkerStyle(20);
histo_ratio2->SetMarkerSize(0.75);
// histo_ratio2 ->SetLineColor(2);
// histo_ratio2 ->SetMarkerColor(2);
histo_ratio2 ->SetLineColor(kPink+6);
histo_ratio2 ->SetMarkerColor(kPink+6);
}
if (booname3) {
hist_data3->SetMarkerStyle(20);
hist_data3->SetMarkerSize(0.75);
hist_data3->SetLineColor(kAzure-4);
hist_data3->SetMarkerColor(kAzure-4);
histo_ratio3->SetMarkerStyle(20);
histo_ratio3->SetMarkerSize(0.75);
histo_ratio3->SetLineColor(kAzure-4);
histo_ratio3->SetMarkerColor(kAzure-4);
}
if (booname4) {
hist_data4->SetMarkerStyle(23);
hist_data4->SetMarkerSize(0.75);
hist_data4->SetLineColor(13);
hist_data4->SetMarkerColor(13);
histo_ratio4->SetMarkerStyle(23);
histo_ratio4->SetMarkerSize(0.75);
histo_ratio4->SetLineColor(13);
histo_ratio4->SetMarkerColor(13);
}
if (booname5) {
hist_data5->SetMarkerStyle(33);
hist_data5->SetMarkerSize(0.75);
hist_data5->SetLineColor(6);
hist_data5->SetMarkerColor(6);
histo_ratio5->SetMarkerStyle(33);
histo_ratio5->SetMarkerSize(0.75);
histo_ratio5->SetLineColor(6);
histo_ratio5->SetMarkerColor(6);
}
if (booname6) {
hist_data6->SetMarkerStyle(29);
hist_data6->SetMarkerSize(0.75);
hist_data6->SetLineColor(7);
hist_data6->SetMarkerColor(7);
histo_ratio6->SetMarkerStyle(29);
histo_ratio6->SetMarkerSize(0.75);
histo_ratio6->SetLineColor(7);
histo_ratio6->SetMarkerColor(7);
}
if (booname7) {
hist_data7->SetMarkerStyle(33);
hist_data7->SetMarkerSize(0.75);
hist_data7->SetLineColor(16);
hist_data7->SetMarkerColor(16);
histo_ratio7->SetMarkerStyle(33);
histo_ratio7->SetMarkerSize(0.75);
histo_ratio7->SetLineColor(16);
histo_ratio7->SetMarkerColor(16);
}
if (booname8) {
hist_data8->SetMarkerStyle(33);
hist_data8->SetLineColor(13);
hist_data8->SetMarkerColor(13);
histo_ratio8->SetLineColor(13);
histo_ratio8->SetMarkerColor(13);
}
setTDRStyle();
gStyle->SetErrorX(0.);
TCanvas *c1 = new TCanvas(name, name,10,32,782,552);
c1->SetFillColor(10);
c1->SetBorderMode(0);
c1->SetBorderSize(2);
c1->SetFrameFillColor(0);
c1->SetFrameBorderMode(0);
c1-> cd();
TPad* canvas_1 = new TPad("canvas"+name, "canvas"+name,0,0.23,1.0,0.98);
canvas_1 ->Draw();
canvas_1->SetFillColor(0);
canvas_1->SetBorderMode(0);
canvas_1->SetBorderSize(2);
canvas_1->SetTopMargin(0.065);
canvas_1->SetFrameBorderMode(0);
canvas_1 ->cd();
canvas_1->SetLogy(log);
if (!log) stack->SetMaximum( stack->GetMaximum()*2);
else stack->SetMaximum( stack->GetMaximum()*5000);
if (name=="trk_multi_sel" && log) stack->SetMaximum( stack->GetMaximum()*50000);
if (miny==-1) {
if (log) stack->SetMinimum(0.1);
else stack->SetMinimum(0.);
}
else {
stack->SetMinimum(miny);
}
stack ->Draw("hist");
stack ->GetHistogram()->GetXaxis()->SetTitle(name);
stack ->GetHistogram()->GetYaxis()->SetTitle(ytitle);
stack ->GetHistogram()->SetTitleSize(0.08,"Y");
stack ->GetHistogram()->SetTitleOffset(0.65,"Y");
stack->GetHistogram()->SetTitleOffset(0.81,"Y");
stack->GetHistogram()->GetYaxis()->SetLabelSize( 0.05 );
stack->GetHistogram()->GetYaxis()->SetTitleSize( 0.06 );
if (name=="sv_mass" || name=="tagvarCSV_vertexmass_cat0") stack ->GetHistogram()->SetTitleOffset(0.91,"Y");
hist_data1->Draw("same E1X0");
if (booname2) {
hist_data2->Draw("same E1X0");
}
if (booname3) { hist_data3->Draw("same E1X0"); }
if (booname4) { hist_data4->Draw("same E1X0"); }
if (booname5) { hist_data5->Draw("same E1X0"); }
if (booname6) { hist_data6->Draw("same E1X0"); }
if (booname7) { hist_data7->Draw("same E1X0"); }
if (booname8) { hist_data8->Draw("same E1X0"); }
hist_data1->Draw("same E1X0");
int move_legend=0;
if (name=="jet_phi" || name=="sv_phi" || name=="muon_phi" || name=="pfelectron_phi" || name=="pfmuon_phi") move_legend=1;
if (btag) {
if (name=="CombCSVJPSL" || name=="CombCSVSL" || (name=="SoftMu" && !log) ) move_legend=2;
if (name=="CSV" || name=="CombCSVJP" || (name=="RetCombSvx" && !log) ) move_legend=3;
if ((name=="RetCombSvx" || name=="SoftMu" ) && log) move_legend=1;
}
if (log && name=="sv_en_ratio" ) move_legend=1;
TLegend* qw;
qw = new TLegend(0.65,0.60,0.95,0.90,NULL,"brNDC");
// qw->AddEntry(hist_data, datacaption, "ep");
qw->AddEntry(hist_b, "b quark" , "f");
qw->AddEntry(hist_c, "c quark" , "f");
// qw->AddEntry(hist_cfromg, "c from g split" , "f");
if (name=="prob_DeepFlavourUDS" || name=="prob_DeepFlavourG") {
qw->AddEntry(hist_l, "uds quark" , "f");
qw->AddEntry(hist_g, "gluon" , "f");
}
else {
qw->AddEntry(hist_l, "uds quark or gluon" , "f");
}
// qw->AddEntry(hist_g, "gluon" , "f");
qw->AddEntry(hist_bfromg, "b from gluon splitting" ,"f");
qw->AddEntry(hist_puu, "pile-up" , "f");
qw->AddEntry(hist_data1, qwname1, "ep");
if (booname2) qw->AddEntry(hist_data2, qwname2 , "ep");
if (booname3) qw->AddEntry(hist_data3, qwname3 , "ep");
if (booname4) qw->AddEntry(hist_data4, qwname4 , "ep");
if (booname5) qw->AddEntry(hist_data5, qwname5 , "ep");
if (booname7) qw->AddEntry(hist_data7, qwname7 , "ep");
if (booname6) qw->AddEntry(hist_data6, qwname6 , "ep");
if (booname8) qw->AddEntry(hist_data8, qwname8 , "ep");
//
qw->SetBorderSize(1);
qw->SetTextFont(62);
qw->SetLineColor(1);
qw->SetLineStyle(1);
qw->SetLineWidth(1);
qw->SetFillColor(0);
qw->SetFillStyle(1001);
qw->SetBorderSize(0);
qw->SetFillColor(0);
qw->Draw();
/*
int iPeriod = 4; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV
int iPos = 11 ;
CMS_lumi( canvas_1, iPeriod, iPos );
*/
// TLatex * tex = new TLatex(0.98,0.95125,"#sqrt{s}=13 TeV, 50ns");
TLatex * tex = new TLatex(0.98,0.95125,"#sqrt{s}=13 TeV");
tex->SetNDC();
tex->SetTextAlign(31);
tex->SetTextFont(42);
tex->SetTextSize(0.04875);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0.20,0.89,"CMS");
tex->SetNDC();
tex->SetTextAlign(13);
tex->SetTextFont(62);
tex->SetTextSize(0.065);
tex->SetLineWidth(2);
tex->Draw();
tex = new TLatex(0.20,0.82,"Preliminary");
tex->SetNDC();
tex->SetTextAlign(13);
tex->SetTextFont(52);
tex->SetTextSize(0.05681);
tex->SetLineWidth(2);
tex->Draw();
TString sample = "";
// if (filename.Contains("pfsel")) sample += "Multijets" ;
// else if (filename.Contains("musel")) sample += "Muon enriched QCD" ;
// sample += "Multijets" ;
if (btag) {
sample += "Muon enriched QCD" ;
}
else {
sample += "Multijets" ;
}
TLatex *tex1 = new TLatex(0.20,0.74,sample);
tex1->SetNDC();
tex1->SetTextAlign(13);
tex1->SetTextFont(42);
tex1->SetTextSize(0.055);
tex1->SetLineWidth(2);
tex1->Draw();
TLatex *tex2 = new TLatex(0.20,0.68,jettype);
tex2->SetNDC();
tex2->SetTextAlign(13);