ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
StandaloneBunchgroupHandler.BunchgroupHandler Class Reference
Inheritance diagram for StandaloneBunchgroupHandler.BunchgroupHandler:
Collaboration diagram for StandaloneBunchgroupHandler.BunchgroupHandler:

Public Member Functions

def __init__ (self)
 
def openDB (self)
 
def closeDB (self)
 
def loadRunData (self, run)
 
def loadBunchgroups (self, run)
 
def getTrainPosition (self, run, lb, bcid)
 
def getNeighbourBcids (self, run, lb, bcid)
 
def getNeighbourPattern (self, run, lb, bcid)
 

Public Attributes

 trigProdDbName
 
 bunchGroupContentFolder
 
 bunchGroupDescFolder
 
 trigProdDb
 
 verbose
 
 physicsBunchgroupBit
 
 runObjects
 
 runArchive
 
 runsToArchive
 
 bcidRange
 

Detailed Description

Definition at line 71 of file StandaloneBunchgroupHandler.py.

Constructor & Destructor Documentation

◆ __init__()

def StandaloneBunchgroupHandler.BunchgroupHandler.__init__ (   self)

Definition at line 73 of file StandaloneBunchgroupHandler.py.

73  def __init__(self):
74 
75  # Database parameters
76  self.trigProdDbName = 'COOLONL_TRIGGER/COMP200'
77  self.bunchGroupContentFolder = '/TRIGGER/LVL1/BunchGroupContent'
78  self.bunchGroupDescFolder = '/TRIGGER/LVL1/BunchGroupDescription'
79 
80  # Database handle
81  self.trigProdDb = None
82 
83  # self.verbose = False
84  self.verbose = True
85 
86  # set physics bunch group
87  self.physicsBunchgroupBit = 1
88 
89  # run objects
90  self.runObjects = dict()
91 
92  # remember how many runs we have, keep only runsToArchive in memory
93  self.runArchive = []
94  # number of runs we keep in memory
95  self.runsToArchive = 20
96 
97  # BCID range
98  self.bcidRange = 32
99 

Member Function Documentation

◆ closeDB()

def StandaloneBunchgroupHandler.BunchgroupHandler.closeDB (   self)

Definition at line 110 of file StandaloneBunchgroupHandler.py.

110  def closeDB(self):
111  # Close the database
112  if self.trigProdDb is not None:
113  self.trigProdDb.closeDatabase()
114  self.trigProdDb = None
115 

◆ getNeighbourBcids()

def StandaloneBunchgroupHandler.BunchgroupHandler.getNeighbourBcids (   self,
  run,
  lb,
  bcid 
)

Definition at line 155 of file StandaloneBunchgroupHandler.py.

155  def getNeighbourBcids(self,run,lb,bcid):
156 
157  if self.verbose:
158  print('getNeighbourBcids called')
159 
160  before, after = self.getNeighbourPattern(run,lb,bcid)
161 
162  l1 = []
163  for bcidOffset in range(len(before)):
164  checkBcid = bcid - (bcidOffset+1)
165  if checkBcid < 0: checkBcid += 3564
166  if before[bcidOffset]:
167  if self.verbose:
168  print("BCID",checkBcid,"is filled")
169  l1.append(checkBcid)
170  l2 = []
171  for bcidOffset in range(len(after)):
172  checkBcid = bcid + (bcidOffset+1)
173  if checkBcid > 3563: checkBcid -= 3564
174  if after[bcidOffset]:
175  if self.verbose:
176  print("BCID",checkBcid,"is filled")
177  l2.append(checkBcid)
178  return l1, l2
179 
180 

◆ getNeighbourPattern()

def StandaloneBunchgroupHandler.BunchgroupHandler.getNeighbourPattern (   self,
  run,
  lb,
  bcid 
)

Definition at line 181 of file StandaloneBunchgroupHandler.py.

181  def getNeighbourPattern(self,run,lb,bcid):
182 
183  if self.verbose:
184  print('getNeighbourPattern called')
185 
186  lbList = []
187  try:
188  lbList = list(self.runObjects[run].physicsBunchgroupBcids.keys())
189  except KeyError:
190  self.loadRunData(run)
191  lbList = list(self.runObjects[run].physicsBunchgroupBcids.keys())
192 
193  latestLb = -1
194  try:
195  latestLb = self.runObjects[run].lbLookup[lb]
196  except KeyError:
197  for testLb in sorted(lbList):
198  if latestLb < 0: latestLb = testLb
199  if lb > testLb: latestLb = testLb
200  if self.verbose:
201  print("LB",lb,"latest LB",latestLb)
202  self.runObjects[run].lbLookup[lb] = latestLb
203 
204  return (self.runObjects[run].bcidLookupBefore[latestLb][bcid], self.runObjects[run].bcidLookupAfter[latestLb][bcid])
205 

◆ getTrainPosition()

def StandaloneBunchgroupHandler.BunchgroupHandler.getTrainPosition (   self,
  run,
  lb,
  bcid 
)

Definition at line 148 of file StandaloneBunchgroupHandler.py.

148  def getTrainPosition(self,run,lb,bcid):
149 
150  if self.verbose:
151  print('getTrainPosition called')
152  before, after = self.getNeighbourBcids(run,lb,bcid)
153  return (len(before)+1)
154 

◆ loadBunchgroups()

def StandaloneBunchgroupHandler.BunchgroupHandler.loadBunchgroups (   self,
  run 
)

Definition at line 126 of file StandaloneBunchgroupHandler.py.

126  def loadBunchgroups(self, run):
127 
128  self.runObjects[run] = BunchgroupRunData(run)
129  self.runArchive.append(run)
130  self.runObjects[run].verbose = self.verbose
131 
132  if self.verbose:
133  print('loadBounchgroups called, run',run)
134 
135  bgFolder = self.trigProdDb.getFolder(self.bunchGroupContentFolder)
136  itr = bgFolder.browseObjects(run << 32,(run+1) << 32,cool.ChannelSelection.all())
137  while itr.goToNext() :
138  obj=itr.currentRef()
139  lb=(obj.since() & 0xffff)
140  self.runObjects[run].physicsBunchgroupBcids[lb] = []
141  bgcont = obj.payload()['BunchCode']
142  for bcid in range(3564):
143  if(bgcont[bcid]>>self.physicsBunchgroupBit & 1): self.runObjects[run].physicsBunchgroupBcids[lb].append(bcid)
144  self.runObjects[run].createLookup(lb,self.bcidRange)
145  if self.verbose:
146  print("LB",lb,"BCIDs",self.runObjects[run].physicsBunchgroupBcids[lb])
147 

◆ loadRunData()

def StandaloneBunchgroupHandler.BunchgroupHandler.loadRunData (   self,
  run 
)

Definition at line 116 of file StandaloneBunchgroupHandler.py.

116  def loadRunData(self, run):
117  self.openDB()
118  self.loadBunchgroups(run)
119  self.closeDB()
120  if len(self.runArchive) > self.runsToArchive:
121  if self.verbose:
122  print("Remove run",self.runArchive[0],"from memory")
123  del self.runObjects[self.runArchive[0]]
124  self.runArchive.pop(0)
125 

◆ openDB()

def StandaloneBunchgroupHandler.BunchgroupHandler.openDB (   self)

Definition at line 100 of file StandaloneBunchgroupHandler.py.

100  def openDB(self):
101  # Open the trigger COOL database
102  try:
103  self.trigProdDb = indirectOpen(self.trigProdDbName, True, False)
104  if self.verbose: print('Connected to', self.trigProdDbName, 'for Trigger data')
105  except Exception as e:
106  print(e)
107  return False
108  return True
109 

Member Data Documentation

◆ bcidRange

StandaloneBunchgroupHandler.BunchgroupHandler.bcidRange

Definition at line 98 of file StandaloneBunchgroupHandler.py.

◆ bunchGroupContentFolder

StandaloneBunchgroupHandler.BunchgroupHandler.bunchGroupContentFolder

Definition at line 77 of file StandaloneBunchgroupHandler.py.

◆ bunchGroupDescFolder

StandaloneBunchgroupHandler.BunchgroupHandler.bunchGroupDescFolder

Definition at line 78 of file StandaloneBunchgroupHandler.py.

◆ physicsBunchgroupBit

StandaloneBunchgroupHandler.BunchgroupHandler.physicsBunchgroupBit

Definition at line 87 of file StandaloneBunchgroupHandler.py.

◆ runArchive

StandaloneBunchgroupHandler.BunchgroupHandler.runArchive

Definition at line 93 of file StandaloneBunchgroupHandler.py.

◆ runObjects

StandaloneBunchgroupHandler.BunchgroupHandler.runObjects

Definition at line 90 of file StandaloneBunchgroupHandler.py.

◆ runsToArchive

StandaloneBunchgroupHandler.BunchgroupHandler.runsToArchive

Definition at line 95 of file StandaloneBunchgroupHandler.py.

◆ trigProdDb

StandaloneBunchgroupHandler.BunchgroupHandler.trigProdDb

Definition at line 81 of file StandaloneBunchgroupHandler.py.

◆ trigProdDbName

StandaloneBunchgroupHandler.BunchgroupHandler.trigProdDbName

Definition at line 76 of file StandaloneBunchgroupHandler.py.

◆ verbose

StandaloneBunchgroupHandler.BunchgroupHandler.verbose

Definition at line 84 of file StandaloneBunchgroupHandler.py.


The documentation for this class was generated from the following file:
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.AtlCoolLib.indirectOpen
def indirectOpen(coolstr, readOnly=True, debug=False)
Definition: AtlCoolLib.py:130