Belle II Software  release-08-01-10
trg_tsim_check_warnings.py
1 
8 
9 import basf2 as b2
10 import generators as ge
11 import simulation as si
12 import b2test_utils as b2u
13 
14 
15 __offending_warning = '[WARNING] Unknown bitname { module: TRGGRLProjects }'
16 
17 
18 def 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 
26 if __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, 'r') as log:
34  if __offending_warning in log.read():
35  offended = True
36  if offended:
37  bits = []
38  with open(log_file, 'r') 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))