ATLAS Offline Software
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | List of all members
python.DQUtilities.IDBSDefectData Class Reference
Collaboration diagram for python.DQUtilities.IDBSDefectData:

Public Member Functions

def __init__ (self, database='COOLOFL_GLOBAL/CONDBR2', tag='HEAD', debug=False)
 
def __del__ (self)
 
def connect (self)
 
def defectList (self)
 
def defect (self, run, lb, channels=None)
 
def defectsRange (self, run, lbStart, lbEnd, channels=None)
 
def dumpRun (self, run, channels=None)
 

Public Attributes

 db
 
 idbsDefects
 

Static Public Attributes

list defectBitPos
 
 database
 
 tag
 
 lastRun
 
 iovsets
 
 debug
 

Private Member Functions

def _defectForLB (self, lb)
 

Detailed Description

Container for beamspot DQ defects from COOL

Definition at line 196 of file DQUtilities.py.

Constructor & Destructor Documentation

◆ __init__()

def python.DQUtilities.IDBSDefectData.__init__ (   self,
  database = 'COOLOFL_GLOBAL/CONDBR2',
  tag = 'HEAD',
  debug = False 
)

Definition at line 205 of file DQUtilities.py.

205  def __init__(self, database='COOLOFL_GLOBAL/CONDBR2', tag='HEAD', debug=False):

◆ __del__()

def python.DQUtilities.IDBSDefectData.__del__ (   self)
Delete db to clear connection

Definition at line 221 of file DQUtilities.py.

221  def __del__(self):
222  """
223  Delete db to clear connection
224  """
225 
226  del self.db
227  pass
228 
229 

Member Function Documentation

◆ _defectForLB()

def python.DQUtilities.IDBSDefectData._defectForLB (   self,
  lb 
)
private
Get the DQ defects for the given LB from the full run info

Definition at line 298 of file DQUtilities.py.

298  def _defectForLB(self, lb):
299  """
300  Get the DQ defects for the given LB from the full run info
301  """
302 
303  defects = []
304  for since, until, states in process_iovs(*self.iovsets):
305  if since.lumi <= lb < until.lumi:
306  # defects is true if set for a given run/LB
307  defects = [state.channel for state in states if state]
308 
309  return list(set(defects))
310 
311 

◆ connect()

def python.DQUtilities.IDBSDefectData.connect (   self)
Open connection to defect DB

Definition at line 230 of file DQUtilities.py.

230  def connect(self):
231  """
232  Open connection to defect DB
233  """
234 
235  self.db = DefectsDB(self.database, read_only=True, create=False, tag=self.tag)
236  self.idbsDefects = [d for d in self.db.defect_names if d.startswith('ID_BS_') or d == 'LUMI_VDM']
237 
238  if self.debug:
239  print (self.idbsDefects)
240 
241  return
242 

◆ defect()

def python.DQUtilities.IDBSDefectData.defect (   self,
  run,
  lb,
  channels = None 
)
Get list of DQ defects for a particular run and lb, caching the result for the latest (succesful) run
e.g.
 from InDetBeamSpotExample.DQUtilities import IDBSDefectData
 idbs = IDBSDefectData()
 idbs.defect(167661,372)

channels is the list of defects to look for (defaults to all ID_BS defects)

Definition at line 250 of file DQUtilities.py.

250  def defect(self, run, lb, channels=None):
251  """
252  Get list of DQ defects for a particular run and lb, caching the result for the latest (succesful) run
253  e.g.
254  from InDetBeamSpotExample.DQUtilities import IDBSDefectData
255  idbs = IDBSDefectData()
256  idbs.defect(167661,372)
257 
258  channels is the list of defects to look for (defaults to all ID_BS defects)
259  """
260 
261  if channels is None:
262  channels = self.idbsDefects
263 
264  # Encode start and end of run
265  lbMin = 0
266  lbMax = (1 << 32)-1
267  since = (run << 32)+lbMin
268  until = (run << 32)+lbMax
269 
270  # If the run is the same at the previous one return defects from cache
271  if run == self.lastRun:
272  defects = self._defectForLB(lb)
273  if self.debug:
274  print (run, lb, defects)
275  return defects
276 
277  # Retrive info for entire run
278  iovs = self.db.retrieve(since, until, channels=channels)
279 
280  # Check if run exists
281  if not iovs:
282  print ("Unable to access folder with given parameters")
283  return []
284 
285  # If found, update last run and get list of IOVSets for each defect/channel
286  self.lastRun = run
287  chans, self.iovsets = iovs.chans_iovsets
288 
289  defects = self._defectForLB(lb)
290 
291  # Debug
292  if self.debug:
293  iovs.pprint()
294  print (run, lb, defects)
295 
296  return defects
297 

◆ defectList()

def python.DQUtilities.IDBSDefectData.defectList (   self)
List of all possible beamspot defects

Definition at line 243 of file DQUtilities.py.

243  def defectList(self):
244  """
245  List of all possible beamspot defects
246  """
247 
248  return self.idbsDefects
249 

◆ defectsRange()

def python.DQUtilities.IDBSDefectData.defectsRange (   self,
  run,
  lbStart,
  lbEnd,
  channels = None 
)
Return the maximal list of defects for a given range. lbEnd is exclusive

Definition at line 312 of file DQUtilities.py.

312  def defectsRange(self, run, lbStart, lbEnd, channels=None):
313  """
314  Return the maximal list of defects for a given range. lbEnd is exclusive
315  """
316 
317  defects = []
318  for lb in range(lbStart, lbEnd):
319  defects.extend(self.defect(run, lb, channels=channels))
320 
321  return list(set(defects))
322 

◆ dumpRun()

def python.DQUtilities.IDBSDefectData.dumpRun (   self,
  run,
  channels = None 
)
Dump DQ info for a particular run (useful in reprocessing to compare new to old)

Definition at line 323 of file DQUtilities.py.

323  def dumpRun(self, run, channels=None):
324  """
325  Dump DQ info for a particular run (useful in reprocessing to compare new to old)
326  """
327 
328  if channels is None:
329  channels = self.idbsDefects
330 
331  # Encode start and end of run
332  lbMin = 0
333  lbMax = (1 << 32)-1
334  since = (run << 32)+lbMin
335  until = (run << 32)+lbMax
336 
337  # Retrive info for entire run
338  iovs = self.db.retrieve(since, until, channels=channels, nonpresent=True)
339 
340  # Check if run exists
341  if not iovs:
342  print ("Unable to access folder with given parameters")
343  return []
344 
345  iovs.pprint()
346 
347  return
348 

Member Data Documentation

◆ database

python.DQUtilities.IDBSDefectData.database
static
Initialise database connection 

Definition at line 211 of file DQUtilities.py.

◆ db

python.DQUtilities.IDBSDefectData.db

Definition at line 235 of file DQUtilities.py.

◆ debug

python.DQUtilities.IDBSDefectData.debug
static

Definition at line 215 of file DQUtilities.py.

◆ defectBitPos

list python.DQUtilities.IDBSDefectData.defectBitPos
static
Initial value:
= ['UNKNOWN', 'ID_BS_2010YELLOW', 'ID_BS_RUNAVERAGE', 'ID_BS_PARAMETERSTEP',
'ID_BS_NOBEAMSPOT', 'ID_BS_2010RED', 'LUMI_VDM']

Definition at line 201 of file DQUtilities.py.

◆ idbsDefects

python.DQUtilities.IDBSDefectData.idbsDefects

Definition at line 236 of file DQUtilities.py.

◆ iovsets

python.DQUtilities.IDBSDefectData.iovsets
static

Definition at line 214 of file DQUtilities.py.

◆ lastRun

python.DQUtilities.IDBSDefectData.lastRun
static

Definition at line 213 of file DQUtilities.py.

◆ tag

python.DQUtilities.IDBSDefectData.tag
static

Definition at line 212 of file DQUtilities.py.


The documentation for this class was generated from the following file:
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.events.process_iovs
def process_iovs(*iovsets)
Definition: events.py:30
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
dq_defect_bulk_create_defects.defect
defect
Definition: dq_defect_bulk_create_defects.py:35
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.AthDsoLogger.__del__
def __del__(self)
Definition: AthDsoLogger.py:82