ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/mkTMDfits.py
(Generate patch)

Comparing UserCode/RateMonShiftTool_dev/mkTMDfits.py (file contents):
Revision 1.1 by grchrist, Tue Apr 3 12:38:40 2012 UTC vs.
Revision 1.3 by grchrist, Tue Apr 10 14:26:04 2012 UTC

# Line 9 | Line 9 | def usage():
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"
16      
17   ############# fIT FILE NAME ###########
18      
19 <    fit_file="fits_TMD.pkl"
19 >    fit_file="fits_TMD_ncolbunch%s.pkl"
20 >
21 > #######################################
22 >
23 >    ncolbunch=28
24 >    ntotbunch=1331
25 >    bunfrac=float(ncolbunch)/float(ntotbunch)
26  
27   #######################################
21    
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)
# Line 30 | Line 36 | def main():
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:
# Line 40 | Line 50 | def main():
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                      
# Line 81 | Line 92 | def main():
92          
93          OutputFit[keys]=fit_list_fortrig
94          ##print "trig=",keys, "fit pars=",fit_list_fortrig
95 +
96 +    fit_file = fit_file % (ncolbunch)
97      
98      if os.path.exists(fit_file):
99              os.remove(fit_file)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines