Belle II Software development
submitAll.py
1#!/usr/bin/env python3
2
3
10
11import glob
12import subprocess
13from functools import reduce
14
15'''
16Simple script submitting jobs to process all data.
17Usage:
18basf2 submitAll.py
19'''
20
21# Experimantl number
22exp = 1
23
24# Data directory
25# GCR 2017
26dir = f'/hsm/belle2/bdata/Data/Raw/e{exp:0>4}'
27# pre GCR period
28# dir = '/ghi/fs01/belle2/bdata/group/detector/CDC/unpacked/'
29# files = glob.glob(dir + exp + '/gcr.cdc.*.root')
30
31# run lists
32# runs = [3118, 3119]
33runs = [3944, 3948, 3964, 4011, 3966, 3980, 3996, 4002, 4004, 4005]
34# runs = [3860, 3871, 3883, 3912, 3917, 3927]
35# runs = [3944, 3948, 3964, 4011, 3966,3980,3996,4002,4004,4005,
36# 3860, 3871, 3883, 3912, 3917, 3927, 3965, 3967, 3981]
37# runs = [i for i in range(3939,4020)]
38
39
40files_nested = [glob.glob(dir + f'/r{run:0>5}/sub00/cosmic.{exp:0>4}.{run:0>5}' + '.HLT1.f*.root') for run in runs]
41# flatting nested list.
42files = reduce(lambda x, y: x + y, files_nested)
43
44if not files:
45 print("No data are found.")
46 quit()
47
48for f in files:
49 input = f # input file name.
50 name = f.split('/')
51 logfile = name[-1].replace('.root', '.log') # input file name.
52 output = 'output_' + name[-1] # output file name.
53 command = ' '.join(['basf2 runReconstruction.py', input, output, '>&', logfile])
54 # Check submitting job list
55 # print('bsub -q s \"' + command + ' \"')
56 # Submit jobs.
57 subprocess.run(["bsub", "-q", "l", command])