Commit e539edfe authored by Moritz Huetten's avatar Moritz Huetten
Browse files

Merge branch 'bugfix_singlefilereading' into 'master'

bugfix to find correct event numbers when single tel file is read

See merge request !3
parents 8c7121e6 ebadbcd1
Pipeline #68152 failed with stage
in 58 seconds
......@@ -19,6 +19,7 @@ __all__ = ['MAGICEventSource']
logger = logging.getLogger(__name__)
class MAGICEventSource(EventSource):
"""
EventSource for MAGIC calibrated data.
......@@ -657,7 +658,6 @@ class MarsRun:
def n_pedestal_events_m2(self):
return len(self.pedestal_ids['M2'])
@staticmethod
def load_events(file_list, is_mc):
"""
......@@ -980,14 +980,18 @@ class MarsRun:
A list of pairs (M1_id, M2_id) corresponding to stereo events in the run.
"""
if self.event_data['M1']['mars_meta'][0]['is_simulation'] == False:
stereo_ids = []
n_m1_events = len(self.event_data['M1']['stereo_event_number'])
n_m2_events = len(self.event_data['M2']['stereo_event_number'])
if (n_m1_events == 0) or (n_m2_events == 0):
return stereo_ids
if not self.is_mc:
data_trigger_pattern = 128
m2_data_condition = (self.event_data['M2']['trigger_pattern'] == data_trigger_pattern)
stereo_ids = []
n_m1_events = len(self.event_data['M1']['stereo_event_number'])
for m1_id in range(0, n_m1_events):
if self.event_data['M1']['trigger_pattern'][m1_id] == data_trigger_pattern:
m2_stereo_condition = (self.event_data['M2']['stereo_event_number'] ==
......@@ -1003,9 +1007,6 @@ class MarsRun:
m2_data_condition = (self.event_data['M2']['trigger_pattern'] == data_trigger_pattern)
stereo_ids = []
n_m1_events = len(self.event_data['M1']['stereo_event_number'])
for m1_id in range(0, n_m1_events):
if self.event_data['M1']['trigger_pattern'][m1_id] == data_trigger_pattern and self.event_data['M1']['stereo_event_number'][m1_id] != 0:
m2_stereo_condition = (self.event_data['M2']['stereo_event_number'] ==
......@@ -1037,14 +1038,12 @@ class MarsRun:
n_m1_events = len(self.event_data['M1']['stereo_event_number'])
n_m2_events = len(self.event_data['M2']['stereo_event_number'])
if self.event_data['M1']['mars_meta'][0]['is_simulation'] == False:
if not self.is_mc:
data_trigger_pattern = 128
m1_data_condition = self.event_data['M1']['trigger_pattern'] == data_trigger_pattern
m2_data_condition = self.event_data['M2']['trigger_pattern'] == data_trigger_pattern
for m1_id in range(0, n_m1_events):
if m1_data_condition[m1_id]:
m2_stereo_condition = (self.event_data['M2']['stereo_event_number'] ==
......@@ -1067,10 +1066,19 @@ class MarsRun:
else:
data_trigger_pattern = 1
m1_data_condition = self.event_data['M1']['trigger_pattern'] == data_trigger_pattern
m2_data_condition = self.event_data['M2']['trigger_pattern'] == data_trigger_pattern
# shortcut if only single file is loaded:
if n_m1_events == 0:
if n_m2_events > 0:
mono_ids['M2'] = np.arange(0, n_m2_events)[m2_data_condition]
return mono_ids
if n_m2_events == 0:
if n_m1_events > 0:
mono_ids['M1'] = np.arange(0, n_m1_events)[m1_data_condition]
return mono_ids
for m1_id in range(0, n_m1_events):
if m1_data_condition[m1_id]:
if self.event_data['M1']['stereo_event_number'][m1_id] == 0:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment