forked from erc-asymow/TemplateStudies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_massloop_data.py
81 lines (73 loc) · 2.73 KB
/
run_massloop_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import argparse
import os
import sys
import copy
import math
import ROOT
import time
parser = argparse.ArgumentParser(description='run')
parser.add_argument('--none', action='store_true' , help = 'none')
parser.add_argument('--dryrun', action='store_true' , help = 'dry run')
parser.add_argument('--tag', default='SmearRealistic' , help = 'algo')
parser.add_argument('--niter', dest = 'niter' , type = int, default=1, help='')
parser.add_argument('--forceIter', dest = 'forceIter' , type = int, default=-1, help='')
args = parser.parse_args()
def loop_one():
tag = args.tag
cmd_histo_iter0 = './massscales_data --lumi=51. --firstIter=-1 --lastIter=2 '+\
' --tag='+tag+' '+\
' --run=Iter0 '+\
' --nRMSforGausFit=-1 '+\
' --minNumEvents=100 --minNumEventsPerBin=30 '+\
' --minNumMassBins=4 '+\
' --rebin=2 '+\
' --fitNorm --fitWidth '+\
' --y2018 --scaleToData '
#' --useKf '
if not args.forceIter>0:
print(cmd_histo_iter0)
if not (args.dryrun or args.forceIter>0):
os.system(cmd_histo_iter0)
cmd_fit_iter0 = './massfit --nevents=1 --bias=-1 '+\
'--tag='+tag+' '+\
'--run=Iter0 '
if not args.forceIter>0:
print(cmd_fit_iter0)
if not (args.dryrun or args.forceIter>0):
os.system(cmd_fit_iter0)
cmd_resol_iter0 = './resolfit --nevents=1 --bias=-1 '+\
' --tag='+tag+' '+\
' --run=Iter0 '+\
' --maxSigmaErr=0.1 '
if not args.forceIter>0:
print(cmd_resol_iter0)
if not (args.dryrun or args.forceIter>0):
os.system(cmd_resol_iter0)
for iter in range(1, args.niter+1):
if args.forceIter>0 and iter!=args.forceIter:
continue
cmd_histo_iteri = cmd_histo_iter0.replace('--run=Iter0', '--run=Iter'+str(iter))
cmd_histo_iteri += ' --usePrevFit '+\
' --tagPrevFit='+tag+' '+\
' --runPrevFit=Iter'+str(iter-1)+' '
cmd_histo_iteri += ' --useSmearFit '+\
' --tagSmearFit='+tag+' '+\
' --runSmearFit=Iter'+str(iter-1)+' '
print(cmd_histo_iteri)
if not args.dryrun:
os.system(cmd_histo_iteri)
cmd_fit_iteri = cmd_fit_iter0.replace('--run=Iter0', '--run=Iter'+str(iter))
print(cmd_fit_iteri)
if not args.dryrun:
os.system(cmd_fit_iteri)
cmd_resol_iteri = cmd_resol_iter0.replace('--run=Iter0', '--run=Iter'+str(iter))
print(cmd_resol_iteri)
if not args.dryrun:
os.system(cmd_resol_iteri)
return
if __name__ == '__main__':
start = time.time()
print('Running on data and MC')
loop_one()
end = time.time()
print('Done', args.niter, 'iterations in', (end - start)/60., 'min.')