From ca4645664a3aec5f67fe2ce82803ab66ee5bbbd0 Mon Sep 17 00:00:00 2001 From: Manu Le Guirriec <eleguirriec@km3net.de> Date: Fri, 24 Jun 2022 16:22:23 +0000 Subject: [PATCH] Create a tool to check nanobeacon flag in trigger mask --- src/km3io/tools.py | 11 +++++++++++ tests/test_tools.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/km3io/tools.py b/src/km3io/tools.py index c684219..c2d8a82 100644 --- a/src/km3io/tools.py +++ b/src/km3io/tools.py @@ -536,3 +536,14 @@ def is_3dmuon(trigger_mask): A value or an array of the trigger_mask, either of an event, or a hit. """ return is_bit_set(trigger_mask, ktrg.JTRIGGER3DMUON) + + +def is_nanobeacon(trigger_mask): + """Returns True if the trigger mask contains the nano-beacon flag. + + Parameters + ---------- + trigger_mask : int or array(int) + A value or an array of the trigger_mask, either of an event, or a hit. + """ + return is_bit_set(trigger_mask, ktrg.JTRIGGERNB) diff --git a/tests/test_tools.py b/tests/test_tools.py index 5cad5ff..c55cf6f 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -31,6 +31,7 @@ from km3io.tools import ( is_3dshower, is_mxshower, is_3dmuon, + is_nanobeacon, ) OFFLINE_FILE = OfflineReader(data_path("offline/km3net_offline.root")) @@ -642,3 +643,13 @@ class TestTriggerMaskChecks(unittest.TestCase): [False, False, False, True, False, False, True, False, True, True], list(is_3dmuon(GENHEN_OFFLINE_FILE.events.trigger_mask)), ) + + def test_is_nanobeacon(self): + assert np.allclose( + [False, False, False, False, False, False, False, False, False, False], + list(is_nanobeacon(OFFLINE_FILE.events.trigger_mask)), + ) + assert np.allclose( + [False, False, False, False, False, False, False, False, False, False], + list(is_nanobeacon(GENHEN_OFFLINE_FILE.events.trigger_mask)), + ) -- GitLab