-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add software basic trigger structure and test
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from ctapipe.containers import ArrayEventContainer | ||
|
||
|
||
def test_softare_trigger(subarray_prod5_paranal): | ||
from ctapipe.instrument.trigger import SoftwareTrigger | ||
|
||
subarray = subarray_prod5_paranal | ||
trigger = SoftwareTrigger( | ||
subarray=subarray, | ||
min_telescopes=2, | ||
min_telescopes_by_type=[ | ||
("type", "*", 1), | ||
("type", "LST*", 2), | ||
], | ||
) | ||
|
||
# only one telescope, no SWAT | ||
event = ArrayEventContainer() | ||
event.trigger.tels_with_trigger = [5] | ||
assert trigger(event) == False | ||
assert event.trigger.tels_with_trigger == [] | ||
|
||
# 1 LST + 1 MST, 1 LST would not have triggered LST hardware trigger | ||
# and after LST is removed, we only have 1 telescope, so no SWAT either | ||
event = ArrayEventContainer() | ||
event.trigger.tels_with_trigger = [1, 6] | ||
assert trigger(event) == False | ||
assert event.trigger.tels_with_trigger == [] | ||
|
||
# two MSTs and 1 LST, -> remove single LST | ||
event = ArrayEventContainer() | ||
event.trigger.tels_with_trigger = [1, 5, 6] | ||
assert trigger(event) == True | ||
assert event.trigger.tels_with_trigger == [5, 6] | ||
|
||
# two MSTs, nothing to change | ||
event = ArrayEventContainer() | ||
event.trigger.tels_with_trigger = [5, 6] | ||
assert trigger(event) == True | ||
assert event.trigger.tels_with_trigger == [5, 6] | ||
|
||
# three LSTs, nothing to change | ||
event = ArrayEventContainer() | ||
event.trigger.tels_with_trigger = [1, 2, 3] | ||
assert trigger(event) == True | ||
assert event.trigger.tels_with_trigger == [1, 2, 3] | ||
|
||
# thee LSTs, plus MSTs, nothing to change | ||
event = ArrayEventContainer() | ||
event.trigger.tels_with_trigger = [1, 2, 3, 5, 6, 7] | ||
assert trigger(event) == True | ||
assert event.trigger.tels_with_trigger == [1, 2, 3, 5, 6, 7] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from ctapipe.containers import ArrayEventContainer | ||
from ctapipe.core import TelescopeComponent | ||
from ctapipe.core.traits import Integer, IntTelescopeParameter | ||
|
||
|
||
class SoftwareTrigger(TelescopeComponent): | ||
|
||
min_telescopes = Integer( | ||
default_value=1, | ||
help=( | ||
"Minimum number of telescopes required globally." | ||
" Events with fewer telescopes will be filtered out completely." | ||
), | ||
).tag(config=True) | ||
|
||
min_telescopes_by_type = IntTelescopeParameter( | ||
default_value=1, | ||
help=( | ||
"Minimum number of telescopes required for a specific type." | ||
" In events with fewer telescopes of a given type" | ||
" , those telescopes will be removed from the array event." | ||
" This might result in the event not fullfilling ``min_telescopes`` anymore" | ||
" and thus being filtered completely." | ||
), | ||
).tag(config=True) | ||
|
||
def __call__(self, event: ArrayEventContainer) -> bool: | ||
return True |