Skip to content

Commit edcb5ad

Browse files
committed
Merge pull request #212 from kreczko/random-things-p1
[MRG] Random things p1
2 parents 298d78e + ae8f222 commit edcb5ad

6 files changed

Lines changed: 101 additions & 16 deletions

File tree

bin/plots2tdr

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env python
2+
'''
3+
plot2tdr --plots <path to DPS plots folder> --tdr <path to tdr plot folder [--noop, --type=paper|AN]
4+
5+
Copies plots from the DailyPythonScripts plots folder to the latex document folder
6+
--plots DailyPythonScripts plots folder
7+
--tdr latex document plots folder
8+
--noop Don't do anything, just print what you will do (aka dry-run)
9+
--type paper|AN, default is paper. Determines the set of plots to be copied
10+
'''
11+
from optparse import OptionParser
12+
import shutil
13+
from glob import glob
14+
15+
plot_map_common = {}
16+
17+
plot_map_paper = {
18+
# <src relative to DPS plots folder> : <dst relative to TDR plots folder>,
19+
# results 8 TeV
20+
'7TeV/MET/central/normalised_xsection_combined_*.pdf': '7TeV/MET/',
21+
'7TeV/HT/central/normalised_xsection_combined_*.pdf': '7TeV/HT/',
22+
'7TeV/ST/central/normalised_xsection_combined_*.pdf': '7TeV/ST/',
23+
'7TeV/WPT/central/normalised_xsection_combined_*.pdf': '7TeV/WPT/',
24+
# results 8 TeV
25+
'8TeV/MET/central/normalised_xsection_combined_*.pdf': '8TeV/MET/',
26+
'8TeV/HT/central/normalised_xsection_combined_*.pdf': '8TeV/HT/',
27+
'8TeV/ST/central/normalised_xsection_combined_*.pdf': '8TeV/ST/',
28+
'8TeV/WPT/central/normalised_xsection_combined_*.pdf': '8TeV/WPT/',
29+
# control plots 8 TeV
30+
'control_plots/after_fit/8TeV/*_HT_2orMoreBtags_with_ratio.pdf': 'control/',
31+
'control_plots/after_fit/8TeV/*_patType1CorrectedPFMet_2orMoreBtags_with_ratio.pdf': 'control/',
32+
# fit variables 8 TeV
33+
'control_plots/after_fit/8TeV/*_angle_bl_2orMoreBtags_with_ratio.pdf': 'control/fit_variables/8TeV/',
34+
'control_plots/after_fit/8TeV/*_AbsEta_2orMoreBtags_with_ratio.pdf': 'control/fit_variables/8TeV/',
35+
'control_plots/after_fit/8TeV/*_M3_2orMoreBtags_with_ratio.pdf': 'control/fit_variables/8TeV/',
36+
}
37+
38+
plot_map_AN = {}
39+
40+
noop = False
41+
42+
def main():
43+
global noop
44+
plot_src, tdr_dst, t = parse_options()
45+
if t == 'paper':
46+
plot_map_common.update(plot_map_paper)
47+
if t == 'AN':
48+
plot_map_common.update(plot_map_AN)
49+
50+
for src, dst in plot_map_common.iteritems():
51+
full_src = plot_src + src
52+
full_dst = tdr_dst + dst
53+
src_files = glob(full_src)
54+
for f in src_files:
55+
dst_file = full_dst + f.split('/')[-1]
56+
print 'Copying %s -> %s' % (f, dst_file)
57+
if not noop:
58+
shutil.copy2(f, dst_file)
59+
60+
def parse_options():
61+
global noop
62+
parser = OptionParser( __doc__ )
63+
parser.add_option( "--plots", dest = "plot_src", default = "plots/",
64+
help = "path to DPS plot location" )
65+
parser.add_option( "--tdr", dest = "tdr_dst", default = "tdr/",
66+
help = "path to tdr plot location" )
67+
parser.add_option( "--type", dest = "type", default = "paper",
68+
help = "paper|AN" )
69+
parser.add_option( "--noop", dest = "noop", action = "store_true",
70+
help = "Don't copy anything" )
71+
( options, _ ) = parser.parse_args()
72+
plot_src, tdr_dst = options.plot_src, options.tdr_dst
73+
t = options.type
74+
if not plot_src.endswith('/'):
75+
plot_src += '/'
76+
if not tdr_dst.endswith('/'):
77+
tdr_dst += '/'
78+
79+
noop = options.noop
80+
81+
return plot_src, tdr_dst, t
82+
83+
if __name__ == '__main__':
84+
main()

config/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class XSectionConfig():
88
current_analysis_path = '/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_7th_draft/'
99
known_centre_of_mass_energies = [7, 8]
1010
# has to be separate as many variables depend on it
11-
luminosities = {7:5050, 8:19584}
11+
luminosities = {7:5050, 8:19712}
1212
parameters = ['SingleTop_category_templates', 'SingleTop_file',
1313
'VJets_category_templates', 'analysis_types',
1414
'categories_and_prefixes', 'central_general_template',
@@ -281,7 +281,7 @@ def __fill_defaults_7TeV__( self ):
281281
middle = self.middle
282282
path_to_files = self.path_to_files
283283

284-
self.new_luminosity = self.luminosity # pb^-1
284+
self.new_luminosity = 5050 # pb^-1
285285
self.ttbar_xsection = 177.31 # pb from https://twiki.cern.ch/twiki/bin/view/LHCPhysics/TtbarNNLO
286286

287287
self.data_file_electron = path_to_files + 'central/ElectronHad' + middle + '.root'

config/latex_labels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
'absolute_eta' : r'lepton $|\eta|$',
9797
'M3' : r'$M3$',
9898
'M_bl' : r'$M(b,l)$',
99-
'angle_bl' : r'angle$(b,l)$',
99+
'angle_bl' : r'$\alpha$',
100100
}
101101

102102
typical_systematics_latex = {"typical_systematics_electron": "Electron trigger efficiency \& electron selection",

src/cross_section_measurement/04_make_plots_matplotlib.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
326326

327327
axes.minorticks_on()
328328

329-
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '} \left[\mathrm{GeV}^{-1}\\right]$', CMS.y_axis_title )
329+
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '}$', CMS.y_axis_title )
330330
plt.tick_params( **CMS.axis_label_major )
331331
plt.tick_params( **CMS.axis_label_minor )
332332

@@ -342,7 +342,7 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
342342

343343
for key, hist in sorted( histograms.iteritems() ):
344344
if not 'unfolded' in key and not 'measured' in key:
345-
hist.linewidth = 2
345+
hist.linewidth = 4
346346
# setting colours
347347
if 'POWHEG_PYTHIA' in key or 'matchingdown' in key:
348348
hist.linestyle = 'longdashdot'
@@ -415,7 +415,7 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
415415
plt.ylabel( '$\\frac{\\textrm{pred.}}{\\textrm{data}}$', CMS.y_axis_title )
416416
ax1.yaxis.set_label_coords(-0.115, 0.8)
417417
#draw a horizontal line at y=1 for data
418-
plt.axhline(y = 1, color = 'black', linewidth = 1)
418+
plt.axhline(y = 1, color = 'black', linewidth = 2)
419419

420420
for key, hist in sorted( histograms.iteritems() ):
421421
if not 'unfolded' in key and not 'measured' in key:
@@ -437,14 +437,15 @@ def make_plots( histograms, category, output_folder, histname, show_ratio = True
437437
syst_errors = graph_to_value_errors_tuplelist(hist_data_with_systematics)
438438
syst_lower.SetBinContent( bin_i, 1 - syst_errors[bin_i-1][1]/syst_errors[bin_i-1][0] )
439439
syst_upper.SetBinContent( bin_i, 1 + syst_errors[bin_i-1][2]/syst_errors[bin_i-1][0] )
440-
441440
if category == 'central':
442-
rplt.fill_between( syst_lower, syst_upper, ax1, facecolor = 'yellow', alpha = 0.5 )
441+
rplt.fill_between( syst_lower, syst_upper, ax1,
442+
color = 'yellow', alpha = 0.5 )
443443

444-
rplt.fill_between( stat_upper, stat_lower, ax1, facecolor = '0.75', alpha = 0.5 )
444+
rplt.fill_between( stat_upper, stat_lower, ax1, color = '0.75',
445+
alpha = 0.5 )
445446
# legend for ratio plot
446-
p_stat = mpatches.Patch(color='0.75', label='Stat.', alpha = 0.5 )
447-
p_stat_and_syst = mpatches.Patch(color='yellow', label=r'Stat. $\oplus$ Syst.', alpha = 0.5 )
447+
p_stat = mpatches.Patch(facecolor='0.75', label='Stat.',alpha = 0.5, edgecolor='black' )
448+
p_stat_and_syst = mpatches.Patch(facecolor='yellow', label=r'Stat. $\oplus$ Syst.', alpha = 0.5, edgecolor='black' )
448449
l1 = ax1.legend(handles = [p_stat], loc = 'upper left',
449450
frameon = False, prop = {'size':26})
450451

@@ -498,7 +499,7 @@ def plot_central_and_systematics( channel, systematics, exclude = [], suffix = '
498499

499500

500501
plt.xlabel( '$%s$ [GeV]' % variables_latex[variable], CMS.x_axis_title )
501-
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '} \left[\mathrm{GeV}^{-1}\\right]$', CMS.y_axis_title )
502+
plt.ylabel( r'$\frac{1}{\sigma} \frac{d\sigma}{d' + variables_latex[variable] + '}$', CMS.y_axis_title )
502503
plt.tick_params( **CMS.axis_label_major )
503504
plt.tick_params( **CMS.axis_label_minor )
504505

src/cross_section_measurement/make_control_plots.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from optparse import OptionParser
22
from config.latex_labels import b_tag_bins_latex, samples_latex, channel_latex, \
3-
variables_latex
3+
variables_latex, fit_variables_latex
44
from config.variable_binning import variable_bins_ROOT
55
from config import XSectionConfig
66
from tools.file_utilities import read_data_from_JSON, make_folder_if_not_exists
@@ -637,7 +637,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
637637
tmp = 'TTbar_plus_X_analysis/EPlusJets/Ref selection/Binned_MT_Analysis/MT_with_patType1CorrectedPFMet_bin_%s/angle_bl_' + b_tag_bin
638638
regions = [tmp % bin_i for bin_i in variable_bins_ROOT['MT']]
639639
make_plot( 'electron',
640-
x_axis_title = 'angle(bl)',
640+
x_axis_title = fit_variables_latex['angle_bl'],
641641
y_axis_title = 'Events/(0.2)',
642642
signal_region = regions,
643643
qcd_data_region_btag = '1btag',
@@ -651,7 +651,7 @@ def make_plot( channel, x_axis_title, y_axis_title,
651651
tmp = 'TTbar_plus_X_analysis/MuPlusJets/Ref selection/Binned_MT_Analysis/MT_with_patType1CorrectedPFMet_bin_%s/angle_bl_' + b_tag_bin
652652
regions = [tmp % bin_i for bin_i in variable_bins_ROOT['MT']]
653653
make_plot( 'muon',
654-
x_axis_title = 'angle(bl)',
654+
x_axis_title = fit_variables_latex['angle_bl'],
655655
y_axis_title = 'Events/(0.2)',
656656
signal_region = regions,
657657
qcd_data_region_btag = '1btag',

test/config_XSectionConfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_invalid_centre_of_mass_energy( self ):
3838

3939
def test_luminosity( self ):
4040
self.assertEqual( self.config_7TeV.luminosity, 5050 )
41-
self.assertEqual( self.config_8TeV.luminosity, 19584 )
41+
self.assertEqual( self.config_8TeV.luminosity, 19712 )
4242

4343
def test_parameters( self ):
4444
for param in XSectionConfig.parameters:

0 commit comments

Comments
 (0)