From a934572f6b0c03f3e1853eb1579c706c6df77737 Mon Sep 17 00:00:00 2001
From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Date: Mon, 20 Jan 2025 06:42:34 -0500
Subject: [PATCH] sigma_plots: another place to ignore fit fail

---
 benchmarks/zdc_sigma/analysis/sigma_plots.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/benchmarks/zdc_sigma/analysis/sigma_plots.py b/benchmarks/zdc_sigma/analysis/sigma_plots.py
index 228dbb92..302bbe07 100644
--- a/benchmarks/zdc_sigma/analysis/sigma_plots.py
+++ b/benchmarks/zdc_sigma/analysis/sigma_plots.py
@@ -39,7 +39,7 @@ for p in momenta:
     plt.hist(nclusters[p],bins=20, range=(0,20))
     plt.xlabel("number of clusters")
     plt.yscale('log')
-    plt.title(f"$p_\Sigma={p}$ GeV")
+    plt.title(rf"$p_\Sigma={p}$ GeV")
     plt.ylim(1)
     plt.savefig(outdir+f"nclust_{p}GeV_recon.pdf")
     print("saved file ", outdir+f"nclust_{p}GeV_recon.pdf")
@@ -309,10 +309,13 @@ from scipy.optimize import curve_fit
 slc=abs(bc)<5
 fnc=gauss
 p0=[100, 0, 1]
-coeff, var_matrix = curve_fit(fnc, bc[slc], y[slc], p0=p0,
-                                 sigma=np.sqrt(y[slc])+(y[slc]==0), maxfev=10000)
-x=np.linspace(-5, 5)
-plt.plot(x, gauss(x, *coeff), color='tab:orange')
+try:
+    coeff, var_matrix = curve_fit(fnc, bc[slc], y[slc], p0=p0,
+                                     sigma=np.sqrt(y[slc])+(y[slc]==0), maxfev=10000)
+    x=np.linspace(-5, 5)
+    plt.plot(x, gauss(x, *coeff), color='tab:orange')
+except RuntimeError:
+    print("fit failed")
 plt.xlabel("$z^{*\\rm recon}_{\\rm vtx}-z^{*\\rm truth}_{\\rm vtx}$ [m]")
 plt.ylabel("events")
 
-- 
GitLab