Skip to content
Snippets Groups Projects
Commit d0681f28 authored by ViaFerrata's avatar ViaFerrata
Browse files

Small bugfix for run_id readout and check for particle type.

parent 5430773f
No related branches found
No related tags found
No related merge requests found
......@@ -294,9 +294,13 @@ def get_file_particle_type(event_pump):
file_particle_type = 'undefined'
else:
particle_type = event_pump[0]['McTracks'].type
if np.abs(particle_type) == 13:
# if mupage file: first mc_track is an empty neutrino track, second track is the first muon
if particle_type[0] == 0 and np.abs(particle_type[1]) == 13:
file_particle_type = 'muon'
elif np.abs(particle_type) in [12, 14, 16]:
# the first mc_track is the primary neutrino if the input file is containing neutrino events
elif np.abs(particle_type[0]) in [12, 14, 16]:
file_particle_type = 'neutrino'
else:
raise ValueError('The type of the particles in the "McTracks" folder, <', str(particle_type), '> is not known.')
......
......@@ -132,10 +132,19 @@ def get_tracks(event_blob, file_particle_type, event_hits, prod_ident):
"""
# parse EventInfo and Header information
event_id = event_blob['EventInfo'].event_id[0]
if 'Header' in event_blob: # if Header exists in file, take run_id from it. Else take it from RawHeader.
# the run_id info in the EventInfo group is broken for ORCA neutrino and mupage files
# The Header run_id is the most reliable one.
if 'Header' in event_blob: # if Header exists in file, take run_id from it.
run_id = event_blob['Header'].start_run.run_id.astype('float32')
else:
run_id = event_blob['RawHeader'][0][0].astype('float32')
if file_particle_type == 'muon':
run_id = event_blob['RawHeader'][1][0].astype('float32')
elif file_particle_type == 'undefined': # currently used with random_noise files
run_id = event_blob['EventInfo'].run_id
else:
run_id = event_blob['RawHeader'][0][0].astype('float32')
# collect all event_track information, dependent on file_particle_type
......
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