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.19 by grchrist, Thu Apr 5 05:03:24 2012 UTC vs.
Revision 1.34 by grchrist, Mon Jul 16 10:02:38 2012 UTC

# Line 2 | Line 2 | import sys
2   from colors import *
3   from DatabaseParser import *
4   from termcolor import colored, cprint
5 + import time
6 +
7 +
8   write = sys.stdout.write
9  
10   NHighExpress=0
# Line 9 | Line 12 | NHighStreamA=0
12  
13   def MoreTableInfo(parser,LumiRange,config,isCol=True):
14      print "Monitoring Run %d" % (parser.RunNumber,)
15 <    [AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
16 <    deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange)
15 >    localtime = time.asctime( time.localtime(time.time()) )
16 >    print "Local current time :", localtime
17 >    print "len=",len(LumiRange)
18 >    print "LSRange=", LumiRange
19 >    if len(LumiRange)>0:
20 >        
21 >        [AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
22 >        deadtimebeamactive=parser.GetDeadTimeBeamActive(LumiRange)*100
23 >        ##print "dtba=",deadtimebeamactive
24 >    else:
25 >        print "no lumisections to monitor"
26 >        return
27      try:
28          LastPSCol = PSCols[-1]
29      except:
# Line 18 | Line 31 | def MoreTableInfo(parser,LumiRange,confi
31      if isCol:
32          
33          aRates = parser.GetTriggerRatesByLS("AOutput")
34 +        bRates = parser.GetTriggerRatesByLS("BOutput")
35 +        if len(bRates) == 0:
36 +            realARates = aRates
37 +        else:
38 +            realARates={}
39 +            for k,v in bRates.iteritems():
40 +                realARates[k]=aRates[k]-bRates[k]*20
41 +                #realARates = aRates - bRates*20;
42      else:
43          if len(parser.GetTriggerRatesByLS("AOutput"))>0:
44              aRates = parser.GetTriggerRatesByLS("AOutput")
45 +            bRates = parser.GetTriggerRatesByLS("BOutput")
46          else:
47              aRates = parser.GetTriggerRatesByLS("AForPPOutput")
48 +            bRates = parser.GetTriggerRatesByLS("BForPPOutput")
49              
50      
51      expressRates = {}
# Line 41 | Line 64 | def MoreTableInfo(parser,LumiRange,confi
64      PeakRateA=0
65      AvgRateA=0
66      
67 +    realARate=0
68 +    realPeakRateA=0
69 +    realAvgRateA=0
70 +    
71      if len(expressRates.values()) > 20:
72          AvgExpRate = sum(expressRates.values())/len(expressRates.values())
73  
# Line 54 | Line 81 | def MoreTableInfo(parser,LumiRange,confi
81          ARate+=thisRateA
82          if thisRateA>PeakRateA:
83              PeakRateA=thisRateA
84 <        
84 >
85 >        thisRealRateA = aRates.get(ls,0) - bRates.get(ls,0)*20
86 >        realARate+=thisRealRateA
87 >        if thisRealRateA > realPeakRateA:
88 >            realReakRateA = thisRealRateA
89          #ARate+=aRates.get(ls,0)
90      ## Print Stream A Rate --moved see below
91      ##print "Current Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
# Line 62 | Line 93 | def MoreTableInfo(parser,LumiRange,confi
93      Warn = False
94  
95      ##########################################
96 <    ## Check if the express stream is too high
96 >    ## Check if the express stream is too high or low
97      ##########################################
98      global NHighExpress
99 <    badExpress = ExpRate/len(LumiRange) > config.MaxExpressRate ## avg express stream rate too high?
99 >    badExpress = ((ExpRate/len(LumiRange) > config.MaxExpressRate) or (ExpRate/len(LumiRange)<0.1 and isCol)) ## avg express stream rate too high?
100      baseText = "\nCurrent Express Stream rate is: %0.1f Hz" % (ExpRate/len(LumiRange),) ## text to display
101      if badExpress:
102          text = colored(baseText,'red',attrs=['reverse'])  ## bad, make the text white on red
# Line 76 | Line 107 | def MoreTableInfo(parser,LumiRange,confi
107          
108      write(text)
109      if badExpress:
110 <        if (ExpRate-PeakRate)/(len(LumiRange)-1) <=config.MaxExpressRate: ## one lumisection causes this
111 <            write("  <<  This appears to be due to a 1 lumisection spike, please monitor\n")
112 <        else:
113 <            if NHighExpress > 1:  # big problem, call HLT DOC
114 <                write(colored("  <<  WARNING: Current Express rate is too high!",'red',attrs=['reverse']) )
115 <                Warn = True
110 >        if len(LumiRange)>1:
111 >            if (ExpRate-PeakRate)/(len(LumiRange)-1) <=config.MaxExpressRate: ## one lumisection causes this
112 >                write("  <<  This appears to be due to a 1 lumisection spike, please monitor\n")
113 >            else:
114 >                if NHighExpress > 1:  # big problem, call HLT DOC
115 >                    write(colored("  <<  WARNING: Current Express rate is too high!",'red',attrs=['reverse']) )
116 >                    Warn = True
117  
118                  #    if AvgExpRate > config.MaxExpressRate:
119                  #        write( colored("\n\nWARNING: Average Express Stream Rate is too high (%0.1f Hz)  << CALL HLT DOC" % AvgExpRate,'red',attrs=['reverse']) )
120                  #        Warn = True
121 <    
121 >        
122 >            
123  
124  
125      #########################################
126      ##Check if Stream A is too high
127      #########################################
128      global NHighStreamA
129 <    badStreamA =ARate/len(LumiRange) > config.MaxStreamARate ##Cosmics Express Rate 300 Hz max
129 >    badStreamA =realARate/len(LumiRange) > config.MaxStreamARate ##Cosmics Express Rate 300 Hz max
130      baseTextA= "\nCurrent Steam A Rate is: %0.1f Hz" % (ARate/len(LumiRange),)
131 +    baseTextRealA= "\nCurrent PROMPT Steam A Rate is: %0.1f Hz" % (realARate/len(LumiRange),)
132      if badStreamA:
133          textA=colored(baseTextA,'red',attrs=['reverse'])  ## bad, make the text white on red
134 +        textRealA=colored(baseTextRealA,'red',attrs=['reverse'])  ## bad, make the text white on red
135          NHighStreamA+=1
136      else:
137          textA=baseTextA
138 +        textRealA=baseTextRealA
139          NHighStreamA=0
140  
141      write(textA)
142 +    write(textRealA)
143      if badStreamA:
144 <        if (ARate-PeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this
145 <            write("  <<  This appears to be due to a 1 lumisection spike, please monitor\n")
146 <        else:
147 <            if NHighStreamA >1: ##Call HLT doc!
148 <                write(colored("  <<  WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) )
149 <                Warn = True
144 >        if len(LumiRange)>1:
145 >            if (realARate-realPeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this
146 >                write("  <<  This appears to be due to a 1 lumisection spike, please monitor\n")
147 >            else:
148 >                if NHighStreamA >1: ##Call HLT doc!
149 >                    write(colored("  <<  WARNING: Current Stream A rate is too high!",'red',attrs=['reverse']) )
150 >                    Warn = True
151      write("\n\n")
152              
153      ######################################
# Line 146 | Line 184 | def MoreTableInfo(parser,LumiRange,confi
184              write(bcolors.OKBLUE)
185          write(str(round(deadtimebeamactive,2))+"%")
186          write(bcolors.ENDC+"\n")
187 <
188 <    print "Used prescale column(s): "+str(PrescaleColumnString)    
189 <    write("Lumisections: ")
187 >    write("Used prescale column(s): %s  " % (str(PrescaleColumnString),) )
188 >    if LastPSCol in config.ForbiddenCols and isCol:
189 >        write( colored("<< Using column %d! Please check in the documentation that this is the correct column" % (LastPSCol),'red',attrs=['reverse']) )
190 >    write("\nLumisections: ")
191      if not isSequential(LumiRange):
192          write(str(LumiRange)+"   Lumisections are not sequential (bad LS skipped)\n")
193      else:
194          write("%d - %d\n" % (min(LumiRange),max(LumiRange),))
195 <    print "\nLast Lumisection of the run is:        "+str(parser.GetLastLS())
196 <    write(  "Last Lumisection good where DAQ is active is:  "+str(parser.GetLastLS(isCol)) )
195 >    ##print "\nLast Lumisection of the run is:        "+str(parser.GetLastLS())
196 >    write(  "\nLast Lumisection good where DAQ is active is:  "+str(parser.GetLastLS(isCol)) )
197      ##write(  "Last Lumisection where DAQ is active is:  "+str(parser.GetLastLS(True)) )
198      write("\n\n\n")
199  
200 <    if isCol:
201 <        L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi)
202 <        if len(L1RatePredictions):
203 <            print "Expected Level 1 Rates:"
204 <        for key,val in L1RatePredictions.iteritems():
205 <            write("Prescale Column "+str(key)+":  "+str(round(val/1000,1))+" kHz")
206 <            if key == LastPSCol:
207 <                write(' << taking data in this column')
208 <            write('\n')
200 >    ## if isCol:
201 > ##         L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi)
202 > ##         if len(L1RatePredictions):
203 > ##             print "Expected Level 1 Rates:"
204 > ##         for key,val in L1RatePredictions.iteritems():
205 > ##             write("Prescale Column "+str(key)+":  "+str(round(val/1000,1))+" kHz")
206 > ##             if key == LastPSCol:
207 > ##                 write(' << taking data in this column')
208 > ##             write('\n')
209          
210      
211  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines