Skip to content

Commit ea1eb40

Browse files
authored
Merge pull request #10 from LPC-HH/dev-plotting-update
improve roc plotting, add exception printout when loading data
2 parents e6fe4d5 + 17fb7b5 commit ea1eb40

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

src/boostedhh/plotting.py

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -846,14 +846,14 @@ def multiROCCurveGreyOld(
846846

847847

848848
th_colours = [
849-
# "#36213E",
849+
"#36213E",
850850
# "#9381FF",
851851
"#1f78b4",
852-
# "#a6cee3",
852+
"#a6cee3",
853853
# "#32965D",
854854
"#7CB518",
855855
"#EDB458",
856-
# "#ff7f00",
856+
"#ff7f00",
857857
"#a70000",
858858
]
859859

@@ -1026,14 +1026,19 @@ def multiROCCurve(
10261026
plot_dir="",
10271027
name="",
10281028
prelim=True,
1029+
lumi=None,
10291030
show=False,
10301031
):
10311032
if ylim is None:
10321033
ylim = [1e-06, 1]
10331034
if xlim is None:
10341035
xlim = [0, 1]
10351036
if thresholds is None:
1036-
thresholds = [[0.9, 0.98, 0.995, 0.9965, 0.998], [0.99, 0.997, 0.998, 0.999, 0.9997]]
1037+
thresholds = [
1038+
0.9,
1039+
0.99,
1040+
0.998,
1041+
] # [0.9, 0.98, 0.995, 0.9965, 0.998] # [[0.99, 0.997, 0.998, 0.999, 0.9997]]
10371042

10381043
plt.rcParams.update({"font.size": 32})
10391044

@@ -1053,13 +1058,12 @@ def multiROCCurve(
10531058
color=COLOURS[ROC_COLOURS[i * len(roc_sigs) + j]],
10541059
linestyle=LINESTYLES[i * len(roc_sigs) + j],
10551060
)
1056-
10571061
pths = {th: [[], []] for th in pthresholds}
10581062
for th in pthresholds:
10591063
idx = _find_nearest(roc["thresholds"], th)
10601064
pths[th][0].append(roc["tpr"][idx])
10611065
pths[th][1].append(roc["fpr"][idx])
1062-
print(roc["tpr"][idx])
1066+
# print(roc["tpr"][idx])
10631067

10641068
for k, th in enumerate(pthresholds):
10651069
ax.scatter(
@@ -1091,7 +1095,15 @@ def multiROCCurve(
10911095
alpha=0.5,
10921096
)
10931097

1094-
add_cms_label(ax, year, data=False, label="Preliminary" if prelim else None, loc=1, lumi=False)
1098+
hep.cms.label(
1099+
ax=ax,
1100+
label="Preliminary" if prelim else "",
1101+
data=True,
1102+
year=year,
1103+
com="13.6",
1104+
fontsize=20,
1105+
lumi=lumi,
1106+
)
10951107

10961108
if log:
10971109
plt.yscale("log")
@@ -1100,16 +1112,16 @@ def multiROCCurve(
11001112
ax.set_ylabel("Background efficiency")
11011113
ax.set_xlim(*xlim)
11021114
ax.set_ylim(*ylim)
1103-
ax.legend(loc="lower right", fontsize=24)
1115+
ax.legend(loc="lower right", fontsize=21)
11041116

11051117
if title:
11061118
ax.text(
1107-
0.05,
1108-
0.83,
1119+
0.02,
1120+
0.93,
11091121
title,
11101122
transform=ax.transAxes,
1111-
fontsize=24,
1112-
fontproperties="Tex Gyre Heros:bold",
1123+
fontsize=20,
1124+
# fontproperties="Tex Gyre Heros:bold",
11131125
)
11141126

11151127
if kin_label:
@@ -1124,6 +1136,7 @@ def multiROCCurve(
11241136

11251137
if len(name):
11261138
plt.savefig(f"{plot_dir}/{name}.pdf", bbox_inches="tight")
1139+
plt.savefig(f"{plot_dir}/{name}.png", bbox_inches="tight")
11271140

11281141
if show:
11291142
plt.show()

src/boostedhh/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,12 @@ def load_sample(
541541
logger.debug(f"Loading {load_sample}")
542542
try:
543543
events = pd.read_parquet(parquet_path, filters=filters, columns=load_columns)
544-
except Exception:
544+
except Exception as e:
545545
warnings.warn(
546546
f"Can't read file with requested columns/filters for {load_sample}!",
547547
stacklevel=1,
548548
)
549+
print(e)
549550
continue
550551

551552
# no events?

0 commit comments

Comments
 (0)