Skip to content

Commit 247104c

Browse files
authored
Merge pull request #235 from cta-observatory/update_swat_data
Add new swat dtype definition
2 parents 0c553fc + 65b6a4d commit 247104c

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/ctapipe_io_lst/__init__.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
CDTS_AFTER_37201_DTYPE,
4444
CDTS_BEFORE_37201_DTYPE,
4545
SWAT_DTYPE,
46+
SWAT_DTYPE_2024,
4647
DRAGON_COUNTERS_DTYPE,
4748
TIB_DTYPE,
4849
parse_tib_10MHz_counter,
@@ -592,8 +593,15 @@ def fill_lst_from_ctar1(self, zfits_event):
592593

593594
# if SWAT data are there
594595
if evt.extdevices_presence & 4:
595-
# unpack SWAT data
596-
swat = debug.swat_data.view(SWAT_DTYPE)[0]
596+
# unpack SWAT data, new, larger dtype introduced in 2024
597+
if len(debug.swat_data) == 56:
598+
swat = debug.swat_data.view(SWAT_DTYPE_2024)[0]
599+
evt.swat_event_request_bunch_id = swat["event_request_bunch_id"]
600+
evt.swat_bunch_id = swat["bunch_id"]
601+
else:
602+
# older dtype user before 2024-11-25
603+
swat = debug.swat_data.view(SWAT_DTYPE)[0]
604+
597605
evt.swat_assigned_event_id = swat["assigned_event_id"]
598606
evt.swat_trigger_id = swat["trigger_id"]
599607
evt.swat_trigger_type = swat["trigger_type"]

src/ctapipe_io_lst/anyarray_dtypes.py

+15
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@
6464
], align=True).newbyteorder('<')
6565

6666

67+
SWAT_DTYPE_2024 = np.dtype([
68+
("assigned_event_id", np.uint64),
69+
("event_request_bunch_id", np.uint64),
70+
("trigger_id", np.uint64),
71+
("bunch_id", np.uint64),
72+
("trigger_type", np.uint8),
73+
("trigger_time_s", np.uint32),
74+
("trigger_time_qns", np.uint32),
75+
("readout_requested", np.bool_),
76+
("data_available", np.bool_),
77+
("hardware_stereo_trigger_mask", np.uint16),
78+
("negative_flag", np.bool_),
79+
], align=True).newbyteorder('<')
80+
81+
6782
def parse_tib_10MHz_counter(counter):
6883
"""
6984
Convert the tib 10MHz counter to uint32

src/ctapipe_io_lst/containers.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ class LSTEventContainer(Container):
8989
ucts_num_in_bunch = Field(-1, "UCTS num in bunch (for debugging)")
9090
ucts_cdts_version = Field(-1, "UCTS CDTS version")
9191

92-
swat_assigned_event_id = Field(np.uint32(0), "SWAT assigned event id")
92+
swat_assigned_event_id = Field(np.uint64(0), "SWAT assigned event id")
93+
swat_event_request_bunch_id = Field(np.uint64(0), "SWAT event request bunch id")
94+
swat_trigger_request_id = Field(np.uint64(0), "SWAT trigger request bunch id")
9395
swat_trigger_id = Field(np.uint64(0), "SWAT trigger id")
96+
swat_bunch_id = Field(np.uint64(0), "SWAT bunch id")
9497
swat_trigger_type = Field(np.uint8(0), "SWAT trigger type")
9598
swat_trigger_time_s = Field(np.uint32(0), "SWAT trigger_time_s")
9699
swat_trigger_time_qns = Field(np.uint32(0), "SWAT trigger_time_qns")

0 commit comments

Comments
 (0)