4 from PyCool
import cool
5 from CoolConvUtilities.MagFieldUtils
import getTimeForLB
6 from CoolConvUtilities.AtlCoolLib
import indirectOpen
10 print (
"WARNING BunchSpacingUtils don't work for run-1 data")
13 tdaqDBName=
"COOLONL_TDAQ/CONDBR2"
14 folder=
"/TDAQ/OLC/LHC/FILLPARAMS"
18 print (
"ERROR, can't get start time of run %i, LB %i" % (runnumber,LB))
27 f=db.getFolder(folder)
28 obj=f.findObject(cool.ValidityKey(iovtime),0)
29 except Exception
as e:
31 if len(e.args)>1
and e.args[0].
find(
"Object not found - 0"):
32 print (
"WARNING No data found in folder %s for run/LB %i/%i" % (folder,runnumber,LB))
34 print (
"BunchSpacingUtils: ERROR accesssing folder",folder,
"on db",tdaqDBName)
50 for iBucket,filled
in enumerate(buf):
52 if (verbose):
print (
"Bucket",iBucket,
"filled")
56 if (verbose):
print (
"First filled bucket=",iBucket)
58 if (verbose):
print (
"Bucket #%i, bunch spacing=%i * 25ns" % (iBucket,bucketDiff))
59 bucketDiffs.append(bucketDiff)
64 if (verbose):
print (
"Bucket",iBucket,
"not filled")
69 if (firstFilled>=0
and lastFilled>0):
70 bucketDiffs.append(len(buf)-lastFilled+firstFilled)
71 if (verbose):
print (
"Bunchdiff at wrap-around:",(len(buf)-lastFilled+firstFilled))
74 if len(bucketDiffs)==0:
77 return min(bucketDiffs)
80 if __name__==
"__main__":
83 print (
"Usage: BunchSpacingUtils.py <run> <lb>")
87 print (
"Checking bunch spacing for run,lb",rn,lb)