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.24 by grchrist, Fri Apr 6 15:32:24 2012 UTC vs.
Revision 1.40 by grchrist, Wed Oct 3 11:36:09 2012 UTC

# Line 2 | Line 2 | import sys
2   from colors import *
3   from DatabaseParser import *
4   from termcolor import colored, cprint
5 + from StreamMonitor import *
6 + import time
7 +
8 +
9   write = sys.stdout.write
10  
11 < NHighExpress=0
12 < NHighStreamA=0
11 > NHighStreamA = 0
12 > NHighExpress = 0
13  
14   def MoreTableInfo(parser,LumiRange,config,isCol=True):
15      print "Monitoring Run %d" % (parser.RunNumber,)
16 +    localtime = time.asctime( time.localtime(time.time()) )
17 +    print "Local current time :", localtime
18 +    #print "Lumisections used=", LumiRange
19      if len(LumiRange)>0:
20 +        
21          [AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
22          deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange)*100
23 +        
24          ##print "dtba=",deadtimebeamactive
25      else:
26          print "no lumisections to monitor"
27          return
28 +  ## check if lumi is being filled
29 +    if parser.LastLSParsed > 4 and isCol:
30 +        if set(parser.InstLumiByLS.values()) == set([None]):
31 +            write(colored("\n\nLUMI INFORMATION NOT BEING SENT!\n",'red',attrs=['reverse']))
32 +            write(colored("Check with Shift Leader if this is expected\n",'red',attrs=['reverse']))
33 +            write(colored("If not, HFLUMI needs to be red-recycled\n\n\n",'red',attrs=['reverse']))
34 +            write(colored("If in doubt, call Lumi DOC\n\n\n",'red',attrs=['reverse']))
35 +            #return
36 +                                                                                                                                                                                                                                                                    
37 +    try:
38 +        #print "trying v3"
39 +        lograte=parser.GetTriggerRatesByLS("HLT_LogMonitor_v3")
40 +        #print lograte
41 +        if not len(lograte):
42 +            #print "trying v4"
43 +            lograte=parser.GetTriggerRatesByLS("HLT_LogMonitor_v4")
44 +            
45 +        #print lograte
46 +        for lumi in lograte.iterkeys():
47 +            #print lumi, lograte[lumi]
48 +            if lograte[lumi]>config.MaxLogMonRate:
49 +                write(bcolors.WARNING)
50 +                print lograte[lumi], "post to elog. LogMonitor rate is high."
51 +                write(bcolors.ENDC+"\n")
52 +    except:
53 +        write(bcolors.WARNING)
54 +        print "problem getting log monitor rates"
55 +        write(bcolors.ENDC+"\n")
56 +
57      try:
58          LastPSCol = PSCols[-1]
59      except:
60          LastPSCol = -1
23    if isCol:
24        
25        aRates = parser.GetTriggerRatesByLS("AOutput")
26    else:
27        if len(parser.GetTriggerRatesByLS("AOutput"))>0:
28            aRates = parser.GetTriggerRatesByLS("AOutput")
29        else:
30            aRates = parser.GetTriggerRatesByLS("AForPPOutput")
31            
61      
62      expressRates = {}
63      if isCol:
64          expressRates = parser.GetTriggerRatesByLS("ExpressOutput")
65      else:
66          if len(parser.GetTriggerRatesByLS("ExpressOutput"))>0:
67 <            expressRates=parser.GetTriggerRatesByLS("ExpressOutput")
67 >            expressRates=parser.GetTriggerRatesByLS("else")
68          else:
69              expressRates = parser.GetTriggerRatesByLS("ExpressForCosmicsOutput")
70 +
71      ExpRate=0
72      PeakRate=0
73      AvgExpRate=0
74      
45    ARate=0
46    PeakRateA=0
47    AvgRateA=0
48    
75      if len(expressRates.values()) > 20:
76          AvgExpRate = sum(expressRates.values())/len(expressRates.values())
77 +    counter=0    
78  
79      for ls in LumiRange:  ## Find the sum and peak express stream rates
80          thisR = expressRates.get(ls,0)
# Line 55 | Line 82 | def MoreTableInfo(parser,LumiRange,confi
82          if thisR>PeakRate:
83              PeakRate=thisR
84  
85 <        thisRateA=aRates.get(ls,0)
59 <        ARate+=thisRateA
60 <        if thisRateA>PeakRateA:
61 <            PeakRateA=thisRateA
62 <        
63 <        #ARate+=aRates.get(ls,0)
85 >
86      ## Print Stream A Rate --moved see below
87      ##print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
88  
89      Warn = False
90  
91      ##########################################
92 <    ## Check if the express stream is too high
92 >    ## Check if the express stream is too high or low
93      ##########################################
94 <    global NHighExpress
73 <    badExpress = ExpRate/len(LumiRange) > config.MaxExpressRate ## avg express stream rate too high?
94 >    badExpress = ((ExpRate/len(LumiRange) > config.MaxExpressRate) or (ExpRate/len(LumiRange)<0.1 and isCol)) ## avg express stream rate too high?
95      baseText = "\nCurrent Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display
96      if badExpress:
97          text = colored(baseText,'red',attrs=['reverse'])  ## bad, make the text white on red
# Line 100 | Line 121 | def MoreTableInfo(parser,LumiRange,confi
121      ##Check if Stream A is too high
122      #########################################
123      global NHighStreamA
124 <    badStreamA =ARate/len(LumiRange) > config.MaxStreamARate ##Cosmics Express Rate 300 Hz max
125 <    baseTextA= "\nCurrent Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
126 <    if badStreamA:
127 <        textA=colored(baseTextA,'red',attrs=['reverse'])  ## bad, make the text white on red
128 <        NHighStreamA+=1
129 <    else:
130 <        textA=baseTextA
131 <        NHighStreamA=0
124 >    stream_mon = StreamMonitor()
125 >    core_a_rates = stream_mon.getStreamACoreRatesByLS(parser,LumiRange,config,isCol).values()
126 >    a_rates = stream_mon.getStreamARatesByLS(parser,LumiRange).values()
127 >    peak_core_a_rate = max(core_a_rates)
128 >
129 >    if len(LumiRange) > 0:
130 >        avg_core_a_rate = sum(core_a_rates)/len(LumiRange)
131 >        avg_a_rate = sum(a_rates)/len(LumiRange)
132 >        badStreamA = stream_mon.compareStreamARate(config, avg_core_a_rate, LumiRange,AvInstLumi,isCol)
133 >
134 >        baseTextA= "\nCurrent Stream A Rate is: %0.1f Hz" % (avg_a_rate)
135 >        baseTextRealA= "\nCurrent PROMPT Stream A Rate is: %0.1f Hz" % (avg_core_a_rate)
136 >
137 >        if badStreamA:
138 >            textA=colored(baseTextA,'red',attrs=['reverse'])  ## bad, make the text white on red
139 >            textRealA=colored(baseTextRealA,'red',attrs=['reverse'])  ## bad, make the text white on red
140 >            NHighStreamA+=1
141 >        else:
142 >            textA=baseTextA
143 >            textRealA=baseTextRealA
144  
145 <    write(textA)
146 <    if badStreamA:
147 <        if len(LumiRange)>1:
148 <            if (ARate-PeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this
145 >        write(textA)
146 >        write(textRealA)
147 >    
148 >        if badStreamA and len(LumiRange) > 1:
149 >            trimmed_core_a_rates = core_a_rates
150 >            trimmed_core_a_rates.remove(peak_core_a_rate)
151 >            if sum(trimmed_core_a_rates)/(len(LumiRange)-1) <= config.MaxStreamARate: ## one lumisection causes this
152                  write("  <<  This appears to be due to a 1 lumisection spike, please monitor\n")
153              else:
154 <                if NHighStreamA >1: ##Call HLT doc!
154 >                if NHighStreamA > 1: ##Call HLT doc!
155                      write(colored("  <<  WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) )
156                      Warn = True
157      write("\n\n")
# Line 131 | Line 167 | def MoreTableInfo(parser,LumiRange,confi
167  
168          write( colored(line,'red',attrs=['reverse','blink']) )
169          write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) )
170 <    
170 >        
171      
172      PrescaleColumnString=''
173      PSCols = list(set(PSCols))
# Line 154 | Line 190 | def MoreTableInfo(parser,LumiRange,confi
190              write(bcolors.OKBLUE)
191          write(str(round(deadtimebeamactive,2))+"%")
192          write(bcolors.ENDC+"\n")
193 <
194 <    print "Used prescale column(s): "+str(PrescaleColumnString)    
195 <    write("Lumisections: ")
193 >    write("Used prescale column(s): %s  " % (str(PrescaleColumnString),) )
194 >    if LastPSCol in config.ForbiddenCols and isCol:
195 >        write( colored("<< Using column %d! Please check in the documentation that this is the correct column" % (LastPSCol),'red',attrs=['reverse']) )
196 >    write("\nLumisections: ")
197      if not isSequential(LumiRange):
198          write(str(LumiRange)+"   Lumisections are not sequential (bad LS skipped)\n")
199      else:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines