ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
GoodRunsLists
python
GoodRunsListTool.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
4
import
os, sys
5
6
def
importModule
(moduleName,className,objectName=""):
7
if
len(objectName)==0: objectName=className
8
if
len(moduleName)>0:
9
modname =
'%s.%s'
% (moduleName,className)
10
else
:
11
modname = className
12
import
importlib
13
mod = importlib.import_module (modname)
14
return
getattr (mod, objectName)
15
16
def
getObjectOfClass
(moduleName,className=""):
17
moduleArr = moduleName.split(
"."
)
18
if
len(moduleArr)==2:
19
libraryName = moduleArr[0]
20
else
: libraryName =
"GoodRunsLists"
21
configModule = moduleArr[len(moduleArr)-1]
22
if
len(className)==0: className=configModule
23
24
try
:
25
cls = importModule (libraryName,configModule,className)
26
except
Exception:
27
try
:
28
cls = importModule (configModule,className)
29
except
Exception:
30
print
(
"Could not import configuration module \'"
+ configModule +
"\'"
)
31
sys.exit(1)
32
33
return
cls()
34
35
def
createAndVerifyGRL
(configModule,prefix=""):
36
xmlfile =
createGRL
(configModule,prefix)
37
allOk =
verifyGRL
(xmlfile)
38
return
(allOk,xmlfile)
39
40
def
createGRL
(configModule,prefix=""):
41
from
CoolRunQuery.AtlRunQueryLib
import
AtlRunQuery
42
from
CoolRunQuery.AtlRunQueryOptions
import
AtlRunQueryOptions
43
from
CoolRunQuery.AtlRunQueryParser
import
ArgumentParser
44
45
46
config =
getObjectOfClass
(configModule)
47
config.setPrefix(prefix)
48
query = config.getsearchquery()
49
print
(
">> Calling cmd equivalent of: "
)
50
print
(
"%s \"%s\""
% (config.querytool,query))
51
52
53
ap = ArgumentParser()
54
atlqueryarg = config.querytool +
" "
+ ap.ParseArgument( query )
55
(options, args) = AtlRunQueryOptions().
parse
(atlqueryarg)
56
57
#print (atlqueryarg)
58
#print (options)
59
60
61
AtlRunQuery
(options, html=
"NO"
, origQuery=query)
# html can be "YES", "NO", "AUTO"
62
63
xmlfile =
'data/'
+config.listname
64
print
(
">> Good-run list stored as: \'%s\'"
% xmlfile)
65
return
xmlfile
66
67
def
verifyGRL
(xmlfile):
68
69
CWD = os.getcwd()
70
73
from
ROOT
import
gSystem
74
os.chdir(CWD)
75
76
gSystem.Load(
'libGoodRunsListsLib'
)
77
from
ROOT
import
Root
78
79
reader =
Root.TGoodRunsListReader
()
80
81
reader.SetXMLFile(xmlfile)
82
reader.Interpret()
83
84
grlcollection = reader.GetMergedGRLCollection()
85
print
(
">> Found %d independent good-run list(s). Now checking content."
% len(grlcollection))
86
87
allOk =
True
88
89
90
for
idx
in
range(len(grlcollection)):
91
grl = grlcollection[idx]
92
grlName = grl.GetName()
93
grlVersion = grl.GetVersion()
94
grlMDSize = grl.GetMetaDataSize()
95
grlIsEmpty = grl.IsEmpty()
96
if
len(grlName)==0:
97
print
(
">> ERROR: good run list %d has no name."
% (idx))
98
allOk =
False
99
if
len(grlVersion)==0:
100
print
(
">> ERROR: good run list %d, with name \'%s\', has no version."
% (idx,grlName))
101
allOk =
False
102
if
grlMDSize==0:
103
print
(
">> ERROR: good run list %d, with name \'%s\', has no metadata."
% (idx,grlName))
104
allOk =
False
105
if
grlIsEmpty:
106
print
(
">> ERROR: good run list %d, with name \'%s\', has no run(s) and lumi-block range(s)."
% (idx,grlName))
107
allOk =
False
108
109
if
allOk:
110
print
(
">> Content okay."
)
111
112
return
allOk
113
Root::TGoodRunsListReader
Definition
TGoodRunsListReader.h:34
parse
std::map< std::string, std::string, std::less<> > parse(const std::string &list)
Definition
egammaLayerRecalibTool.cxx:1180
AtlRunQuery
Definition
AtlRunQuery.py:1
python.GoodRunsListTool.importModule
importModule(moduleName, className, objectName="")
Definition
GoodRunsListTool.py:6
python.GoodRunsListTool.createAndVerifyGRL
createAndVerifyGRL(configModule, prefix="")
Definition
GoodRunsListTool.py:35
python.GoodRunsListTool.getObjectOfClass
getObjectOfClass(moduleName, className="")
Definition
GoodRunsListTool.py:16
python.GoodRunsListTool.verifyGRL
verifyGRL(xmlfile)
Definition
GoodRunsListTool.py:67
python.GoodRunsListTool.createGRL
createGRL(configModule, prefix="")
Definition
GoodRunsListTool.py:40
Generated on
for ATLAS Offline Software by
1.17.0