Skip to content

Commit

Permalink
Merge pull request #235 from cta-observatory/update_swat_data
Browse files Browse the repository at this point in the history
Add new swat dtype definition
  • Loading branch information
morcuended authored Nov 26, 2024
2 parents 0c553fc + 65b6a4d commit 247104c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/ctapipe_io_lst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
CDTS_AFTER_37201_DTYPE,
CDTS_BEFORE_37201_DTYPE,
SWAT_DTYPE,
SWAT_DTYPE_2024,
DRAGON_COUNTERS_DTYPE,
TIB_DTYPE,
parse_tib_10MHz_counter,
Expand Down Expand Up @@ -592,8 +593,15 @@ def fill_lst_from_ctar1(self, zfits_event):

# if SWAT data are there
if evt.extdevices_presence & 4:
# unpack SWAT data
swat = debug.swat_data.view(SWAT_DTYPE)[0]
# unpack SWAT data, new, larger dtype introduced in 2024
if len(debug.swat_data) == 56:
swat = debug.swat_data.view(SWAT_DTYPE_2024)[0]
evt.swat_event_request_bunch_id = swat["event_request_bunch_id"]
evt.swat_bunch_id = swat["bunch_id"]
else:
# older dtype user before 2024-11-25
swat = debug.swat_data.view(SWAT_DTYPE)[0]

evt.swat_assigned_event_id = swat["assigned_event_id"]
evt.swat_trigger_id = swat["trigger_id"]
evt.swat_trigger_type = swat["trigger_type"]
Expand Down
15 changes: 15 additions & 0 deletions src/ctapipe_io_lst/anyarray_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@
], align=True).newbyteorder('<')


SWAT_DTYPE_2024 = np.dtype([
("assigned_event_id", np.uint64),
("event_request_bunch_id", np.uint64),
("trigger_id", np.uint64),
("bunch_id", np.uint64),
("trigger_type", np.uint8),
("trigger_time_s", np.uint32),
("trigger_time_qns", np.uint32),
("readout_requested", np.bool_),
("data_available", np.bool_),
("hardware_stereo_trigger_mask", np.uint16),
("negative_flag", np.bool_),
], align=True).newbyteorder('<')


def parse_tib_10MHz_counter(counter):
"""
Convert the tib 10MHz counter to uint32
Expand Down
5 changes: 4 additions & 1 deletion src/ctapipe_io_lst/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ class LSTEventContainer(Container):
ucts_num_in_bunch = Field(-1, "UCTS num in bunch (for debugging)")
ucts_cdts_version = Field(-1, "UCTS CDTS version")

swat_assigned_event_id = Field(np.uint32(0), "SWAT assigned event id")
swat_assigned_event_id = Field(np.uint64(0), "SWAT assigned event id")
swat_event_request_bunch_id = Field(np.uint64(0), "SWAT event request bunch id")
swat_trigger_request_id = Field(np.uint64(0), "SWAT trigger request bunch id")
swat_trigger_id = Field(np.uint64(0), "SWAT trigger id")
swat_bunch_id = Field(np.uint64(0), "SWAT bunch id")
swat_trigger_type = Field(np.uint8(0), "SWAT trigger type")
swat_trigger_time_s = Field(np.uint32(0), "SWAT trigger_time_s")
swat_trigger_time_qns = Field(np.uint32(0), "SWAT trigger_time_qns")
Expand Down

0 comments on commit 247104c

Please sign in to comment.