Skip to content

Commit

Permalink
Merge pull request #205 from cta-observatory/r1_event_type
Browse files Browse the repository at this point in the history
Fill r1 event type also for old data
  • Loading branch information
maxnoe authored Dec 5, 2023
2 parents dafb739 + c4544f3 commit 8cca1cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/ctapipe_io_lst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,9 @@ def fill_trigger_info(self, array_event):
if trigger.event_type == EventType.UNKNOWN:
self.log.warning(f'Event {array_event.index.event_id} has unknown event type, trigger: {trigger_bits:08b}')

if CTAPIPE_0_20:
array_event.r1.tel[tel_id].event_type = trigger.event_type

def tag_flatfield_events(self, array_event):
'''
Use a heuristic based on R1 waveforms to recognize flat field events
Expand Down Expand Up @@ -1139,15 +1142,19 @@ def check_interleaved_pedestal(self, array_event):
event_id = array_event.index.event_id

if event_id in self.pedestal_ids:
array_event.trigger.event_type = EventType.SKY_PEDESTAL
event_type = EventType.SKY_PEDESTAL
self.log.debug("Event %d is an interleaved pedestal", event_id)

elif array_event.trigger.event_type == EventType.SKY_PEDESTAL:
# wrongly tagged pedestal event must be cosmic, since it would
# have been changed to flatfield by the flatfield tagging if ff
array_event.trigger.event_type = EventType.SUBARRAY
event_type = EventType.SUBARRAY
self.log.debug(
"Event %d is tagged as pedestal but not a known pedestal event",
event_id,
)
else:
return

array_event.trigger.event_type = event_type
if CTAPIPE_0_20:
array_event.r1.tel[self.tel_id].event_type = event_type
5 changes: 3 additions & 2 deletions src/ctapipe_io_lst/tests/test_lsteventsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ctapipe.calib.camera.gainselection import ThresholdGainSelector

from ctapipe_io_lst.constants import LST1_LOCATION, N_GAINS, N_PIXELS_MODULE, N_SAMPLES, N_PIXELS
from ctapipe_io_lst import TriggerBits, PixelStatus
from ctapipe_io_lst import CTAPIPE_0_20, TriggerBits, PixelStatus

test_data = Path(os.getenv('LSTCHAIN_TEST_DATA', 'test_data')).absolute()
test_r0_dir = test_data / 'real/R0/20200218'
Expand Down Expand Up @@ -319,7 +319,8 @@ def test_pedestal_events(tmp_path):
else:
assert event.trigger.event_type != EventType.SKY_PEDESTAL


if CTAPIPE_0_20:
assert event.r1.tel[1].event_type == event.trigger.event_type


@pytest.mark.parametrize(
Expand Down

0 comments on commit 8cca1cb

Please sign in to comment.