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 |
< |
print "len=",len(LumiRange) |
19 |
< |
print "LSRange=", 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 |
+ |
#return |
38 |
+ |
|
39 |
+ |
try: |
40 |
+ |
#print "trying v3" |
41 |
+ |
lograte=parser.GetTriggerRatesByLS("HLT_LogMonitor_v3") |
42 |
+ |
#print lograte |
43 |
+ |
if not len(lograte): |
44 |
+ |
#print "trying v4" |
45 |
+ |
lograte=parser.GetTriggerRatesByLS("HLT_LogMonitor_v4") |
46 |
+ |
|
47 |
+ |
#print lograte |
48 |
+ |
for lumi in lograte.iterkeys(): |
49 |
+ |
#print lumi, lograte[lumi] |
50 |
+ |
if lograte[lumi]>config.MaxLogMonRate: |
51 |
+ |
write(bcolors.WARNING) |
52 |
+ |
print lograte[lumi], "post to elog. LogMonitor rate is high." |
53 |
+ |
write(bcolors.ENDC+"\n") |
54 |
+ |
except: |
55 |
+ |
write(bcolors.WARNING) |
56 |
+ |
print "problem getting log monitor rates" |
57 |
+ |
write(bcolors.ENDC+"\n") |
58 |
+ |
|
59 |
|
try: |
60 |
|
LastPSCol = PSCols[-1] |
61 |
|
except: |
62 |
|
LastPSCol = -1 |
26 |
– |
if isCol: |
27 |
– |
|
28 |
– |
aRates = parser.GetTriggerRatesByLS("AOutput") |
29 |
– |
bRates = parser.GetTriggerRatesByLS("BOutput") |
30 |
– |
if len(bRates) == 0: |
31 |
– |
realARates = aRates |
32 |
– |
else: |
33 |
– |
realARates={} |
34 |
– |
for k,v in bRates.iteritems(): |
35 |
– |
realARates[k]=aRates[k]-bRates[k] |
36 |
– |
#realARates = aRates - bRates*20; |
37 |
– |
else: |
38 |
– |
if len(parser.GetTriggerRatesByLS("AOutput"))>0: |
39 |
– |
aRates = parser.GetTriggerRatesByLS("AOutput") |
40 |
– |
else: |
41 |
– |
aRates = parser.GetTriggerRatesByLS("AForPPOutput") |
42 |
– |
|
63 |
|
|
64 |
|
expressRates = {} |
65 |
|
if isCol: |
66 |
|
expressRates = parser.GetTriggerRatesByLS("ExpressOutput") |
67 |
|
else: |
68 |
|
if len(parser.GetTriggerRatesByLS("ExpressOutput"))>0: |
69 |
< |
expressRates=parser.GetTriggerRatesByLS("ExpressOutput") |
69 |
> |
expressRates=parser.GetTriggerRatesByLS("else") |
70 |
|
else: |
71 |
|
expressRates = parser.GetTriggerRatesByLS("ExpressForCosmicsOutput") |
72 |
+ |
|
73 |
|
ExpRate=0 |
74 |
|
PeakRate=0 |
75 |
|
AvgExpRate=0 |
76 |
|
|
56 |
– |
ARate=0 |
57 |
– |
PeakRateA=0 |
58 |
– |
AvgRateA=0 |
59 |
– |
|
60 |
– |
realARate=0 |
61 |
– |
realPeakRateA=0 |
62 |
– |
realAvgRateA=0 |
63 |
– |
|
77 |
|
if len(expressRates.values()) > 20: |
78 |
|
AvgExpRate = sum(expressRates.values())/len(expressRates.values()) |
79 |
+ |
counter=0 |
80 |
|
|
81 |
|
for ls in LumiRange: ## Find the sum and peak express stream rates |
82 |
|
thisR = expressRates.get(ls,0) |
84 |
|
if thisR>PeakRate: |
85 |
|
PeakRate=thisR |
86 |
|
|
87 |
< |
thisRateA=aRates.get(ls,0) |
74 |
< |
ARate+=thisRateA |
75 |
< |
if thisRateA>PeakRateA: |
76 |
< |
PeakRateA=thisRateA |
77 |
< |
|
78 |
< |
thisRealRateA = aRates.get(ls,0) - bRates.get(ls,0) |
79 |
< |
realARate+=thisRealRateA |
80 |
< |
if thisRealRateA > realPeakRateA: |
81 |
< |
realReakRateA = thisRealRateA |
82 |
< |
#ARate+=aRates.get(ls,0) |
87 |
> |
|
88 |
|
## Print Stream A Rate --moved see below |
89 |
|
##print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),) |
90 |
|
|
91 |
|
Warn = False |
92 |
|
|
93 |
|
########################################## |
94 |
< |
## Check if the express stream is too high |
94 |
> |
## Check if the express stream is too high or low |
95 |
|
########################################## |
96 |
< |
global NHighExpress |
92 |
< |
badExpress = ExpRate/len(LumiRange) > config.MaxExpressRate ## avg express stream rate too high? |
96 |
> |
badExpress = ((ExpRate/len(LumiRange) > config.MaxExpressRate) or (ExpRate/len(LumiRange)<0.1 and isCol)) ## avg express stream rate too high? |
97 |
|
baseText = "\nCurrent Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display |
98 |
|
if badExpress: |
99 |
|
text = colored(baseText,'red',attrs=['reverse']) ## bad, make the text white on red |
123 |
|
##Check if Stream A is too high |
124 |
|
######################################### |
125 |
|
global NHighStreamA |
126 |
< |
badStreamA =realARate/len(LumiRange) > config.MaxStreamARate ##Cosmics Express Rate 300 Hz max |
127 |
< |
baseTextA= "\nCurrent Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),) |
128 |
< |
baseTextRealA= "\nCurrent PROMPT Steam A Rate is: %0.1f Hz" % (realARate/len(LumiRange),) |
129 |
< |
if badStreamA: |
130 |
< |
textA=colored(baseTextA,'red',attrs=['reverse']) ## bad, make the text white on red |
131 |
< |
textRealA=colored(baseTextRealA,'red',attrs=['reverse']) ## bad, make the text white on red |
132 |
< |
NHighStreamA+=1 |
133 |
< |
else: |
134 |
< |
textA=baseTextA |
135 |
< |
textRealA=baseTextRealA |
136 |
< |
NHighStreamA=0 |
137 |
< |
|
138 |
< |
write(textA) |
139 |
< |
write(textRealA) |
140 |
< |
if badStreamA: |
141 |
< |
if len(LumiRange)>1: |
142 |
< |
if (realARate-realPeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this |
126 |
> |
stream_mon = StreamMonitor() |
127 |
> |
core_a_rates = stream_mon.getStreamACoreRatesByLS(parser,LumiRange,config,isCol).values() |
128 |
> |
a_rates = stream_mon.getStreamARatesByLS(parser,LumiRange).values() |
129 |
> |
peak_core_a_rate = max(core_a_rates) |
130 |
> |
|
131 |
> |
if len(LumiRange) > 0: |
132 |
> |
avg_core_a_rate = sum(core_a_rates)/len(LumiRange) |
133 |
> |
avg_a_rate = sum(a_rates)/len(LumiRange) |
134 |
> |
badStreamA = stream_mon.compareStreamARate(config, avg_core_a_rate, LumiRange,AvInstLumi,isCol) |
135 |
> |
|
136 |
> |
baseTextA= "\nCurrent Stream A Rate is: %0.1f Hz" % (avg_a_rate) |
137 |
> |
baseTextRealA= "\nCurrent PROMPT Stream A Rate is: %0.1f Hz" % (avg_core_a_rate) |
138 |
> |
|
139 |
> |
if badStreamA: |
140 |
> |
textA=colored(baseTextA,'red',attrs=['reverse']) ## bad, make the text white on red |
141 |
> |
textRealA=colored(baseTextRealA,'red',attrs=['reverse']) ## bad, make the text white on red |
142 |
> |
NHighStreamA+=1 |
143 |
> |
else: |
144 |
> |
textA=baseTextA |
145 |
> |
textRealA=baseTextRealA |
146 |
> |
|
147 |
> |
write(textA) |
148 |
> |
write(textRealA) |
149 |
> |
|
150 |
> |
if badStreamA and len(LumiRange) > 1: |
151 |
> |
trimmed_core_a_rates = core_a_rates |
152 |
> |
trimmed_core_a_rates.remove(peak_core_a_rate) |
153 |
> |
if sum(trimmed_core_a_rates)/(len(LumiRange)-1) <= config.MaxStreamARate: ## one lumisection causes this |
154 |
|
write(" << This appears to be due to a 1 lumisection spike, please monitor\n") |
155 |
|
else: |
156 |
< |
if NHighStreamA >1: ##Call HLT doc! |
156 |
> |
if NHighStreamA > 1: ##Call HLT doc! |
157 |
|
write(colored(" << WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) ) |
158 |
|
Warn = True |
159 |
|
write("\n\n") |
169 |
|
|
170 |
|
write( colored(line,'red',attrs=['reverse','blink']) ) |
171 |
|
write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) ) |
172 |
< |
|
172 |
> |
|
173 |
|
|
174 |
|
PrescaleColumnString='' |
175 |
|
PSCols = list(set(PSCols)) |