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