Skip to content

Commit 60aa367

Browse files
author
Mori Ludovico
committed
improve roc plotting, add exception printout when loading data
1 parent e5b500e commit 60aa367

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 multiROCCurveGrey(
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

@@ -870,14 +870,19 @@ def multiROCCurve(
870870
plot_dir="",
871871
name="",
872872
prelim=True,
873+
lumi=None,
873874
show=False,
874875
):
875876
if ylim is None:
876877
ylim = [1e-06, 1]
877878
if xlim is None:
878879
xlim = [0, 1]
879880
if thresholds is None:
880-
thresholds = [[0.9, 0.98, 0.995, 0.9965, 0.998], [0.99, 0.997, 0.998, 0.999, 0.9997]]
881+
thresholds = [
882+
0.9,
883+
0.99,
884+
0.998,
885+
] # [0.9, 0.98, 0.995, 0.9965, 0.998] # [[0.99, 0.997, 0.998, 0.999, 0.9997]]
881886

882887
plt.rcParams.update({"font.size": 32})
883888

@@ -897,13 +902,12 @@ def multiROCCurve(
897902
color=COLOURS[ROC_COLOURS[i * len(roc_sigs) + j]],
898903
linestyle=LINESTYLES[i * len(roc_sigs) + j],
899904
)
900-
901905
pths = {th: [[], []] for th in pthresholds}
902906
for th in pthresholds:
903907
idx = _find_nearest(roc["thresholds"], th)
904908
pths[th][0].append(roc["tpr"][idx])
905909
pths[th][1].append(roc["fpr"][idx])
906-
print(roc["tpr"][idx])
910+
# print(roc["tpr"][idx])
907911

908912
for k, th in enumerate(pthresholds):
909913
ax.scatter(
@@ -935,7 +939,15 @@ def multiROCCurve(
935939
alpha=0.5,
936940
)
937941

938-
add_cms_label(ax, year, data=False, label="Preliminary" if prelim else None, loc=1, lumi=False)
942+
hep.cms.label(
943+
ax=ax,
944+
label="Preliminary" if prelim else "",
945+
data=True,
946+
year=year,
947+
com="13.6",
948+
fontsize=20,
949+
lumi=lumi,
950+
)
939951

940952
if log:
941953
plt.yscale("log")
@@ -944,16 +956,16 @@ def multiROCCurve(
944956
ax.set_ylabel("Background efficiency")
945957
ax.set_xlim(*xlim)
946958
ax.set_ylim(*ylim)
947-
ax.legend(loc="lower right", fontsize=24)
959+
ax.legend(loc="lower right", fontsize=21)
948960

949961
if title:
950962
ax.text(
951-
0.05,
952-
0.83,
963+
0.02,
964+
0.93,
953965
title,
954966
transform=ax.transAxes,
955-
fontsize=24,
956-
fontproperties="Tex Gyre Heros:bold",
967+
fontsize=20,
968+
# fontproperties="Tex Gyre Heros:bold",
957969
)
958970

959971
if kin_label:
@@ -968,6 +980,7 @@ def multiROCCurve(
968980

969981
if len(name):
970982
plt.savefig(f"{plot_dir}/{name}.pdf", bbox_inches="tight")
983+
plt.savefig(f"{plot_dir}/{name}.png", bbox_inches="tight")
971984

972985
if show:
973986
plt.show()

src/boostedhh/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,12 @@ def load_sample(
450450
logger.debug(f"Loading {load_sample}")
451451
try:
452452
events = pd.read_parquet(parquet_path, filters=filters, columns=load_columns)
453-
except Exception:
453+
except Exception as e:
454454
warnings.warn(
455455
f"Can't read file with requested columns/filters for {load_sample}!",
456456
stacklevel=1,
457457
)
458+
print(e)
458459
continue
459460

460461
# no events?

0 commit comments

Comments
 (0)