ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/AddTableInfo_db.py
Revision: 1.26
Committed: Sat Apr 14 09:47:09 2012 UTC (13 years ago) by grchrist
Content type: text/x-python
Branch: MAIN
CVS Tags: V00-00-31, V00-00-30, V00-00-29
Changes since 1.25: +1 -0 lines
Log Message:
100% deadtime problem patched in HLT rates

File Contents

# User Rev Content
1 amott 1.1 import sys
2     from colors import *
3     from DatabaseParser import *
4 amott 1.12 from termcolor import colored, cprint
5 amott 1.1 write = sys.stdout.write
6    
7 amott 1.12 NHighExpress=0
8 grchrist 1.16 NHighStreamA=0
9 amott 1.12
10 amott 1.13 def MoreTableInfo(parser,LumiRange,config,isCol=True):
11 amott 1.14 print "Monitoring Run %d" % (parser.RunNumber,)
12 grchrist 1.25 print "len=",len(LumiRange)
13 grchrist 1.26 print "LSRange=", LumiRange
14 grchrist 1.23 if len(LumiRange)>0:
15 grchrist 1.25
16 grchrist 1.23 [AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
17 grchrist 1.24 deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange)*100
18     ##print "dtba=",deadtimebeamactive
19 grchrist 1.23 else:
20     print "no lumisections to monitor"
21     return
22 amott 1.13 try:
23     LastPSCol = PSCols[-1]
24     except:
25     LastPSCol = -1
26 grchrist 1.19 if isCol:
27 amott 1.13
28 grchrist 1.19 aRates = parser.GetTriggerRatesByLS("AOutput")
29     else:
30     if len(parser.GetTriggerRatesByLS("AOutput"))>0:
31     aRates = parser.GetTriggerRatesByLS("AOutput")
32     else:
33     aRates = parser.GetTriggerRatesByLS("AForPPOutput")
34    
35    
36 amott 1.13 expressRates = {}
37     if isCol:
38     expressRates = parser.GetTriggerRatesByLS("ExpressOutput")
39     else:
40 grchrist 1.19 if len(parser.GetTriggerRatesByLS("ExpressOutput"))>0:
41     expressRates=parser.GetTriggerRatesByLS("ExpressOutput")
42     else:
43     expressRates = parser.GetTriggerRatesByLS("ExpressForCosmicsOutput")
44 amott 1.12 ExpRate=0
45     PeakRate=0
46 amott 1.13 AvgExpRate=0
47 grchrist 1.15
48 amott 1.13 ARate=0
49 grchrist 1.15 PeakRateA=0
50     AvgRateA=0
51    
52 amott 1.13 if len(expressRates.values()) > 20:
53     AvgExpRate = sum(expressRates.values())/len(expressRates.values())
54    
55 amott 1.12 for ls in LumiRange: ## Find the sum and peak express stream rates
56     thisR = expressRates.get(ls,0)
57     ExpRate+=thisR
58     if thisR>PeakRate:
59     PeakRate=thisR
60 grchrist 1.15
61     thisRateA=aRates.get(ls,0)
62     ARate+=thisRateA
63     if thisRateA>PeakRateA:
64     PeakRateA=thisRateA
65    
66     #ARate+=aRates.get(ls,0)
67     ## Print Stream A Rate --moved see below
68     ##print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
69 amott 1.12
70 amott 1.13 Warn = False
71 amott 1.12
72 grchrist 1.15 ##########################################
73 amott 1.12 ## Check if the express stream is too high
74 grchrist 1.15 ##########################################
75 amott 1.12 global NHighExpress
76     badExpress = ExpRate/len(LumiRange) > config.MaxExpressRate ## avg express stream rate too high?
77 grchrist 1.16 baseText = "\nCurrent Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display
78 amott 1.12 if badExpress:
79     text = colored(baseText,'red',attrs=['reverse']) ## bad, make the text white on red
80     NHighExpress+=1 ## increment the bad express counter
81     else:
82     text = baseText
83     NHighExpress=0
84    
85     write(text)
86     if badExpress:
87 grchrist 1.21 if len(LumiRange)>1:
88 grchrist 1.20 if (ExpRate-PeakRate)/(len(LumiRange)-1) <=config.MaxExpressRate: ## one lumisection causes this
89     write(" << This appears to be due to a 1 lumisection spike, please monitor\n")
90     else:
91     if NHighExpress > 1: # big problem, call HLT DOC
92     write(colored(" << WARNING: Current Express rate is too high!",'red',attrs=['reverse']) )
93     Warn = True
94 amott 1.13
95     # if AvgExpRate > config.MaxExpressRate:
96     # write( colored("\n\nWARNING: Average Express Stream Rate is too high (%0.1f Hz) << CALL HLT DOC" % AvgExpRate,'red',attrs=['reverse']) )
97     # Warn = True
98 grchrist 1.20
99    
100 grchrist 1.15
101    
102     #########################################
103     ##Check if Stream A is too high
104     #########################################
105     global NHighStreamA
106     badStreamA =ARate/len(LumiRange) > config.MaxStreamARate ##Cosmics Express Rate 300 Hz max
107     baseTextA= "\nCurrent Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
108     if badStreamA:
109 grchrist 1.16 textA=colored(baseTextA,'red',attrs=['reverse']) ## bad, make the text white on red
110 grchrist 1.15 NHighStreamA+=1
111     else:
112     textA=baseTextA
113     NHighStreamA=0
114    
115     write(textA)
116     if badStreamA:
117 grchrist 1.20 if len(LumiRange)>1:
118     if (ARate-PeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this
119     write(" << This appears to be due to a 1 lumisection spike, please monitor\n")
120     else:
121     if NHighStreamA >1: ##Call HLT doc!
122     write(colored(" << WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) )
123     Warn = True
124 amott 1.13 write("\n\n")
125 grchrist 1.15
126     ######################################
127     ##Warning for HLT doc
128     ######################################
129 amott 1.13 if Warn: ## WARNING
130     rows, columns = os.popen('stty size', 'r').read().split() ## Get the terminal size
131     cols = int(columns)
132     write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) )
133     line = "*" + " "*int((cols-22)/2)+"CALL HLT DOC (165575)"+" "*int((cols-23)/2)+"*\n"
134 amott 1.12
135 amott 1.13 write( colored(line,'red',attrs=['reverse','blink']) )
136     write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) )
137 amott 1.12
138 grchrist 1.17
139 amott 1.1 PrescaleColumnString=''
140 abrinke1 1.10 PSCols = list(set(PSCols))
141 amott 1.1 for c in PSCols:
142     PrescaleColumnString = PrescaleColumnString + str(c) + ","
143    
144 amott 1.13 if isCol:
145     write("The average instantaneous lumi of these lumisections is: ")
146     write(str(round(AvInstLumi,1))+"e30\n")
147     write("The delivered lumi of these lumi sections is: ")
148     write(str(round(len(LumiRange)*AvDeliveredLumi,1))+"e30"+"\n")
149     write("The live (recorded) lumi of these lumi sections is: ")
150     write(str(round(len(LumiRange)*AvLiveLumi,1))+"e30\n\n")
151     write("The average deadtime of these lumi sections is: ")
152 grchrist 1.17 if deadtimebeamactive > 5:
153 amott 1.13 write(bcolors.FAIL)
154 grchrist 1.17 elif deadtimebeamactive > 10:
155 amott 1.13 write(bcolors.WARNING)
156     else:
157     write(bcolors.OKBLUE)
158 grchrist 1.17 write(str(round(deadtimebeamactive,2))+"%")
159 amott 1.13 write(bcolors.ENDC+"\n")
160 amott 1.1
161 amott 1.3 print "Used prescale column(s): "+str(PrescaleColumnString)
162 amott 1.4 write("Lumisections: ")
163 amott 1.3 if not isSequential(LumiRange):
164 amott 1.4 write(str(LumiRange)+" Lumisections are not sequential (bad LS skipped)\n")
165     else:
166     write("%d - %d\n" % (min(LumiRange),max(LumiRange),))
167 grchrist 1.23 ##print "\nLast Lumisection of the run is: "+str(parser.GetLastLS())
168     write( "\nLast Lumisection good where DAQ is active is: "+str(parser.GetLastLS(isCol)) )
169 grchrist 1.19 ##write( "Last Lumisection where DAQ is active is: "+str(parser.GetLastLS(True)) )
170 amott 1.12 write("\n\n\n")
171 amott 1.5
172 grchrist 1.22 ## if isCol:
173     ## L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi)
174     ## if len(L1RatePredictions):
175     ## print "Expected Level 1 Rates:"
176     ## for key,val in L1RatePredictions.iteritems():
177     ## write("Prescale Column "+str(key)+": "+str(round(val/1000,1))+" kHz")
178     ## if key == LastPSCol:
179     ## write(' << taking data in this column')
180     ## write('\n')
181 amott 1.6
182 amott 1.5
183 amott 1.3
184     def isSequential(t):
185     try:
186     if len(t)<2:
187     return True
188     except:
189     return True
190     for i,e in enumerate(t[1:]):
191     if not abs(e-t[i])==1:
192     return False
193     return True