ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/ReadConfig.py
Revision: 1.2
Committed: Fri Dec 16 19:43:52 2011 UTC (13 years, 4 months ago) by grchrist
Content type: text/x-python
Branch: MAIN
CVS Tags: V00-00-04, V00-00-03, V00-00-02, V00-00-01
Changes since 1.1: +8 -0 lines
Log Message:
More integration: adeded extra table info. fixed bug in ref runs.


File Contents

# User Rev Content
1 grchrist 1.1 #!/usr/bin/env python
2     import os
3    
4     class RateMonConfig:
5    
6     def __init__(self,path='./'):
7     self.CFGfile=path+"/defaults.cfg"
8     self.BasePath=path
9     self.ReferenceRun=""
10     self.DefAllowRateDiff=0.0
11     self.DefAllowIgnoreThresh=0.0
12     self.ExcludeList=[]
13     self.MonitorList=[]
14     self.MonitorIntercept=[]
15     self.MonitorSlope=[]
16     self.MonitorQuad=[]
17     self.MonitorOnly=0
18     self.MonTargetLumi=0
19     self.FindL1Zeros=0
20     self.LSWindow=-1
21     self.CompareReference=0
22 grchrist 1.2 self.ShifterMode=0
23 grchrist 1.1
24     def ReadList(self,filename):
25     filename=self.BasePath+'/'+filename
26     list = []
27     if not os.path.exists(filename):
28     return list
29     f = open(filename)
30     for line in f:
31     if line.startswith('#'):
32     continue
33     if len(line)<3 or line=='\n':
34     continue
35     line = ((line.rstrip('\n')).rstrip(' '))
36     if line.find(':')==-1: # exclude list, no rate estimates
37     list.append( line )
38     else:
39     split = line.split(':')
40     list.append([split[0],split[1],split[2],split[3]])
41     f.close()
42     return list
43    
44     def ReadCFG(self):
45     f=open(self.CFGfile)
46     for line in f:
47     if line.startswith('#'):
48     continue
49     if len(line)<1:
50     continue
51    
52     strippedLine = line.split('#')[0]
53     strippedLine = strippedLine.rstrip('\n').rstrip(' ')
54     if strippedLine=='':
55     continue
56     tok = strippedLine.split('=')
57     par = tok[0].rstrip(' ').lstrip(' ')
58     if len(tok)>=2:
59     arg=tok[1].rstrip('\n').rstrip(' ').lstrip(' ')
60     else:
61     arg=''
62    
63     if par=="ReferenceRun":
64     self.ReferenceRun=arg
65     elif par=="DefaultAllowedRateDiff":
66     self.DefAllowRateDiff=float(arg)
67     elif par=="DefaultIgnoreThreshold":
68     self.DefAllowIgnoreThresh=float(arg)
69     elif par=="ExcludeTriggerList":
70     self.ExcludeList=self.ReadList(arg)
71     elif par=="TriggerToMonitorList":
72     tmp=self.ReadList(arg)
73     for line in tmp:
74     self.MonitorList.append(line[0])
75     self.MonitorIntercept.append(float(line[1]))
76     self.MonitorSlope.append(float(line[2]))
77     self.MonitorQuad.append(float(line[3]))
78     elif par == "MonitorOnlyListed":
79     self.MonitorOnly=int(arg)
80     elif par=="MonitorTargetLumi":
81     self.MonTargetLumi=float(arg)
82     elif par=="FindL1Zeros":
83     self.FindL1Zeros=int(arg)
84     elif par=="LSSlidingWindow":
85     self.LSWindow=int(arg)
86     elif par=="CompareReference":
87     self.CompareReference=int(arg)
88 grchrist 1.2 elif par=="ShifterMode":
89     self.ShifterMode=arg
90    
91 grchrist 1.1 else:
92     print "Invalid Option : "+strippedLine
93     f.close()
94    
95     def AnalyzeTrigger(self,TrigName): ## Have to pass this a version number stripped Trigger
96     if TrigName in self.ExcludeList:
97     return False
98     if self.MonitorOnly and not TrigName in self.MonitorList:
99     return False
100     return True
101    
102     def GetExpectedRate(self,TrigName,lumi):
103     for trig,intercept,slope,quad in zip(self.MonitorList,self.MonitorIntercept,self.MonitorSlope,self.MonitorQuad):
104     if trig==TrigName:
105 grchrist 1.2 #print "mon list",self.MonitorList
106 grchrist 1.1 if lumi:
107     return intercept + lumi*slope/1000 + lumi*lumi*quad/1000000
108     else:
109     return intercept + 3000*slope/1000 + 3000*3000*quad/1000000
110     return -1
111    
112 grchrist 1.2
113    
114