1 import matplotlib
as mpl
3 import matplotlib.pyplot
as plt
14 from concurrent.futures
import ThreadPoolExecutor
16 plt.style.use(hep.style.ATLAS)
18 plt.rcParams.update({
'font.sans-serif':
"Arial",
19 'font.family':
"sans-serif",
21 'mathtext.fontset':
'custom',
22 'mathtext.rm':
'Arial',
25 import EICAnalysisTools
as eat
29 global u_fb, u_mb, xsection
41 print(
"Loading data...")
43 branchlist = [
"Jet.PT",
"Jet.Eta",
"Jet.Flavor",
"Jet.BTag",
"GenJet.PT",
"GenJet.Eta",
"GenJet.Flavor"]
46 df_ct18nnlo = eat.UprootLoad([f
"../CC_DIS_e10_p275_B15_dR5_maxIP3mm_trkpt10_22sigmin_CT18NNLO/*/out.root"],
"Delphes",
66 print(
"Done loading data for the study!")
70 def DifferentialXS(df, x='GenJet.PT', xrange=[10,50], xbins=[10,12.5,15,20,25,30,40,50], which='all', process='CC_DIS_e18_p275'):
71 global u_fb, u_mb, n_gen
73 print(f
"n_gen = {n_gen}")
74 jet_pt = np.concatenate(df[
'GenJet.PT'].to_numpy()).ravel()
75 jet_eta = np.concatenate(df[
'GenJet.Eta'].to_numpy()).ravel()
76 jet_flavor = np.concatenate(df[
'GenJet.Flavor'].to_numpy()).ravel()
78 jet_x = np.concatenate(df[x].to_numpy()).ravel()
82 jet_basics = (-5.0 < jet_eta) & (jet_eta < 5.0)
84 all_flavor = ( jet_flavor > -999.0 ) & (jet_basics)
85 light_flavor = ( jet_flavor < 4 ) & (jet_basics)
86 charm_flavor = ( jet_flavor == 4 ) & (jet_basics)
88 selection = all_flavor
90 selection = charm_flavor
93 (counts, bins) = np.histogram(jet_x[ selection ], range=xrange,
97 bin_widths = np.diff(bins)
98 bin_centers = bins[:-1] + bin_widths/2
100 errors = np.sqrt(counts)
101 rel_errors = errors/counts
105 dsigma_dx = counts * eat.TotalXSection(process) * 100*u_fb**(-1) / n_gen / bin_widths
106 dsigma_dx_errors = rel_errors * dsigma_dx
108 return (bin_centers, bin_widths, dsigma_dx, dsigma_dx_errors)
116 draw_config_eta[
'xvar'] =
'GenJet.Eta'
117 draw_config_eta[
'xrange'] = [-4.0, 4.0]
118 draw_config_eta[
'xbins'] = [-4.0, -3.5, -2.5, -1.0, 1.0, 2.5, 3.5, 4.0]
119 draw_config_eta[
'ylimits'] = [10, 1e7]
120 draw_config_eta[
'xlimits'] = [-5,5]
121 draw_config_eta[
'yunits'] =
''
122 draw_config_eta[
'xunits'] =
''
125 draw_config_pt[
'xvar'] =
'GenJet.PT'
126 draw_config_pt[
'xrange'] = [10,50]
127 draw_config_pt[
'xbins'] = [10,12.5,15,20,25,30,40,50]
128 draw_config_pt[
'ylimits'] = [10, 2e5]
129 draw_config_pt[
'xlimits'] = [0,60]
130 draw_config_pt[
'yunits'] =
'[$\\mathrm{GeV^{-1}}$]'
131 draw_config_pt[
'xunits'] =
'[GeV]'
135 xvar=draw_config[
'xvar']
136 xrange=draw_config[
'xrange']
137 xbins=draw_config[
'xbins']
138 ylimits=draw_config[
'ylimits']
139 xlimits=draw_config[
'xlimits']
140 yunits=draw_config[
'yunits']
141 xunits=draw_config[
'xunits']
143 fig, ax = plt.subplots(figsize=(12,12))
148 if process.find(
'CC') != -1:
149 gridspec = fig.add_gridspec(ncols=1, nrows=1, width_ratios=[1], height_ratios=[1])
153 ax1 = fig.add_subplot(gridspec[0, 0])
155 ax1.grid(which=
'both', axis=
'both')
156 (bins, bin_widths, xs, xs_error) =
DifferentialXS(df_ct18nnlo, x=xvar, xrange=xrange, xbins=xbins, which=
'all', process=
'CC_DIS_e10_p275_CT18NNLO')
157 ax1.errorbar(bins, xs, xerr = bin_widths/2, yerr=xs_error, label=
'all jets (CT18NNLO)', marker=
'o', ms=10, ls=
'none', linewidth=2, color=
'red')
174 charm_ct18nnlo =
DifferentialXS(df_ct18nnlo, x=xvar, xrange=xrange, xbins=xbins, which=
'charm')
175 (bins, bin_widths, xs, xs_error) = charm_ct18nnlo
176 ax1.errorbar(bins, xs, xerr = bin_widths/2, yerr=xs_error, label=
'charm jets (CT18NNLO)', marker=
'D', ms=10, ls=
'none', linewidth=2, fillstyle=
'none', color=
'blue')
200 if xvar.find(
'Eta') != -1:
203 plt.ylabel(f
'$d\\sigma/d{xvar_symbol} \\times 100\\mathrm{{fb^{{-1}}}}$ {yunits}')
204 plt.xlabel(f
'Generated Jet ${xvar_symbol}$ [GeV]')
207 plt.title(
"CC-DIS, 10x275GeV, $Q^2>100\\mathrm{GeV^2}$", fontsize=20)
209 ax1.set_ylim(ylimits)
210 ax1.set_xlim(xlimits)
212 ax1.legend(fontsize=18)
260 elif process.find(
'NC') != -1:
261 gridspec = fig.add_gridspec(ncols=1, nrows=1, width_ratios=[1], height_ratios=[1])
265 ax1 = fig.add_subplot(gridspec[0, 0])
267 ax1.grid(which=
'both', axis=
'both')
268 (bins, bin_widths, xs, xs_error) =
DifferentialXS(df_ct18nnlo_nc, x=xvar, xrange=xrange, xbins=xbins, which=
'all', process=process)
269 ax1.errorbar(bins, xs, xerr = bin_widths/2, yerr=xs_error, label=
'all jets (CT18NNLO)', marker=
'o', ms=10, ls=
'none', linewidth=2, color=
'red')
271 charm_ct18nnlo =
DifferentialXS(df_ct18nnlo_nc, x=xvar, xrange=xrange, xbins=xbins, which=
'charm', process=process)
272 (bins, bin_widths, xs, xs_error) = charm_ct18nnlo
273 ax1.errorbar(bins, xs, xerr = bin_widths/2, yerr=xs_error, label=
'charm jets (CT18NNLO)', marker=
'D', ms=10, ls=
'none', linewidth=2, fillstyle=
'none', color=
'blue')
276 if xvar.find(
'Eta') != -1:
279 plt.ylabel(f
'$d\\sigma/d{xvar_symbol} \\times 100\\mathrm{{fb^{{-1}}}}$ {yunits}')
280 plt.xlabel(f
'Generated Jet ${xvar_symbol}$ [GeV]')
283 plt.title(
"NC-DIS, 18x275GeV, $Q^2>100\\mathrm{GeV^2}$", fontsize=20)
285 ax1.set_ylim(ylimits)
286 ax1.set_xlim(xlimits)
288 ax1.legend(fontsize=18)
293 plt.savefig(f
"jet_differential_xs_{xvar}_{process}.png")
294 plt.savefig(f
"jet_differential_xs_{xvar}_{process}.pdf")
304 draw_config_pt[
'xvar'] =
'GenJet.PT'
305 draw_config_pt[
'xrange'] = [10,50]
306 draw_config_pt[
'xbins'] = [10,12.5,15,20,25,30,40,50]
307 draw_config_pt[
'ylimits'] = [1e2, 5e8]
308 draw_config_pt[
'xlimits'] = [0,60]
309 draw_config_pt[
'yunits'] =
'[$\\mathrm{GeV^{-1}}$]'
310 draw_config_pt[
'xunits'] =
'[GeV]'
315 def DifferentialTaggingYield(df, x='Jet.PT', xrange=[10,50], xbins=[10,12.5,15,20,25,30,40,50], which='all', process='CC_DIS_e18_p275_B15'):
316 global u_fb, u_mb, xs_map, n_gen
318 print(f
"n_gen = {n_gen}")
319 jet_pt = np.concatenate(df[
'Jet.PT'].to_numpy()).ravel()
320 jet_eta = np.concatenate(df[
'Jet.Eta'].to_numpy()).ravel()
321 jet_flavor = np.concatenate(df[
'Jet.Flavor'].to_numpy()).ravel()
322 jet_tag = np.concatenate(df[
'Jet.BTag'].to_numpy()).ravel()
324 jet_x = np.concatenate(df[x].to_numpy()).ravel()
328 jet_basics = (jet_tag == 1)
330 all_flavor = ( jet_flavor > -999.0 ) & (jet_basics)
331 light_flavor = ( jet_flavor < 4 ) & (jet_basics)
332 charm_flavor = ( jet_flavor == 4 ) & (jet_basics)
334 selection = all_flavor
336 selection = charm_flavor
337 elif which ==
'light':
338 selection = light_flavor
340 (counts, bins) = np.histogram(jet_x[ selection ], range=xrange,
344 bin_widths = np.diff(bins)
345 bin_centers = bins[:-1] + bin_widths/2
347 errors = np.sqrt(counts)
348 rel_errors = errors/counts
352 dsigma_dx = counts * eat.TotalXSection(process) * 100*u_fb**(-1) / n_gen / bin_widths
353 dsigma_dx_errors = rel_errors * dsigma_dx
355 return (bin_centers, bin_widths, dsigma_dx, dsigma_dx_errors)
363 draw_config_eta[
'xvar'] =
'Jet.Eta'
364 draw_config_eta[
'xrange'] = [-4.0, 4.0]
365 draw_config_eta[
'xbins'] = [-4.0, -3.5, -2.5, -1.0, 1.0, 2.5, 3.5, 4.0]
366 draw_config_eta[
'ylimits'] = [1, 1e3]
367 draw_config_eta[
'xlimits'] = [-5,5]
368 draw_config_eta[
'yunits'] =
''
369 draw_config_eta[
'xunits'] =
''
370 draw_config_eta[
'data'] = df_ct18nnlo
373 draw_config_pt[
'xvar'] =
'Jet.PT'
374 draw_config_pt[
'xrange'] = [10,50]
375 draw_config_pt[
'xbins'] = [10,12.5,15,20,25,30,40,50]
376 draw_config_pt[
'ylimits'] = [1, 1e3]
377 draw_config_pt[
'xlimits'] = [0,60]
378 draw_config_pt[
'yunits'] =
'[$\\mathrm{GeV^{-1}}$]'
379 draw_config_pt[
'xunits'] =
'[GeV]'
380 draw_config_pt[
'data'] = df_ct18nnlo
386 xvar=draw_config[
'xvar']
387 xrange=draw_config[
'xrange']
388 xbins=draw_config[
'xbins']
389 ylimits=draw_config[
'ylimits']
390 xlimits=draw_config[
'xlimits']
391 yunits=draw_config[
'yunits']
392 xunits=draw_config[
'xunits']
394 fig, ax = plt.subplots(figsize=(12,8))
398 gridspec = fig.add_gridspec(ncols=1, nrows=1, width_ratios=[1], height_ratios=[1])
402 ax1 = fig.add_subplot(gridspec[0, 0])
404 ax1.grid(which=
'both', axis=
'both')
406 (bins, bin_widths, xs, xs_error) =
DifferentialTaggingYield(draw_config[
'data'], x=xvar, xrange=xrange, xbins=xbins, which=
'light', process=process)
407 ax1.errorbar(bins, xs, xerr = bin_widths/2, yerr=xs_error, label=
'light jets (CT18NNLO)', marker=
'o', ms=10, ls=
'none', linewidth=2, color=
'red')
410 charm_ct18nnlo =
DifferentialTaggingYield(draw_config[
'data'], x=xvar, xrange=xrange, xbins=xbins, which=
'charm', process=process)
411 (bins, bin_widths, xs, xs_error) = charm_ct18nnlo
412 ax1.errorbar(bins, xs, xerr = bin_widths/2, yerr=xs_error, label=
'charm jets (CT18NNLO)', marker=
'D', ms=10, ls=
'none', linewidth=2, fillstyle=
'none', color=
'blue')
417 if xvar.find(
'Eta') != -1:
420 plt.ylabel(f
'$\\varepsilon_{{tag}} \\times d\\sigma/d{xvar_symbol} \\times 100\\mathrm{{fb^{{-1}}}}$ {yunits}')
421 plt.xlabel(f
'Reconstructed Jet ${xvar_symbol}$ {xunits}')
424 process_name =
'CC-DIS'
425 if process.find(
'NC') != -1:
426 process_name =
'NC-DIS'
427 plt.title(f
"{process_name}, 18x275GeV, $Q^2>100\\mathrm{{GeV^2}}$", fontsize=20)
429 ax1.set_ylim(ylimits)
430 ax1.set_xlim(xlimits)
432 ax1.legend(fontsize=18)
437 plt.savefig(f
"jet_differential_tagyield_{xvar}_{process}.png")
438 plt.savefig(f
"jet_differential_tagyield_{xvar}_{process}.pdf")
446 draw_config_pt[
'xvar'] =
'Jet.PT'
447 draw_config_pt[
'xrange'] = [10,50]
448 draw_config_pt[
'xbins'] = [10,12.5,15,20,25,30,40,50]
449 draw_config_pt[
'ylimits'] = [1e-1, 1e6]
450 draw_config_pt[
'xlimits'] = [0,60]
451 draw_config_pt[
'yunits'] =
'[$\\mathrm{GeV^{-1}}$]'
452 draw_config_pt[
'xunits'] =
'[GeV]'
453 draw_config_pt[
'data'] = df_ct18nnlo_nc
459 def DifferentialTaggingEfficiency(df, x='Jet.PT', xrange=[10,50], xbins=[10,12.5,15,20,25,30,40,50], which='all'):
461 print(f
"n_gen = {n_gen}")
462 jet_pt = np.concatenate(df[
'Jet.PT'].to_numpy()).ravel()
463 jet_eta = np.concatenate(df[
'Jet.Eta'].to_numpy()).ravel()
464 jet_flavor = np.concatenate(df[
'Jet.Flavor'].to_numpy()).ravel()
465 jet_tag = np.concatenate(df[
'Jet.BTag'].to_numpy()).ravel()
467 jet_x = np.concatenate(df[x].to_numpy()).ravel()
470 jet_tagged = (jet_tag == 1)
472 all_flavor = ( jet_flavor > -999.0 )
473 light_flavor = ( jet_flavor < 4 )
474 charm_flavor = ( jet_flavor == 4 )
476 selection = all_flavor
478 selection = charm_flavor
479 elif which ==
'light':
480 selection = light_flavor
482 (tru_counts, bins) = np.histogram(jet_x[ selection ], range=xrange,
485 (tag_counts, bins) = np.histogram(jet_x[ (selection) & (jet_tagged) ], range=xrange,
489 eff = tag_counts/tru_counts
490 n_err = scipy.stats.binom.interval(1.0-math.exp(-1), tru_counts, eff)
492 eff_err=[np.fabs(n_err[0]/tru_counts-eff), np.fabs(n_err[1]/tru_counts-eff)]
494 bin_widths = np.diff(bins)
495 bin_centers = bins[:-1] + bin_widths/2
498 return (bin_centers, bin_widths, eff, eff_err)
504 draw_config_eta[
'xvar'] =
'Jet.Eta'
505 draw_config_eta[
'xrange'] = [-4.0, 4.0]
506 draw_config_eta[
'xbins'] = [-4.0, -3.5, -2.5, -1.0, 1.0, 2.5, 3.5, 4.0]
507 draw_config_eta[
'ylimits'] = [1e-5, 1]
508 draw_config_eta[
'xlimits'] = [-5,5]
509 draw_config_eta[
'yunits'] =
''
510 draw_config_eta[
'xunits'] =
''
513 draw_config_pt[
'xvar'] =
'Jet.PT'
514 draw_config_pt[
'xrange'] = [10,50]
515 draw_config_pt[
'xbins'] = [10,12.5,15,20,25,30,40,50]
516 draw_config_pt[
'ylimits'] = [1e-5, 1]
517 draw_config_pt[
'xlimits'] = [0,60]
518 draw_config_pt[
'yunits'] =
'[$\\mathrm{GeV^{-1}}$]'
519 draw_config_pt[
'xunits'] =
'[GeV]'
524 xvar=draw_config[
'xvar']
525 xrange=draw_config[
'xrange']
526 xbins=draw_config[
'xbins']
527 ylimits=draw_config[
'ylimits']
528 xlimits=draw_config[
'xlimits']
529 yunits=draw_config[
'yunits']
530 xunits=draw_config[
'xunits']
533 fig, ax = plt.subplots(figsize=(12,8))
537 gridspec = fig.add_gridspec(ncols=1, nrows=1, width_ratios=[1], height_ratios=[1])
541 ax1 = fig.add_subplot(gridspec[0, 0])
543 ax1.grid(which=
'both', axis=
'both')
546 ax1.errorbar(bins, eff, xerr = bin_widths/2, yerr=eff_error, label=
'light jets (CT18NNLO)', marker=
'o', ms=10, ls=
'none', linewidth=2, color=
'red')
550 ax1.errorbar(bins, eff, xerr = bin_widths/2, yerr=eff_error, label=
'charm jets (CT18NNLO)', marker=
'D', ms=10, ls=
'none', linewidth=2, color=
'blue')
555 if xvar.find(
'Eta') != -1:
558 plt.ylabel(f
'$\\varepsilon_{{tag}}$ {yunits}')
559 plt.xlabel(f
'Reconstructed Jet ${xvar_symbol}$ {xunits}')
561 plt.title(
"CC-DIS, 18x275GeV, $Q^2>100\\mathrm{GeV^2}$", fontsize=20)
563 ax1.set_ylim(ylimits)
564 ax1.set_xlim(xlimits)
566 ax1.legend(fontsize=18)
572 plt.savefig(f
"jet_differential_tagefficiency_{xvar}.png")
573 plt.savefig(f
"jet_differential_tagefficiency_{xvar}.pdf")