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 |
|
|
|
9 |
amott |
1.13 |
def MoreTableInfo(parser,LumiRange,config,isCol=True):
|
10 |
amott |
1.14 |
print "Monitoring Run %d" % (parser.RunNumber,)
|
11 |
abrinke1 |
1.10 |
[AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
|
12 |
amott |
1.13 |
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 |
amott |
1.12 |
ExpRate=0
|
24 |
|
|
PeakRate=0
|
25 |
amott |
1.13 |
AvgExpRate=0
|
26 |
|
|
|
27 |
|
|
ARate=0
|
28 |
|
|
if len(expressRates.values()) > 20:
|
29 |
|
|
AvgExpRate = sum(expressRates.values())/len(expressRates.values())
|
30 |
|
|
|
31 |
amott |
1.12 |
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 |
amott |
1.13 |
ARate+=aRates.get(ls,0)
|
37 |
|
|
## Print Stream A Rate
|
38 |
|
|
print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
|
39 |
amott |
1.12 |
|
40 |
amott |
1.13 |
Warn = False
|
41 |
amott |
1.12 |
|
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 |
amott |
1.13 |
baseText = "Current Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display
|
46 |
amott |
1.12 |
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 |
amott |
1.13 |
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 |
amott |
1.12 |
|
73 |
amott |
1.13 |
write( colored(line,'red',attrs=['reverse','blink']) )
|
74 |
|
|
write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) )
|
75 |
amott |
1.12 |
|
76 |
amott |
1.1 |
if AvDeadTime==0: ## For some reason the dead time in the DB is occasionally broken
|
77 |
amott |
1.2 |
try:
|
78 |
|
|
AvDeadTime = AvLiveLumi/AvDeliveredLumi * 100
|
79 |
|
|
except:
|
80 |
|
|
AvDeadTime = 100
|
81 |
amott |
1.1 |
PrescaleColumnString=''
|
82 |
abrinke1 |
1.10 |
PSCols = list(set(PSCols))
|
83 |
amott |
1.1 |
for c in PSCols:
|
84 |
|
|
PrescaleColumnString = PrescaleColumnString + str(c) + ","
|
85 |
|
|
|
86 |
amott |
1.13 |
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 |
amott |
1.1 |
|
103 |
amott |
1.3 |
print "Used prescale column(s): "+str(PrescaleColumnString)
|
104 |
amott |
1.4 |
write("Lumisections: ")
|
105 |
amott |
1.3 |
if not isSequential(LumiRange):
|
106 |
amott |
1.4 |
write(str(LumiRange)+" Lumisections are not sequential (bad LS skipped)\n")
|
107 |
|
|
else:
|
108 |
|
|
write("%d - %d\n" % (min(LumiRange),max(LumiRange),))
|
109 |
amott |
1.3 |
print "\nLast Lumisection of the run is: "+str(parser.GetLastLS())
|
110 |
|
|
write( "Last Lumisection good for physics is: "+str(parser.GetLastLS(True)) )
|
111 |
amott |
1.12 |
write("\n\n\n")
|
112 |
amott |
1.5 |
|
113 |
amott |
1.13 |
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 |
amott |
1.6 |
|
123 |
amott |
1.5 |
|
124 |
amott |
1.3 |
|
125 |
|
|
def isSequential(t):
|
126 |
|
|
try:
|
127 |
|
|
if len(t)<2:
|
128 |
|
|
return True
|
129 |
|
|
except:
|
130 |
|
|
return True
|
131 |
|
|
for i,e in enumerate(t[1:]):
|
132 |
|
|
if not abs(e-t[i])==1:
|
133 |
|
|
return False
|
134 |
|
|
return True
|