Belle II Software  release-05-01-25
submitAll.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import glob
5 import subprocess
6 from functools import reduce
7 import argparse
8 
9 parser = argparse.ArgumentParser()
10 parser.add_argument('type', help='dqm or qam', type=str)
11 args = parser.parse_args()
12 
13 mode = args.type
14 
15 
16 def getRunList(dir):
17  files = glob.glob(dir + '*/all/dst/sub00/dst.cosmic.*.root')
18 # files = glob.glob(dir + 'run_*.root')
19  runs = []
20  # print(list)
21  for f in files:
22  run = int((f.split('/'))[-1].split('.')[3])
23  runs.append(run)
24  # print(run)
25 
26  # Remove duplicated elements, and sort them.
27  runs = sorted(list(set(runs)))
28  # print(runs)
29  return(runs)
30 
31 
32 # Experimantl number
33 exp = 1
34 # dir = '/ghi/fs01/belle2/bdata/users/karim/data/GCR1/build-2017-08-21'
35 dir = '/hsm/belle2/bdata/Data/release-00-09-01/DB00000266/GCR1/prod00000001/e{0:0>4}/cosmics/'.format(exp)
36 # dir = '/ghi/fs01/belle2/bdata/users/karim/MC/GCR1/release-00-09-02'
37 # dir = '/ghi/fs01/belle2/bdata/users/karim/data/GCR1/release-00-09-00_new'
38 # dir = '/home/belle/muchida/basf2/release/cdc/examples/performance/output'
39 
40 runs = getRunList(dir)
41 # runs = [i for i in range(4000,4200)]
42 
43 for run in runs:
44  if mode == 'dqm':
45  logfile = 'dqm.cosmic.{0:0>4}.{1:0>5}.log'.format(exp, run)
46  command = ' '.join(['basf2 CDCHistMaker.py', str(exp), str(run), '>&', logfile])
47  elif mode == 'qam':
48  logfile = 'qam.cosmic.{0:0>4}.{1:0>5}.log'.format(exp, run)
49  command = ' '.join(['basf2 QAMHistMaker.py', str(exp), str(run), '>&', logfile])
50  else:
51  print('Specify the type : dqm/qam')
52  exit(1)
53 
54  # Check submitting job list
55  # print('bsub -q s \"' + command + ' \"')
56  # Submit jobs.
57  subprocess.run(["bsub", "-q", "l", command])