ATLAS Offline Software
Trigger
TrigConfiguration
TrigConfMuctpi
python
XMLReader.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
2
3
4
import
xml.etree.cElementTree
as
ET
5
from
functools
import
cache
6
7
class
TrigXMLElement
:
8
def
__init__
(self,element):
9
self.
element
= element
10
self.
tag
= element.tag
11
self.
items
= element.items()
12
self.
children
= element.getchildren()
13
self.
readchildren
()
14
def
__str__
(self):
15
s =
"<%s%s>"
% (
" "
.
join
([self.
tag
] + [
'%s="%s"'
% x
for
x
in
self.
items
]),
"/"
if
len(self.
children
)==0
else
""
)
16
return
s
17
def
__repr__
(self):
18
return
self.
tag
19
20
def
__contains__
(self,k):
21
return
k
in
dict(self.
items
)
22
23
def
__getitem__
(self,k):
24
return
dict(self.
items
)[k]
25
26
def
strippedText
(self):
27
return
self.
element
.text.strip()
28
29
def
readchildren
(self):
30
self.
childtags
= []
31
self.
_childtagdict
= {}
32
for
c
in
self.
children
:
33
self.
_childtagdict
.setdefault(c.tag,[]).
append
(
TrigXMLElement
(c))
34
if
c.tag
not
in
self.
childtags
: self.
childtags
+= [c.tag]
35
for
t
in
self.
childtags
:
36
self.__dict__[
'%ss'
%t] = self.
_childtagdict
[t]
37
if
len(self.
_childtagdict
[t])==1:
38
self.__dict__[
'%s'
%t] = self.
_childtagdict
[t][0]
39
40
41
42
class
TrigXMLDocumentReader
(
object
):
43
def
__init__
(self,filename):
44
self.
filename
=filename
45
self.
read
(self.
filename
)
46
47
def
read
(self,filename):
48
self.
doc
= ET.parse(filename)
49
root =
TrigXMLElement
(self.
doc
.getroot())
50
self.__dict__[root.tag] = root
51
52
def
getFileName
(self):
53
return
self.
filename
54
55
56
class
MioctGeometryXMLReader
(
TrigXMLDocumentReader
):
57
def
__init__
(self,filename):
58
super(MioctGeometryXMLReader,self).
__init__
(filename)
59
60
def
getMIOCTs
(self):
61
return
self.MuCTPiGeometry.MIOCTs
62
63
@cache
64
def
getMIOCT
(self, id):
65
for
mioct
in
self.MuCTPiGeometry.MIOCTs:
66
if
int
(mioct[
"id"
]) == id:
67
return
mioct
68
69
70
if
__name__ ==
"__main__"
:
71
from
PathResolver
import
PathResolver
72
xmlfile =
PathResolver.FindCalibFile
(
"TrigConfMuctpi/TestMioctGeometry_2016_05_30_CS_2600573263.xml"
)
73
l1menu =
MioctGeometryXMLReader
(xmlfile)
python.XMLReader.TrigXMLDocumentReader.read
def read(self, filename)
Definition:
XMLReader.py:47
python.XMLReader.TrigXMLElement.children
children
Definition:
XMLReader.py:12
python.XMLReader.MioctGeometryXMLReader
Definition:
XMLReader.py:56
python.XMLReader.MioctGeometryXMLReader.__init__
def __init__(self, filename)
Definition:
XMLReader.py:57
PathResolver::FindCalibFile
static std::string FindCalibFile(const std::string &logical_file_name)
Definition:
PathResolver.h:108
CaloCellPos2Ntuple.int
int
Definition:
CaloCellPos2Ntuple.py:24
python.XMLReader.TrigXMLElement.__getitem__
def __getitem__(self, k)
Definition:
XMLReader.py:23
python.XMLReader.MioctGeometryXMLReader.getMIOCT
def getMIOCT(self, id)
Definition:
XMLReader.py:64
python.XMLReader.TrigXMLDocumentReader.doc
doc
Definition:
XMLReader.py:48
dumpHVPathFromNtuple.append
bool append
Definition:
dumpHVPathFromNtuple.py:91
python.XMLReader.TrigXMLElement.items
items
Definition:
XMLReader.py:11
python.XMLReader.TrigXMLElement.element
element
Definition:
XMLReader.py:9
python.XMLReader.TrigXMLElement.__contains__
def __contains__(self, k)
Definition:
XMLReader.py:20
python.XMLReader.MioctGeometryXMLReader.getMIOCTs
def getMIOCTs(self)
Definition:
XMLReader.py:60
python.XMLReader.TrigXMLDocumentReader.filename
filename
Definition:
XMLReader.py:44
python.XMLReader.TrigXMLElement.__str__
def __str__(self)
Definition:
XMLReader.py:14
python.XMLReader.TrigXMLElement.__repr__
def __repr__(self)
Definition:
XMLReader.py:17
python.XMLReader.TrigXMLElement
Definition:
XMLReader.py:7
python.XMLReader.TrigXMLElement.__init__
def __init__(self, element)
Definition:
XMLReader.py:8
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition:
Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.XMLReader.TrigXMLElement.readchildren
def readchildren(self)
Definition:
XMLReader.py:29
python.XMLReader.TrigXMLDocumentReader.getFileName
def getFileName(self)
Definition:
XMLReader.py:52
python.XMLReader.TrigXMLElement.tag
tag
Definition:
XMLReader.py:10
python.XMLReader.TrigXMLDocumentReader
Definition:
XMLReader.py:42
python.XMLReader.TrigXMLElement.strippedText
def strippedText(self)
Definition:
XMLReader.py:26
python.XMLReader.TrigXMLElement._childtagdict
_childtagdict
Definition:
XMLReader.py:31
python.XMLReader.TrigXMLElement.childtags
childtags
Definition:
XMLReader.py:30
pickleTool.object
object
Definition:
pickleTool.py:30
python.XMLReader.TrigXMLDocumentReader.__init__
def __init__(self, filename)
Definition:
XMLReader.py:43
Generated on Fri Jan 10 2025 21:22:00 for ATLAS Offline Software by
1.8.18