Belle II Software  light-2309-munchkin
check_overlaps.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """
13 Check if the Belle II geometry has some overlaps.
14 """
15 
16 import b2test_utils as b2tu
17 import basf2 as b2
18 import subprocess
19 
20 
21 with b2tu.clean_working_directory():
22 
23  overlap_checker = b2.find_file('geometry/examples/check_geometry.py')
24  try:
25  output = subprocess.check_output(['basf2', overlap_checker, '100'], encoding='utf-8')
26  except subprocess.CalledProcessError as error:
27  output = error.output
28 
29  good_string = 'Checking overlaps for volume'
30  error_string = '[ERROR] Overlap'
31 
32  if error_string in output:
33  errors = [e for e in output.splitlines() if not e.startswith(good_string)]
34  print('\n'.join(errors))
35  b2.B2FATAL('There are overlaps in the geometry. '
36  f'Please run the script {overlap_checker} and fix them.')