From 6438abee6fe4bf4fe3fa44919db9f06f7952bda3 Mon Sep 17 00:00:00 2001
From: Johannes Schumann <johannes.schumann@fau.de>
Date: Mon, 25 Oct 2021 11:45:44 +0200
Subject: [PATCH] Add gibuu weight to an additional field in w2list

---
 km3buu/output.py            | 2 ++
 km3buu/tests/test_output.py | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/km3buu/output.py b/km3buu/output.py
index 095b157..c495ff6 100644
--- a/km3buu/output.py
+++ b/km3buu/output.py
@@ -201,6 +201,7 @@ W2LIST_LOOKUP = {
     "TARGETZ": 16,
     "VERINCAN": 17,
     "LEPINCAN": 18,
+    "GIBUU_WEIGHT": 19
 }
 
 W2LIST_LENGTH = len(W2LIST_LOOKUP)
@@ -646,6 +647,7 @@ def write_detector_file(gibuu_output,
         evt.w2list[W2LIST_LOOKUP["ICHAN"]] = event.evType
         evt.w2list[W2LIST_LOOKUP["VERINCAN"]] = 1
         evt.w2list[W2LIST_LOOKUP["LEPINCAN"]] = 1
+        evt.w2list[W2LIST_LOOKUP["GIBUU_WEIGHT"]] = event.weight
 
         # Vertex Position
         vtx_pos = np.array(geometry.random_pos())
diff --git a/km3buu/tests/test_output.py b/km3buu/tests/test_output.py
index ece49b3..3ea01d9 100644
--- a/km3buu/tests/test_output.py
+++ b/km3buu/tests/test_output.py
@@ -130,3 +130,5 @@ class TestAANET(unittest.TestCase):
         np.testing.assert_equal(evt.w2list[9], 34)
         # CC/NC
         np.testing.assert_equal(evt.w2list[10], 2)
+        # GiBUU weight
+        np.testing.assert_almost_equal(evt.w2list[19], 0.8167222969153614)
-- 
GitLab