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.12 by amott, Fri Mar 9 09:00:31 2012 UTC vs.
Revision 1.13 by amott, Mon Mar 12 16:48:37 2012 UTC

# Line 6 | Line 6 | write = sys.stdout.write
6  
7   NHighExpress=0
8  
9 < def MoreTableInfo(parser,LumiRange,config):
9 > def MoreTableInfo(parser,LumiRange,config,isCol=True):
10      [AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
11 <    LastPSCol = PSCols[-1]
12 <
13 <    expressRates = parser.GetTriggerRatesByLS("ExpressOutput")
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 = "Express stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display
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
# Line 36 | Line 54 | def MoreTableInfo(parser,LumiRange,confi
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 > 3:  # big problem, call HLT DOC
58 <                write(colored("  <<  WARNING: Express rate is too high!  Call HLT DOC",'red',attrs=['reverse','blink']) )
59 <
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:
# Line 51 | Line 82 | def MoreTableInfo(parser,LumiRange,confi
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(len(LumiRange)*AvDeliveredLumi,1))+"e30"+"\n")
89 <    write("The live (recorded) lumi of these lumi sections is:      ")
90 <    write(str(round(len(LumiRange)*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,2))+"%")
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 77 | Line 109 | def MoreTableInfo(parser,LumiRange,confi
109      write(  "Last Lumisection good for physics is:  "+str(parser.GetLastLS(True)) )
110      write("\n\n\n")
111  
112 <    L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi)
113 <    if len(L1RatePredictions):
114 <        print "Expected Level 1 Rates:"
115 <    for key,val in L1RatePredictions.iteritems():
116 <        write("Prescale Column "+str(key)+":  "+str(round(val/1000,1))+" kHz")
117 <        if key == LastPSCol:
118 <            write(' << taking data in this column')
119 <        write('\n')
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines