ATLAS Offline Software
Loading...
Searching...
No Matches
python.AtlRunQuerySFO Namespace Reference

Functions

 executeCachedQuery (run, cu, q, cachekey)
 executeQuery (run, cu, q, cachekey)
 GetSFO_streamsAll (cursor, runlist)
 GetSFO_filesAll (cursor, runlist)
 GetSFO_LBsAll (cursor, runlist)
 GetSFO_NeventsAll (cursor, runlist)
 GetSFO_overlapAll (cursor, runlist)
 GetSFO_NeventsAllPhysics (cursor, runlist)
 GetSFO_NphysicseventsAll (cursor, runlist)
 GetSFO_lastNruns (cursor, nruns)
 SetOKSLinks (runlist)
 The following function is used to get OKS info.
 main ()

Function Documentation

◆ executeCachedQuery()

python.AtlRunQuerySFO.executeCachedQuery ( run,
cu,
q,
cachekey )

Definition at line 110 of file AtlRunQuerySFO.py.

110def executeCachedQuery(run,cu,q,cachekey):
111 cu.execute(q, run=run)
112 return cu.fetchall()
113

◆ executeQuery()

python.AtlRunQuerySFO.executeQuery ( run,
cu,
q,
cachekey )

Definition at line 114 of file AtlRunQuerySFO.py.

114def executeQuery(run,cu,q,cachekey):
115 cu.execute(q, run=run)
116 return cu.fetchall()
117
118
119

◆ GetSFO_filesAll()

python.AtlRunQuerySFO.GetSFO_filesAll ( cursor,
runlist )
returns nfiles, fsize, nevents

Definition at line 140 of file AtlRunQuerySFO.py.

140def GetSFO_filesAll( cursor, runlist ):
141 """returns nfiles, fsize, nevents"""
142 res = defaultdict(dict)
143 q = "SELECT STREAMTYPE, STREAM, COUNT(FILESIZE), SUM(FILESIZE), SUM(NREVENTS) FROM SFO_TZ_File WHERE RUNNR = :run GROUP BY STREAM, STREAMTYPE"
144 cursor.prepare(q)
145
146 for run in runlist:
147 if run==Run.runnropen:
148 qr = executeQuery(run, cursor, q, cachekey=("filesAll",run))
149 else:
150 qr = executeCachedQuery(run, cursor, q, cachekey=("filesAll",run))
151 for e in qr:
152 key = "%s_%s" % (e[0],e[1])
153 res[run][key] = e[2:5] # #files, filesize, nevents
154 return res
155
156
157

◆ GetSFO_lastNruns()

python.AtlRunQuerySFO.GetSFO_lastNruns ( cursor,
nruns )
returns list of last 'nruns' run numbers, where at least one stream is not calibration

Definition at line 266 of file AtlRunQuerySFO.py.

266def GetSFO_lastNruns( cursor, nruns ):
267 """returns list of last 'nruns' run numbers, where at least one stream is not calibration"""
268 cursor.execute( "SELECT RUNNR,STATE FROM (SELECT UNIQUE RUNNR,STATE FROM SFO_TZ_RUN WHERE STREAMTYPE!='calibration' AND RUNNR < 999999 ORDER BY RUNNR DESC) SFO_TZ_RUN2 WHERE rownum<=:arg_1", arg_1=nruns )
269 return cursor.fetchall()
270
271
272

◆ GetSFO_LBsAll()

python.AtlRunQuerySFO.GetSFO_LBsAll ( cursor,
runlist )

Definition at line 158 of file AtlRunQuerySFO.py.

158def GetSFO_LBsAll( cursor, runlist ):
159 res = defaultdict(dict)
160 q = "SELECT STREAMTYPE, STREAM, MIN(LUMIBLOCKNR), MAX(LUMIBLOCKNR), COUNT(DISTINCT LUMIBLOCKNR) FROM SFO_TZ_Lumiblock WHERE RUNNR=:run GROUP BY STREAM, STREAMTYPE"
161 cursor.prepare(q)
162
163 for run in runlist:
164 if run==Run.runnropen:
165 qr = executeQuery(run, cursor, q, cachekey=("LBsAll",run))
166 else:
167 qr = executeCachedQuery(run, cursor, q, cachekey=("LBsAll",run))
168 for e in qr:
169 key2 = "%s_%s" % (e[0],e[1])
170 res[run][key2] = e[2:5] # minlb,maxlb,nlb
171 return res
172
173
174

◆ GetSFO_NeventsAll()

python.AtlRunQuerySFO.GetSFO_NeventsAll ( cursor,
runlist )

Definition at line 175 of file AtlRunQuerySFO.py.

175def GetSFO_NeventsAll( cursor, runlist ):
176 # due to the amount of information oracle access is faster than file access
177 res = {}
178 q = "SELECT STREAMTYPE, STREAM, LUMIBLOCKNR, SUM(NREVENTS) FROM SFO_TZ_File WHERE RUNNR=:run GROUP BY STREAMTYPE, STREAM, LUMIBLOCKNR ORDER BY LUMIBLOCKNR"
179 cursor.prepare(q)
180
181 for run in runlist:
182 if run==Run.runnropen:
183 qr = executeQuery(run, cursor, q, cachekey=("NeventsAll",run))
184 else:
185 qr = executeCachedQuery(run, cursor, q, cachekey=("NeventsAll",run))
186 res[run] = defaultdict(list)
187 for e in qr:
188 key2 = "%s_%s" % (e[0],e[1])
189 res[run][key2].append(e[2:4]) # lbNr, NrEv
190
191 return res
192
193

◆ GetSFO_NeventsAllPhysics()

python.AtlRunQuerySFO.GetSFO_NeventsAllPhysics ( cursor,
runlist )

Definition at line 224 of file AtlRunQuerySFO.py.

224def GetSFO_NeventsAllPhysics( cursor, runlist ):
225 res = {}
226 q = "SELECT STREAM, LUMIBLOCKNR, SUM(NREVENTS) FROM SFO_TZ_File WHERE RUNNR=:run AND STREAMTYPE='physics' GROUP BY STREAM, LUMIBLOCKNR ORDER BY LUMIBLOCKNR"
227 cursor.prepare(q)
228
229 for run in runlist:
230 if run==Run.runnropen:
231 qr = executeQuery(run, cursor, q, cachekey=("NeventsAllPhysics",run))
232 else:
233 qr = executeCachedQuery(run, cursor, q, cachekey=("NeventsAllPhysics",run))
234 res[run] = defaultdict(list)
235 for e in qr:
236 key2 = "physics_%s" % e[0]
237 res[run][key2].append(e[1:3]) # lbNr, NrEv
238
239 return res
240
241
242

◆ GetSFO_NphysicseventsAll()

python.AtlRunQuerySFO.GetSFO_NphysicseventsAll ( cursor,
runlist )

Definition at line 249 of file AtlRunQuerySFO.py.

249def GetSFO_NphysicseventsAll( cursor, runlist ):
250 res = {}
251 q = "SELECT SUM(OVERLAP_EVENTS) from SFO_TZ_OVERLAP WHERE RUNNR=:run AND TYPE='EVENTCOUNT' AND REFERENCE_STREAM='physics_EventCount'"
252 cursor.prepare(q)
253 for run in runlist:
254 if run==Run.runnropen or 1: # FIXME problem in cache
255 qr = executeQuery(run, cursor, q, cachekey=("SumOverlap",run))
256 else:
257 qr = executeCachedQuery(run, cursor, q, cachekey=("SumOverlap",run))
258 for e in qr:
259 if e[0] is not None:
260 res[run] = e[0]
261 return res
262
263
264
265

◆ GetSFO_overlapAll()

python.AtlRunQuerySFO.GetSFO_overlapAll ( cursor,
runlist )
returns number of overlap events

Definition at line 194 of file AtlRunQuerySFO.py.

194def GetSFO_overlapAll( cursor, runlist ):
195 """returns number of overlap events"""
196 res = {}
197 q = "SELECT REFERENCE_STREAM, OVERLAP_STREAM, SUM(OVERLAP_EVENTS) FROM SFO_TZ_Overlap WHERE TYPE='FILE' and RUNNR=:run GROUP BY REFERENCE_STREAM, OVERLAP_STREAM"
198 cursor.prepare(q)
199
200 for run in runlist:
201 if run==Run.runnropen:
202 qr = executeQuery(run, cursor, q, cachekey=("overlapAll",run))
203 else:
204 qr = executeCachedQuery(run, cursor, q, cachekey=("overlapAll",run))
205
206 res[run] = defaultdict(dict)
207 for e in qr:
208 res[run][e[0]][e[1]] = e[2] # overlap
209
210 return res
211
212
213
214

◆ GetSFO_streamsAll()

python.AtlRunQuerySFO.GetSFO_streamsAll ( cursor,
runlist )

Definition at line 126 of file AtlRunQuerySFO.py.

126def GetSFO_streamsAll( cursor, runlist ):
127 res = defaultdict(list)
128 q = "SELECT DISTINCT STREAMTYPE, STREAM FROM SFO_TZ_RUN WHERE RUNNR=:run"
129 cursor.prepare(q)
130
131 for run in runlist:
132 cursor.execute(q,run=run)
133 qr = cursor.fetchall()
134 for e in qr:
135 res[run].append("%s_%s" % (e[0],e[1]))
136
137 return res
138
139

◆ main()

python.AtlRunQuerySFO.main ( )

Definition at line 292 of file AtlRunQuerySFO.py.

292def main():
293 test_oks = True
294 test_sfo = False
295
296 if test_oks:
297 #from os import environ as env
298 #from CoolRunQuery.AtlRunQueryUtils import coolDbConn
299 #coolDbConn.get_auth('oracle://atlr/rn_r') # only in /afs/cern.ch/atlas/project/tdaq/databases/.coral/authentication.xml
300 #print (coolDbConn.get_auth('oracle://ATLAS_COOLPROD/ATLAS_COOLOFL_TRIGGER'))
301 from CoolRunQuery.AtlRunQuerySFO import SetOKSLinks
302 SetOKSLinks([Run(178211)]) # Run 2
303 SetOKSLinks([Run(405396)]) # Run 3
304
305 if test_sfo:
306
307 runno = 122050
308 import sys
309 if len(sys.argv)>1:
310 runno = int(sys.argv[1])
311
312 runno = [140541, 140571, 140579, 140592, 140616, 140620,
313 140622, 140638, 140670, 140682, 140704, 140737, 140747,
314 140748, 140754, 140762, 140765, 140769, 140772, 140776,
315 140790, 140794, 140822, 140836, 140842, 140929, 140953,
316 140955, 140974, 140975, 141046, 141059, 141066, 141079,
317 141109, 141150, 141189, 141192, 141194, 141203, 141209,
318 141226, 141234, 141236, 141237, 141238, 141266, 141270,
319 141359, 141374, 141387, 141398, 141401, 141403, 141461,
320 141473, 141474, 141525, 141527, 141529, 141533, 141534,
321 141561, 141562, 141563, 141565, 141599, 141624, 141655,
322 141667, 141670, 141688, 141689, 141691, 141695, 141700,
323 141702, 141704, 141705, 141706, 141707, 141718, 141721,
324 141730, 141746, 141748, 141749, 141755, 141769, 141807,
325 141811, 141818, 141841, 141915, 141928, 141976, 141979,
326 141994, 141998, 141999, 142042, 142065, 142081, 142091,
327 142094, 142111, 142123, 142125, 142128, 142133, 142144,
328 142149, 142154, 142155, 142157, 142159, 142161, 142165,
329 142166, 142171, 142174, 142183, 142185, 142187, 142189,
330 142190, 142191, 142192, 142193, 142194, 142195, 142199,
331 142203, 142205, 142210, 142214, 142216, 142240, 142258,
332 142259, 142265, 142291, 142301, 142308, 142309, 142310,
333 142319, 142356, 142368, 142383, 142390, 142391, 142392,
334 142394, 142395, 142397, 142400, 142401, 142402, 142403,
335 142404, 142405, 142406, 143019, 143023, 143027, 143033,
336 143034, 143131, 143136, 143143, 143163, 143169, 143171,
337 143178, 143182, 143185, 143190, 143192, 143198, 143203,
338 143204, 143205, 143207, 143210, 143218, 143222, 143225,
339 143236, 143242]
340
341 #runno = range(141000,143000)
342
343
344 from CoolRunQuery.utils.AtlRunQueryUtils import coolDbConn
345 connection = coolDbConn.GetSFODBConnection()
346 cursor = connection.cursor()
347
348 # find last N runs
349 if False:
350 n = 10
351 runs = GetSFO_lastNruns( cursor, n )
352 print ('Last %i runs:' % n)
353 for r in runs:
354 print ('... %i' % r)
355 sys.exit()
356
357 # retrieve streams
358 if True:
359 start = time()
360 GetSFO_streamsAll( cursor, runno )
361 print ("streams",time()-start)
362 start = time()
363 GetSFO_LBsAll ( cursor, runno )
364 print ("lbs",time()-start)
365 start = time()
366 GetSFO_NeventsAll( cursor, runno )
367 print ("events",time()-start)
368 start = time()
369 GetSFO_filesAll ( cursor, runno )
370 print ("files",time()-start)
371 start = time()
372 GetSFO_overlapAll( cursor, runno )
373 print ("overlap",time()-start)
374
375
376 print ("Query execution time: %f sec" % (time()-start))
377
378 cursor.close()
379 connection.close()
380
381
382
int main()
Definition hello.cxx:18

◆ SetOKSLinks()

python.AtlRunQuerySFO.SetOKSLinks ( runlist)

The following function is used to get OKS info.

Definition at line 279 of file AtlRunQuerySFO.py.

279def SetOKSLinks( runlist ):
280 from CoolRunQuery.utils.AtlRunQueryUtils import coolDbConn
281 conn = coolDbConn.GetAtlasRunDBConnection()
282 cursor = conn.cursor()
283 query = [
284 "select ConfigSchema,ConfigData from ATLAS_RUN_NUMBER.RunNumber where RunNumber=:run", # Run 1+2
285 "select ConfigVersion,Release from ATLAS_RUN_NUMBER.RunNumber where RunNumber=:run" # Run 3
286 ]
287 for run in runlist:
288 cursor.execute(query[0 if run.lhcRun<3 else 1], run=run.runNr)
289 re = cursor.fetchall()
290 run.addResult('oks',re[0])
291