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