Belle II Software  release-08-01-10
reco_cdst_physics.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 '''
13 Test reconstruction of physics run.
14 '''
15 
16 import basf2
17 import b2test_utils as b2u
18 import glob
19 import os
20 import subprocess as sp
21 import multiprocessing as mp
22 import random
23 
24 if __name__ == '__main__':
25  # Skip this test if needed.
26  if 'BELLE2_VALIDATION_DATA_DIR' not in os.environ:
27  b2u.skip_test('BELLE2_VALIDATION_DATA_DIR environment variable not set, skipping the test.')
28  # First, let's check in a smart way how many cores we can use.
29  num_workers = max(int(mp.cpu_count() / (1. + os.getloadavg()[1])), 1)
30  basf2.B2INFO(f'The test will be executed using {num_workers} workers.')
31  # Then, let's run the test!
32  steering_file = basf2.find_file('reconstruction/tests/reco_cdst.py_noexec')
33  rawdata_files = glob.glob(os.environ['BELLE2_VALIDATION_DATA_DIR'] + '/rawdata/physics.*HLT?.*.root')
34  rawdata_file = random.choice(rawdata_files)
35  basf2.B2INFO(f'Running the test using {rawdata_file} as input file.')
36  assert(sp.call(['basf2', steering_file, rawdata_file, 'physics']) == 0)