Belle II Software  release-08-01-10
test_software_trigger_variables_database.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import basf2 as b2
12 import modularAnalysis as ma
13 import b2test_utils as b2tu
14 
15 
16 triggers_to_test = [
17  ("software_trigger_cut&filter&1_Estargt1_GeV_cluster_no_other_cluster_Estargt0.3_GeV",
18  "filter 1_Estargt1_GeV_cluster_no_other_cluster_Estargt0.3_GeV"),
19  ("INVALID_INPUT", "this is not a valid trigger identifier")
20 ]
21 
22 
23 def check_file(input_file_name, trigger_variables):
24  """Run the check with a quick basf2 printout for the
25  first event in ``input_file_name`` on the validation server"""
26  input_file = b2tu.require_file(input_file_name, 'validation')
27  pa = b2.Path()
28  ma.inputMdst(input_file, path=pa)
29  ma.printVariableValues("", trigger_variables, path=pa)
30  b2tu.safe_process(pa, 1)
31 
32 
33 def swtr(name):
34  """Make the string form variable name"""
35  return "SoftwareTriggerResult(%s)" % name
36 
37 
38 def swtp(name):
39  """Make the string form prescale variable name"""
40  return "SoftwareTriggerPrescaling(%s)" % name
41 
42 
43 if __name__ == "__main__":
44 
45  # build the variables
46  trigger_variables = [f(lng) for lng, _ in triggers_to_test for f in (swtr, swtp)]
47  trigger_variables += [f(shrt) for _, shrt in triggers_to_test for f in (swtr, swtp)]
48 
49  # test on some files
50  b2.set_random_seed(r"\m/")
51  b2tu.configure_logging_for_tests()
52  check_file("mdst14.root", trigger_variables)
53  # TODO: update this to check a data event when a suitable file is added