Skip to content

Commit

Permalink
Merge pull request #192 from cta-observatory/assign_tel_ids
Browse files Browse the repository at this point in the history
Simplify reassignment of tel_ids.
  • Loading branch information
aleberti authored Feb 16, 2024
2 parents ce8fd32 + b02998a commit f51075b
Showing 1 changed file with 16 additions and 34 deletions.
50 changes: 16 additions & 34 deletions magicctapipe/scripts/lst1_magic/magic_calib_to_dl1.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,46 +358,28 @@ def magic_calib_to_dl1(
n_islands=n_islands,
)

tel_ids_new_assignments = {
1: assigned_tel_ids["MAGIC-I"],
2: assigned_tel_ids["MAGIC-II"],
3: assigned_tel_ids["LST-1"],
}

# Reset the telescope IDs
if tel_id == 1:
event_info.tel_id = assigned_tel_ids["MAGIC-I"] # MAGIC-I

elif tel_id == 2:
event_info.tel_id = assigned_tel_ids["MAGIC-II"] # MAGIC-II

# M1+M2 trigger
if event.trigger.tels_with_trigger == [1, 2]:
tels_with_trigger_magic_lst = [
assigned_tel_ids["MAGIC-I"],
assigned_tel_ids["MAGIC-II"],
]
# M2+LST1 trigger
elif event.trigger.tels_with_trigger == [2, 3]:
tels_with_trigger_magic_lst = [
assigned_tel_ids["LST-1"],
assigned_tel_ids["MAGIC-II"],
]
# M1+LST1 trigger
elif event.trigger.tels_with_trigger == [1, 3]:
tels_with_trigger_magic_lst = [
assigned_tel_ids["LST-1"],
assigned_tel_ids["MAGIC-I"],
]
# M1+M2+LST1 trigger
elif event.trigger.tels_with_trigger == [1, 2, 3]:
tels_with_trigger_magic_lst = [
assigned_tel_ids["LST-1"],
assigned_tel_ids["MAGIC-I"],
assigned_tel_ids["MAGIC-II"],
]
event_info.tel_id = tel_ids_new_assignments[tel_id]

# encode tels_with_trigger as an int value
# that can be decoded later as a binary
# tels_with_trigger = sum_{tel_id} 2**tel_id
# where tel_id is only for those triggered
tels_with_trigger_binary_int = np.array(
[2 ** (tel_id) for tel_id in tels_with_trigger_magic_lst]
).sum()
tels_with_trigger_binary_int = np.sum(
2
** np.array(
[
tel_ids_new_assignments[tel_idx]
for tel_idx in event.trigger.tels_with_trigger
]
)
)

event_info.tels_with_trigger = tels_with_trigger_binary_int

Expand Down

0 comments on commit f51075b

Please sign in to comment.