Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • simulation/km3buu
1 result
Show changes
Commits on Source (6)
......@@ -80,6 +80,36 @@ FLUX_INFORMATION_DTYPE = np.dtype([("energy", np.float64),
EVENT_TYPE = {
1: "QE",
2: "P33(1232)",
3: "P11(1440)",
4: "S11(1535)",
5: "S11(1650)",
6: "S11(2090)",
7: "D13(1520)",
8: "D13(1700)",
9: "D13(2080)",
10: "D15(1675)",
11: "G17(2190)",
12: "P11(1710)",
13: "P11(2100)",
14: "P13(1720)",
15: "P13(1900)",
16: "F15(1680)",
17: "F15(2000)",
18: "F17(1990)",
19: "S31(1620)",
20: "S31(1900)",
21: "D33(1700)",
22: "D33(1940)",
23: "D35(1930)",
24: "D35(2350)",
25: "P31(1750)",
26: "P31(1910)",
27: "P33(1600)",
28: "P33(1920)",
29: "F35(1750)",
30: "F35(1905)",
31: "F37(1950)",
32: "pi neutron-background",
33: "pi proton-background",
34: "DIS",
......@@ -171,10 +201,17 @@ W2LIST_LOOKUP = {
"TARGETZ": 16,
"VERINCAN": 17,
"LEPINCAN": 18,
"GIBUU_WEIGHT": 19
}
W2LIST_LENGTH = len(W2LIST_LOOKUP)
GIBUU_FIELDNAMES = [
'weight', 'barcode', 'Px', 'Py', 'Pz', 'E', 'evType', 'lepIn_E',
'lepIn_Px', 'lepIn_Py', 'lepIn_Pz', 'lepOut_E', 'lepOut_Px', 'lepOut_Py',
'lepOut_Pz', 'nuc_E', 'nuc_Px', 'nuc_Py', 'nuc_Pz'
]
def read_nu_abs_xsection(filepath):
"""
......@@ -436,6 +473,8 @@ class GiBUUOutput:
"""
import pandas as pd
df = ak.to_pandas(self.arrays)
if len(df) == 0:
return df
sec_df = df[df.index.get_level_values(1) == 0].copy()
sec_df.loc[:, "E"] = sec_df.lepOut_E
sec_df.loc[:, "Px"] = sec_df.lepOut_Px
......@@ -463,6 +502,8 @@ class GiBUUOutput:
else:
tmp = fobj["RootTuple"].arrays()
retval = np.concatenate((retval, tmp))
if len(retval) == 0:
retval = ak.Array(np.recarray((0,), dtype=list(zip(GIBUU_FIELDNAMES, len(GIBUU_FIELDNAMES)*[float]))))
# Calculate additional information
retval["xsec"] = self._event_xsec(retval)
retval["Bx"] = GiBUUOutput.bjorken_x(retval)
......@@ -616,6 +657,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())
......
......@@ -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)