2 from pathlib
import Path
3 from typing
import List, Optional
9 import matplotlib.pyplot
12 def main(files: List[Path], output: str, title: str =
""):
17 m = re.match(
".*mu(\d+).*", file.name)
21 mus = list(sorted(mus))
23 fig, (ax, tax) = matplotlib.pyplot.subplots(
24 2, 1, gridspec_kw={
"hspace": 0,
"height_ratios": [2, 1]}
27 for fitter, color
in zip((
"Iterative",
"AMVF"), [
"tab:blue",
"tab:orange"]):
28 mean = numpy.array([])
29 stddev = numpy.array([])
30 ntrue_mean = numpy.array([])
31 ntrue_stddev = numpy.array([])
32 time = numpy.array([])
36 if f
"mu{mu}" in file.name
and fitter
in file.name:
39 time_file = file.parent / f
"{file.stem}_time.txt"
40 if time_file.exists():
41 time = numpy.append(time, float(time_file.read_text()))
43 fime.append(float(
"nan"))
45 rf = uproot.open(f
"{file}:vertexing")
47 nreco = rf[
"nRecoVtx"].
array(library=
"np")
48 ntrue = rf[
"nTrueVtx"].
array(library=
"np")
50 nreco_mean = nreco.mean()
52 nreco_std = nreco.std()
54 mean = numpy.append(mean, nreco_mean)
55 stddev = numpy.append(stddev, nreco_std)
57 ntrue_mean = numpy.append(ntrue_mean, ntrue.mean())
58 ntrue_stddev = numpy.append(ntrue_stddev, ntrue.std())
60 ax.fill_between(mus, mean - stddev, mean + stddev, fc=color, alpha=0.2)
61 ax.plot(mus, mean, label=fitter, c=color)
62 tax.plot(mus, time, label=f
"{fitter} time", c=color)
64 ax.plot(mus, mus, label=
"truth", c=
"gray", ls=
"--")
66 tax.set_xlabel(
"$\mu$")
67 ax.set_ylabel(
"Number of vertices")
68 tax.set_ylabel(
"wall time [s]")
80 if __name__ ==
"__main__":