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