ATLAS Offline Software
Loading...
Searching...
No Matches
AtlRunQueryTier0.py
Go to the documentation of this file.
1#!/bin/env python
2
3# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
4#
5# ----------------------------------------------------------------
6# Script : AtlRunQueryTier0.py
7# Project: AtlRunQuery
8# Purpose: Utility to retrieve information from Tier0 DB
9# Authors: Andreas Hoecker (CERN), Joerg Stelzer (DESY)
10# Created: Nov 4, 2009
11# ----------------------------------------------------------------
12#
13# Tier-0 Schema (dataset class only)
14# ==============================================
15#
16# http://hoecker.home.cern.ch/hoecker/Tier0DatasetSchema.png
17#
18
19def GetTier0_allDatasets( cursor, runlist, dsnamepattern = [] ):
20 res = {}
21 pos = 0
22 blocksize = 200
23 # build dataset selection string
24 dsselstring = ''
25 for p in dsnamepattern:
26 p = p.replace('*','%')
27 dsselstring += "LOWER(DATASETNAME) like LOWER('%s') OR " % p
28 if dsselstring:
29 dsselstring = 'and (' + dsselstring[:len(dsselstring)-4] + ')'
30
31 # do selection
32 while pos<len(runlist):
33 cursor.execute("SELECT DISTINCT RUNNR,DATASETNAME,TYPE,PSTATES,DDM,NFILES,TOTSIZE,TOTEVENTS,CREATIONTIME FROM dataset WHERE RUNNR in (%s) and TYPE!='LOG' %s and not DATASETNAME like '%%.LOG%%'"% (','.join([str(i) for i in runlist[pos:pos+blocksize]]), dsselstring))
34 r = cursor.fetchall()
35 for e in r:
36 res.setdefault(e[0],[]).append((e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8]))
37 pos += blocksize
38
39 return res
40
41def GetTier0_datasetsAndTypes( cursor, runlist ):
42 res = {}
43 pos = 0
44 blocksize = 200
45 while pos<len(runlist):
46 cursor.execute("SELECT DISTINCT RUNNR,DATASETNAME,TYPE,PSTATES FROM dataset WHERE RUNNR in (%s) and TYPE!='LOG' and not DATASETNAME like '%%.LOG%%'"% ','.join([str(i) for i in runlist[pos:pos+blocksize]]))
47 r = cursor.fetchall()
48 for e in r:
49 res.setdefault(e[0],[]).append((e[1],e[2],e[3]))
50 pos += blocksize
51
52 return res
GetTier0_datasetsAndTypes(cursor, runlist)
GetTier0_allDatasets(cursor, runlist, dsnamepattern=[])