Belle II Software  release-08-01-10
full_calib.py
1 
8 import os
9 import subprocess
10 import glob
11 import shutil
12 # import ndf_and_pval
13 
14 col = 'submit_collector.py'
15 algo = {'t0': ['t0_cal_algo.py', 'histT0.root'],
16  'xt': ['xt_cal_algo.py', 'histXT.root'],
17  'sigma': ['space_reso_cal_algo.py', 'histSigma.root'],
18  'tw': ['time_walk_cal_algo.py', 'histTW.root']
19  }
20 
21 if os.path.exists('calib_result') is False:
22  os.mkdir('calib_result')
23 
24 seq = ['t0', 't0', 't0', 't0', 't0', 't0', 't0', 't0',
25  'xt', 'sigma', 'xt', 'sigma',
26  'tw', 't0']
27 
28 nSeq = len(seq)
29 # print(nSeq)
30 # sys.exit()
31 
32 # t0
33 for i, s in enumerate(seq):
34  command = ' '.join(['basf2', col, '0.00001']) if i < 2 else ' '.join(['basf2 ', col, '0.001'])
35  print(command)
36  subprocess.run(command, shell=True)
37 
38  dlist = glob.glob('rootfile/*/centraldb')
39  # Delete centraldb cache
40  for d in dlist:
41  # print(d)
42  shutil.rmtree(d)
43  command_alg = ' '.join(['basf2', algo[s][0]])
44  print(command_alg)
45  subprocess.run(command_alg, shell=True)
46  cdir = '/'.join(['calib_result', str(i)])
47  os.mkdir(cdir)
48  hist = algo[s][1]
49  if os.path.exists('rootfile') is True:
50  shutil.move('rootfile', cdir)
51  if os.path.exists(hist) is True:
52  shutil.move(hist, cdir)
53 
54 
55 # final reconstruction after all calibration
56 command = ' '.join(['basf2 ', col, '0.001'])
57 print(command)
58 subprocess.run(command, shell=True)
59 cdir = '/'.join(['calib_result', str(nSeq)])
60 os.mkdir(cdir)
61 if os.path.exists('rootfile') is True:
62  shutil.move('rootfile', cdir)
63 
64 # ndf_and_pval.plot()