Belle II Software development
full_calib.py
1
8import os
9import subprocess
10import glob
11import shutil
12# import ndf_and_pval
13
14col = 'submit_collector.py'
15algo = {'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
21if os.path.exists('calib_result') is False:
22 os.mkdir('calib_result')
23
24seq = ['t0', 't0', 't0', 't0', 't0', 't0', 't0', 't0',
25 'xt', 'sigma', 'xt', 'sigma',
26 'tw', 't0']
27
28nSeq = len(seq)
29# print(nSeq)
30# sys.exit()
31
32# t0
33for 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
56command = ' '.join(['basf2 ', col, '0.001'])
57print(command)
58subprocess.run(command, shell=True)
59cdir = '/'.join(['calib_result', str(nSeq)])
60os.mkdir(cdir)
61if os.path.exists('rootfile') is True:
62 shutil.move('rootfile', cdir)
63
64# ndf_and_pval.plot()