From 7f865e4af047c8487080721f2c1adf706b4310ac Mon Sep 17 00:00:00 2001
From: Johannes Schumann <johannes.schumann@fau.de>
Date: Wed, 27 Jan 2021 21:55:13 +0100
Subject: [PATCH] Replace total event calculation by sum of flux bins

---
 km3buu/output.py | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/km3buu/output.py b/km3buu/output.py
index 605aa70..66ebca0 100644
--- a/km3buu/output.py
+++ b/km3buu/output.py
@@ -194,14 +194,9 @@ class GiBUUOutput:
 
     def _event_xsec(self, root_tupledata):
         weights = np.array(root_tupledata.weight)
-        deltaE = np.mean(self.flux_data['energy'][1:] -
-                         self.flux_data['energy'][:-1])
-        energy_min = np.min(self.flux_data["energy"])
-        energy_max = np.max(self.flux_data["energy"])
-        total_flux_events = self.flux_interpolation.integral(
-            energy_min, energy_max)
+        total_events = np.sum(self.flux_data["events"])
         n_files = len(self.root_pert_files)
-        xsec = np.divide(total_flux_events * weights, deltaE * n_files)
+        xsec = np.divide(total_events * weights, n_files)
         return xsec
 
     def w2weights(self, volume, target_density, solid_angle):
@@ -339,9 +334,7 @@ class GiBUUOutput:
 
     @property
     def generated_events(self):
-        energy_min = np.min(self.flux_data["energy"])
-        energy_max = np.max(self.flux_data["energy"])
-        return int(self.flux_interpolation.integral(energy_min, energy_max))
+        return int(np.sum(self.flux_data["events"]))
 
 
 def write_detector_file(gibuu_output,
-- 
GitLab