Belle II Software development
collector_execution.py
1
8import os
9import subprocess
10import sys
11
12from hlt.clean_execution import CleanBasf2Execution
13from argparse import ArgumentParser
14
15
16def main(script_name):
17 """Shortcut method to do the basf2 execution on hltout"""
18 os.chdir(sys.path[0])
19
20 parser = ArgumentParser()
21 parser.add_argument("input_ring_buffer", help="Name of the input ring buffer")
22 parser.add_argument("output_ring_buffer", help="Name of the output ring buffer")
23 parser.add_argument("unused-histoport", help="Unused in the moment")
24 parser.add_argument("--number-of-collectors", help="Number of collectors to start", default=3, type=int)
25
26 args = parser.parse_args()
27
28 input_ring_buffer_list = [f"{args.input_ring_buffer}{i + 1}" for i in range(0, args.number_of_collectors)]
29 output_ring_buffer_list = [f"{args.output_ring_buffer}{i + 1}" for i in range(0, args.number_of_collectors)]
30 message_queue_list = [f"/roi{i}" for i in range(0, args.number_of_collectors)]
31
32 for input_rb in input_ring_buffer_list:
33 subprocess.run(["removerb", input_rb])
34 for output_rb in output_ring_buffer_list:
35 subprocess.run(["removerb", output_rb])
36
37 execution = CleanBasf2Execution()
38 try:
39 execution.start(["hlt_rb2mrb", args.input_ring_buffer] + input_ring_buffer_list)
40 execution.start(["hlt_mrb2rb"] + output_ring_buffer_list + [args.output_ring_buffer])
41 for input_rb, output_rb, roi_message_queue in zip(input_ring_buffer_list, output_ring_buffer_list,
42 message_queue_list):
43 execution.start(["basf2", "--no-stats", script_name, "--", input_rb, output_rb, roi_message_queue])
44 return_code = execution.wait()
45 finally:
46 execution.kill()
47 subprocess.run(["framework-pcore-clear_ipcs"])
48 for input_rb in input_ring_buffer_list:
49 subprocess.run(["removerb", input_rb])
50 for output_rb in output_ring_buffer_list:
51 subprocess.run(["removerb", output_rb])
52
53 exit(return_code)
Definition: main.py:1