9 |
|
print sys.argv[0]+" [options]" |
10 |
|
print "This script makes a pkl file from TMD rate predictions\nto be used in the RatePredictor script for new menu deployment" |
11 |
|
print "--TriggerList=<path>" |
12 |
+ |
print "--NColBunch=<# colliding bunches>" |
13 |
|
|
14 |
|
def main(): |
15 |
|
print "making TMD pkl fit files" |
19 |
|
fit_file="fits_TMD.pkl" |
20 |
|
|
21 |
|
####################################### |
22 |
< |
|
22 |
> |
|
23 |
> |
ncolbunch=28 |
24 |
> |
ntotbunch=1331 |
25 |
> |
bunfrac=float(ncolbunch)/float(ntotbunch) |
26 |
> |
|
27 |
> |
####################################### |
28 |
|
try: |
29 |
< |
opt, args = getopt.getopt(sys.argv[1:],"",["TriggerList="]) |
29 |
> |
opt, args = getopt.getopt(sys.argv[1:],"",["NColBunch=","TriggerList="]) |
30 |
|
|
31 |
|
except getopt.GetoptError, err: |
32 |
|
print str(err) |
36 |
|
trig_list=[] |
37 |
|
fit_list={} |
38 |
|
for o,a in opt: |
39 |
< |
if o == "--TriggerList": |
39 |
> |
if o == "--NColBunch": |
40 |
> |
ncolbunch=int(a) |
41 |
> |
ntotbunch=1331 |
42 |
> |
bunfrac=float(ncolbunch)/float(ntotbunch) |
43 |
> |
elif o == "--TriggerList": |
44 |
|
try: |
45 |
|
f = open(a) |
46 |
|
for line in f: |
50 |
|
if len(line)<3 or line=='\n': |
51 |
|
continue |
52 |
|
line = ((line.rstrip('\n')).rstrip(' ')) |
53 |
< |
if line.find(':')==-1: # exclude list, no rate estimates |
53 |
> |
if line.find(':')==-1: |
54 |
|
list.append( line ) |
55 |
+ |
|
56 |
|
else: |
57 |
|
split = line.split(':') |
58 |
|
##trig_list.append([split[0],split[1],split[2],split[3]]) |
59 |
|
trig_list.append(split[0]) |
60 |
< |
fit_list[split[0]]=[float(split[1]),float(split[2]),float(split[3])] |
60 |
> |
fit_list[split[0]]=[float(split[1])*bunfrac,float(split[2])*bunfrac,float(split[3])*bunfrac] |
61 |
|
|
62 |
|
|
63 |
|
|