ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/RateMonShiftTool_dev/AddTableInfo_db.py
Revision: 1.5
Committed: Thu Feb 16 16:25:57 2012 UTC (13 years, 2 months ago) by amott
Content type: text/x-python
Branch: MAIN
Changes since 1.4: +9 -2 lines
Log Message:
Added ability to predict L1 rates

File Contents

# Content
1 import sys
2 from colors import *
3 from DatabaseParser import *
4 write = sys.stdout.write
5
6 def MoreTableInfo(parser,LumiRange,config):
7 [AvInstLumi, AvLiveLumi, AvDeliveredLumi, AvDeadTime,PSCols] = parser.GetAvLumiInfo(LumiRange)
8
9 if AvDeadTime==0: ## For some reason the dead time in the DB is occasionally broken
10 try:
11 AvDeadTime = AvLiveLumi/AvDeliveredLumi * 100
12 except:
13 AvDeadTime = 100
14 PrescaleColumnString=''
15 for c in PSCols:
16 PrescaleColumnString = PrescaleColumnString + str(c) + ","
17
18 write("The average instantaneous lumi of these lumisections is: ")
19 write(str(round(AvInstLumi,1))+"e30\n")
20 write("The delivered lumi of these lumi sections is: ")
21 write(str(round(1000*AvDeliveredLumi,1))+"e30"+"\n")
22 write("The live (recorded) lumi of these lumi sections is: ")
23 write(str(round(1000*AvLiveLumi,1))+"e30\n\n")
24 write("The average deadtime of these lumi sections is: ")
25 if AvDeadTime > 5:
26 write(bcolors.FAIL)
27 elif AvDeadTime > 10:
28 write(bcolors.WARNING)
29 else:
30 write(bcolors.OKBLUE)
31 write(str(round(AvDeadTime,1))+"%")
32 write(bcolors.ENDC+"\n")
33
34 print "Used prescale column(s): "+str(PrescaleColumnString)
35 write("Lumisections: ")
36 if not isSequential(LumiRange):
37 write(str(LumiRange)+" Lumisections are not sequential (bad LS skipped)\n")
38 else:
39 write("%d - %d\n" % (min(LumiRange),max(LumiRange),))
40 print "\nLast Lumisection of the run is: "+str(parser.GetLastLS())
41 write( "Last Lumisection good for physics is: "+str(parser.GetLastLS(True)) )
42 if parser.GetLastLS(True)!=max(LumiRange):
43 write(bcolors.WARNING)
44 write(" << This exceeds the last lumisection parsed")
45 write(bcolors.ENDC+"\n\n\n")
46
47 L1RatePredictions = config.GetExpectedL1Rates(AvInstLumi)
48 if len(L1RatePredictions):
49 print "Expected Level 1 Rates:"
50 for key,val in L1RatePredictions.iteritems():
51 print "Prescale Column "+str(key)+": "+str(round(val/1000,1))+" kHz"
52
53
54 def isSequential(t):
55 try:
56 if len(t)<2:
57 return True
58 except:
59 return True
60 for i,e in enumerate(t[1:]):
61 if not abs(e-t[i])==1:
62 return False
63 return True