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