Skip to content
Snippets Groups Projects
Commit 63995388 authored by Cedric Verstege's avatar Cedric Verstege
Browse files

Add theory uncertainty plots

parent eedead9c
Branches
No related tags found
No related merge requests found
import os
import matplotlib.pyplot as plt
import numpy as np
import ROOT
......@@ -176,3 +178,82 @@ class PlotTheoryComparison(law.Task):
fig.tight_layout()
self.output().dir.touch()
MatplotlibFormatter.dump(self.output()[ybys], fig)
class PlotTheoryUncertainties(law.Task):
order = luigi.Parameter(default="NNLO")
jet_radius = luigi.Parameter(default="4")
pdf = luigi.Parameter(default="PDF4LHC21_40")
def output(self):
plot_targets = {}
for ybys in ybys_bins:
plot_targets[ybys] = law.LocalFileTarget(
os.path.join(
self.__class__.__name__.replace("Plot", ""),
f"{self.order}_{self.pdf}",
f"AK{self.jet_radius}_{ybys}.pdf",
),
fs="local_plots",
)
return law.SiblingFileCollection(plot_targets)
def requires(self):
return TheoryPrediction.req(self)
def run(self):
hep.style.use("CMS")
self.output().dir.touch()
theory_file = uproot.open(self.input().abspath)
uncs = {
"total": dict(
label="Total theory unc.", color="black", linestyle="solid", linewidth=3
),
"stat": dict(label="Stat. unc.", color="#9c9ca1"),
"scale": dict(label="Scale", color="#f89c20", linestyle="dashdot"),
"pdf": dict(label=f"{self.pdf}", color="#5790fc", linestyle="dotted"),
"np": dict(label="NP corr.", color="#964a8b", linestyle="dashed"),
}
for ybys, _d in ybys_bins.items():
fig, ax = plt.subplots()
theory, bins = theory_file[f"{ybys}/h_genzpt_weight"].to_numpy()
hep.label.exp_label(data=True, ax=ax)
for unc, unc_dict in uncs.items():
up = theory_file[f"{ybys}/h_genzpt_weight_{unc}_up"].to_numpy()[0]
dn = theory_file[f"{ybys}/h_genzpt_weight_{unc}_down"].to_numpy()[0]
ax.stairs(
up / theory,
edges=bins,
label=unc_dict["label"],
color=unc_dict["color"],
linestyle=unc_dict.get("linestyle", "-"),
linewidth=unc_dict.get("linewidth", 2),
baseline=None,
)
ax.stairs(
dn / theory,
edges=bins,
color=unc_dict["color"],
linestyle=unc_dict.get("linestyle", "-"),
linewidth=unc_dict.get("linewidth", 2),
baseline=None,
)
ax.set_ylabel("Relative Uncertainty")
ax.set_xlabel(QUANTITIES["zpt"]["label"])
ax.set_xscale("log")
ax.set_xlim(QUANTITIES["zpt"]["range"])
ax.set_ylim(-0.25, 0.3)
ax.hlines(0, 25, 1000, color="black", linestyle="dashed")
ax.text(
0.03,
0.95,
_d["label"],
fontsize="small",
verticalalignment="top",
fontproperties="Tex Gyre Heros",
transform=ax.transAxes,
)
set_ticklabels(ax)
ax.legend(loc="upper right")
fig.tight_layout()
MatplotlibFormatter.dump(self.output()[ybys], fig)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment