ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/AddTableInfo_db.py
(Generate patch)

Comparing UserCode/RateMonShiftTool_dev/AddTableInfo_db.py (file contents):
Revision 1.4 by amott, Wed Feb 15 12:16:37 2012 UTC vs.
Revision 1.13 by amott, Mon Mar 12 16:48:37 2012 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines