From 852baf920ab846f4966f68df3e0987049ac3b6be Mon Sep 17 00:00:00 2001
From: Philipp Schmidt <philipp.schmidt@xfel.eu>
Date: Mon, 16 Oct 2023 10:27:54 +0200
Subject: [PATCH] Scale pulse height Y axis to actual counts and disable for
 CFD

---
 notebooks/REMI/REMI_Digitize_and_Transform.ipynb | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/notebooks/REMI/REMI_Digitize_and_Transform.ipynb b/notebooks/REMI/REMI_Digitize_and_Transform.ipynb
index 1be86e742..809aca90a 100644
--- a/notebooks/REMI/REMI_Digitize_and_Transform.ipynb
+++ b/notebooks/REMI/REMI_Digitize_and_Transform.ipynb
@@ -601,11 +601,14 @@
     "                                 gridspec_kw=dict(left=0.1, right=0.98, top=0.98, bottom=0.1, hspace=0.25))\n",
     "    \n",
     "    fig.text(0.02, 0.98, det_name.upper(), rotation=90, ha='left', va='top', size='x-large')\n",
+    "    \n",
+    "    max_num = 0\n",
     "\n",
     "    for edge_idx, edge_name in enumerate(['u1', 'u2', 'v1', 'v2', 'w1', 'w2', 'mcp']):\n",
-    "        ux.hist(finite_flattened_slice(amplitudes, np.s_[:, edge_idx, :]),\n",
-    "                bins=1000, range=(0, 2048), histtype='step', lw=1,\n",
-    "                color=f'C{edge_idx}' if edge_idx < 6 else 'k', label=edge_name)\n",
+    "        n, _, _ = ux.hist(finite_flattened_slice(amplitudes, np.s_[:, edge_idx, :]),\n",
+    "                          bins=1000, range=(0, 2048), histtype='step', lw=1,\n",
+    "                          color=f'C{edge_idx}' if edge_idx < 6 else 'k', label=edge_name)\n",
+    "        max_num = max(max_num, n.max())\n",
     "        \n",
     "        cur_edges = finite_flattened_slice(edges, np.s_[:, edge_idx, :])\n",
     "        bx.hist(cur_edges - np.floor(cur_edges), bins=500, range=(0, 1), histtype='step',\n",
@@ -616,7 +619,11 @@
     "    ux.set_xlabel('Pulse height')\n",
     "    ux.set_yscale('log')\n",
     "    ux.set_xlim(0, 2048)\n",
-    "    ux.set_ylim(10, 1.5*ux.get_ylim()[1])\n",
+    "    ux.set_ylim(10, 1.5*max(max_num, 10))\n",
+    "    \n",
+    "    if remi['digitizer']['discriminator'] == 'cfd':\n",
+    "        ux.text(1024, 12.5, 'No pulse height feedback for constant fraction discrimination',\n",
+    "                ha='center', va='center')\n",
     "    \n",
     "    bx.set_title('Fractional edge distributions')\n",
     "    bx.set_xlabel('Edge positions - ⌊edge positions⌋')\n",
-- 
GitLab