Skip to content

Commit db3b1a5

Browse files
committed
Update jet substructure preliminary figures.
1 parent 6db4dd6 commit db3b1a5

File tree

2 files changed

+64
-38
lines changed

2 files changed

+64
-38
lines changed

machine_learning_hep/analysis/analyzer_jet.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def __init__(self, datap, case, typean, period):
276276
self.text_pth = "%g #leq #it{p}_{T}^{%s} < %g GeV/#it{c}, #left|#it{y}_{%s}#right| #leq 0.8"
277277
self.text_sd = "Soft Drop (#it{z}_{cut} = 0.1, #it{#beta} = 0)"
278278
self.text_acc_h = "#left|#it{y}_{%s}#right| #leq 0.8" % self.p_latexnhadron
279+
self.text_powheg = "POWHEG + PYTHIA 6 + EvtGen"
279280

280281
def fit(self):
281282
self.loadstyle()
@@ -805,7 +806,7 @@ def efficiency(self): # pylint: disable=too-many-branches, too-many-locals
805806

806807
# pylint: disable=too-many-locals, too-many-branches
807808
def side_band_sub(self):
808-
#This function perform side band subtraction of the histograms.
809+
#This function perform sideband subtraction of the histograms.
809810
#The input files for this function are coming from:
810811
# - root file containing the histograms of mass vs z called here
811812
# "hzvsmass". There is one for each bin of HF pt and jet pt.
@@ -865,7 +866,7 @@ def side_band_sub(self):
865866

866867
# Here I define the boundaries for the side-band subtractions
867868
# based on the results of the fit. We get usually 4-9 sigma from
868-
# the mean in both sides to extract the side band distributions
869+
# the mean in both sides to extract the sideband distributions
869870

870871
hzvsmass = lfile.Get("hzvsmass" + suffix)
871872
binmasslow2sig = \
@@ -902,7 +903,7 @@ def side_band_sub(self):
902903
binmasshigh4sig, binmasshigh9sig, "e")
903904

904905
# the background histogram is made by adding the left and
905-
# right side band in general. self.sidebandleftonly = True is
906+
# right sideband in general. self.sidebandleftonly = True is
906907
# just made for systematic studies
907908

908909
# Below a list of histograms are defined:
@@ -969,7 +970,7 @@ def side_band_sub(self):
969970
hzsub_noteffscaled.Write()
970971
hzsub.Write("hzsub" + suffix)
971972

972-
# Canvas to compare the shape of the left and right side bands.
973+
# Canvas to compare the shape of the left and right sidebands.
973974

974975
csblr = TCanvas("csblr" + suffix, "The Side-Band Left-Right Canvas" + suffix)
975976
setup_canvas(csblr)
@@ -1043,7 +1044,7 @@ def side_band_sub(self):
10431044
line.Draw("same")
10441045
csblr.SaveAs("%s/side_band_left_right_%s.eps" % (self.d_resultsallpdata, suffix_plot))
10451046

1046-
# This canvas will contain the distributions of the side band
1047+
# This canvas will contain the distributions of the sideband
10471048
# subtracted z-distributions in bin of the reco jet pt
10481049
# variable, corrected for HF candidate efficiency
10491050

@@ -1133,8 +1134,8 @@ def side_band_sub(self):
11331134
else:
11341135
leg_pos = [.68, .72, .85, .85]
11351136
list_obj = [hzsig, hzbkg_scaled, hzsub_noteffscaled]
1136-
labels_obj = ["signal region", "side band region", "after subtraction"]
1137-
colours = [get_colour(i) for i in [1, 2, 3]]
1137+
labels_obj = ["signal region", "sideband region", "after subtraction"]
1138+
colours = [get_colour(i) for i in [2, 3, 1]]
11381139
markers = [get_marker(i) for i in [0, 1, 2]]
11391140
y_margin_up = 0.4
11401141
y_margin_down = 0.05
@@ -1980,7 +1981,7 @@ def unfolding(self):
19801981
mc_reco_matched_z[ibin2].GetYaxis().SetRangeUser(*get_plot_range(y_min_h, y_max_h, y_margin_down, y_margin_up))
19811982
mc_reco_matched_z[ibin2].SetTitle("")
19821983
mc_reco_matched_z[ibin2].SetXTitle(self.v_varshape_latex)
1983-
mc_reco_matched_z[ibin2].SetYTitle("normalised yield")
1984+
mc_reco_matched_z[ibin2].SetYTitle("self-normalised yield")
19841985
mc_reco_matched_z[ibin2].SetTitleOffset(1.3, "Y")
19851986
mc_reco_matched_z[ibin2].GetXaxis().SetRangeUser(round(self.lvarshape_binmin_reco[0], 2), round(self.lvarshape_binmax_reco[-1], 2))
19861987
mc_reco_matched_z[ibin2].Draw()
@@ -2070,7 +2071,7 @@ def unfolding(self):
20702071
if self.shape == "nsd":
20712072
hz_genvsreco_full.GetXaxis().SetNdivisions(5)
20722073
hz_genvsreco_full.GetYaxis().SetNdivisions(5)
2073-
hz_genvsreco_full.SetTitle(";%s^{gen};%s^{rec};normalised yield" % (self.v_varshape_latex, self.v_varshape_latex))
2074+
hz_genvsreco_full.SetTitle(";%s^{gen};%s^{rec};self-normalised yield" % (self.v_varshape_latex, self.v_varshape_latex))
20742075
hz_genvsreco_full.Draw("colz")
20752076
y_latex = 0.95
20762077
list_latex = []
@@ -2119,7 +2120,7 @@ def unfolding(self):
21192120
if self.shape == "nsd":
21202121
hz_genvsreco_full_real.GetXaxis().SetNdivisions(5)
21212122
hz_genvsreco_full_real.GetYaxis().SetNdivisions(5)
2122-
hz_genvsreco_full_real.SetTitle(";%s^{gen};%s^{rec};normalised yield" % (self.v_varshape_latex, self.v_varshape_latex))
2123+
hz_genvsreco_full_real.SetTitle(";%s^{gen};%s^{rec};self-normalised yield" % (self.v_varshape_latex, self.v_varshape_latex))
21232124
hz_genvsreco_full_real.Draw("colz")
21242125
y_latex = 0.95
21252126
list_latex = []
@@ -3527,18 +3528,18 @@ def jetsystematics(self):
35273528
# preliminary figure
35283529
if ibin2 == 1:
35293530
gStyle.SetErrorX(0)
3530-
leg_pos = [.16, .595, .31, .645]
3531+
leg_pos = [.16, .545, .31, .595]
35313532
list_obj = [tg_feeddown_fraction[ibin2], h_feeddown_fraction[ibin2]]
35323533
labels_obj = ["POWHEG uncertainty"]
3533-
colours = [get_colour(i, j) for i, j in zip((0, 0), (2, 1))]
3534+
colours = [get_colour(i, j) for i, j in zip((1, 0), (2, 1))]
35343535
markers = [get_marker(0)]
3535-
y_margin_up = 0.45
3536+
y_margin_up = 0.5
35363537
y_margin_down = 0.05
35373538
c_fd_fr_sys, list_obj_data_new = make_plot("c_fd_fr_sys_" + suffix, size=self.size_can, \
35383539
list_obj=list_obj, labels_obj=labels_obj, opt_leg_g="F", opt_plot_g=self.opt_plot_g, offsets_xy=self.offsets_axes, \
35393540
colours=colours, markers=markers, leg_pos=leg_pos, margins_y=[y_margin_down, y_margin_up], margins_c=self.margins_can, \
35403541
title=";%s;feed-down fraction" % self.title_x)
3541-
tg_feeddown_fraction[ibin2].SetMarkerColor(get_colour(0))
3542+
tg_feeddown_fraction[ibin2].SetMarkerColor(get_colour(1))
35423543
tg_feeddown_fraction[ibin2].GetYaxis().SetTitleOffset(1.2)
35433544
list_obj_data_new[0].SetTextSize(self.fontsize)
35443545
if self.shape == "nsd":
@@ -3547,17 +3548,16 @@ def jetsystematics(self):
35473548
c_fd_fr_sys.Update()
35483549
# Draw LaTeX
35493550
y_latex = self.y_latex_top
3550-
list_latex_data = []
3551-
for text_latex in [self.text_alice, self.text_jets, text_ptjet_full, text_pth_full, self.text_sd]:
3551+
list_latex = []
3552+
for text_latex in [self.text_alice, self.text_jets, text_ptjet_full, text_pth_full, self.text_sd, self.text_powheg]:
35523553
latex = TLatex(self.x_latex, y_latex, text_latex)
3553-
list_latex_data.append(latex)
3554+
list_latex.append(latex)
35543555
draw_latex(latex, textsize=self.fontsize)
35553556
y_latex -= self.y_step
35563557
c_fd_fr_sys.Update()
35573558
c_fd_fr_sys.SaveAs("%s/%s_fd_fr_sys_%s.pdf" % (self.d_resultsallpdata, self.shape, suffix_plot))
35583559
gStyle.SetErrorX(0.5)
35593560

3560-
35613561
def get_simulated_yields(self, file_path: str, dim: int, prompt: bool):
35623562
"""Create a histogram from a simulation tree.
35633563
file_path - input file path

machine_learning_hep/plotting/plot_jetsubstructure.py

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,13 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
198198
size_thg = 0.05
199199
offset_thg = 0.85
200200

201-
gStyle.SetErrorX(0)
201+
gStyle.SetErrorX(0) # do not plot horizontal error bars of histograms
202202
fontsize = 0.035
203203
opt_leg_g = "FP"
204204
opt_plot_g = "2"
205205

206+
list_new = [] # list to avoid loosing objects created in loops
207+
206208
# labels
207209

208210
x_latex = 0.16
@@ -215,12 +217,14 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
215217
title_full_ratio = ";%s;data/MC: ratio of %s" % (title_x, title_y)
216218

217219
text_alice = "#bf{ALICE} Preliminary, pp, #sqrt{#it{s}} = 13 TeV"
220+
text_alice_sim = "#bf{ALICE} Simulation, pp, #sqrt{#it{s}} = 13 TeV"
218221
text_pythia = "PYTHIA 8 (Monash)"
219222
text_pythia_split = "#splitline{PYTHIA 8}{(Monash)}"
220223
text_jets = "charged jets, anti-#it{k}_{T}, #it{R} = 0.4"
221224
text_ptjet = "%g #leq %s < %g GeV/#it{c}, #left|#it{#eta}_{jet}#right| #leq 0.5" % (lvar2_binmin_reco[ibin2], p_latexbin2var, lvar2_binmax_reco[ibin2])
222225
text_pth = "%g #leq #it{p}_{T}^{%s} < %g GeV/#it{c}, #left|#it{y}_{%s}#right| #leq 0.8" % (lpt_finbinmin[0], p_latexnhadron, min(lpt_finbinmax[-1], lvar2_binmax_reco[ibin2]), p_latexnhadron)
223226
text_ptcut = "#it{p}_{T, incl. ch. jet}^{leading track} #geq 5.33 GeV/#it{c}"
227+
text_ptcut_sim = "#it{p}_{T, incl. ch. jet}^{leading h^{#pm}} #geq 5.33 GeV/#it{c} (varied)"
224228
text_sd = "Soft Drop (#it{z}_{cut} = 0.1, #it{#beta} = 0)"
225229

226230
title_thetag = "#it{#theta}_{g} = #it{R}_{g}/#it{R}"
@@ -230,9 +234,17 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
230234
c_hf_data = 0
231235
c_incl_data = 1
232236
c_hf_mc = 2
233-
c_incl_mc = 3
234-
c_quark_mc = 4
235-
c_gluon_mc = 5
237+
c_incl_mc = 6
238+
c_quark_mc = 5
239+
c_gluon_mc = 0
240+
241+
# markers
242+
m_hf_data = get_marker(0)
243+
m_incl_data = get_marker(1)
244+
m_hf_mc = get_marker(0, 2)
245+
m_incl_mc = get_marker(1, 2)
246+
m_quark_mc = get_marker(2)
247+
m_gluon_mc = get_marker(3)
236248

237249
# make the horizontal error bars smaller
238250
if shape == "nsd":
@@ -249,7 +261,7 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
249261
list_obj = [hf_data_syst, incl_data_syst, hf_data_stat, incl_data_stat]
250262
labels_obj = ["%s-tagged" % p_latexnhadron, "inclusive", "", ""]
251263
colours = [get_colour(i, j) for i, j in zip((c_hf_data, c_incl_data, c_hf_data, c_incl_data), (2, 2, 1, 1))]
252-
markers = [get_marker(i) for i in (c_hf_data, c_incl_data, c_hf_data, c_incl_data)]
264+
markers = [m_hf_data, m_incl_data, m_hf_data, m_incl_data]
253265
y_margin_up = 0.46
254266
y_margin_down = 0.05
255267
cshape_data, list_obj_data_new = make_plot("cshape_data_" + suffix, size=size_can, \
@@ -261,6 +273,13 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
261273
list_obj_data_new[0].SetTextSize(fontsize)
262274
if shape == "nsd":
263275
hf_data_syst.GetXaxis().SetNdivisions(5)
276+
# Draw a line through the points.
277+
if shape == "nsd":
278+
for h in (hf_data_stat, incl_data_stat):
279+
h_line = h.Clone(h.GetName() + "_line")
280+
h_line.SetLineStyle(2)
281+
h_line.Draw("l hist same")
282+
list_new.append(h_line)
264283
cshape_data.Update()
265284
if shape == "rg":
266285
# plot the theta_g axis
@@ -298,7 +317,7 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
298317
list_obj = [hf_data_syst_cl, hf_data_stat, hf_pythia_stat]
299318
labels_obj = ["data", "", text_pythia_split]
300319
colours = [get_colour(i, j) for i, j in zip((c_hf_data, c_hf_data, c_hf_mc), (2, 1, 1))]
301-
markers = [get_marker(i) for i in (c_hf_data, c_hf_data, c_hf_mc)]
320+
markers = [m_hf_data, m_hf_data, m_hf_mc]
302321
y_margin_up = 0.4
303322
y_margin_down = 0.05
304323
cshape_data_mc_hf, list_obj_data_mc_hf_new = make_plot("cshape_data_mc_hf_" + suffix, size=size_can, \
@@ -355,7 +374,7 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
355374
list_obj = [incl_data_syst, incl_pythia_syst, incl_data_stat, incl_pythia_stat]
356375
labels_obj = ["data", text_pythia_split]
357376
colours = [get_colour(i, j) for i, j in zip((c_incl_data, c_incl_mc, c_incl_data, c_incl_mc), (2, 2, 1, 1))]
358-
markers = [get_marker(i) for i in (c_incl_data, c_incl_mc, c_incl_data, c_incl_mc)]
377+
markers = [m_incl_data, m_incl_mc, m_incl_data, m_incl_mc]
359378
y_margin_up = 0.4
360379
y_margin_down = 0.05
361380
cshape_data_mc_incl, list_obj_data_mc_incl_new = make_plot("cshape_data_mc_incl_" + suffix, size=size_can, \
@@ -411,7 +430,7 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
411430
list_obj = [hf_ratio_syst, line_1, incl_ratio_syst, hf_ratio_stat, incl_ratio_stat]
412431
labels_obj = ["%s-tagged" % p_latexnhadron, "inclusive"]
413432
colours = [get_colour(i, j) for i, j in zip((c_hf_data, c_incl_data, c_hf_data, c_incl_data), (2, 2, 1, 1))]
414-
markers = [get_marker(i) for i in (c_hf_data, c_incl_data, c_hf_data, c_incl_data)]
433+
markers = [m_hf_data, m_incl_data, m_hf_data, m_incl_data]
415434
y_margin_up = 0.52
416435
y_margin_down = 0.05
417436
if shape == "nsd":
@@ -476,14 +495,14 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
476495
list_obj = [incl_pythia_syst, quark_pythia_syst, gluon_pythia_syst, hf_pythia_stat, incl_pythia_stat, quark_pythia_stat, gluon_pythia_stat]
477496
labels_obj = ["inclusive", "quark", "gluon", "%s-tagged" % p_latexnhadron]
478497
colours = [get_colour(i, j) for i, j in zip((c_incl_mc, c_quark_mc, c_gluon_mc, c_hf_mc, c_incl_mc, c_quark_mc, c_gluon_mc), (2, 2, 2, 1, 1, 1, 1))]
479-
markers = [get_marker(i) for i in (c_incl_mc, c_quark_mc, c_gluon_mc, c_hf_mc, c_incl_mc, c_quark_mc, c_gluon_mc)]
498+
markers = [m_incl_mc, m_quark_mc, m_gluon_mc, m_hf_mc, m_incl_mc, m_quark_mc, m_gluon_mc]
480499
y_margin_up = 0.46
481500
y_margin_down = 0.05
482501
cshape_mc, list_obj_mc_new = make_plot("cshape_mc_" + suffix, size=size_can, \
483502
list_obj=list_obj, labels_obj=labels_obj, opt_leg_g=opt_leg_g, opt_plot_g=opt_plot_g, offsets_xy=offsets_axes, \
484503
colours=colours, markers=markers, leg_pos=leg_pos, range_y=[y_min_plot, y_max_plot], margins_c=margins_can, \
485504
title=title_full)
486-
cshape_ratio.Update()
505+
cshape_mc.Update()
487506
for gr, c in zip((incl_pythia_syst, quark_pythia_syst, gluon_pythia_syst), (c_incl_mc, c_quark_mc, c_gluon_mc)):
488507
gr.SetMarkerColor(get_colour(c))
489508
leg_mc = list_obj_mc_new[0]
@@ -513,7 +532,7 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
513532
# Draw LaTeX
514533
y_latex = y_latex_top
515534
list_latex_mc = []
516-
for text_latex in [text_alice, text_jets, text_ptjet, text_pth, text_ptcut, text_sd]:
535+
for text_latex in [text_alice_sim, text_jets, text_ptjet, text_pth, text_ptcut_sim, text_sd]:
517536
latex = TLatex(x_latex, y_latex, text_latex)
518537
list_latex_mc.append(latex)
519538
draw_latex(latex, textsize=fontsize)
@@ -528,14 +547,14 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
528547
list_obj = [quark_pythia_syst, gluon_pythia_syst, hf_pythia_stat, quark_pythia_stat, gluon_pythia_stat]
529548
labels_obj = ["quark", "gluon", "%s-tagged" % p_latexnhadron]
530549
colours = [get_colour(i, j) for i, j in zip((c_quark_mc, c_gluon_mc, c_hf_mc, c_quark_mc, c_gluon_mc), (2, 2, 1, 1, 1))]
531-
markers = [get_marker(i) for i in (c_quark_mc, c_gluon_mc, c_hf_mc, c_quark_mc, c_gluon_mc)]
550+
markers = [m_quark_mc, m_gluon_mc, m_hf_mc, m_quark_mc, m_gluon_mc]
532551
y_margin_up = 0.46
533552
y_margin_down = 0.05
534553
cshape_mc, list_obj_mc_new = make_plot("cshape_mc_qgd_" + suffix, size=size_can, \
535554
list_obj=list_obj, labels_obj=labels_obj, opt_leg_g=opt_leg_g, opt_plot_g=opt_plot_g, offsets_xy=offsets_axes, \
536555
colours=colours, markers=markers, leg_pos=leg_pos, range_y=[y_min_plot, y_max_plot], margins_c=margins_can, \
537556
title=title_full)
538-
cshape_ratio.Update()
557+
cshape_mc.Update()
539558
for gr, c in zip((quark_pythia_syst, gluon_pythia_syst), (c_quark_mc, c_gluon_mc)):
540559
gr.SetMarkerColor(get_colour(c))
541560
leg_mc = list_obj_mc_new[0]
@@ -565,7 +584,7 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
565584
# Draw LaTeX
566585
y_latex = y_latex_top
567586
list_latex_mc = []
568-
for text_latex in [text_alice, text_jets, text_ptjet, text_pth, text_ptcut, text_sd]:
587+
for text_latex in [text_alice_sim, text_jets, text_ptjet, text_pth, text_ptcut_sim, text_sd]:
569588
latex = TLatex(x_latex, y_latex, text_latex)
570589
list_latex_mc.append(latex)
571590
draw_latex(latex, textsize=fontsize)
@@ -577,17 +596,24 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
577596

578597
#leg_pos = [.6, .65, .75, .85]
579598
leg_pos = [.72, .67, .85, .85]
580-
list_obj = [incl_pythia_syst_cl, hf_pythia_stat, incl_pythia_stat]
581-
labels_obj = ["inclusive", "%s-tagged" % p_latexnhadron]
582-
colours = [get_colour(i, j) for i, j in zip((c_incl_mc, c_hf_mc, c_incl_mc), (2, 1, 1))]
583-
markers = [get_marker(i) for i in (c_incl_mc, c_hf_mc, c_incl_mc)]
599+
list_obj = [incl_pythia_syst_cl, incl_pythia_stat, hf_pythia_stat]
600+
labels_obj = ["inclusive", "", "%s-tagged" % p_latexnhadron]
601+
colours = [get_colour(i, j) for i, j in zip((c_incl_mc, c_incl_mc, c_hf_mc), (2, 1, 1))]
602+
markers = [m_incl_mc, m_incl_mc, m_hf_mc]
584603
y_margin_up = 0.46
585604
y_margin_down = 0.05
586605
cshape_mc, list_obj_mc_new = make_plot("cshape_mc_id_" + suffix, size=size_can, \
587606
list_obj=list_obj, labels_obj=labels_obj, opt_leg_g=opt_leg_g, opt_plot_g=opt_plot_g, offsets_xy=offsets_axes, \
588607
colours=colours, markers=markers, leg_pos=leg_pos, range_y=[y_min_plot, y_max_plot], margins_c=margins_can, \
589608
title=title_full)
590-
cshape_ratio.Update()
609+
# Draw a line through the points.
610+
if shape == "nsd":
611+
for h in (incl_pythia_stat, hf_pythia_stat):
612+
h_line = h.Clone(h.GetName() + "_line")
613+
h_line.SetLineStyle(2)
614+
h_line.Draw("l hist same")
615+
list_new.append(h_line)
616+
cshape_mc.Update()
591617
incl_pythia_syst_cl.SetMarkerColor(get_colour(c_incl_mc))
592618
leg_mc = list_obj_mc_new[0]
593619
leg_mc.SetTextSize(fontsize)
@@ -616,7 +642,7 @@ def main(): # pylint: disable=too-many-locals, too-many-statements, too-many-bra
616642
# Draw LaTeX
617643
y_latex = y_latex_top
618644
list_latex_mc = []
619-
for text_latex in [text_alice, text_jets, text_ptjet, text_pth, text_ptcut, text_sd]:
645+
for text_latex in [text_alice_sim, text_jets, text_ptjet, text_pth, text_ptcut_sim, text_sd]:
620646
latex = TLatex(x_latex, y_latex, text_latex)
621647
list_latex_mc.append(latex)
622648
draw_latex(latex, textsize=fontsize)

0 commit comments

Comments
 (0)