2 |
|
from colors import * |
3 |
|
from DatabaseParser import * |
4 |
|
from termcolor import colored, cprint |
5 |
+ |
from StreamMonitor import * |
6 |
+ |
import time |
7 |
+ |
|
8 |
+ |
|
9 |
|
write = sys.stdout.write |
10 |
|
|
11 |
< |
NHighExpress=0 |
12 |
< |
NHighStreamA=0 |
11 |
> |
NHighStreamA = 0 |
12 |
> |
NHighExpress = 0 |
13 |
|
|
14 |
|
def MoreTableInfo(parser,LumiRange,config,isCol=True): |
15 |
+ |
global NHighStreamA |
16 |
+ |
global NHighExpress |
17 |
|
print "Monitoring Run %d" % (parser.RunNumber,) |
18 |
< |
[AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange) |
19 |
< |
deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange) |
18 |
> |
localtime = time.asctime( time.localtime(time.time()) ) |
19 |
> |
print "Local current time :", localtime |
20 |
> |
#print "Lumisections used=", LumiRange |
21 |
> |
if len(LumiRange)>0: |
22 |
> |
|
23 |
> |
[AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange) |
24 |
> |
deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange)*100 |
25 |
> |
|
26 |
> |
##print "dtba=",deadtimebeamactive |
27 |
> |
else: |
28 |
> |
print "no lumisections to monitor" |
29 |
> |
return |
30 |
> |
## check if lumi is being filled |
31 |
> |
if parser.LastLSParsed > 4 and isCol: |
32 |
> |
if set(parser.InstLumiByLS.values()) == set([None]): |
33 |
> |
write(colored("\n\nLUMI INFORMATION NOT BEING SENT!\n",'red',attrs=['reverse'])) |
34 |
> |
write(colored("Check with Shift Leader if this is expected\n",'red',attrs=['reverse'])) |
35 |
> |
write(colored("If not, HFLUMI needs to be red-recycled\n\n\n",'red',attrs=['reverse'])) |
36 |
> |
write(colored("If in doubt, call Lumi DOC\n\n\n",'red',attrs=['reverse'])) |
37 |
> |
|
38 |
> |
try: |
39 |
> |
lograte=parser.GetTriggerRatesByLS("HLT_LogMonitor_v3") |
40 |
> |
if not len(lograte): |
41 |
> |
lograte=parser.GetTriggerRatesByLS("HLT_LogMonitor_v4") |
42 |
> |
|
43 |
> |
for ls in LumiRange: |
44 |
> |
current_lograte = lograte.get(ls,0) |
45 |
> |
lograte_sum =+ current_lograte |
46 |
> |
|
47 |
> |
lograte_average = lograte_sum/len(LumiRange) |
48 |
> |
if lograte_average > config.MaxLogMonRate: |
49 |
> |
write(bcolors.WARNING) |
50 |
> |
print "Post to elog. LogMonitor rate is high: %.2f" % (lograte_average) |
51 |
> |
write(bcolors.ENDC+"\n") |
52 |
> |
|
53 |
> |
except: |
54 |
> |
write(bcolors.WARNING) |
55 |
> |
print "problem getting log monitor rates" |
56 |
> |
write(bcolors.ENDC+"\n") |
57 |
> |
|
58 |
|
try: |
59 |
|
LastPSCol = PSCols[-1] |
60 |
|
except: |
61 |
|
LastPSCol = -1 |
18 |
– |
if isCol: |
19 |
– |
|
20 |
– |
aRates = parser.GetTriggerRatesByLS("AOutput") |
21 |
– |
else: |
22 |
– |
if len(parser.GetTriggerRatesByLS("AOutput"))>0: |
23 |
– |
aRates = parser.GetTriggerRatesByLS("AOutput") |
24 |
– |
else: |
25 |
– |
aRates = parser.GetTriggerRatesByLS("AForPPOutput") |
26 |
– |
|
62 |
|
|
63 |
|
expressRates = {} |
64 |
|
if isCol: |
68 |
|
expressRates=parser.GetTriggerRatesByLS("ExpressOutput") |
69 |
|
else: |
70 |
|
expressRates = parser.GetTriggerRatesByLS("ExpressForCosmicsOutput") |
71 |
+ |
|
72 |
|
ExpRate=0 |
73 |
|
PeakRate=0 |
74 |
|
AvgExpRate=0 |
75 |
|
|
40 |
– |
ARate=0 |
41 |
– |
PeakRateA=0 |
42 |
– |
AvgRateA=0 |
43 |
– |
|
76 |
|
if len(expressRates.values()) > 20: |
77 |
|
AvgExpRate = sum(expressRates.values())/len(expressRates.values()) |
78 |
+ |
counter=0 |
79 |
|
|
80 |
|
for ls in LumiRange: ## Find the sum and peak express stream rates |
81 |
|
thisR = expressRates.get(ls,0) |
83 |
|
if thisR>PeakRate: |
84 |
|
PeakRate=thisR |
85 |
|
|
86 |
< |
thisRateA=aRates.get(ls,0) |
54 |
< |
ARate+=thisRateA |
55 |
< |
if thisRateA>PeakRateA: |
56 |
< |
PeakRateA=thisRateA |
57 |
< |
|
58 |
< |
#ARate+=aRates.get(ls,0) |
86 |
> |
|
87 |
|
## Print Stream A Rate --moved see below |
88 |
|
##print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),) |
89 |
|
|
90 |
|
Warn = False |
91 |
|
|
92 |
|
########################################## |
93 |
< |
## Check if the express stream is too high |
93 |
> |
## Check if the express stream is too high or low |
94 |
|
########################################## |
95 |
< |
global NHighExpress |
68 |
< |
badExpress = ExpRate/len(LumiRange) > config.MaxExpressRate ## avg express stream rate too high? |
95 |
> |
badExpress = ((ExpRate/len(LumiRange) > config.MaxExpressRate) or (ExpRate/len(LumiRange)<0.1 and isCol)) ## avg express stream rate too high? |
96 |
|
baseText = "\nCurrent Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display |
97 |
|
if badExpress: |
98 |
|
text = colored(baseText,'red',attrs=['reverse']) ## bad, make the text white on red |
103 |
|
|
104 |
|
write(text) |
105 |
|
if badExpress: |
106 |
< |
if (ExpRate-PeakRate)/(len(LumiRange)-1) <=config.MaxExpressRate: ## one lumisection causes this |
107 |
< |
write(" << This appears to be due to a 1 lumisection spike, please monitor\n") |
108 |
< |
else: |
109 |
< |
if NHighExpress > 1: # big problem, call HLT DOC |
110 |
< |
write(colored(" << WARNING: Current Express rate is too high!",'red',attrs=['reverse']) ) |
111 |
< |
Warn = True |
106 |
> |
if len(LumiRange)>1: |
107 |
> |
if (ExpRate-PeakRate)/(len(LumiRange)-1) <=config.MaxExpressRate: ## one lumisection causes this |
108 |
> |
write(" << This appears to be due to a 1 lumisection spike, please monitor\n") |
109 |
> |
else: |
110 |
> |
if NHighExpress > 1: # big problem, call HLT DOC |
111 |
> |
write(colored(" << WARNING: Current Express rate is too high!",'red',attrs=['reverse']) ) |
112 |
> |
Warn = True |
113 |
|
|
114 |
|
# if AvgExpRate > config.MaxExpressRate: |
115 |
|
# write( colored("\n\nWARNING: Average Express Stream Rate is too high (%0.1f Hz) << CALL HLT DOC" % AvgExpRate,'red',attrs=['reverse']) ) |
116 |
|
# Warn = True |
117 |
< |
|
117 |
> |
|
118 |
> |
|
119 |
|
|
120 |
|
|
121 |
|
######################################### |
122 |
|
##Check if Stream A is too high |
123 |
|
######################################### |
124 |
|
global NHighStreamA |
125 |
< |
badStreamA =ARate/len(LumiRange) > config.MaxStreamARate ##Cosmics Express Rate 300 Hz max |
126 |
< |
baseTextA= "\nCurrent Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),) |
127 |
< |
if badStreamA: |
128 |
< |
textA=colored(baseTextA,'red',attrs=['reverse']) ## bad, make the text white on red |
129 |
< |
NHighStreamA+=1 |
130 |
< |
else: |
131 |
< |
textA=baseTextA |
132 |
< |
NHighStreamA=0 |
133 |
< |
|
134 |
< |
write(textA) |
135 |
< |
if badStreamA: |
136 |
< |
if (ARate-PeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this |
137 |
< |
write(" << This appears to be due to a 1 lumisection spike, please monitor\n") |
125 |
> |
stream_mon = StreamMonitor() |
126 |
> |
core_a_rates = stream_mon.getStreamACoreRatesByLS(parser,LumiRange,config,isCol).values() |
127 |
> |
a_rates = stream_mon.getStreamARatesByLS(parser,LumiRange).values() |
128 |
> |
peak_core_a_rate = max(core_a_rates) |
129 |
> |
|
130 |
> |
if len(LumiRange) > 0: |
131 |
> |
avg_core_a_rate = sum(core_a_rates)/len(LumiRange) |
132 |
> |
avg_a_rate = sum(a_rates)/len(LumiRange) |
133 |
> |
badStreamA = stream_mon.compareStreamARate(config, avg_core_a_rate, LumiRange,AvInstLumi,isCol) |
134 |
> |
|
135 |
> |
baseTextA= "\nCurrent Stream A Rate is: %0.1f Hz" % (avg_a_rate) |
136 |
> |
baseTextRealA= "\nCurrent PROMPT Stream A Rate is: %0.1f Hz" % (avg_core_a_rate) |
137 |
> |
|
138 |
> |
if badStreamA: |
139 |
> |
textA=colored(baseTextA,'red',attrs=['reverse']) ## bad, make the text white on red |
140 |
> |
textRealA=colored(baseTextRealA,'red',attrs=['reverse']) ## bad, make the text white on red |
141 |
> |
NHighStreamA+=1 |
142 |
|
else: |
143 |
< |
if NHighStreamA >1: ##Call HLT doc! |
144 |
< |
write(colored(" << WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) ) |
145 |
< |
Warn = True |
143 |
> |
textA=baseTextA |
144 |
> |
textRealA=baseTextRealA |
145 |
> |
|
146 |
> |
write(textA) |
147 |
> |
write(textRealA) |
148 |
> |
|
149 |
> |
if badStreamA and len(LumiRange) > 1: |
150 |
> |
trimmed_core_a_rates = core_a_rates |
151 |
> |
trimmed_core_a_rates.remove(peak_core_a_rate) |
152 |
> |
if sum(trimmed_core_a_rates)/(len(LumiRange)-1) <= config.MaxStreamARate: ## one lumisection causes this |
153 |
> |
write(" << This appears to be due to a 1 lumisection spike, please monitor\n") |
154 |
> |
else: |
155 |
> |
if NHighStreamA > 1: ##Call HLT doc! |
156 |
> |
write(colored(" << WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) ) |
157 |
> |
Warn = True |
158 |
|
write("\n\n") |
159 |
|
|
160 |
|
###################################### |
168 |
|
|
169 |
|
write( colored(line,'red',attrs=['reverse','blink']) ) |
170 |
|
write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) ) |
171 |
< |
|
171 |
> |
|
172 |
|
|
173 |
|
PrescaleColumnString='' |
174 |
|
PSCols = list(set(PSCols)) |
191 |
|
write(bcolors.OKBLUE) |
192 |
|
write(str(round(deadtimebeamactive,2))+"%") |
193 |
|
write(bcolors.ENDC+"\n") |
194 |
< |
|
195 |
< |
print "Used prescale column(s): "+str(PrescaleColumnString) |
196 |
< |
write("Lumisections: ") |
194 |
> |
write("Used prescale column(s): %s " % (str(PrescaleColumnString),) ) |
195 |
> |
if LastPSCol in config.ForbiddenCols and isCol: |
196 |
> |
write( colored("<< Using column %d! Please check in the documentation that this is the correct column" % (LastPSCol),'red',attrs=['reverse']) ) |
197 |
> |
write("\nLumisections: ") |
198 |
|
if not isSequential(LumiRange): |
199 |
|
write(str(LumiRange)+" Lumisections are not sequential (bad LS skipped)\n") |
200 |
|
else: |
201 |
|
write("%d - %d\n" % (min(LumiRange),max(LumiRange),)) |
202 |
< |
print "\nLast Lumisection of the run is: "+str(parser.GetLastLS()) |
203 |
< |
write( "Last Lumisection good where DAQ is active is: "+str(parser.GetLastLS(isCol)) ) |
202 |
> |
##print "\nLast Lumisection of the run is: "+str(parser.GetLastLS()) |
203 |
> |
write( "\nLast Lumisection good where DAQ is active is: "+str(parser.GetLastLS(isCol)) ) |
204 |
|
##write( "Last Lumisection where DAQ is active is: "+str(parser.GetLastLS(True)) ) |
205 |
|
write("\n\n\n") |
206 |
|
|
207 |
< |
if isCol: |
208 |
< |
L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi) |
209 |
< |
if len(L1RatePredictions): |
210 |
< |
print "Expected Level 1 Rates:" |
211 |
< |
for key,val in L1RatePredictions.iteritems(): |
212 |
< |
write("Prescale Column "+str(key)+": "+str(round(val/1000,1))+" kHz") |
213 |
< |
if key == LastPSCol: |
214 |
< |
write(' << taking data in this column') |
215 |
< |
write('\n') |
207 |
> |
## if isCol: |
208 |
> |
## L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi) |
209 |
> |
## if len(L1RatePredictions): |
210 |
> |
## print "Expected Level 1 Rates:" |
211 |
> |
## for key,val in L1RatePredictions.iteritems(): |
212 |
> |
## write("Prescale Column "+str(key)+": "+str(round(val/1000,1))+" kHz") |
213 |
> |
## if key == LastPSCol: |
214 |
> |
## write(' << taking data in this column') |
215 |
> |
## write('\n') |
216 |
|
|
217 |
|
|
218 |
|
|