103 from __future__
import with_statement, print_function
104 from CoolRunQuery.utils.AtlRunQueryCache
import Cache
105 from CoolRunQuery.AtlRunQueryRun
import Run
107 from time
import time
108 from collections
import defaultdict
110 @Cache(
"cache/sfo",
"%s_run_%i")
112 cu.execute(q, run=run)
116 cu.execute(q, run=run)
128 res = defaultdict(list)
129 q =
"SELECT DISTINCT STREAMTYPE, STREAM FROM SFO_TZ_RUN WHERE RUNNR=:run"
133 cursor.execute(q,run=run)
134 qr = cursor.fetchall()
136 res[run].
append(
"%s_%s" % (e[0],e[1]))
142 """returns nfiles, fsize, nevents"""
143 res = defaultdict(dict)
144 q =
"SELECT STREAMTYPE, STREAM, COUNT(FILESIZE), SUM(FILESIZE), SUM(NREVENTS) FROM SFO_TZ_File WHERE RUNNR = :run GROUP BY STREAM, STREAMTYPE"
148 if run==Run.runnropen:
149 qr =
executeQuery(run, cursor, q, cachekey=(
"filesAll",run))
153 key =
"%s_%s" % (e[0],e[1])
154 res[run][key] = e[2:5]
160 res = defaultdict(dict)
161 q =
"SELECT STREAMTYPE, STREAM, MIN(LUMIBLOCKNR), MAX(LUMIBLOCKNR), COUNT(DISTINCT LUMIBLOCKNR) FROM SFO_TZ_Lumiblock WHERE RUNNR=:run GROUP BY STREAM, STREAMTYPE"
165 if run==Run.runnropen:
166 qr =
executeQuery(run, cursor, q, cachekey=(
"LBsAll",run))
170 key2 =
"%s_%s" % (e[0],e[1])
171 res[run][key2] = e[2:5]
179 q =
"SELECT STREAMTYPE, STREAM, LUMIBLOCKNR, SUM(NREVENTS) FROM SFO_TZ_File WHERE RUNNR=:run GROUP BY STREAMTYPE, STREAM, LUMIBLOCKNR ORDER BY LUMIBLOCKNR"
183 if run==Run.runnropen:
184 qr =
executeQuery(run, cursor, q, cachekey=(
"NeventsAll",run))
187 res[run] = defaultdict(list)
189 key2 =
"%s_%s" % (e[0],e[1])
190 res[run][key2].
append(e[2:4])
196 """returns number of overlap events"""
198 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"
202 if run==Run.runnropen:
203 qr =
executeQuery(run, cursor, q, cachekey=(
"overlapAll",run))
207 res[run] = defaultdict(dict)
209 res[run][e[0]][e[1]] = e[2]
227 q =
"SELECT STREAM, LUMIBLOCKNR, SUM(NREVENTS) FROM SFO_TZ_File WHERE RUNNR=:run AND STREAMTYPE='physics' GROUP BY STREAM, LUMIBLOCKNR ORDER BY LUMIBLOCKNR"
231 if run==Run.runnropen:
232 qr =
executeQuery(run, cursor, q, cachekey=(
"NeventsAllPhysics",run))
235 res[run] = defaultdict(list)
237 key2 =
"physics_%s" % e[0]
238 res[run][key2].
append(e[1:3])
252 q =
"SELECT SUM(OVERLAP_EVENTS) from SFO_TZ_OVERLAP WHERE RUNNR=:run AND TYPE='EVENTCOUNT' AND REFERENCE_STREAM='physics_EventCount'"
255 if run==Run.runnropen
or 1:
256 qr =
executeQuery(run, cursor, q, cachekey=(
"SumOverlap",run))
268 """returns list of last 'nruns' run numbers, where at least one stream is not calibration"""
269 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 )
270 return cursor.fetchall()
281 from CoolRunQuery.utils.AtlRunQueryUtils
import coolDbConn
282 conn = coolDbConn.GetAtlasRunDBConnection()
283 cursor = conn.cursor()
285 "select ConfigSchema,ConfigData from ATLAS_RUN_NUMBER.RunNumber where RunNumber=:run",
286 "select ConfigVersion,Release from ATLAS_RUN_NUMBER.RunNumber where RunNumber=:run"
289 cursor.execute(query[0
if run.lhcRun<3
else 1], run=run.runNr)
290 re = cursor.fetchall()
291 run.addResult(
'oks',re[0])
302 from CoolRunQuery.AtlRunQuerySFO
import SetOKSLinks
311 runno =
int(sys.argv[1])
313 runno = [140541, 140571, 140579, 140592, 140616, 140620,
314 140622, 140638, 140670, 140682, 140704, 140737, 140747,
315 140748, 140754, 140762, 140765, 140769, 140772, 140776,
316 140790, 140794, 140822, 140836, 140842, 140929, 140953,
317 140955, 140974, 140975, 141046, 141059, 141066, 141079,
318 141109, 141150, 141189, 141192, 141194, 141203, 141209,
319 141226, 141234, 141236, 141237, 141238, 141266, 141270,
320 141359, 141374, 141387, 141398, 141401, 141403, 141461,
321 141473, 141474, 141525, 141527, 141529, 141533, 141534,
322 141561, 141562, 141563, 141565, 141599, 141624, 141655,
323 141667, 141670, 141688, 141689, 141691, 141695, 141700,
324 141702, 141704, 141705, 141706, 141707, 141718, 141721,
325 141730, 141746, 141748, 141749, 141755, 141769, 141807,
326 141811, 141818, 141841, 141915, 141928, 141976, 141979,
327 141994, 141998, 141999, 142042, 142065, 142081, 142091,
328 142094, 142111, 142123, 142125, 142128, 142133, 142144,
329 142149, 142154, 142155, 142157, 142159, 142161, 142165,
330 142166, 142171, 142174, 142183, 142185, 142187, 142189,
331 142190, 142191, 142192, 142193, 142194, 142195, 142199,
332 142203, 142205, 142210, 142214, 142216, 142240, 142258,
333 142259, 142265, 142291, 142301, 142308, 142309, 142310,
334 142319, 142356, 142368, 142383, 142390, 142391, 142392,
335 142394, 142395, 142397, 142400, 142401, 142402, 142403,
336 142404, 142405, 142406, 143019, 143023, 143027, 143033,
337 143034, 143131, 143136, 143143, 143163, 143169, 143171,
338 143178, 143182, 143185, 143190, 143192, 143198, 143203,
339 143204, 143205, 143207, 143210, 143218, 143222, 143225,
345 from CoolRunQuery.utils.AtlRunQueryUtils
import coolDbConn
346 connection = coolDbConn.GetSFODBConnection()
347 cursor = connection.cursor()
353 print (
'Last %i runs:' % n)
362 print (
"streams",time()-start)
364 GetSFO_LBsAll ( cursor, runno )
365 print (
"lbs",time()-start)
368 print (
"events",time()-start)
370 GetSFO_filesAll ( cursor, runno )
371 print (
"files",time()-start)
374 print (
"overlap",time()-start)
377 print (
"Query execution time: %f sec" % (time()-start))
384 if __name__ ==
'__main__':