From d0681f28e5ad460d5e43256b26c2a51df7fd3c8c Mon Sep 17 00:00:00 2001 From: ViaFerrata <michimoser@onlinehome.de> Date: Thu, 6 Dec 2018 13:53:16 +0100 Subject: [PATCH] Small bugfix for run_id readout and check for particle type. --- orcasong/data_to_images.py | 8 ++++++-- orcasong/file_to_hits.py | 13 +++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/orcasong/data_to_images.py b/orcasong/data_to_images.py index 87b12e8..ed2202d 100644 --- a/orcasong/data_to_images.py +++ b/orcasong/data_to_images.py @@ -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.') diff --git a/orcasong/file_to_hits.py b/orcasong/file_to_hits.py index 785da07..e55265e 100644 --- a/orcasong/file_to_hits.py +++ b/orcasong/file_to_hits.py @@ -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 -- GitLab