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.27 by amott, Thu May 3 15:31:09 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 +    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:
# Line 26 | 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 49 | 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 62 | 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 70 | 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 103 | Line 126 | def MoreTableInfo(parser,LumiRange,confi
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 len(LumiRange)>1:
145 <            if (ARate-PeakRateA)/(len(LumiRange)-1) <=config.MaxStreamARate: ## one lumisection causes this
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!

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines