1 |
|
import sys |
2 |
|
from colors import * |
3 |
|
from DatabaseParser import * |
4 |
+ |
from termcolor import colored, cprint |
5 |
|
write = sys.stdout.write |
6 |
|
|
7 |
< |
def MoreTableInfo(parser,LumiRange): |
7 |
> |
NHighExpress=0 |
8 |
> |
|
9 |
> |
def MoreTableInfo(parser,LumiRange,config,isCol=True): |
10 |
> |
print "Monitoring Run %d" % (parser.RunNumber,) |
11 |
|
[AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange) |
12 |
+ |
try: |
13 |
+ |
LastPSCol = PSCols[-1] |
14 |
+ |
except: |
15 |
+ |
LastPSCol = -1 |
16 |
+ |
|
17 |
+ |
aRates = parser.GetTriggerRatesByLS("AOutput") |
18 |
+ |
expressRates = {} |
19 |
+ |
if isCol: |
20 |
+ |
expressRates = parser.GetTriggerRatesByLS("ExpressOutput") |
21 |
+ |
else: |
22 |
+ |
expressRates = parser.GetTriggerRatesByLS("ExpressCosmicsOutput") |
23 |
+ |
ExpRate=0 |
24 |
+ |
PeakRate=0 |
25 |
+ |
AvgExpRate=0 |
26 |
+ |
|
27 |
+ |
ARate=0 |
28 |
+ |
if len(expressRates.values()) > 20: |
29 |
+ |
AvgExpRate = sum(expressRates.values())/len(expressRates.values()) |
30 |
+ |
|
31 |
+ |
for ls in LumiRange: ## Find the sum and peak express stream rates |
32 |
+ |
thisR = expressRates.get(ls,0) |
33 |
+ |
ExpRate+=thisR |
34 |
+ |
if thisR>PeakRate: |
35 |
+ |
PeakRate=thisR |
36 |
+ |
ARate+=aRates.get(ls,0) |
37 |
+ |
## Print Stream A Rate |
38 |
+ |
print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),) |
39 |
+ |
|
40 |
+ |
Warn = False |
41 |
|
|
42 |
+ |
## Check if the express stream is too high |
43 |
+ |
global NHighExpress |
44 |
+ |
badExpress = ExpRate/len(LumiRange) > config.MaxExpressRate ## avg express stream rate too high? |
45 |
+ |
baseText = "Current Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display |
46 |
+ |
if badExpress: |
47 |
+ |
text = colored(baseText,'red',attrs=['reverse']) ## bad, make the text white on red |
48 |
+ |
NHighExpress+=1 ## increment the bad express counter |
49 |
+ |
else: |
50 |
+ |
text = baseText |
51 |
+ |
NHighExpress=0 |
52 |
+ |
|
53 |
+ |
write(text) |
54 |
+ |
if badExpress: |
55 |
+ |
if (ExpRate-PeakRate)/(len(LumiRange)-1) <=config.MaxExpressRate: ## one lumisection causes this |
56 |
+ |
write(" << This appears to be due to a 1 lumisection spike, please monitor\n") |
57 |
+ |
else: |
58 |
+ |
if NHighExpress > 1: # big problem, call HLT DOC |
59 |
+ |
write(colored(" << WARNING: Current Express rate is too high!",'red',attrs=['reverse']) ) |
60 |
+ |
Warn = True |
61 |
+ |
|
62 |
+ |
# if AvgExpRate > config.MaxExpressRate: |
63 |
+ |
# write( colored("\n\nWARNING: Average Express Stream Rate is too high (%0.1f Hz) << CALL HLT DOC" % AvgExpRate,'red',attrs=['reverse']) ) |
64 |
+ |
# Warn = True |
65 |
+ |
write("\n\n") |
66 |
+ |
|
67 |
+ |
if Warn: ## WARNING |
68 |
+ |
rows, columns = os.popen('stty size', 'r').read().split() ## Get the terminal size |
69 |
+ |
cols = int(columns) |
70 |
+ |
write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) ) |
71 |
+ |
line = "*" + " "*int((cols-22)/2)+"CALL HLT DOC (165575)"+" "*int((cols-23)/2)+"*\n" |
72 |
+ |
|
73 |
+ |
write( colored(line,'red',attrs=['reverse','blink']) ) |
74 |
+ |
write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) ) |
75 |
+ |
|
76 |
|
if AvDeadTime==0: ## For some reason the dead time in the DB is occasionally broken |
77 |
|
try: |
78 |
|
AvDeadTime = AvLiveLumi/AvDeliveredLumi * 100 |
79 |
|
except: |
80 |
|
AvDeadTime = 100 |
81 |
|
PrescaleColumnString='' |
82 |
+ |
PSCols = list(set(PSCols)) |
83 |
|
for c in PSCols: |
84 |
|
PrescaleColumnString = PrescaleColumnString + str(c) + "," |
85 |
|
|
86 |
< |
write("The average instantaneous lumi of these lumisections is: ") |
87 |
< |
write(str(round(AvInstLumi,1))+"e30\n") |
88 |
< |
write("The delivered lumi of these lumi sections is: ") |
89 |
< |
write(str(round(1000*AvDeliveredLumi,1))+"e30"+"\n") |
90 |
< |
write("The live (recorded) lumi of these lumi sections is: ") |
91 |
< |
write(str(round(1000*AvLiveLumi,1))+"e30\n\n") |
92 |
< |
write("The average deadtime of these lumi sections is: ") |
93 |
< |
if AvDeadTime > 5: |
94 |
< |
write(bcolors.FAIL) |
95 |
< |
elif AvDeadTime > 10: |
96 |
< |
write(bcolors.WARNING) |
97 |
< |
else: |
98 |
< |
write(bcolors.OKBLUE) |
99 |
< |
write(str(round(AvDeadTime,1))+"%") |
100 |
< |
write(bcolors.ENDC+"\n") |
86 |
> |
if isCol: |
87 |
> |
write("The average instantaneous lumi of these lumisections is: ") |
88 |
> |
write(str(round(AvInstLumi,1))+"e30\n") |
89 |
> |
write("The delivered lumi of these lumi sections is: ") |
90 |
> |
write(str(round(len(LumiRange)*AvDeliveredLumi,1))+"e30"+"\n") |
91 |
> |
write("The live (recorded) lumi of these lumi sections is: ") |
92 |
> |
write(str(round(len(LumiRange)*AvLiveLumi,1))+"e30\n\n") |
93 |
> |
write("The average deadtime of these lumi sections is: ") |
94 |
> |
if AvDeadTime > 5: |
95 |
> |
write(bcolors.FAIL) |
96 |
> |
elif AvDeadTime > 10: |
97 |
> |
write(bcolors.WARNING) |
98 |
> |
else: |
99 |
> |
write(bcolors.OKBLUE) |
100 |
> |
write(str(round(AvDeadTime,2))+"%") |
101 |
> |
write(bcolors.ENDC+"\n") |
102 |
|
|
103 |
|
print "Used prescale column(s): "+str(PrescaleColumnString) |
104 |
|
write("Lumisections: ") |
108 |
|
write("%d - %d\n" % (min(LumiRange),max(LumiRange),)) |
109 |
|
print "\nLast Lumisection of the run is: "+str(parser.GetLastLS()) |
110 |
|
write( "Last Lumisection good for physics is: "+str(parser.GetLastLS(True)) ) |
111 |
< |
if parser.GetLastLS(True)!=max(LumiRange): |
112 |
< |
write(bcolors.WARNING) |
113 |
< |
write(" << This exceeds the last lumisection parsed") |
114 |
< |
write(bcolors.ENDC+"\n") |
111 |
> |
write("\n\n\n") |
112 |
> |
|
113 |
> |
if isCol: |
114 |
> |
L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi) |
115 |
> |
if len(L1RatePredictions): |
116 |
> |
print "Expected Level 1 Rates:" |
117 |
> |
for key,val in L1RatePredictions.iteritems(): |
118 |
> |
write("Prescale Column "+str(key)+": "+str(round(val/1000,1))+" kHz") |
119 |
> |
if key == LastPSCol: |
120 |
> |
write(' << taking data in this column') |
121 |
> |
write('\n') |
122 |
> |
|
123 |
> |
|
124 |
|
|
125 |
|
def isSequential(t): |
126 |
|
try: |