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 |
grchrist |
1.16 |
NHighStreamA=0
|
9 |
amott |
1.12 |
|
10 |
amott |
1.13 |
def MoreTableInfo(parser,LumiRange,config,isCol=True):
|
11 |
amott |
1.14 |
print "Monitoring Run %d" % (parser.RunNumber,)
|
12 |
abrinke1 |
1.10 |
[AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
|
13 |
grchrist |
1.17 |
deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange)
|
14 |
amott |
1.13 |
try:
|
15 |
|
|
LastPSCol = PSCols[-1]
|
16 |
|
|
except:
|
17 |
|
|
LastPSCol = -1
|
18 |
grchrist |
1.19 |
if isCol:
|
19 |
amott |
1.13 |
|
20 |
grchrist |
1.19 |
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 |
|
|
|
27 |
|
|
|
28 |
amott |
1.13 |
expressRates = {}
|
29 |
|
|
if isCol:
|
30 |
|
|
expressRates = parser.GetTriggerRatesByLS("ExpressOutput")
|
31 |
|
|
else:
|
32 |
grchrist |
1.19 |
if len(parser.GetTriggerRatesByLS("ExpressOutput"))>0:
|
33 |
|
|
expressRates=parser.GetTriggerRatesByLS("ExpressOutput")
|
34 |
|
|
else:
|
35 |
|
|
expressRates = parser.GetTriggerRatesByLS("ExpressForCosmicsOutput")
|
36 |
amott |
1.12 |
ExpRate=0
|
37 |
|
|
PeakRate=0
|
38 |
amott |
1.13 |
AvgExpRate=0
|
39 |
grchrist |
1.15 |
|
40 |
amott |
1.13 |
ARate=0
|
41 |
grchrist |
1.15 |
PeakRateA=0
|
42 |
|
|
AvgRateA=0
|
43 |
|
|
|
44 |
amott |
1.13 |
if len(expressRates.values()) > 20:
|
45 |
|
|
AvgExpRate = sum(expressRates.values())/len(expressRates.values())
|
46 |
|
|
|
47 |
amott |
1.12 |
for ls in LumiRange: ## Find the sum and peak express stream rates
|
48 |
|
|
thisR = expressRates.get(ls,0)
|
49 |
|
|
ExpRate+=thisR
|
50 |
|
|
if thisR>PeakRate:
|
51 |
|
|
PeakRate=thisR
|
52 |
grchrist |
1.15 |
|
53 |
|
|
thisRateA=aRates.get(ls,0)
|
54 |
|
|
ARate+=thisRateA
|
55 |
|
|
if thisRateA>PeakRateA:
|
56 |
|
|
PeakRateA=thisRateA
|
57 |
|
|
|
58 |
|
|
#ARate+=aRates.get(ls,0)
|
59 |
|
|
## Print Stream A Rate --moved see below
|
60 |
|
|
##print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
|
61 |
amott |
1.12 |
|
62 |
amott |
1.13 |
Warn = False
|
63 |
amott |
1.12 |
|
64 |
grchrist |
1.15 |
##########################################
|
65 |
amott |
1.12 |
## Check if the express stream is too high
|
66 |
grchrist |
1.15 |
##########################################
|
67 |
amott |
1.12 |
global NHighExpress
|
68 |
|
|
badExpress = ExpRate/len(LumiRange) > config.MaxExpressRate ## avg express stream rate too high?
|
69 |
grchrist |
1.16 |
baseText = "\nCurrent Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display
|
70 |
amott |
1.12 |
if badExpress:
|
71 |
|
|
text = colored(baseText,'red',attrs=['reverse']) ## bad, make the text white on red
|
72 |
|
|
NHighExpress+=1 ## increment the bad express counter
|
73 |
|
|
else:
|
74 |
|
|
text = baseText
|
75 |
|
|
NHighExpress=0
|
76 |
|
|
|
77 |
|
|
write(text)
|
78 |
|
|
if badExpress:
|
79 |
|
|
if (ExpRate-PeakRate)/(len(LumiRange)-1) <=config.MaxExpressRate: ## one lumisection causes this
|
80 |
|
|
write(" << This appears to be due to a 1 lumisection spike, please monitor\n")
|
81 |
|
|
else:
|
82 |
amott |
1.13 |
if NHighExpress > 1: # big problem, call HLT DOC
|
83 |
|
|
write(colored(" << WARNING: Current Express rate is too high!",'red',attrs=['reverse']) )
|
84 |
|
|
Warn = True
|
85 |
|
|
|
86 |
|
|
# if AvgExpRate > config.MaxExpressRate:
|
87 |
|
|
# write( colored("\n\nWARNING: Average Express Stream Rate is too high (%0.1f Hz) << CALL HLT DOC" % AvgExpRate,'red',attrs=['reverse']) )
|
88 |
|
|
# Warn = True
|
89 |
grchrist |
1.15 |
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
#########################################
|
93 |
|
|
##Check if Stream A is too high
|
94 |
|
|
#########################################
|
95 |
|
|
global NHighStreamA
|
96 |
|
|
badStreamA =ARate/len(LumiRange) > config.MaxStreamARate ##Cosmics Express Rate 300 Hz max
|
97 |
|
|
baseTextA= "\nCurrent Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
|
98 |
|
|
if badStreamA:
|
99 |
grchrist |
1.16 |
textA=colored(baseTextA,'red',attrs=['reverse']) ## bad, make the text white on red
|
100 |
grchrist |
1.15 |
NHighStreamA+=1
|
101 |
|
|
else:
|
102 |
|
|
textA=baseTextA
|
103 |
|
|
NHighStreamA=0
|
104 |
|
|
|
105 |
|
|
write(textA)
|
106 |
|
|
if badStreamA:
|
107 |
|
|
if (ARate-PeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this
|
108 |
|
|
write(" << This appears to be due to a 1 lumisection spike, please monitor\n")
|
109 |
|
|
else:
|
110 |
|
|
if NHighStreamA >1: ##Call HLT doc!
|
111 |
grchrist |
1.16 |
write(colored(" << WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) )
|
112 |
grchrist |
1.15 |
Warn = True
|
113 |
amott |
1.13 |
write("\n\n")
|
114 |
grchrist |
1.15 |
|
115 |
|
|
######################################
|
116 |
|
|
##Warning for HLT doc
|
117 |
|
|
######################################
|
118 |
amott |
1.13 |
if Warn: ## WARNING
|
119 |
|
|
rows, columns = os.popen('stty size', 'r').read().split() ## Get the terminal size
|
120 |
|
|
cols = int(columns)
|
121 |
|
|
write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) )
|
122 |
|
|
line = "*" + " "*int((cols-22)/2)+"CALL HLT DOC (165575)"+" "*int((cols-23)/2)+"*\n"
|
123 |
amott |
1.12 |
|
124 |
amott |
1.13 |
write( colored(line,'red',attrs=['reverse','blink']) )
|
125 |
|
|
write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) )
|
126 |
amott |
1.12 |
|
127 |
grchrist |
1.17 |
|
128 |
amott |
1.1 |
PrescaleColumnString=''
|
129 |
abrinke1 |
1.10 |
PSCols = list(set(PSCols))
|
130 |
amott |
1.1 |
for c in PSCols:
|
131 |
|
|
PrescaleColumnString = PrescaleColumnString + str(c) + ","
|
132 |
|
|
|
133 |
amott |
1.13 |
if isCol:
|
134 |
|
|
write("The average instantaneous lumi of these lumisections is: ")
|
135 |
|
|
write(str(round(AvInstLumi,1))+"e30\n")
|
136 |
|
|
write("The delivered lumi of these lumi sections is: ")
|
137 |
|
|
write(str(round(len(LumiRange)*AvDeliveredLumi,1))+"e30"+"\n")
|
138 |
|
|
write("The live (recorded) lumi of these lumi sections is: ")
|
139 |
|
|
write(str(round(len(LumiRange)*AvLiveLumi,1))+"e30\n\n")
|
140 |
|
|
write("The average deadtime of these lumi sections is: ")
|
141 |
grchrist |
1.17 |
if deadtimebeamactive > 5:
|
142 |
amott |
1.13 |
write(bcolors.FAIL)
|
143 |
grchrist |
1.17 |
elif deadtimebeamactive > 10:
|
144 |
amott |
1.13 |
write(bcolors.WARNING)
|
145 |
|
|
else:
|
146 |
|
|
write(bcolors.OKBLUE)
|
147 |
grchrist |
1.17 |
write(str(round(deadtimebeamactive,2))+"%")
|
148 |
amott |
1.13 |
write(bcolors.ENDC+"\n")
|
149 |
amott |
1.1 |
|
150 |
amott |
1.3 |
print "Used prescale column(s): "+str(PrescaleColumnString)
|
151 |
amott |
1.4 |
write("Lumisections: ")
|
152 |
amott |
1.3 |
if not isSequential(LumiRange):
|
153 |
amott |
1.4 |
write(str(LumiRange)+" Lumisections are not sequential (bad LS skipped)\n")
|
154 |
|
|
else:
|
155 |
|
|
write("%d - %d\n" % (min(LumiRange),max(LumiRange),))
|
156 |
amott |
1.3 |
print "\nLast Lumisection of the run is: "+str(parser.GetLastLS())
|
157 |
grchrist |
1.19 |
write( "Last Lumisection good where DAQ is active is: "+str(parser.GetLastLS(isCol)) )
|
158 |
|
|
##write( "Last Lumisection where DAQ is active is: "+str(parser.GetLastLS(True)) )
|
159 |
amott |
1.12 |
write("\n\n\n")
|
160 |
amott |
1.5 |
|
161 |
amott |
1.13 |
if isCol:
|
162 |
|
|
L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi)
|
163 |
|
|
if len(L1RatePredictions):
|
164 |
|
|
print "Expected Level 1 Rates:"
|
165 |
|
|
for key,val in L1RatePredictions.iteritems():
|
166 |
|
|
write("Prescale Column "+str(key)+": "+str(round(val/1000,1))+" kHz")
|
167 |
|
|
if key == LastPSCol:
|
168 |
|
|
write(' << taking data in this column')
|
169 |
|
|
write('\n')
|
170 |
amott |
1.6 |
|
171 |
amott |
1.5 |
|
172 |
amott |
1.3 |
|
173 |
|
|
def isSequential(t):
|
174 |
|
|
try:
|
175 |
|
|
if len(t)<2:
|
176 |
|
|
return True
|
177 |
|
|
except:
|
178 |
|
|
return True
|
179 |
|
|
for i,e in enumerate(t[1:]):
|
180 |
|
|
if not abs(e-t[i])==1:
|
181 |
|
|
return False
|
182 |
|
|
return True
|