forked from sagittaeri/htt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot-pvalues
More file actions
executable file
·153 lines (127 loc) · 7.18 KB
/
plot-pvalues
File metadata and controls
executable file
·153 lines (127 loc) · 7.18 KB
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
#!/usr/bin/env python
from mva import save_canvas
from statstools.plotting import pvalue_plot
from rootpy.plotting import Canvas, Legend, set_style
from rootpy.plotting.style.atlas.labels import ATLAS_label
import pickle
import os
import ROOT
import logging
log = logging.getLogger(os.path.basename(__file__))
set_style('ATLAS', shape='rect')
gaus_cdf = ROOT.Math.gaussian_cdf_c
# bdt_path = 'workspaces/hh_nos_nonisol_ebz_mva_fixed'
single_bdt_path = 'workspaces/30_05_2014/hh_nos_nonisol_ebz_mva_single_bdt_125_fixed'
cut_path = 'workspaces/hh_nos_nonisol_ebz_cuts_fixed_merged/'
bdt_path = 'workspaces/hh_nos_nonisol_ebz_mva_fixed/'
#cut_path = 'workspaces/30_05_2014/hh_nos_nonisol_ebz_cuts_fixed_full_sym_merged_6'
masses = range(100, 155, 5)
colors = ['black', 'red', 'blue', 'purple', 'darkgreen']
lines = ['solid', 'dashed', 'dotted', 'dashdot', 'longdash', 'verylongdash']
def get_sigs(path, category, year=None, meas=True, blind=True, profile='0'):
if year is None:
dir_pattern = 'hh_{0}_{{0}}'.format(category)
else:
dir_pattern = 'hh_{0}_{1}_{{0}}'.format(year % 1000, category)
sigs = []
for mass in masses:
dirname = dir_pattern.format(mass)
if blind:
filename = '{1}{0}.pickle'.format(dirname, 'measurement_' if meas else '')
else:
filename = '{1}{0}_profiled_mu{2}_unblind.pickle'.format(dirname, 'measurement_' if meas else '', profile)
with open(os.path.join(path, dirname, filename), 'r') as pickle_file:
sig_dict = pickle.load(pickle_file)
sigs.append(sig_dict['combined'])
return sigs
def plot(name, curves, labels):
c = Canvas()
log.info(labels)
_, graphs = pvalue_plot(
masses, curves, pad=c, xtitle='m_{H} [GeV]',
linestyle=lines, linecolor=colors,
yrange=(gaus_cdf(2.5), 50))
for label, graph in zip(labels, graphs):
graph.title = label
graph.legendstyle = 'L'
log.info( '-------- {0} -------'.format(graph.title))
log.info(['{0:1.1f}'.format(xval) for xval in list(graph.x())])
log.info(['{0:0.3f}'.format(yval) for yval in list(graph.y())])
leg = Legend(graphs, leftmargin=0.4,
topmargin=0.1, margin=0.15,
textsize=20)
leg.Draw()
ATLAS_label(0.75, 0.88, text="Internal", sqrts=None, pad=c, sep=0.09)
save_canvas(c, 'plots/pvalues', name, formats=('.eps', '.png'))
# compare single BDT vs multiple trainings
#bdt_combined = map(gaus_cdf, get_sigs(bdt_path, 'combination'))
#single_bdt_combined = map(gaus_cdf, get_sigs(single_bdt_path, 'combination', meas=False))
#plot('compare_single_multi', [bdt_combined, single_bdt_combined], ['Multi-BDT', '125 GeV BDT'])
# # overall combination
# bdt_combined = map(gaus_cdf, get_sigs(bdt_path, 'combination'))
# cut_combined = map(gaus_cdf, get_sigs(cut_path, 'combination'))
# plot('comination', [bdt_combined, cut_combined], ['MVA 7+8 TeV', 'CBA 7+8 TeV'])
# # 7TeV combination
# bdt_combined_11 = map(gaus_cdf, get_sigs(bdt_path, 'combination', year=11))
# cut_combined_11 = map(gaus_cdf, get_sigs(cut_path, 'combination', year=11))
# plot('comination_11', [bdt_combined_11, cut_combined_11], ['MVA 7 TeV', 'CBA 7 TeV'])
# # 8TeV combination
# bdt_combined_12 = map(gaus_cdf, get_sigs(bdt_path, 'combination', year=12))
# cut_combined_12 = map(gaus_cdf, get_sigs(cut_path, 'combination', year=12))
# plot('comination_12', [bdt_combined_12, cut_combined_12], ['MVA 8 TeV', 'CBA 8 TeV'])
# # vbf combination
# bdt_combined_vbf = map(gaus_cdf, get_sigs(bdt_path, 'vbf'))
# cut_combined_vbf = map(gaus_cdf, get_sigs(cut_path, 'cuts_vbf'))
# plot('comination_vbf', [bdt_combined_vbf, cut_combined_vbf], ['MVA VBF 7+8 TeV', 'CBA VBF 7+8 TeV'])
# # 7TeV vbf
# bdt_vbf_11 = map(gaus_cdf, get_sigs(bdt_path, 'vbf', year=11))
# cut_vbf_11 = map(gaus_cdf, get_sigs(cut_path, 'cuts_vbf', year=11))
# plot('vbf_11', [bdt_vbf_11, cut_vbf_11], ['MVA VBF 7 TeV', 'CBA VBF 7 TeV'])
# # 8TeV vbf
# bdt_vbf_12 = map(gaus_cdf, get_sigs(bdt_path, 'vbf', year=12))
# cut_vbf_12 = map(gaus_cdf, get_sigs(cut_path, 'cuts_vbf', year=12))
# plot('vbf_12', [bdt_vbf_12, cut_vbf_12], ['MVA VBF 8 TeV', 'CBA VBF 8 TeV'])
# # boosted combination
# bdt_combined_boosted = map(gaus_cdf, get_sigs(bdt_path, 'boosted'))
# cut_combined_boosted = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted'))
# plot('comination_boosted', [bdt_combined_boosted, cut_combined_boosted], ['MVA Boosted 7+8 TeV', 'CBA Boosted 7+8 TeV'])
# # 7TeV boosted
# bdt_boosted_11 = map(gaus_cdf, get_sigs(bdt_path, 'boosted', year=11))
# cut_boosted_11 = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted', year=11))
# plot('boosted_11', [bdt_boosted_11, cut_boosted_11], ['MVA Boosted 7 TeV', 'CBA Boosted 7 TeV'])
# # 8TeV boosted
# bdt_boosted_12 = map(gaus_cdf, get_sigs(bdt_path, 'boosted', year=12))
# cut_boosted_12 = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted', year=12))
# plot('boosted_12', [bdt_boosted_12, cut_boosted_12], ['MVA Boosted 8 TeV', 'CBA Boosted 8 TeV'])
# # 7, 8 and total
# plot('7_8_final_mva', [bdt_combined_11, bdt_combined_12, bdt_combined], ['MVA 7 TeV', 'MVA 8 TeV', 'MVA 7+8 TeV'])
# plot('7_8_final_cba', [cut_combined_11, cut_combined_12, cut_combined], ['CBA 7 TeV', 'CBA 8 TeV', 'CBA 7+8 TeV'])
# 8 TeV mu=0, mu=1, mu=muhat
#cut_combined_12_mu0 = map(gaus_cdf, get_sigs(cut_path, 'combination', year=12, blind=False, profile='0'))
#
#cut_vbf_12_mu0 = map(gaus_cdf, get_sigs(cut_path, 'cuts_vbf', year=12, blind=False, profile='0'))
#cut_vbf_lowdr_12_mu0 = map(gaus_cdf, get_sigs(cut_path, 'cuts_vbf_lowdr', year=12, blind=False, profile='0'))
#cut_vbf_highdr_tight_12_mu0 = map(gaus_cdf, get_sigs(cut_path, 'cuts_vbf_highdr_tight', year=12, blind=False, profile='0'))
#cut_vbf_highdr_loose_12_mu0 = map(gaus_cdf, get_sigs(cut_path, 'cuts_vbf_highdr_loose', year=12, blind=False, profile='0'))
#
#cut_boosted_12_mu0 = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted', year=12, blind=False, profile='0'))
#cut_boosted_tight_12_mu0 = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted_tight', year=12, blind=False, profile='0'))
cut_boosted_loose_12_mu0 = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted_loose', year=12, blind=False, profile='0'))
cut_boosted_loose_12_mu1 = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted_loose', year=12, blind=False, profile='1'))
cut_boosted_loose_12_muhat = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted_loose', year=12, blind=False, profile='hat'))
cut_boosted_loose_12 = map(gaus_cdf, get_sigs(cut_path, 'cuts_boosted_loose', year=12, blind=True))
plot('12_boosted_loose',
[cut_boosted_loose_12_mu0,
cut_boosted_loose_12_mu1,
cut_boosted_loose_12_muhat,
cut_boosted_loose_12],
['CBA Profiled at #mu=0',
'CBA Profiled at #mu=1',
'CBA Profiled at #mu=#mu_{hat}',
'CBA No Profile'])
#
#plot('12_profile_mu0', [cut_combined_12_mu0, cut_vbf_12_mu0, cut_boosted_12_mu0], ['Combined', 'vbf', 'boosted'])
# plot('12_profile_vbf_mu0', [cut_vbf_12_mu0, cut_vbf_lowdr_12_mu0, cut_vbf_highdr_tight_12_mu0, cut_vbf_highdr_loose_12_mu0],
# ['vbf', 'vbf lowdr', 'vbf highdr tight', 'vbf highdr loose'])
# plot('12_profile_boosted_mu0', [cut_boosted_12_mu0, cut_boosted_tight_12_mu0, cut_boosted_loose_12_mu0],
# ['boosted', 'boosted tight', 'boosted loose'])