From daabce223a6b6d531ae86f94b3df37e3a1777caa Mon Sep 17 00:00:00 2001
From: Michele Cascella <michele.cascella@xfel.eu>
Date: Fri, 20 Aug 2021 14:39:16 +0200
Subject: [PATCH] fixed hist double filling and cluster abs gain corr

---
 .../ePix100/Correction_ePix100_NBC.ipynb      | 25 +++----------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/notebooks/ePix100/Correction_ePix100_NBC.ipynb b/notebooks/ePix100/Correction_ePix100_NBC.ipynb
index 29afe43fa..e682ca1d4 100644
--- a/notebooks/ePix100/Correction_ePix100_NBC.ipynb
+++ b/notebooks/ePix100/Correction_ePix100_NBC.ipynb
@@ -478,23 +478,6 @@
     "Applying corrections"
    ]
   },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# if common_mode:\n",
-    "#     cmCorrectionB.debug()\n",
-    "#     cmCorrectionR.debug()\n",
-    "#     cmCorrectionC.debug()\n",
-    "#     histCalCMCor.debug()\n",
-    "\n",
-    "# if pattern_classification:\n",
-    "#     patternClassifier.debug()\n",
-    "#     histCalSECor.debug()"
-   ]
-  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -563,14 +546,12 @@
     "                data = cmCorrectionR.correct(data)\n",
     "                # COL CM\n",
     "                data = cmCorrectionC.correct(data)\n",
-    "\n",
     "                histCalCMCor.fill(data)\n",
     "\n",
     "            # relative gain correction.\n",
     "            if relative_gain:\n",
     "                data = gainCorrection.correct(data.astype(np.float32))\n",
     "\n",
-    "            histCalOffsetCor.fill(data)\n",
     "            ddset[...] = np.moveaxis(data, 2, 0)\n",
     "            \n",
     "            if pattern_classification:\n",
@@ -595,10 +576,11 @@
     "\n",
     "                data_clu[patterns != 100] = np.nan\n",
     "                histCalSECor.fill(data_clu)\n",
-    "                \n",
+    "\n",
+    "            # absolute gain correction\n",
+    "            # changes data from ADU to keV (or n. of photons)\n",
     "            if absolute_gain:\n",
     "                data = data*gain_cnst\n",
-    "                # does the following work here?\n",
     "                if photon_energy > 0:\n",
     "                    data /= photon_energy\n",
     "                histCalGainCor.fill(data)\n",
@@ -607,6 +589,7 @@
     "                    data_clu = data_clu*gain_cnst\n",
     "                    if photon_energy > 0:\n",
     "                        data_clu /= photon_energy\n",
+    "                    ddsetc[...] = np.moveaxis(data_clu, 2, 0)\n",
     "                    histCalGainCorSingles.fill(data_clu)\n",
     "\n",
     "        except Exception as e:\n",
-- 
GitLab