Belle II Software development
test_low_multiplicity_sorcery.py
1
8
9'''Test for checking if the low_multiplicity_sorcery package works.'''
10
11import basf2 as b2
12import b2test_utils as b2tu
13import low_multiplicity_sorcery as lms
14
15
16def run_lms_generation(event_codes):
17 '''Create and process a path where lms.add_generators is used.'''
18 with b2tu.clean_working_directory():
19 n_events = 10000 if event_code is lms.EventCodes_llXX else 500
20 b2.set_random_seed('lms')
21 main = b2.Path()
22 main.add_module('EventInfoSetter')
23 lms.add_generators(path=main, event_codes=event_codes)
24 b2.process(main, n_events)
25 print(b2.statistics)
26
27
28# Check if llXX and hhISR productions work fine.
29for event_code in [lms.EventCodes_llXX, lms.EventCodes_hhISR]:
30 b2.B2INFO(f'Running the test for {"llXX" if event_code is lms.EventCodes_llXX else "hhISR"}')
31 return_code = b2tu.run_in_subprocess(target=run_lms_generation, event_codes=event_code)
32 if return_code != 0:
33 b2.B2FATAL(f'low_multiplicity_sorcery fails when generating {"llXX" if event_code is lms.EventCodes_llXX else "hhISR"}')