Belle II Software development
test_L1_variables_database.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12import modularAnalysis as ma
13import b2test_utils as b2tu
14
15
16output_triggers_to_test = ["ffo", "hie", "INVALID_INPUT"]
17
18
19input_triggers_to_test = ["t3_3", "ehigh", "INVALID_INPUT"]
20
21
22bits_to_test = [0, 17, 321]
23# ^ should be out of range
24
25
26def check_file(input_file_name, trigger_variables):
27 """Run the check with a quick basf2 printout for the
28 first event in ``input_file_name`` on the validation server"""
29 input_file = b2tu.require_file(input_file_name, '')
30 pa = b2.Path()
31 ma.inputMdst(input_file, path=pa)
32 ma.printVariableValues("", trigger_variables, path=pa)
33 b2tu.safe_process(pa, 10)
34
35
36def name_variables(name):
37 """List of trigger bits by name access"""
38 return f"L1PSNM({name})", f"L1FTDL({name})", f"L1Prescale({name})"
39
40
41def bit_number_variables(bit):
42 """List of trigger bits by bit number access"""
43 return f"L1PSNMBit({bit})", f"L1FTDLBit({bit})", f"L1InputBit({bit})", f"L1PSNMBitPrescale({bit})"
44
45
46if __name__ == "__main__":
47
48 # build the variables
49 trigger_variables = [name_variables(name) for name in output_triggers_to_test]
50 trigger_variables += [bit_number_variables(bit) for bit in bits_to_test]
51
52 # flatten
53 trigger_variables = [var for row in trigger_variables for var in row]
54 trigger_variables += [f"L1Input({name})" for name in input_triggers_to_test]
55 trigger_variables.sort()
56
57 # test on some files
58 b2.set_random_seed(r"\m/")
59 b2tu.configure_logging_for_tests()
60 check_file("mdst/tests/mdst-v05-00-00.root", trigger_variables)
61 # TODO: update this to check a data event when a suitable file is added