Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill r1 event type also for old data #205

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 @@
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

Check warning on line 1150 in src/ctapipe_io_lst/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/ctapipe_io_lst/__init__.py#L1150

Added line #L1150 was not covered by tests
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
Loading