diff --git a/src/km3io/tools.py b/src/km3io/tools.py index ae6b015fe0c7da409c8f84d776dab02b241af522..30e32c7c2e0bdc5591229ecf344ce04a4ac241ae 100644 --- a/src/km3io/tools.py +++ b/src/km3io/tools.py @@ -556,3 +556,13 @@ def get_w2list_idx(f): sim_program = f.header.simul.program.lower() return w2s_idx.get(sim_program) + +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 5cad5ffa48eacf2f08179b38fcd7d56e3e4916f6..c55cf6fecf52fc0b039a5faecb4124cdcec9ec61 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)), + )