ATLAS Offline Software
Functions | Variables
python.BunchSpacingUtils Namespace Reference

Functions

def bunchSpacingOfRun (runnumber, LB, verbose=False)
 

Variables

 rn = int(sys.argv[1])
 
 lb = int(sys.argv[2])
 

Function Documentation

◆ bunchSpacingOfRun()

def python.BunchSpacingUtils.bunchSpacingOfRun (   runnumber,
  LB,
  verbose = False 
)

Definition at line 9 of file BunchSpacingUtils.py.

9 def bunchSpacingOfRun(runnumber,LB,verbose=False):
10  if (runnumber<236107):
11  print ("WARNING BunchSpacingUtils don't work for run-1 data")
12  return None
13 
14  tdaqDBName="COOLONL_TDAQ/CONDBR2"
15  folder="/TDAQ/OLC/LHC/FILLPARAMS"
16  iovtime=getTimeForLB(runnumber,LB)
17 
18  if iovtime==0:
19  print ("ERROR, can't get start time of run %i, LB %i" % (runnumber,LB))
20  return None
21 
22  obj=None
23  db = None
24  try:
25  db=indirectOpen(tdaqDBName)
26  print (db)
27  print (iovtime)
28  f=db.getFolder(folder)
29  obj=f.findObject(cool.ValidityKey(iovtime),0)
30  except Exception as e:
31  print (e)
32  if len(e.args)>1 and e.args[0].find("Object not found - 0"):
33  print ("WARNING No data found in folder %s for run/LB %i/%i" % (folder,runnumber,LB))
34  else:
35  print ("BunchSpacingUtils: ERROR accesssing folder",folder,"on db",tdaqDBName)
36  print (e)
37 
38  if db is not None:
39  db.closeDatabase()
40  return None
41 
42  pl=obj.payload()
43  buf=pl["BCIDmasks"]
44 
45 
46  bucketDiff=0
47  firstFilled=-1
48  lastFilled=-1
49  bucketDiffs=[]
50 
51  for iBucket,filled in enumerate(buf):
52  if filled!=0:
53  if (verbose): print ("Bucket",iBucket,"filled")
54  lastFilled=iBucket
55  if firstFilled<0:
56  firstFilled=iBucket
57  if (verbose): print ("First filled bucket=",iBucket)
58  else:
59  if (verbose): print ("Bucket #%i, bunch spacing=%i * 25ns" % (iBucket,bucketDiff))
60  bucketDiffs.append(bucketDiff)
61  bucketDiff=1
62 
63  pass
64  else: # not filled
65  if (verbose): print ("Bucket",iBucket,"not filled")
66  bucketDiff+=1
67  pass
68 
69  #Handle wrap-around:
70  if (firstFilled>=0 and lastFilled>0):
71  bucketDiffs.append(len(buf)-lastFilled+firstFilled)
72  if (verbose): print ("Bunchdiff at wrap-around:",(len(buf)-lastFilled+firstFilled))
73  if db is not None:
74  db.closeDatabase()
75  if len(bucketDiffs)==0:
76  return None
77  else:
78  return min(bucketDiffs)
79 
80 

Variable Documentation

◆ lb

python.BunchSpacingUtils.lb = int(sys.argv[2])

Definition at line 87 of file BunchSpacingUtils.py.

◆ rn

python.BunchSpacingUtils.rn = int(sys.argv[1])

Definition at line 86 of file BunchSpacingUtils.py.

find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
python.BunchSpacingUtils.bunchSpacingOfRun
def bunchSpacingOfRun(runnumber, LB, verbose=False)
Definition: BunchSpacingUtils.py:9
python.MagFieldUtils.getTimeForLB
def getTimeForLB(run, LB)
Definition: MagFieldUtils.py:144
python.AtlCoolLib.indirectOpen
def indirectOpen(coolstr, readOnly=True, debug=False)
Definition: AtlCoolLib.py:130