Skip to content

Commit b5769af

Browse files
committed
Final changes in legacy analysis.
1 parent 71dddff commit b5769af

23 files changed

+1171
-140
lines changed

bin/plot

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ from tools.ROOT_utils import set_root_defaults
8484
from tools.file_utilities import write_data_to_JSON, read_data_from_JSON
8585
from tools.HistSet import HistSet
8686
from copy import deepcopy
87+
from tools.ROOT_utils import get_histogram_from_file
88+
from math import sqrt
8789

8890
supported_commands = ['compare-files', 'compare-hists']
8991

@@ -95,7 +97,7 @@ plot_options = {}
9597
global_options = ['files', 'file-aliases', 'histograms', 'labels', 'plot_type', 'output_folder',
9698
'output_format', 'command', 'data_index', 'normalise',
9799
'show_ratio', 'show_stat_errors_on_mc', 'colours', 'name_prefix',
98-
'fill_area', 'alpha']
100+
'fill_area', 'alpha', 'subtractFiles']
99101

100102
def main():
101103
options, input_values_sets, json_input_files = parse_options()
@@ -173,7 +175,63 @@ def _exit_( msg ):
173175
def prepare_inputs( input_values ):
174176
input_values = check_and_fix_inputs( input_values )
175177
global files, histograms, global_options
178+
179+
subtractFiles = []
180+
if input_values.has_key('subtractFiles'):
181+
subtractFiles = input_values['subtractFiles']
182+
176183
sets = group_by_command( input_values['command'] )
184+
185+
for s in sets:
186+
print s.histograms
187+
# subtractFiles_sets = getBackgroundHists( subtractFiles, )
188+
189+
# if input_values['command'] == 'compare-hists' and len( input_values['subtractFiles'] ) > 0:
190+
191+
# subtract_background( input_values['subtractFiles'] )
192+
if len( subtractFiles ) > 0:
193+
hist_sets = []
194+
i = 0
195+
196+
for h in input_values['histograms']:
197+
print h
198+
# name = h.replace( '/', '_' )
199+
# name = name.replace( ' ', '' )
200+
201+
uncDict = {'VJets' : 0.3,
202+
'TTJet' : 0.06,
203+
'SingleTop' : 0.3 }
204+
205+
for f in subtractFiles:
206+
hist = get_histogram_from_file( histogram_path = h,
207+
input_file = f )
208+
print f
209+
print hist
210+
unc = 0
211+
if 'VJets' in f or 'SingleTop' in f:
212+
unc = 0.3
213+
elif 'TTJet' in f:
214+
unc = 0.3
215+
216+
for bin in range(1,hist.GetNbinsX()):
217+
binContent = hist.GetBinContent(bin)
218+
binError = hist.GetBinError(bin)
219+
newError = sqrt( binError ** 2 + ( binContent * unc ) ** 2 )
220+
# print 'Errors :',binError,newError
221+
hist.SetBinError( bin, newError )
222+
223+
sets[0].histograms[i] -= hist
224+
i += 1
225+
# hist_sets.append( HistSet( h, hist_inputs = hist_set, output_hist_labels = labels ) )
226+
227+
228+
# print hist_sets
229+
# print 'Looping sets'
230+
# for s in sets:
231+
# for h in s.histograms:
232+
# print s.inputs
233+
# print s.histograms
234+
177235
if input_values.has_key('name_prefix'):
178236
for s in sets:
179237
s.name = input_values['name_prefix'] + s.name
@@ -234,6 +292,7 @@ def group_by_file():
234292
[{name:{f:h}, ...] where f = file and h = histogram path. The name is taken from the file name
235293
'''
236294
global files, file_aliases, histograms, labels
295+
237296
hist_sets = []
238297
for f,name in zip(files, file_aliases):
239298
hist_set = []

bin/x_05b_all_vars

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ N_JOBS=1
77
i=0
88
for var in MET HT ST WPT; do
99
echo "Tabulating diff. x-section for distribution: $var"
10-
nohup time python src/cross_section_measurement/05_make_tables.py -v $var -c 7 -p data/normalisation/background_subtraction/ -a -o tables/background_subtraction &> logs/05b_${var}_table_7TeV.log &
10+
# nohup time
11+
echo $var
12+
echo "7"
13+
python src/cross_section_measurement/05_make_tables.py -v $var -c 7 -p data/normalisation/background_subtraction/ -a -o tables/background_subtraction
14+
# &> logs/05b_${var}_table_7TeV.log &
1115
# wait;
1216

13-
nohup time python src/cross_section_measurement/05_make_tables.py -v $var -c 8 -p data/normalisation/background_subtraction/ -a -o tables/background_subtraction &> logs/05b_${var}_table_8TeV.log &
17+
# nohup time
18+
echo $var
19+
echo "8"
20+
python src/cross_section_measurement/05_make_tables.py -v $var -c 8 -p data/normalisation/background_subtraction/ -a -o tables/background_subtraction
21+
# &> logs/05b_${var}_table_8TeV.log &
1422
wait;
1523
done
1624

config/latex_labels.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
'WPT': '\wpt'
2525
}
2626

27+
variables_hepdata = {
28+
'MET': 'E_{T}^{miss}',
29+
'HT': 'H_{T}',
30+
'ST': 'S_{T}',
31+
'WPT': 'p^{W}_{T}'
32+
}
33+
2734
ttBarLatex = '$\mathrm{t}\\bar{\mathrm{t}}$'
2835

2936
measurements_latex = {'unfolded': 'unfolded',
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"command": "compare-hists",
3+
"files": [
4+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_8th_draft/7TeV/central/ElectronHad_5050pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"
5+
],
6+
"histograms": [
7+
"TTbar_plus_X_analysis/EPlusJets/QCDConversions/MET/HT_0btag",
8+
"TTbar_plus_X_analysis/EPlusJets/QCD non iso e+jets/MET/HT_0btag",
9+
"TTbar_plus_X_analysis/EPlusJets/QCDConversions/MET/HT_2btags"
10+
],
11+
"labels": [
12+
"Conversion 0 btag",
13+
"Non Iso 0 btag",
14+
"Conversion 2 btags"
15+
],
16+
"output_folder": "plots/QCD_shape_e",
17+
"output_format": ["pdf"],
18+
"name_prefix": "compare_QCD_btag_regions_in_HT_electron_channel_",
19+
"plot_type": "shape_comparison",
20+
"ratio_y_limits": [
21+
[0.95, 1.05]
22+
],
23+
"title": [
24+
"Comparison of $H_T$ \\\\(QCD control regions: 0,1 and 2 btags) $\\sqrt{s}$ = 8 TeV"
25+
],
26+
"x_axis_title": [
27+
"$H_T$ [GeV]"
28+
],
29+
"x_limits": [
30+
[120, 1000]
31+
],
32+
"y_axis_title": [
33+
"normalised to unit area"
34+
],
35+
"y_limits": [
36+
[0, 0.25]
37+
],
38+
"rebin" : [
39+
[120.0, 185.0, 215.0, 247.0, 283.0, 323.0, 365.0, 409.0, 458.0, 512.0, 570.0, 629.0, 691.0, 769.0, 1000.0]
40+
],
41+
"colours": ["green", "blue", "red"],
42+
"normalise":1,
43+
"fill_area":false,
44+
45+
"subtractFiles" : [
46+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/7TeV/central/VJets_5050pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
47+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/7TeV/central/SingleTop_5050pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
48+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/7TeV/central/TTJet_5050pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"
49+
]
50+
51+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"command": "compare-files",
3+
"files": [
4+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleElectron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
5+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/QCD_Electron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
6+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/VJets_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
7+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleTop_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
8+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"
9+
],
10+
"histograms": [
11+
"TTbar_plus_X_analysis/EPlusJets/QCDConversions/MET/HT_2orMoreBtags"
12+
],
13+
"labels": [
14+
"Data",
15+
"QCD",
16+
"W/Z + jets",
17+
"single-top",
18+
"$t\\bar{t}$"
19+
],
20+
"output_folder": "plots/8TeV",
21+
"output_format": ["png"],
22+
"plot_type": "data_mc_comparison",
23+
"ratio_y_limits": [
24+
[
25+
0.8,
26+
1.3
27+
]
28+
],
29+
"title": [
30+
"$H_T$ at $\\sqrt{s}$ = 8 TeV, e+jets"
31+
],
32+
"x_axis_title": [
33+
"$H_T [GeV]$"
34+
],
35+
"x_limits": [
36+
[
37+
120,
38+
1000
39+
]
40+
],
41+
"rebin" : [
42+
[120.0, 185.0, 215.0, 247.0, 283.0, 323.0, 365.0, 409.0, 458.0, 512.0, 570.0, 629.0, 691.0, 769.0, 1000.0]
43+
],
44+
"y_axis_title": [
45+
"events"
46+
],
47+
"colours": ["black", "yellow", "green", "magenta", "red"],
48+
"mc_error": [0.15]
49+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"command": "compare-hists",
3+
"files": [
4+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_8th_draft/8TeV/central/SingleElectron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"
5+
],
6+
"histograms": [
7+
"TTbar_plus_X_analysis/EPlusJets/QCDConversions/MET/HT_0btag",
8+
"TTbar_plus_X_analysis/EPlusJets/QCD non iso e+jets/MET/HT_0btag",
9+
"TTbar_plus_X_analysis/EPlusJets/QCDConversions/MET/HT_2btags"
10+
],
11+
"labels": [
12+
"Conversion 0 btag",
13+
"Non Iso 0 btag",
14+
"Conversion 2 btags"
15+
],
16+
"output_folder": "plots/QCD_shape_e",
17+
"output_format": ["pdf"],
18+
"name_prefix": "compare_QCD_btag_regions_in_HT_electron_channel_",
19+
"plot_type": "shape_comparison",
20+
"ratio_y_limits": [
21+
[0.95, 1.05]
22+
],
23+
"title": [
24+
"Comparison of $H_T$ \\\\(QCD control regions: 0,1 and 2 btags) $\\sqrt{s}$ = 8 TeV"
25+
],
26+
"x_axis_title": [
27+
"$H_T$ [GeV]"
28+
],
29+
"x_limits": [
30+
[120, 1000]
31+
],
32+
"y_axis_title": [
33+
"normalised to unit area"
34+
],
35+
"y_limits": [
36+
[0, 0.25]
37+
],
38+
"rebin" : [
39+
[120.0, 185.0, 215.0, 247.0, 283.0, 323.0, 365.0, 409.0, 458.0, 512.0, 570.0, 629.0, 691.0, 769.0, 1000.0]
40+
],
41+
"colours": ["green", "blue", "red"],
42+
"normalise":1,
43+
"fill_area":false,
44+
45+
"subtractFiles" : [
46+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/VJets_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
47+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleTop_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
48+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"
49+
]
50+
51+
}

config/plots/MET_8TeV_electron_channel.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"
99
],
1010
"histograms": [
11-
"TTbar_plus_X_analysis/EPlusJets/Ref selection/MET/patType1CorrectedPFMet/MET_2orMoreBtags"
11+
"TTbar_plus_X_analysis/EPlusJets/QCDConversions/MET/patType1CorrectedPFMet/MET_2orMoreBtags"
1212
],
1313
"labels": [
14-
"data",
14+
"Data",
1515
"QCD",
1616
"W/Z + jets",
1717
"single-top",
@@ -38,6 +38,9 @@
3838
300
3939
]
4040
],
41+
"rebin" : [
42+
[0.0, 27.0, 52.0, 87.0, 130.0, 172.0, 300]
43+
],
4144
"y_axis_title": [
4245
"events/5 GeV"
4346
],

config/plots/MET_8TeV_electron_channel_QCD_shape_comparison.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_8th_draft/8TeV/central/SingleElectron_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"
55
],
66
"histograms": [
7+
"TTbar_plus_X_analysis/EPlusJets/QCDConversions/MET/patType1CorrectedPFMet/MET_0btag",
78
"TTbar_plus_X_analysis/EPlusJets/QCD non iso e+jets/MET/patType1CorrectedPFMet/MET_0btag",
8-
"TTbar_plus_X_analysis/EPlusJets/QCD non iso e+jets/MET/patType1CorrectedPFMet/MET_1btag",
9-
"TTbar_plus_X_analysis/EPlusJets/QCD non iso e+jets/MET/patType1CorrectedPFMet/MET_2btags"
9+
"TTbar_plus_X_analysis/EPlusJets/QCDConversions/MET/patType1CorrectedPFMet/MET_2btags"
1010
],
1111
"labels": [
12-
"0 btag",
13-
"1 btag",
14-
"2 btags"
12+
"Conversion 0 btag",
13+
"Non Iso 0 btag",
14+
"Conversion 2 btags"
1515
],
1616
"output_folder": "plots/QCD_shape_e",
1717
"output_format": ["pdf"],
@@ -33,11 +33,19 @@
3333
"normalised to unit area"
3434
],
3535
"y_limits": [
36-
[0, 0.6]
36+
[0, 1.0]
3737
],
3838
"rebin" : [
3939
[0.0, 27.0, 52.0, 87.0, 130.0, 172.0, 300]
4040
],
41-
"colours": ["green", "yellow", "red"],
42-
"normalise":1
41+
"colours": ["green", "blue", "red"],
42+
"normalise":1,
43+
"fill_area":false,
44+
45+
"subtractFiles" : [
46+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/VJets_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
47+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/SingleTop_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root",
48+
"/hdfs/TopQuarkGroup/results/histogramfiles/AN-14-071_6th_draft/8TeV/central/TTJet_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root"
49+
]
50+
4351
}

0 commit comments

Comments
 (0)