diff --git a/orcasong/data_to_images.py b/orcasong/data_to_images.py index 87b12e81e5080168daaf69a32828d6b30fb66ac8..ed2202d3db38cc90eba14e47e46b9b56f0f6d62e 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 785da075b9b4a2670e07157c63c96bd7e9516758..e55265edbc598aa79bc90b030851443b2c48ac0b 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