-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmake_ZToTauTau_plots.py
250 lines (213 loc) · 11.7 KB
/
make_ZToTauTau_plots.py
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
eventselection='#mu+#tau_{h}'
subfolder='/plotsL1Run3'
channelname='ZToTauTau'
import yaml
import drawplots
import argparse
def main():
parser = argparse.ArgumentParser(
description='''Plotter''',
usage='use "%(prog)s --help" for more information',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("-d", "--dir", dest="dir", help="The directory to read the inputs files from and draw the plots to", type=str, default='./')
parser.add_argument("-c", "--config", dest="config", help="The YAML config to read from", type=str, default='../config_cards/full_ZToTauTau.yaml')
parser.add_argument("-l", "--lumi", dest="lumi", help="The integrated luminosity to display in the top right corner of the plot", type=str, default='')
args = parser.parse_args()
config = yaml.safe_load(open(args.config, 'r'))
input_file = args.dir + "/all_ZToTauTau.root"
if args.lumi != '':
toplabel="#sqrt{s} = 13.6 TeV, L_{int} = " + args.lumi #+ " fb^{-1}"
else:
toplabel="#sqrt{s} = 13.6 TeV"
suffixes = ['']
if config['PU_plots']['make_histos']:
bins = config['PU_plots']['nvtx_bins']
suffixes += ['_nvtx{}to{}'.format(bins[i], bins[i+1]) for i in range(len(bins) - 1)]
# NVTX distribution:
drawplots.makedist(
inputFiles_list = [input_file],
saveplot = True,
saveroot = False,
h1d = ['h_nvtx'],
xtitle = 'N_{vtx}',
ytitle = 'Events',
top_label = toplabel,
plotname = channelname+'_L1Tau_nvtx',
dirname = args.dir + subfolder,
)
for s in suffixes:
for r in config['Regions']:
region = config['Regions'][r]
eta_range = "eta{}to{}".format(region[0], region[1]).replace(".","p")
eta_label = '{'+'{}'.format(region[0])+ '#leq | #eta^{#tau_{h}}(reco)| < '+'{}'.format(region[1])+'}'
if config['Efficiency']:
# Efficiency vs Run Number
drawplots.makeeff(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
nvtx_suffix = s,
den = ['h_PlateauEffVsRunNb_Denominator_TauNonIso_plots_{}'.format(eta_range)],
num = ['h_PlateauEffVsRunNb_Numerator_{}_plots_{}'.format(iso, eta_range) for iso in config['Isos']],
xtitle = 'run number',
ytitle = 'L1Tau30 Efficiency',
axisranges = [0, 1, 0.5, 1.05],
legendlabels = [label(iso) for iso in config['Isos']],
extralabel = "#splitline{"+eventselection+", p_{T}^{#tau_{h}}(reco) #geq 40 GeV}"+"{}".format(eta_label),
top_label = toplabel,
plotname = "L1Tau_EffVsRunNb_{}".format(r),
)
for iso in config['Isos']:
if config['TurnOns']:
# Efficiency vs pT
# all eta ranges and all qualities
drawplots.makeeff(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
nvtx_suffix = s,
den = ['h_{}_plots_{}'.format(iso, eta_range)],
num = ['h_{}_plots_{}_l1thrgeq{}'.format(iso, eta_range, thr) for thr in config['Thresholds']],
xtitle = 'p_{T}^{#tau_{h}}(reco) (GeV)',
ytitle = 'Efficiency',
legendlabels = ['p_{T}^{L1 Tau} '+'#geq {} GeV'.format(thr) for thr in config['Thresholds']],
axisranges = [20, 500],
extralabel = "#splitline{"+eventselection+", {}".format(label(iso))+"}"+"{}".format(eta_label),
setlogx = True,
top_label = toplabel,
plotname = channelname+'_L1Tau_TurnOn{}_{}'.format(iso, r) ,
)
#Zoom
drawplots.makeeff(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
nvtx_suffix = s,
den = ['h_{}_plots_{}'.format(iso, eta_range)],
num = ['h_{}_plots_{}_l1thrgeq{}'.format(iso, eta_range, thr) for thr in config['Thresholds']],
xtitle = 'p_{T}^{#tau_{h}}(reco) (GeV)',
ytitle = 'Efficiency',
legendlabels = ['p_{T}^{L1 Tau} '+'#geq {} GeV'.format(thr) for thr in config['Thresholds']],
axisranges = [20, 50],
extralabel = "#splitline{"+eventselection+", {}".format(label(iso))+"}"+"{}".format(eta_label),
setlogx = True,
top_label = toplabel,
plotname = channelname+'_L1Tau_TurnOn{}_{}_Zoom'.format(iso, r) ,
)
# Comparisons between bins of PU:
if config['PU_plots']['make_histos'] and s == '':
bins = config['PU_plots']['nvtx_bins']
for thr in config['PU_plots']['draw_thresholds']:
drawplots.makeeff(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
den = ['h_{}_plots_{}{}'.format(iso, eta_range, suf) for suf in suffixes[1:]],
num = ['h_{}_plots_{}_l1thrgeq{}{}'.format(iso, eta_range, thr, suf) for suf in suffixes[1:]],
xtitle = 'p_{T}^{#tau_{h}}(reco) (GeV)',
ytitle = 'Efficiency',
legendlabels = ['{} #leq nvtx < {}'.format(bins[i], bins[i+1]) for i in range(len(bins)-1)],
axisranges = [20, 500],
extralabel = "#splitline{"+eventselection+", {}".format(label(iso))+"}"+"{}".format(eta_label),
setlogx = True,
top_label = toplabel,
plotname = channelname+'_L1Tau{}_TurnOn{}_{}_vsPU'.format(thr, iso, r) ,
)
if config['TurnOns']:
# Efficiency vs pT
# Comparison between isos
for thr in [26, 34]:
drawplots.makeeff(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
nvtx_suffix = s,
den = ['h_{}_plots_{}'.format(iso, eta_range) for iso in config['Isos']],
num = ['h_{}_plots_{}_l1thrgeq{}'.format(iso, eta_range, thr) for iso in config['Isos']],
xtitle = 'p_{T}^{#tau_{h}}(reco) (GeV)',
ytitle = 'Efficiency',
legendlabels = [iso for iso in config['Isos']],
axisranges = [20, 500],
extralabel = "#splitline{"+eventselection+"}"+"{p_{T}^{L1 Tau} #geq "+"{}".format(thr)+" GeV, "+"{}".format(eta_label[1:-1])+"}",
setlogx = True,
top_label = toplabel,
plotname = channelname+'_L1Tau{}_TurnOn_{}_IsoComparison'.format(thr, r) ,
)
drawplots.makeeff(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
nvtx_suffix = s,
den = ['h_{}_plots_{}'.format(iso, eta_range) for iso in config['Isos']],
num = ['h_{}_plots_{}_l1thrgeq{}'.format(iso, eta_range, thr) for iso in config['Isos']],
xtitle = 'p_{T}^{#tau_{h}}(reco) (GeV)',
ytitle = 'Efficiency',
legendlabels = [iso for iso in config['Isos']],
axisranges = [20, 50],
extralabel = "#splitline{"+eventselection+"}"+"{p_{T}^{L1 Tau} #geq "+"{}".format(thr)+" GeV, "+"{}".format(eta_label[1:-1])+"}",
top_label = toplabel,
plotname = channelname+'_L1Tau{}_TurnOn_{}_IsoComparison_Zoom'.format(thr, r) ,
)
if config['Efficiency']:
# Efficiency vs Eta Phi
drawplots.makeeff(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
nvtx_suffix = s,
num = ['h_Tau30_EtaPhi_NumeratorTauNonIso'],
den = ['h_Tau30_EtaPhi_DenominatorTauNonIso'],
xtitle = '#eta^{#tau_{h}}(reco)',
ytitle = '#phi^{#tau_{h}}(reco)',
ztitle = 'L1Tau30 efficiency (p_{T}^{#tau_{h}}(reco) > 40 GeV)',
legendlabels = [''],
extralabel = '#splitline{'+eventselection+'}{L1 Tau NonIso}',
top_label = toplabel,
plotname = channelname+'_L1Tau_EffVsEtaPhi',
axisranges = [-2.5, 2.5, -3.1416, 3.1416, 0, 1.1],
)
if config['Response'] and 'TauNonIso' in config['Isos']:
regions = config['Regions'].values()
eta_ranges = ["eta{}to{}".format(region[0], region[1]).replace(".","p") for region in regions]
eta_labels = ['{} #leq | #eta| < {}'.format(region[0], region[1]) for region in regions]
# Resolution Vs Pt
drawplots.makeresol(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
nvtx_suffix = s,
h2d = ['h_ResponseVsPt_TauNonIso_plots_{}'.format(eta_range) for eta_range in eta_ranges],
xtitle = 'p_{T}^{#tau_{h}}(reco) (GeV)',
ytitle = '(p_{T}^{L1Tau}/p_{T}^{#tau_{h}}(reco))',
extralabel = '#splitline{'+eventselection+'}{Non Iso.}',
legendlabels = eta_labels,
top_label = toplabel,
plotname = channelname+'_L1Tau_ResponseVsPt',
axisranges = [20, 70, 0.8, 1.2],
)
# Resolution Vs RunNb
drawplots.makeresol(
inputFiles_list = [input_file],
saveplot = True,
dirname = args.dir + subfolder,
nvtx_suffix = s,
h2d = ['h_ResponseVsRunNb_TauNonIso_plots_{}'.format(eta_range) for eta_range in eta_ranges],
xtitle = 'run number',
ytitle = '(p_{T}^{L1Tau}/p_{T}^{#tau_{h}}(reco))',
extralabel = '#splitline{'+eventselection+'}{Non Iso.}',
legendlabels = eta_labels,
top_label = toplabel,
plotname = channelname+'_L1Tau_ResponseVsRunNb',
axisranges = [355374, 362760, 0.8, 1.2],
)
def label(iso):
labels = {
'TauNonIso': 'Non Iso',
'TauIso': 'Iso',
}
if iso in labels:
return(labels[iso])
else:
return('')
if __name__ == '__main__':
main()