Belle II Software development
goall_SAD.py
1
8import os
9
10# run as "python beast/scripts/phase2/goall_SAD.py" from the main directory
11
12# == que list ==
13# s <6h
14# l <48h
15# b_a <48h
16# b_l <720h
17
18
19phase = '2' # geometry for phase2
20outdir_base = '/group/belle2/BGcampaigns/g4sim/' # output base directory
21outdir_sub = 'phase2.1.4_collimators_1_upd' # output sub directory
22
23fileSAD = 'phase2.1.4_collimators_1_upd' # sad filename from /group/belle2/BGcampaigns/SAD/forG4/
24# check the directory for existing SAD samples
25# 28.2.2019
26# early_phase3_1_step5, early phase 3; use 31 for phase!
27# phase2.1.7_Touschek_step5
28# phase2.1.3_june_Touschek_EM_0
29# phase2.1.3_june_Touschek_EM_1
30# phase2.1.3_june_Touschek_EM_2
31# phase2.1.4_collimators_1_upd ; should be same as phase2.1.3_june_Touschek_EM_0
32
33outdir = outdir_base + outdir_sub
34
35bkgs = ['Touschek LER', 'Coulomb LER', 'Brems LER', 'Touschek HER', 'Coulomb HER', 'Brems HER'] # bacground types
36
37bkgs_flag = [1, 1, 1, 1, 1, 1] # skip backgrounds with flag 0
38
39time = [500, 500, 10000, 1000, 1000, 10000] # simulation time in us (per job)
40
41files = 400 # number of jobs to be commited for each background type
42
43q = ['l', 'l', 's', 's', 's', 's'] # queue for jobs of given background
44
45i = 0
46skp = 0
47for f in bkgs:
48 if bkgs_flag[i] != 1:
49 i += 1
50 continue
51 if not os.path.isdir(outdir):
52 os.mkdir(outdir)
53 print("Made directory " + outdir)
54 if not os.path.isdir(outdir + '/output'):
55 os.mkdir(outdir + '/output')
56 print("Made directory " + outdir + '/output')
57 if not os.path.isdir(outdir + '/log'):
58 os.mkdir(outdir + '/log')
59 print("Made directory " + outdir + '/log')
60 for ifile in range(0, files):
61 logname = f + '_' + str(ifile) + '.log'
62 logname = "_".join(logname.split())
63 com = 'bsub -q ' + q[i] + ' -o /dev/null \"basf2 beast/scripts/phase2/generateSADBg.py ' + f + ' ' + str(time[i]) + ' ' + \
64 str(ifile) + ' study ' + phase + ' ' + fileSAD + ' ' + outdir + '/output/ >& ' + outdir + '/log/' + logname + '\"'
65# test locally
66# com = 'basf2 beast/scripts/phase2/generateSADBg.py ' + f + ' ' + str(time[i]) + ' ' + str(ifile) + ' study ' + phase + \
67# ' ' + fileSAD + ' ' + outdir + '/output/'
68 print(com)
69 if os.path.isfile(outdir + '/log/' + logname) and skp == 0:
70 answ = input("Output file already exists. Overwrite for all (y), skip existing (n): ")
71 if answ == 'y':
72 skp = 2
73 elif answ == 'n':
74 skp = 1
75 else:
76 continue
77 if skp == 1:
78 print("Skipped!")
79 continue
80 os.system(com)
81 i += 1