Skip to content
Snippets Groups Projects
Commit b6444ccf authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Fix is_cc

parent 79237108
No related branches found
No related tags found
1 merge request!47Resolve "uproot4 integration"
...@@ -446,38 +446,36 @@ def is_cc(fobj): ...@@ -446,38 +446,36 @@ def is_cc(fobj):
w2list = fobj.events.w2list w2list = fobj.events.w2list
len_w2lists = ak.num(w2list, axis=1) len_w2lists = ak.num(w2list, axis=1)
if all(len_w2lists <= 7): # old nu file have w2list of len 7. # According to: https://wiki.km3net.de/index.php/Simulations/The_gSeaGen_code#Physics_event_entries
usr_names = fobj.events.mc_tracks.usr_names # the interaction types are defined as follow:
usr_data = fobj.events.mc_tracks.usr
mask_cc_flag = usr_names[:, 0] == b"cc"
inter_ID = usr_data[:, 0][mask_cc_flag]
out = ak.flatten(inter_ID == 2) # 2 is the interaction ID for CC.
else: # INTER Interaction type
if "gseagen" in program.lower(): # 1 EM
# 2 Weak[CC]
# 3 Weak[NC]
# 4 Weak[CC+NC+interference]
# 5 NucleonDecay
# According to: https://wiki.km3net.de/index.php/Simulations/The_gSeaGen_code#Physics_event_entries
# the interaction types are defined as follow:
# INTER Interaction type if all(len_w2lists <= 7): # old nu file have w2list of len 7.
# 1 EM # Checking the `cc` value in usr of the first mc_tracks,
# 2 Weak[CC] # which are the primary neutrinos and carry the event property.
# 3 Weak[NC] # This has been changed in 2020 to be a property in the w2list.
# 4 Weak[CC+NC+interference] # See https://git.km3net.de/common/km3net-dataformat/-/issues/23
# 5 NucleonDecay return usr(fobj.events.mc_tracks[:, 0], "cc") == 2
cc_flag = w2list[:, kw2gsg.W2LIST_GSEAGEN_CC] else:
out = cc_flag > 0 # to be tested with a newly generated nu file. # TODO: to be tested with a newly generated files with th eupdated
# w2list definitionn.
if "gseagen" in program.lower():
return w2list[:, kw2gen.W2LIST_GSEAGEN_CC] == 2
if "genhen" in program.lower(): if "genhen" in program.lower():
cc_flag = w2list[:, kw2gen.W2LIST_GENHEN_CC] return w2list[:, kw2gen.W2LIST_GENHEN_CC] == 2
out = cc_flag > 0
else: else:
raise NotImplementedError( raise NotImplementedError(
f"don't know how to determine the CC-ness of {program} files." f"don't know how to determine the CC-ness of {program} files."
) )
return out
def usr(objects, field): def usr(objects, field):
"""Return the usr-data for a given field. """Return the usr-data for a given field.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment