Definition at line 99 of file geometryXMLparser.py.
def geometryXMLparser.MuonGeometry.__init__ |
( |
|
self, |
|
|
|
stream = None |
|
) |
| |
Definition at line 100 of file geometryXMLparser.py.
105 if stream
is not None:
106 parser = xml.sax.make_parser()
107 parser.setContentHandler(self)
def __init__(self, stream=None)
def geometryXMLparser.MuonGeometry.endElement |
( |
|
self, |
|
|
|
tag |
|
) |
| |
def geometryXMLparser.MuonGeometry.startElement |
( |
|
self, |
|
|
|
tag, |
|
|
|
attrib |
|
) |
| |
Definition at line 111 of file geometryXMLparser.py.
References geometryXMLparser.MuonGeometry._operation, cmsPerfStripChart.dict, objects.autophobj.float, createfilelist.int, and harvestTrackValidationPlots.str.
112 attrib =
dict(attrib.items())
113 if "rawId" in attrib:
raise Exception(
"Please use \"rawIds = false\"")
114 if "aa" in attrib:
raise Exception(
"Please use \"survey = false\"")
116 if tag ==
"MuonAlignment":
pass 118 elif tag ==
"collection":
raise NotImplementedError(
"<collection /> and <collection> blocks aren't implemented yet")
120 elif tag ==
"operation":
123 elif self.
_operation is None:
raise Exception(
"All chambers and positions must be enclosed in <operation> blocks")
125 elif tag ==
"setposition":
126 self._operation.setposition[
"relativeto"] =
str(attrib[
"relativeto"])
128 for name
in "x",
"y",
"z":
129 self._operation.setposition[name] =
float(attrib[name])
131 for name
in "phix",
"phiy",
"phiz":
132 self._operation.setposition[name] =
float(attrib[name])
134 for name
in "alpha",
"beta",
"gamma":
135 self._operation.setposition[name] =
float(attrib[name])
137 elif tag ==
"setape":
138 for name
in "xx",
"xy",
"xz",
"xa",
"xb",
"xc",
"yy",
"yz",
"ya",
"yb",
"yc",
"zz",
"za",
"zb",
"zc",
"aa",
"ab",
"ac",
"bb",
"bc",
"cc":
139 self._operation.setposition[name] =
float(attrib[name])
141 elif tag[0:2] ==
"DT":
143 for name
in "wheel",
"station",
"sector",
"superlayer",
"layer":
145 alignable.__dict__[name] =
int(attrib[name])
146 self._operation.chambers.append(alignable)
149 elif tag[0:3] ==
"CSC":
151 for name
in "endcap",
"station",
"ring",
"chamber",
"layer":
153 alignable.__dict__[name] =
int(attrib[name])
154 self._operation.chambers.append(alignable)
def startElement(self, tag, attrib)
def geometryXMLparser.MuonGeometry.xml |
( |
|
self, |
|
|
|
stream = None , |
|
|
|
precision = 10 |
|
) |
| |
Definition at line 167 of file geometryXMLparser.py.
References geometryXMLparser.MuonGeometry.csc, geometryXMLparser.MuonGeometry.dt, f, join(), harvestTrackValidationPlots.str, and ComparisonHelper.zip().
167 def xml(self, stream=None, precision=10):
168 if precision ==
None: format =
"%g" 169 else: format =
"%." +
str(precision) +
"f" 173 writeline =
lambda x: output.append(x)
175 writeline =
lambda x: stream.write(x)
177 writeline(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
178 writeline(
"<?xml-stylesheet type=\"text/xml\" href=\"MuonAlignment.xsl\"?>\n")
179 writeline(
"<MuonAlignment>\n\n")
181 dtkeys = self.dt.keys()
183 csckeys = self.csc.keys()
184 csckeys.sort(cscorder)
186 def f(number):
return format % number
188 def position_ape(ali, attributes):
189 writeline(
" <%s%s />\n" % (level, attributes))
190 writeline(
" <setposition relativeto=\"%s\" x=\"%s\" y=\"%s\" z=\"%s\" phix=\"%s\" phiy=\"%s\" phiz=\"%s\" />\n" % \
191 (ali.relativeto,
f(ali.x),
f(ali.y),
f(ali.z),
f(ali.phix),
f(ali.phiy),
f(ali.phiz)))
193 if "xx" in ali.__dict__:
194 writeline(
" <setape xx=\"%s\" xy=\"%s\" xz=\"%s\" xa=\"%s\" xb=\"%s\" xc=\"%s\" yy=\"%s\" yz=\"%s\" ya=\"%s\" yb=\"%s\" yc=\"%s\" zz=\"%s\" za=\"%s\" zb=\"%s\" zc=\"%s\" aa=\"%s\" ab=\"%s\" ac=\"%s\" bb=\"%s\" bc=\"%s\" cc=\"%s\" />\n" % \
195 (
f(ali.xx),
f(ali.xy),
f(ali.xz),
f(ali.xa),
f(ali.xb),
f(ali.xc),
f(ali.yy),
f(ali.yz),
f(ali.ya),
f(ali.yb),
f(ali.yc),
f(ali.zz),
f(ali.za),
f(ali.zb),
f(ali.zc),
f(ali.aa),
f(ali.ab),
f(ali.ac),
f(ali.bb),
f(ali.bc),
f(ali.cc)))
198 writeline(
"<operation>\n")
200 if len(key) == 0: level =
"DTBarrel" 201 elif len(key) == 1: level =
"DTWheel " 202 elif len(key) == 2: level =
"DTStation " 203 elif len(key) == 3: level =
"DTChamber " 204 elif len(key) == 4: level =
"DTSuperLayer " 205 elif len(key) == 5: level =
"DTLayer " 208 attributes =
" ".
join([
"%s=\"%d\"" % (name, value)
for name, value
in zip((
"wheel",
"station",
"sector",
"superlayer",
"layer"), key)])
209 position_ape(ali, attributes)
211 writeline(
"</operation>\n\n")
214 writeline(
"<operation>\n")
216 if len(key) == 1: level =
"CSCEndcap " 217 elif len(key) == 2: level =
"CSCStation " 218 elif len(key) == 3: level =
"CSCRing " 219 elif len(key) == 4: level =
"CSCChamber " 220 elif len(key) == 5: level =
"CSCLayer " 223 attributes =
" ".
join([
"%s=\"%d\"" % (name, value)
for name, value
in zip((
"endcap",
"station",
"ring",
"chamber",
"layer"), key)])
224 position_ape(ali, attributes)
226 writeline(
"</operation>\n\n")
228 writeline(
"</MuonAlignment>\n")
229 if stream ==
None:
return "".
join(output)
230
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def xml(self, stream=None, precision=10)
static std::string join(char **cmd)
geometryXMLparser.MuonGeometry._operation |
|
private |
geometryXMLparser.MuonGeometry.csc |
geometryXMLparser.MuonGeometry.dt |