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 10 of file BunchSpacingUtils.py.

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

Variable Documentation

◆ lb

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

Definition at line 88 of file BunchSpacingUtils.py.

◆ rn

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

Definition at line 87 of file BunchSpacingUtils.py.

find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
min
#define min(a, b)
Definition: cfImp.cxx:40
python.BunchSpacingUtils.bunchSpacingOfRun
def bunchSpacingOfRun(runnumber, LB, verbose=False)
Definition: BunchSpacingUtils.py:10
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