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

Public Member Functions

def __init__ (self, timeConverter={})
 
def getdb (self, dbName)
 
def getFolder (self, folderName)
 
def getdbName (self, folderName)
 
def convertTime (self, timeStart, timeEnd, timeConverter)
 
def processQuery (self, queryBundle)
 
def close (self)
 
def __call__ (self, queueIn, queueOut)
 

Public Attributes

 db_svc
 
 timeConverter
 
 db
 
 folder
 

Detailed Description

Definition at line 71 of file COOLRates.py.

Constructor & Destructor Documentation

◆ __init__()

def COOLRates.COOLQueryWorker.__init__ (   self,
  timeConverter = {} 
)

Definition at line 72 of file COOLRates.py.

72  def __init__(self,timeConverter = {}):
73  self.db_svc = cool.DatabaseSvcFactory.databaseService()
74  self.timeConverter=timeConverter
75  self.db = {}
76  self.folder = {}
77 

Member Function Documentation

◆ __call__()

def COOLRates.COOLQueryWorker.__call__ (   self,
  queueIn,
  queueOut 
)

Definition at line 133 of file COOLRates.py.

133  def __call__(self,queueIn,queueOut):
134  signal.signal(signal.SIGINT, signal.SIG_IGN)
135  try:
136  while True:
137  try:
138  queryBundle = queueIn.get(False,.001)
139  except Empty:
140  sleep(.001)
141  continue
142  if queryBundle is True:
143  break
144  resultBundle = self.processQuery(queryBundle)
145  queueOut.put(resultBundle)
146  except Exception as exception:
147  logger.critical(exception)
148 
149  self.close()
150  queueOut.put(True)
151  return
152 
153 #====================================================================================================================
154 

◆ close()

def COOLRates.COOLQueryWorker.close (   self)

Definition at line 130 of file COOLRates.py.

130  def close(self):
131  for db in self.db.values(): db.closeDatabase()
132 

◆ convertTime()

def COOLRates.COOLQueryWorker.convertTime (   self,
  timeStart,
  timeEnd,
  timeConverter 
)

Definition at line 98 of file COOLRates.py.

98  def convertTime(self,timeStart,timeEnd,timeConverter):
99  validRunLbs = [runLb for runLb,time in timeConverter.items() if timeStart<=time<=timeEnd]
100  return validRunLbs
101 

◆ getdb()

def COOLRates.COOLQueryWorker.getdb (   self,
  dbName 
)

Definition at line 78 of file COOLRates.py.

78  def getdb(self,dbName):
79  if dbName not in self.db:
80  self.db[dbName] = self.db_svc.openDatabase(dbName,True)
81  return self.db.get(dbName)
82 

◆ getdbName()

def COOLRates.COOLQueryWorker.getdbName (   self,
  folderName 
)

Definition at line 90 of file COOLRates.py.

90  def getdbName(self,folderName):
91  if folderName.startswith('/LHC/DCS/'):
92  return 'oracle://ATLAS_COOLPROD;schema=ATLAS_COOLOFL_DCS;dbname=COMP200;'
93  if folderName.startswith('/TRIGGER/HLT/') and 'Rates' in folderName:
94  return "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=MONP200;"
95  if not folderName.startswith('/'): folderName = '/'+folderName
96  return "oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_{0};dbname=COMP200;".format(folderName.split("/")[1])
97 

◆ getFolder()

def COOLRates.COOLQueryWorker.getFolder (   self,
  folderName 
)

Definition at line 83 of file COOLRates.py.

83  def getFolder(self,folderName):
84  if folderName not in self.folder:
85  dbName = self.getdbName(folderName)
86  db = self.getdb(dbName)
87  self.folder[folderName] = db.getFolder(folderName)
88  return self.folder.get(folderName)
89 

◆ processQuery()

def COOLRates.COOLQueryWorker.processQuery (   self,
  queryBundle 
)

Reimplemented in COOLRates.RateQueryWorker.

Definition at line 102 of file COOLRates.py.

102  def processQuery(self,queryBundle):
103  folder = self.getFolder(queryBundle.folderName)
104  folder.setPrefetchAll(False)
105  result = {}
106  for payloadName,payloadAlias,cast in queryBundle.payloadRequests: result[payloadAlias]={}
107  folderIterator = folder.browseObjects(queryBundle.IoVStart,queryBundle.IoVEnd,queryBundle.channelSelection)
108  if queryBundle.timeBased:
109  while folderIterator.goToNext():
110  currentSlice = folderIterator.currentRef()
111  for payloadName,payloadAlias,cast in queryBundle.payloadRequests:
112  payload = cast(currentSlice.payloadValue(payloadName))
113  if payloadName in queryBundle.payloadRequirements:
114  if not eval(queryBundle.payloadRequirements[payloadName].format(repr(payload))): continue
115  runLbs = self.convertTime(int(currentSlice.since()),int(currentSlice.until()),queryBundle.timeConverter)
116  result[payloadAlias].update(dict.fromkeys(runLbs,payload))
117  else:
118  while folderIterator.goToNext():
119  currentSlice = folderIterator.currentRef()
120  for payloadName,payloadAlias,cast in queryBundle.payloadRequests:
121  payload = cast(currentSlice.payloadValue(payloadName))
122  if payloadName in queryBundle.payloadRequirements:
123  if not eval(queryBundle.payloadRequirements['payloadName'].format(repr(payload))): continue
124  runLbs = range(max(currentSlice.since(),queryBundle.IoVStart),min(currentSlice.until(),queryBundle.IoVEnd))
125  result[payloadAlias].update(dict.fromkeys(runLbs,payload))
126 
127  folderIterator.close()
128  return result
129 

Member Data Documentation

◆ db

COOLRates.COOLQueryWorker.db

Definition at line 75 of file COOLRates.py.

◆ db_svc

COOLRates.COOLQueryWorker.db_svc

Definition at line 73 of file COOLRates.py.

◆ folder

COOLRates.COOLQueryWorker.folder

Definition at line 76 of file COOLRates.py.

◆ timeConverter

COOLRates.COOLQueryWorker.timeConverter

Definition at line 74 of file COOLRates.py.


The documentation for this class was generated from the following file:
COOLRates.int
int
Definition: COOLRates.py:31
vtune_athena.format
format
Definition: vtune_athena.py:14
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:805
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
PyAthena::repr
std::string repr(PyObject *o)
returns the string representation of a python object equivalent of calling repr(o) in python
Definition: PyAthenaUtils.cxx:106
ReadCoolUPD4.openDatabase
def openDatabase(dbstring)
Definition: ReadCoolUPD4.py:21
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67