ATLAS Offline Software
Loading...
Searching...
No Matches
python.COOLUtils.COOLQuery Class Reference
Collaboration diagram for python.COOLUtils.COOLQuery:

Public Member Functions

 __init__ (self, useOracle=False, debug=True)
 __del__ (self)
 getRunStartTime (self, runnr)
 getLHCInfo (self, timeSinceEpochInSec)
 getRunEndTime (self, runnr)
 getLbTimes (self, runnr)
 lbTime (self, runnr, lbnr)
 getScanInfo (self, runnr)
 scanInfo (self, runnr, lbnr)

Public Attributes

str tdaqdbname = 'COOLONL_TDAQ/CONDBR2'
str coolpath = '/TDAQ/RunCtrl'
str coolScanPath = '/TDAQ/OLC/LHC/SCANDATA'
str trigdbname = 'COOLONL_TRIGGER/CONDBR2'
str coollbpath = '/TRIGGER/LUMI/LBLB'
str dcsdbname = 'COOLOFL_DCS/CONDBR2'
str coollhcpath = '/LHC/DCS/FILLSTATE'
 debug = debug
 cooldb = AtlCoolLib.indirectOpen(self.tdaqdbname, True, self.debug)
 cooltrigdb = AtlCoolLib.indirectOpen(self.trigdbname, True, self.debug)
 cooldcsdb = AtlCoolLib.indirectOpen(self.dcsdbname, True, self.debug)
dict lbDictCache = {'runnr': None, 'lbDict': None}
dict scanDictCache = {'runnr': None, 'scanDict': None}

Detailed Description

Utility to query COOL to retrieve start and end time of run and LBs.

Definition at line 122 of file COOLUtils.py.

Constructor & Destructor Documentation

◆ __init__()

python.COOLUtils.COOLQuery.__init__ ( self,
useOracle = False,
debug = True )

Definition at line 124 of file COOLUtils.py.

124 def __init__(self,useOracle=False,debug=True):
125
126 self.tdaqdbname='COOLONL_TDAQ/CONDBR2'
127 self.coolpath='/TDAQ/RunCtrl'
128 self.coolScanPath='/TDAQ/OLC/LHC/SCANDATA'
129
130 self.trigdbname='COOLONL_TRIGGER/CONDBR2'
131 self.coollbpath='/TRIGGER/LUMI/LBLB'
132
133 self.dcsdbname = 'COOLOFL_DCS/CONDBR2'
134 self.coollhcpath = '/LHC/DCS/FILLSTATE'
135
136 self.debug = debug
137
138 print ('open cool db' )
139 self.cooldb = AtlCoolLib.indirectOpen(self.tdaqdbname, True, self.debug)
140 print ('open cooltrig db')
141 self.cooltrigdb = AtlCoolLib.indirectOpen(self.trigdbname, True, self.debug)
142 print ('open cooldcs db')
143 self.cooldcsdb = AtlCoolLib.indirectOpen(self.dcsdbname, True, self.debug)
144
145 self.lbDictCache = {'runnr': None, 'lbDict': None}
146 self.scanDictCache = {'runnr': None, 'scanDict': None}
147

◆ __del__()

python.COOLUtils.COOLQuery.__del__ ( self)

Definition at line 148 of file COOLUtils.py.

148 def __del__(self):
149 try:
150 self.cooldb.closeDatabase()
151 self.cooltrigdb.closeDatabase()
152 self.cooldcsdb.closeDatabase()
153 except Exception:
154 print ("DB time out -- ignore")
155

Member Function Documentation

◆ getLbTimes()

python.COOLUtils.COOLQuery.getLbTimes ( self,
runnr )
Get dict of LB start and end times in Unix time (seconds since epoch).

Definition at line 210 of file COOLUtils.py.

210 def getLbTimes(self,runnr):
211 """Get dict of LB start and end times in Unix time (seconds since epoch)."""
212 iov1=runnr << 32
213 iov2=(runnr+1) << 32
214 if (iov2>cool.ValidityKeyMax): iov2=cool.ValidityKeyMax
215 folderLB_Params = self.cooltrigdb.getFolder(self.coollbpath)
216 itr = folderLB_Params.browseObjects(iov1, iov2, cool.ChannelSelection.all())
217 lbDict = { }
218 while itr.goToNext():
219 obj = itr.currentRef()
220 since = obj.since()
221 run = since >> 32
222 lb = since & 0xFFFFFFFF
223 if (run != runnr): continue
224
225 tlo = obj.payload()['StartTime']
226 thi = obj.payload()['EndTime']
227 lbDict[lb] = (COOLToUnixTime(tlo),COOLToUnixTime(thi))
228 return lbDict
229

◆ getLHCInfo()

python.COOLUtils.COOLQuery.getLHCInfo ( self,
timeSinceEpochInSec )
Get LHC fill and other info from COOL. The relevant COOL folder,
   /LHC/DCS/FILLSTATE is time-based, so the iov must be specified in
   ns since the epoch, but the argument to getLHCInfo is s since the
   epoch for convenience.

Definition at line 171 of file COOLUtils.py.

171 def getLHCInfo(self,timeSinceEpochInSec):
172 """Get LHC fill and other info from COOL. The relevant COOL folder,
173 /LHC/DCS/FILLSTATE is time-based, so the iov must be specified in
174 ns since the epoch, but the argument to getLHCInfo is s since the
175 epoch for convenience."""
176 t = timeSinceEpochInSec*1000000000
177 lhcfolder = self.cooldcsdb.getFolder(self.coollhcpath)
178 itr = lhcfolder.browseObjects(t,t,cool.ChannelSelection.all())
179 try:
180 info = { 'FillNumber': 0,
181 'StableBeams': False,
182 'BeamEnergyGeV': 0,
183 'NumBunchColl': 0 ,
184 'BetaStar': 0}
185 itr.goToNext()
186 obj = itr.currentRef()
187 for k in info.keys():
188 try:
189 info[k] = obj.payload()[k]
190 except Exception:
191 print ('WARNING: Cannot find value for',k)
192 return info
193 except Exception:
194 return None
195

◆ getRunEndTime()

python.COOLUtils.COOLQuery.getRunEndTime ( self,
runnr )
Get end time of run in Unix time (seconds since epoch).

Definition at line 196 of file COOLUtils.py.

196 def getRunEndTime(self,runnr):
197 """Get end time of run in Unix time (seconds since epoch)."""
198 iov=runnr << 32
199 if (iov>cool.ValidityKeyMax): iov=cool.ValidityKeyMax
200 folderEOR_Params = self.cooldb.getFolder(self.coolpath+'/EOR')
201 itr = folderEOR_Params.browseObjects(iov, iov, cool.ChannelSelection.all())
202 try:
203 itr.goToNext()
204 obj = itr.currentRef()
205 eorTime = obj.payload()['EORTime']
206 return COOLToUnixTime(eorTime)
207 except Exception:
208 return
209

◆ getRunStartTime()

python.COOLUtils.COOLQuery.getRunStartTime ( self,
runnr )
Get start time of run in Unix time (seconds since epoch).

Definition at line 156 of file COOLUtils.py.

156 def getRunStartTime(self,runnr):
157 """Get start time of run in Unix time (seconds since epoch)."""
158 iov=runnr << 32
159 if (iov>cool.ValidityKeyMax): iov=cool.ValidityKeyMax
160 folderSOR_Params = self.cooldb.getFolder(self.coolpath+'/SOR')
161 itr = folderSOR_Params.browseObjects(iov, iov, cool.ChannelSelection.all())
162 try:
163 itr.goToNext()
164 obj = itr.currentRef()
165 sorTime = obj.payload()['SORTime']
166 return COOLToUnixTime(sorTime)
167 except Exception:
168 return
169
170

◆ getScanInfo()

python.COOLUtils.COOLQuery.getScanInfo ( self,
runnr )
Get dict of scan info

Definition at line 241 of file COOLUtils.py.

241 def getScanInfo(self,runnr):
242 """Get dict of scan info"""
243 iov1 = self.getRunStartTime(runnr)*1000000000
244 iov2 = self.getRunEndTime(runnr)*1000000000
245 if (iov2>cool.ValidityKeyMax): iov2=cool.ValidityKeyMax
246 folderScan_Params = self.cooldb.getFolder(self.coolScanPath)
247 itr = folderScan_Params.browseObjects(iov1, iov2, cool.ChannelSelection.all())
248 scanDict = { }
249 while itr.goToNext():
250 obj = itr.currentRef()
251 runLB = obj.payload()['RunLB']
252 run = runLB >> 32
253 if (run != runnr): continue
254 lb = runLB & 0xFFFFFFFF
255 channelId = obj.channelId()
256 scanningIP = obj.payload()['ScanningIP']
257 # Select only the channel corresponding to IP
258 mask = 1 << channelId
259 if(scanningIP & mask == 0): continue
260 acquisitionFlag = obj.payload()['AcquisitionFlag']
261 nominalSeparation = obj.payload()['NominalSeparation']
262 nominalSeparationPlane = obj.payload()['NominalSeparationPlane']
263 B1DeltaXSet = obj.payload()['B1DeltaXSet']
264 B2DeltaXSet = obj.payload()['B2DeltaXSet']
265 B1DeltaYSet = obj.payload()['B1DeltaYSet']
266 B2DeltaYSet = obj.payload()['B2DeltaYSet']
267 scanDict[lb] = (scanningIP,acquisitionFlag,nominalSeparation,nominalSeparationPlane,B1DeltaXSet,B2DeltaXSet,B1DeltaYSet,B2DeltaYSet)
268 return scanDict
269
if(febId1==febId2)

◆ lbTime()

python.COOLUtils.COOLQuery.lbTime ( self,
runnr,
lbnr )
Get (startTime,endTime) for a given LB. The LB information is cached
   for the last run, in order make this efficient for querying for the
   times of individual LBs.

Definition at line 230 of file COOLUtils.py.

230 def lbTime(self,runnr,lbnr):
231 """Get (startTime,endTime) for a given LB. The LB information is cached
232 for the last run, in order make this efficient for querying for the
233 times of individual LBs."""
234 runnr = int(runnr)
235 if self.lbDictCache['runnr']!=runnr:
236 # print ('Caching lbDict for run',runnr)
237 self.lbDictCache['lbDict'] = self.getLbTimes(runnr)
238 self.lbDictCache['runnr'] = runnr
239 return self.lbDictCache['lbDict'].get(lbnr,None)
240
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ scanInfo()

python.COOLUtils.COOLQuery.scanInfo ( self,
runnr,
lbnr )
Get scan information for a given LB. The LB information is cached
   for the last run, in order make this efficient for querying for the
   times of individual LBs.

Definition at line 270 of file COOLUtils.py.

270 def scanInfo(self,runnr,lbnr):
271 """Get scan information for a given LB. The LB information is cached
272 for the last run, in order make this efficient for querying for the
273 times of individual LBs."""
274 runnr = int(runnr)
275 if self.scanDictCache['runnr']!=runnr:
276 self.scanDictCache['scanDict'] = self.getScanInfo(runnr)
277 self.scanDictCache['runnr'] = runnr
278 return self.scanDictCache['scanDict'].get(lbnr,None)
279

Member Data Documentation

◆ cooldb

python.COOLUtils.COOLQuery.cooldb = AtlCoolLib.indirectOpen(self.tdaqdbname, True, self.debug)

Definition at line 139 of file COOLUtils.py.

◆ cooldcsdb

python.COOLUtils.COOLQuery.cooldcsdb = AtlCoolLib.indirectOpen(self.dcsdbname, True, self.debug)

Definition at line 143 of file COOLUtils.py.

◆ coollbpath

str python.COOLUtils.COOLQuery.coollbpath = '/TRIGGER/LUMI/LBLB'

Definition at line 131 of file COOLUtils.py.

◆ coollhcpath

str python.COOLUtils.COOLQuery.coollhcpath = '/LHC/DCS/FILLSTATE'

Definition at line 134 of file COOLUtils.py.

◆ coolpath

str python.COOLUtils.COOLQuery.coolpath = '/TDAQ/RunCtrl'

Definition at line 127 of file COOLUtils.py.

◆ coolScanPath

str python.COOLUtils.COOLQuery.coolScanPath = '/TDAQ/OLC/LHC/SCANDATA'

Definition at line 128 of file COOLUtils.py.

◆ cooltrigdb

python.COOLUtils.COOLQuery.cooltrigdb = AtlCoolLib.indirectOpen(self.trigdbname, True, self.debug)

Definition at line 141 of file COOLUtils.py.

◆ dcsdbname

str python.COOLUtils.COOLQuery.dcsdbname = 'COOLOFL_DCS/CONDBR2'

Definition at line 133 of file COOLUtils.py.

◆ debug

python.COOLUtils.COOLQuery.debug = debug

Definition at line 136 of file COOLUtils.py.

◆ lbDictCache

dict python.COOLUtils.COOLQuery.lbDictCache = {'runnr': None, 'lbDict': None}

Definition at line 145 of file COOLUtils.py.

◆ scanDictCache

dict python.COOLUtils.COOLQuery.scanDictCache = {'runnr': None, 'scanDict': None}

Definition at line 146 of file COOLUtils.py.

◆ tdaqdbname

str python.COOLUtils.COOLQuery.tdaqdbname = 'COOLONL_TDAQ/CONDBR2'

Definition at line 126 of file COOLUtils.py.

◆ trigdbname

str python.COOLUtils.COOLQuery.trigdbname = 'COOLONL_TRIGGER/CONDBR2'

Definition at line 130 of file COOLUtils.py.


The documentation for this class was generated from the following file: