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