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.14 by amott, Thu Mar 15 14:50:54 2012 UTC vs.
Revision 1.19 by grchrist, Thu Apr 5 05:03:24 2012 UTC

# Line 5 | Line 5 | from termcolor import colored, cprint
5   write = sys.stdout.write
6  
7   NHighExpress=0
8 + NHighStreamA=0
9  
10   def MoreTableInfo(parser,LumiRange,config,isCol=True):
11      print "Monitoring Run %d" % (parser.RunNumber,)
12      [AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
13 +    deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange)
14      try:
15          LastPSCol = PSCols[-1]
16      except:
17          LastPSCol = -1
18 +    if isCol:
19          
20 <    aRates = parser.GetTriggerRatesByLS("AOutput")
20 >        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      expressRates = {}
29      if isCol:
30          expressRates = parser.GetTriggerRatesByLS("ExpressOutput")
31      else:
32 <        expressRates = parser.GetTriggerRatesByLS("ExpressCosmicsOutput")
32 >        if len(parser.GetTriggerRatesByLS("ExpressOutput"))>0:
33 >            expressRates=parser.GetTriggerRatesByLS("ExpressOutput")
34 >        else:
35 >            expressRates = parser.GetTriggerRatesByLS("ExpressForCosmicsOutput")
36      ExpRate=0
37      PeakRate=0
38      AvgExpRate=0
39 <
39 >    
40      ARate=0
41 +    PeakRateA=0
42 +    AvgRateA=0
43 +    
44      if len(expressRates.values()) > 20:
45          AvgExpRate = sum(expressRates.values())/len(expressRates.values())
46  
# Line 33 | Line 49 | def MoreTableInfo(parser,LumiRange,confi
49          ExpRate+=thisR
50          if thisR>PeakRate:
51              PeakRate=thisR
52 <        ARate+=aRates.get(ls,0)
53 <    ## Print Stream A Rate
54 <    print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
52 >
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  
62      Warn = False
63  
64 +    ##########################################
65      ## Check if the express stream is too high
66 +    ##########################################
67      global NHighExpress
68      badExpress = ExpRate/len(LumiRange) > config.MaxExpressRate ## avg express stream rate too high?
69 <    baseText = "Current Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display
69 >    baseText = "\nCurrent Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display
70      if badExpress:
71          text = colored(baseText,'red',attrs=['reverse'])  ## bad, make the text white on red
72          NHighExpress+=1  ## increment the bad express counter
# Line 62 | Line 86 | def MoreTableInfo(parser,LumiRange,confi
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 <    write("\n\n")
89 >    
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 >        textA=colored(baseTextA,'red',attrs=['reverse'])  ## bad, make the text white on red
100 >        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 +                write(colored("  <<  WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) )
112 +                Warn = True
113 +    write("\n\n")
114 +            
115 +    ######################################
116 +    ##Warning for HLT doc
117 +    ######################################
118      if Warn:  ## WARNING
119          rows, columns = os.popen('stty size', 'r').read().split()  ## Get the terminal size
120          cols = int(columns)
# Line 73 | Line 124 | def MoreTableInfo(parser,LumiRange,confi
124          write( colored(line,'red',attrs=['reverse','blink']) )
125          write( colored("*"*cols+"\n",'red',attrs=['reverse','blink']) )
126      
127 <    if AvDeadTime==0:  ## For some reason the dead time in the DB is occasionally broken
77 <        try:
78 <            AvDeadTime = AvLiveLumi/AvDeliveredLumi * 100
79 <        except:
80 <            AvDeadTime = 100
127 >    
128      PrescaleColumnString=''
129      PSCols = list(set(PSCols))
130      for c in PSCols:
# Line 91 | Line 138 | def MoreTableInfo(parser,LumiRange,confi
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 <        if AvDeadTime > 5:
141 >        if deadtimebeamactive > 5:
142              write(bcolors.FAIL)
143 <        elif AvDeadTime > 10:
143 >        elif deadtimebeamactive > 10:
144              write(bcolors.WARNING)
145          else:
146              write(bcolors.OKBLUE)
147 <        write(str(round(AvDeadTime,2))+"%")
147 >        write(str(round(deadtimebeamactive,2))+"%")
148          write(bcolors.ENDC+"\n")
149  
150      print "Used prescale column(s): "+str(PrescaleColumnString)    
# Line 107 | Line 154 | def MoreTableInfo(parser,LumiRange,confi
154      else:
155          write("%d - %d\n" % (min(LumiRange),max(LumiRange),))
156      print "\nLast Lumisection of the run is:        "+str(parser.GetLastLS())
157 <    write(  "Last Lumisection good for physics is:  "+str(parser.GetLastLS(True)) )
157 >    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      write("\n\n\n")
160  
161      if isCol:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines