Belle II Software development
trg_tsim_check_warnings.py
1
8
9import basf2 as b2
10import generators as ge
11import simulation as si
12import b2test_utils as b2u
13
14
15__offending_warning = '[WARNING] Unknown bitname { module: TRGGRLProjects }'
16
17
18def steering_path():
19 main = b2.Path()
20 main.add_module('EventInfoSetter')
21 ge.add_kkmc_generator(main, 'mu-mu+')
22 si.add_simulation(main)
23 return main
24
25
26if __name__ == '__main__':
27 with b2u.clean_working_directory():
28 log_file = 'log.tmp'
29 b2.logging.log_level = b2.LogLevel.WARNING
30 b2.logging.add_file(log_file)
31 b2u.safe_process(steering_path(), max_event=1)
32 offended = False
33 with open(log_file) as log:
34 if __offending_warning in log.read():
35 offended = True
36 if offended:
37 bits = []
38 with open(log_file) as log:
39 for line in log:
40 if 'bitname =' in line:
41 bits.append(line.split(' ')[2])
42 b2.B2FATAL('Check the TRGGRLProjects module for the following undefined bits: ', ' '.join(bits))