Skip to content

Commit

Permalink
Merge pull request #188 from cta-observatory/FF-1gain
Browse files Browse the repository at this point in the history
Check # of gains in FF events.
  • Loading branch information
moralejo authored Jun 12, 2023
2 parents a1e3db7 + 3308418 commit bf9fb19
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/ctapipe_io_lst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,12 @@ def fill_trigger_info(self, array_event):
)

trigger.event_type = self._event_type_from_trigger_bits(trigger_bits)

if trigger.event_type == EventType.FLATFIELD:
waveform = array_event.r1.tel[tel_id].waveform
if waveform is not None and waveform.ndim == 2:
self.log.warning(f'Event {array_event.index.event_id} tagged as FLATFIELD, but has only one gain!')

if trigger.event_type == EventType.UNKNOWN:
self.log.warning(f'Event {array_event.index.event_id} has unknown event type, trigger: {trigger_bits:08b}')

Expand All @@ -702,8 +708,7 @@ def tag_flatfield_events(self, array_event):
'''
tel_id = self.tel_id
waveform = array_event.r1.tel[tel_id].waveform

# needs to work for gain already selected or not

if waveform.ndim == 3:
image = waveform[HIGH_GAIN].sum(axis=1)
else:
Expand All @@ -713,16 +718,25 @@ def tag_flatfield_events(self, array_event):
n_in_range = np.count_nonzero(in_range)

looks_like_ff = n_in_range >= self.min_flatfield_pixel_fraction * image.size

if looks_like_ff:
array_event.trigger.event_type = EventType.FLATFIELD
self.log.debug(
'Setting event type of event'
f' {array_event.index.event_id} to FLATFIELD'
)
# Tag as FF only events with 2-gains waveforms: both gains are needed for calibration
if waveform.ndim == 3:
array_event.trigger.event_type = EventType.FLATFIELD
self.log.debug(
'Setting event type of event'
f' {array_event.index.event_id} to FLATFIELD'
)
else:
array_event.trigger.event_type = EventType.UNKNOWN
self.log.warning(
'Found FF-looking event that has just one gain:'
f'{array_event.index.event_id}. Setting event type to UNKNOWN'
)
elif array_event.trigger.event_type == EventType.FLATFIELD:
self.log.warning(
'Found FF event that does not fulfill FF criteria: %d',
array_event.index.event_id,
'Found FF event that does not fulfill FF criteria:'
f'{array_event.index.event_id}. Setting event type to UNKNOWN'
)
array_event.trigger.event_type = EventType.UNKNOWN

Expand Down

0 comments on commit bf9fb19

Please sign in to comment.