Skip to content

Commit c79c657

Browse files
committed
Merge pull request BristolTopGroup#287 from EmyrClement/plotCosmetics
Control plot cosmetics.
2 parents cff5ae5 + 6c8c66f commit c79c657

File tree

4 files changed

+49
-45
lines changed

4 files changed

+49
-45
lines changed

config/CMS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
'pad': 12
4444
}
4545

46-
legend_properties = {'size':40}
46+
legend_properties = {'size':42}
4747

4848
figsize = (16,16)
4949
dpi = 400

src/cross_section_measurement/make_control_plots_fromTrees.py

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
5151
use_qcd_data_region = False,
5252
compare_qcd_signal_with_data_control = False,
5353
y_limits = [],
54-
y_max_scale = 1.2,
54+
y_max_scale = 1.3,
5555
rebin = 1,
5656
legend_location = ( 0.98, 0.78 ), cms_logo_location = 'right',
5757
log_y = False,
@@ -353,9 +353,9 @@ def make_plot( channel, x_axis_title, y_axis_title,
353353
'NVertexNoWeight',
354354
'LeptonPt',
355355
'AbsLeptonEta',
356-
# 'Mjj',
357-
# 'M3',
358-
# 'angle_bl',
356+
# # 'Mjj',
357+
# # 'M3',
358+
# # 'angle_bl',
359359
'NJets',
360360
'NBJets',
361361
'NBJetsNoWeight'
@@ -398,16 +398,16 @@ def make_plot( channel, x_axis_title, y_axis_title,
398398
print '---> HT'
399399
make_plot( channel,
400400
x_axis_title = '$%s$ [GeV]' % variables_latex['HT'],
401-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
401+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['HT']),
402402
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
403403
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
404404
branchName = 'HT',
405405
name_prefix = '%s_HT_' % label,
406406
x_limits = control_plots_bins['HT'],
407407
nBins = 20,
408408
rebin = 1,
409-
legend_location = ( 0.95, 0.78 ),
410-
cms_logo_location = 'right',
409+
legend_location = ( 0.9, 0.83 ),
410+
cms_logo_location = 'left',
411411
use_qcd_data_region = useQCDControl,
412412
)
413413

@@ -427,8 +427,8 @@ def make_plot( channel, x_axis_title, y_axis_title,
427427
x_limits = control_plots_bins['MET'],
428428
nBins = len(control_plots_bins['MET'])-1,
429429
rebin = 1,
430-
legend_location = ( 0.95, 0.78 ),
431-
cms_logo_location = 'right',
430+
legend_location = ( 0.9, 0.83 ),
431+
cms_logo_location = 'left',
432432
use_qcd_data_region = useQCDControl,
433433
)
434434

@@ -448,8 +448,8 @@ def make_plot( channel, x_axis_title, y_axis_title,
448448
x_limits = control_plots_bins['MET'],
449449
nBins = len(control_plots_bins['MET'])-1,
450450
rebin = 1,
451-
legend_location = ( 0.95, 0.78 ),
452-
cms_logo_location = 'right',
451+
legend_location = ( 0.9, 0.83 ),
452+
cms_logo_location = 'left',
453453
use_qcd_data_region = useQCDControl,
454454
)
455455

@@ -461,16 +461,16 @@ def make_plot( channel, x_axis_title, y_axis_title,
461461
print '---> ST'
462462
make_plot( channel,
463463
x_axis_title = '$%s$ [GeV]' % variables_latex['ST'],
464-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
464+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['ST']),
465465
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
466466
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
467467
branchName = 'STNoHF',
468468
name_prefix = '%s_STNoHF_' % label,
469469
x_limits = control_plots_bins['ST'],
470470
nBins = 20,
471471
rebin = 1,
472-
legend_location = ( 0.95, 0.78 ),
473-
cms_logo_location = 'right',
472+
legend_location = ( 0.9, 0.83 ),
473+
cms_logo_location = 'left',
474474
use_qcd_data_region = useQCDControl,
475475
)
476476

@@ -482,16 +482,16 @@ def make_plot( channel, x_axis_title, y_axis_title,
482482
print '---> WPT'
483483
make_plot( channel,
484484
x_axis_title = '$%s$ [GeV]' % variables_latex['WPT'],
485-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
485+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['WPT']),
486486
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
487487
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
488488
branchName = 'WPTNoHF',
489489
name_prefix = '%s_WPTNoHF_' % label,
490490
x_limits = control_plots_bins['WPT'],
491491
nBins = 16,
492492
rebin = 1,
493-
legend_location = ( 0.95, 0.78 ),
494-
cms_logo_location = 'right',
493+
legend_location = ( 0.9, 0.83 ),
494+
cms_logo_location = 'left',
495495
use_qcd_data_region = useQCDControl,
496496
)
497497

@@ -514,7 +514,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
514514
x_limits = fit_variable_bin_edges['Mjj'],
515515
nBins = 20,
516516
rebin = 1,
517-
legend_location = ( 0.95, 0.78 ),
517+
legend_location = ( 0.9, 0.78 ),
518518
cms_logo_location = 'right',
519519
)
520520

@@ -525,15 +525,15 @@ def make_plot( channel, x_axis_title, y_axis_title,
525525
print '---> M3'
526526
make_plot( channel,
527527
x_axis_title = '$%s$ [GeV]' % fit_variables_latex['M3'],
528-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
528+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['M3']),
529529
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
530530
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
531531
branchName = 'M3',
532532
name_prefix = '%s_M3_' % label,
533533
x_limits = fit_variable_bin_edges['M3'],
534534
nBins = 20,
535535
rebin = 1,
536-
legend_location = ( 0.95, 0.78 ),
536+
legend_location = ( 0.9, 0.78 ),
537537
cms_logo_location = 'right',
538538
use_qcd_data_region = useQCDControl,
539539
)
@@ -569,31 +569,31 @@ def make_plot( channel, x_axis_title, y_axis_title,
569569
print '---> NJets'
570570
make_plot( channel,
571571
x_axis_title = '$%s$' % control_plots_latex['NJets'],
572-
y_axis_title = 'Events',
572+
y_axis_title = 'Events / 1',
573573
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
574574
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
575575
branchName = 'NJets',
576576
name_prefix = '%s_NJets_' % label,
577577
x_limits = control_plots_bins['NJets'],
578578
nBins = len(control_plots_bins['NJets'])-1,
579579
rebin = 1,
580-
legend_location = ( 0.95, 0.78 ),
581-
cms_logo_location = 'right',
580+
legend_location = ( 0.9, 0.83 ),
581+
cms_logo_location = 'left',
582582
use_qcd_data_region = useQCDControl,
583583
)
584584

585585
make_plot( channel,
586586
x_axis_title = '$%s$' % control_plots_latex['NJets'],
587-
y_axis_title = 'Events',
587+
y_axis_title = 'Events / 1',
588588
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
589589
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % label,
590590
branchName = 'NJets',
591591
name_prefix = '%s_NJets_logY_' % label,
592592
x_limits = control_plots_bins['NJets'],
593593
nBins = len(control_plots_bins['NJets'])-1,
594594
rebin = 1,
595-
legend_location = ( 0.95, 0.78 ),
596-
cms_logo_location = 'right',
595+
legend_location = ( 0.9, 0.83 ),
596+
cms_logo_location = 'left',
597597
use_qcd_data_region = useQCDControl,
598598
log_y = True,
599599
)
@@ -612,7 +612,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
612612
x_limits = control_plots_bins['NBJets'],
613613
nBins = len(control_plots_bins['NBJets'])-1,
614614
rebin = 1,
615-
legend_location = ( 0.95, 0.78 ),
615+
legend_location = ( 0.9, 0.83 ),
616616
cms_logo_location = 'right',
617617
use_qcd_data_region = False,
618618
)
@@ -627,7 +627,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
627627
# x_limits = control_plots_bins['NBJets'],
628628
# nBins = len(control_plots_bins['NBJets'])-1,
629629
# rebin = 1,
630-
# legend_location = ( 0.95, 0.78 ),
630+
# legend_location = ( 0.95, 0.83 ),
631631
# cms_logo_location = 'right',
632632
# log_y = True,
633633
# use_qcd_data_region = False,
@@ -662,7 +662,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
662662

663663
make_plot( channel,
664664
x_axis_title = '$%s$' % control_plots_latex['pt'],
665-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
665+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['JetPt']),
666666
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/Jets/Jets' % ( label ),
667667
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/Jets/Jets' % (label ),
668668
branchName = 'pt',
@@ -720,16 +720,16 @@ def make_plot( channel, x_axis_title, y_axis_title,
720720
binsLabel = 'MuonPt'
721721
make_plot( channel,
722722
x_axis_title = '$%s$' % control_plots_latex['pt'],
723-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
723+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins[binsLabel]),
724724
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % ( label ),
725725
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % (label ),
726726
branchName = 'lepton_pt',
727727
name_prefix = '%s_LeptonPt_' % label,
728728
x_limits = control_plots_bins[binsLabel],
729729
nBins = len(control_plots_bins[binsLabel])-1,
730730
rebin = 1,
731-
legend_location = ( 0.95, 0.78 ),
732-
cms_logo_location = 'right',
731+
legend_location = ( 0.9, 0.83 ),
732+
cms_logo_location = 'left',
733733
use_qcd_data_region = useQCDControl,
734734
)
735735
###################################################
@@ -743,7 +743,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
743743

744744
make_plot( channel,
745745
x_axis_title = '$%s$' % control_plots_latex['eta'],
746-
y_axis_title = 'Events',
746+
y_axis_title = 'Events/(%.1f)' % binWidth(control_plots_bins['LeptonEta']),
747747
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/%s' % ( label, treeName),
748748
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/%s' % (label, treeName),
749749
branchName = 'lepton_eta',
@@ -764,16 +764,16 @@ def make_plot( channel, x_axis_title, y_axis_title,
764764

765765
make_plot( channel,
766766
x_axis_title = '$%s$' % control_plots_latex['eta'],
767-
y_axis_title = 'Events',
767+
y_axis_title = 'Events/(%.1f)' % binWidth(control_plots_bins['AbsLeptonEta']),
768768
signal_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % ( label ),
769769
control_region_tree = 'TTbar_plus_X_analysis/%s/Ref selection/FitVariables' % (label ),
770770
branchName = 'abs(lepton_eta)',
771771
name_prefix = '%s_AbsLeptonEta_' % label,
772772
x_limits = control_plots_bins['AbsLeptonEta'],
773773
nBins = len(control_plots_bins['AbsLeptonEta'])-1,
774774
rebin = 1,
775-
legend_location = ( 0.95, 0.78 ),
776-
cms_logo_location = 'right',
775+
legend_location = ( 0.9, 0.88 ),
776+
cms_logo_location = 'left',
777777
use_qcd_data_region = useQCDControl,
778778
)
779779

@@ -838,7 +838,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
838838
print '---> QCD HT'
839839
make_plot( channel,
840840
x_axis_title = '$%s$ [GeV]' % variables_latex['HT'],
841-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
841+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['HT']),
842842
signal_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % treeName,
843843
control_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % treeName,
844844
branchName = 'HT',
@@ -854,7 +854,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
854854
print '---> QCD HT data to signal QCD'
855855
make_plot( channel,
856856
x_axis_title = '$%s$ [GeV]' % variables_latex['HT'],
857-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
857+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['HT']),
858858
signal_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % signalTreeName,
859859
control_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % treeName,
860860
compare_qcd_signal_with_data_control = True,
@@ -895,7 +895,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
895895
print '---> QCD ST'
896896
make_plot( channel,
897897
x_axis_title = '$%s$ [GeV]' % variables_latex['ST'],
898-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
898+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['ST']),
899899
signal_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % treeName,
900900
control_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % treeName,
901901
branchName = 'STNoHF',
@@ -915,7 +915,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
915915
print '---> QCD WPT'
916916
make_plot( channel,
917917
x_axis_title = '$%s$ [GeV]' % variables_latex['WPT'],
918-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
918+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['WPT']),
919919
signal_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % treeName,
920920
control_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % treeName,
921921
branchName = 'WPTNoHF',
@@ -941,7 +941,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
941941

942942
make_plot( channel,
943943
x_axis_title = '$%s$' % control_plots_latex['eta'],
944-
y_axis_title = 'Events',
944+
y_axis_title = 'Events/(%.1f)' % binWidth(control_plots_bins['AbsLeptonEta']),
945945
signal_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % ( treeName ),
946946
control_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % ( treeName ),
947947
branchName = 'abs(lepton_eta)',
@@ -964,7 +964,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
964964

965965
make_plot( channel,
966966
x_axis_title = '$%s$' % control_plots_latex['pt'],
967-
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins['MET']),
967+
y_axis_title = 'Events/(%i GeV)' % binWidth(control_plots_bins[binsLabel]),
968968
signal_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % ( treeName ),
969969
control_region_tree = 'TTbar_plus_X_analysis/%s/FitVariables' % ( treeName ),
970970
branchName = 'lepton_pt',

tools/plotting.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ def set_labels( plt, histogram_properties, show_x_label = True,
589589
logo_location = (0.95, 0.98)
590590
prelim_location = (0.95, 0.92)
591591
additional_location = (0.95, 0.86)
592+
elif loc == 'left':
593+
logo_location = (0.05, 0.98)
594+
prelim_location = (0.05, 0.92)
595+
additional_location = (0.05, 0.86)
592596

593597
plt.text(logo_location[0], logo_location[1], r"\textbf{CMS}",
594598
transform=axes.transAxes, fontsize=42,
@@ -601,7 +605,7 @@ def set_labels( plt, histogram_properties, show_x_label = True,
601605
axes.text(additional_location[0], additional_location[1],
602606
r"\emph{%s}" %histogram_properties.additional_text,
603607
transform=axes.transAxes, fontsize=40, verticalalignment='top',
604-
horizontalalignment='right')
608+
horizontalalignment=loc)
605609

606610
def adjust_axis_limits( axes, histogram_properties, histograms = [] ):
607611
x_limits = histogram_properties.x_limits

0 commit comments

Comments
 (0)