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 |
|
print "Monitoring Run %d" % (parser.RunNumber,) |
16 |
|
localtime = time.asctime( time.localtime(time.time()) ) |
17 |
|
print "Local current time :", localtime |
18 |
< |
print "len=",len(LumiRange) |
18 |
< |
print "LSRange=", LumiRange |
18 |
> |
#print "Lumisections used=", LumiRange |
19 |
|
if len(LumiRange)>0: |
20 |
|
|
21 |
|
[AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange) |
22 |
|
deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange)*100 |
23 |
+ |
|
24 |
|
##print "dtba=",deadtimebeamactive |
25 |
|
else: |
26 |
|
print "no lumisections to monitor" |
27 |
|
return |
28 |
+ |
|
29 |
+ |
try: |
30 |
+ |
#print "trying v3" |
31 |
+ |
lograte=parser.GetTriggerRatesByLS("HLT_LogMonitor_v3") |
32 |
+ |
#print lograte |
33 |
+ |
if not len(lograte): |
34 |
+ |
#print "trying v4" |
35 |
+ |
lograte=parser.GetTriggerRatesByLS("HLT_LogMonitor_v4") |
36 |
+ |
|
37 |
+ |
#print lograte |
38 |
+ |
for lumi in lograte.iterkeys(): |
39 |
+ |
#print lumi, lograte[lumi] |
40 |
+ |
if lograte[lumi]>config.MaxLogMonRate: |
41 |
+ |
write(bcolors.WARNING) |
42 |
+ |
print lograte[lumi], "post to elog. LogMonitor rate is high." |
43 |
+ |
write(bcolors.ENDC+"\n") |
44 |
+ |
except: |
45 |
+ |
write(bcolors.WARNING) |
46 |
+ |
print "problem getting log monitor rates" |
47 |
+ |
write(bcolors.ENDC+"\n") |
48 |
+ |
|
49 |
|
try: |
50 |
|
LastPSCol = PSCols[-1] |
51 |
|
except: |
52 |
|
LastPSCol = -1 |
31 |
– |
if isCol: |
32 |
– |
|
33 |
– |
aRates = parser.GetTriggerRatesByLS("AOutput") |
34 |
– |
bRates = parser.GetTriggerRatesByLS("BOutput") |
35 |
– |
if len(bRates) == 0: |
36 |
– |
realARates = aRates |
37 |
– |
else: |
38 |
– |
realARates={} |
39 |
– |
for k,v in bRates.iteritems(): |
40 |
– |
realARates[k]=aRates[k]-bRates[k]*20 |
41 |
– |
#realARates = aRates - bRates*20; |
42 |
– |
else: |
43 |
– |
if len(parser.GetTriggerRatesByLS("AOutput"))>0: |
44 |
– |
aRates = parser.GetTriggerRatesByLS("AOutput") |
45 |
– |
bRates = parser.GetTriggerRatesByLS("BOutput") |
46 |
– |
else: |
47 |
– |
aRates = parser.GetTriggerRatesByLS("AForPPOutput") |
48 |
– |
bRates = parser.GetTriggerRatesByLS("BForPPOutput") |
49 |
– |
|
53 |
|
|
54 |
|
expressRates = {} |
55 |
|
if isCol: |
56 |
|
expressRates = parser.GetTriggerRatesByLS("ExpressOutput") |
57 |
|
else: |
58 |
|
if len(parser.GetTriggerRatesByLS("ExpressOutput"))>0: |
59 |
< |
expressRates=parser.GetTriggerRatesByLS("ExpressOutput") |
59 |
> |
expressRates=parser.GetTriggerRatesByLS("else") |
60 |
|
else: |
61 |
|
expressRates = parser.GetTriggerRatesByLS("ExpressForCosmicsOutput") |
62 |
+ |
|
63 |
|
ExpRate=0 |
64 |
|
PeakRate=0 |
65 |
|
AvgExpRate=0 |
66 |
|
|
63 |
– |
ARate=0 |
64 |
– |
PeakRateA=0 |
65 |
– |
AvgRateA=0 |
66 |
– |
|
67 |
– |
realARate=0 |
68 |
– |
realPeakRateA=0 |
69 |
– |
realAvgRateA=0 |
70 |
– |
|
67 |
|
if len(expressRates.values()) > 20: |
68 |
|
AvgExpRate = sum(expressRates.values())/len(expressRates.values()) |
69 |
+ |
counter=0 |
70 |
|
|
71 |
|
for ls in LumiRange: ## Find the sum and peak express stream rates |
72 |
|
thisR = expressRates.get(ls,0) |
74 |
|
if thisR>PeakRate: |
75 |
|
PeakRate=thisR |
76 |
|
|
77 |
< |
thisRateA=aRates.get(ls,0) |
81 |
< |
ARate+=thisRateA |
82 |
< |
if thisRateA>PeakRateA: |
83 |
< |
PeakRateA=thisRateA |
84 |
< |
|
85 |
< |
thisRealRateA = aRates.get(ls,0) - bRates.get(ls,0)*20 |
86 |
< |
realARate+=thisRealRateA |
87 |
< |
if thisRealRateA > realPeakRateA: |
88 |
< |
realReakRateA = thisRealRateA |
89 |
< |
#ARate+=aRates.get(ls,0) |
77 |
> |
|
78 |
|
## Print Stream A Rate --moved see below |
79 |
|
##print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),) |
80 |
|
|
83 |
|
########################################## |
84 |
|
## Check if the express stream is too high or low |
85 |
|
########################################## |
98 |
– |
global NHighExpress |
86 |
|
badExpress = ((ExpRate/len(LumiRange) > config.MaxExpressRate) or (ExpRate/len(LumiRange)<0.1 and isCol)) ## avg express stream rate too high? |
87 |
|
baseText = "\nCurrent Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display |
88 |
|
if badExpress: |
113 |
|
##Check if Stream A is too high |
114 |
|
######################################### |
115 |
|
global NHighStreamA |
116 |
< |
badStreamA =realARate/len(LumiRange) > config.MaxStreamARate ##Cosmics Express Rate 300 Hz max |
117 |
< |
baseTextA= "\nCurrent Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),) |
118 |
< |
baseTextRealA= "\nCurrent PROMPT Steam A Rate is: %0.1f Hz" % (realARate/len(LumiRange),) |
119 |
< |
if badStreamA: |
120 |
< |
textA=colored(baseTextA,'red',attrs=['reverse']) ## bad, make the text white on red |
121 |
< |
textRealA=colored(baseTextRealA,'red',attrs=['reverse']) ## bad, make the text white on red |
122 |
< |
NHighStreamA+=1 |
123 |
< |
else: |
124 |
< |
textA=baseTextA |
125 |
< |
textRealA=baseTextRealA |
126 |
< |
NHighStreamA=0 |
127 |
< |
|
128 |
< |
write(textA) |
129 |
< |
write(textRealA) |
130 |
< |
if badStreamA: |
131 |
< |
if len(LumiRange)>1: |
132 |
< |
if (realARate-realPeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this |
116 |
> |
stream_mon = StreamMonitor() |
117 |
> |
core_a_rates = stream_mon.getStreamACoreRatesByLS(parser,LumiRange,config,isCol).values() |
118 |
> |
a_rates = stream_mon.getStreamARatesByLS(parser,LumiRange).values() |
119 |
> |
peak_core_a_rate = max(core_a_rates) |
120 |
> |
|
121 |
> |
if len(LumiRange) > 0: |
122 |
> |
avg_core_a_rate = sum(core_a_rates)/len(LumiRange) |
123 |
> |
avg_a_rate = sum(a_rates)/len(LumiRange) |
124 |
> |
badStreamA = stream_mon.compareStreamARate(config, avg_core_a_rate, LumiRange,AvInstLumi,isCol) |
125 |
> |
|
126 |
> |
baseTextA= "\nCurrent Stream A Rate is: %0.1f Hz" % (avg_a_rate) |
127 |
> |
baseTextRealA= "\nCurrent PROMPT Stream A Rate is: %0.1f Hz" % (avg_core_a_rate) |
128 |
> |
|
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 |
> |
|
137 |
> |
write(textA) |
138 |
> |
write(textRealA) |
139 |
> |
|
140 |
> |
if badStreamA and len(LumiRange) > 1: |
141 |
> |
trimmed_core_a_rates = core_a_rates |
142 |
> |
trimmed_core_a_rates.remove(peak_core_a_rate) |
143 |
> |
if sum(trimmed_core_a_rates)/(len(LumiRange)-1) <= config.MaxStreamARate: ## one lumisection causes this |
144 |
|
write(" << This appears to be due to a 1 lumisection spike, please monitor\n") |
145 |
|
else: |
146 |
< |
if NHighStreamA >1: ##Call HLT doc! |
146 |
> |
if NHighStreamA > 1: ##Call HLT doc! |
147 |
|
write(colored(" << WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) ) |
148 |
|
Warn = True |
149 |
|
write("\n\n") |
159 |
|
|
160 |
|
write( colored(line,'red',attrs=['reverse','blink']) ) |
161 |
|
write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) ) |
162 |
< |
|
162 |
> |
|
163 |
|
|
164 |
|
PrescaleColumnString='' |
165 |
|
PSCols = list(set(PSCols)) |