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