CMS 3D CMS Logo

geometryCSVtoXML.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # External libraries (standard in Python >= 2.4, at least)
4 from __future__ import print_function
5 from sys import stdin
6 from re import split, sub
7 
8 # Skip the first two lines (headers)
9 next(stdin)
10 next(stdin)
11 
12 print("<MuonAlignment>")
13 print("")
14 
15 for line in stdin:
16  line = sub("[ \t\n]+$", "", line)
17  Alignable, struct1, struct2, struct3, struct4, struct5, \
18  relativeto, x, y, z, angletype, angle1, angle2, angle3, \
19  xx, xy, xz, yy, yz, zz = split("[ \t]*,[ \t]", line)
20 
21  print("<operation>")
22  if Alignable[0:2] == "DT":
23  print((" <%s " % Alignable), end=' ')
24  if struct1 != "":
25  print(("wheel=\"%s\" " % struct1), end=' ')
26  if struct2 != "":
27  print(("station=\"%s\" " % struct2), end=' ')
28  if struct3 != "":
29  print(("sector=\"%s\" " % struct3), end=' ')
30  if struct4 != "":
31  print(("superlayer=\"%s\" " % struct4), end=' ')
32  if struct5 != "":
33  print(("layer=\"%s\" " % struct5), end=' ')
34  print("/>")
35 
36  if Alignable[0:3] == "CSC":
37  print((" <%s " % Alignable), end=' ')
38  if struct1 != "":
39  print(("endcap=\"%s\" " % struct1), end=' ')
40  if struct2 != "":
41  print(("station=\"%s\" " % struct2), end=' ')
42  if struct3 != "":
43  print(("ring=\"%s\" " % struct3), end=' ')
44  if struct4 != "":
45  print(("chamber=\"%s\" " % struct4), end=' ')
46  if struct5 != "":
47  print(("layer=\"%s\" " % struct5), end=' ')
48  print("/>")
49 
50  if angletype == "phixyz":
51  print(" <setposition relativeto=\"%s\" x=\"%s\" y=\"%s\" z=\"%s\" phix=\"%s\" phiy=\"%s\" phiz=\"%s\" />" \
52  % (relativeto, x, y, z, angle1, angle2, angle3))
53  else:
54  print(" <setposition relativeto=\"%s\" x=\"%s\" y=\"%s\" z=\"%s\" alpha=\"%s\" beta=\"%s\" gamma=\"%s\" />" \
55  % (relativeto, x, y, z, angle1, angle2, angle3))
56 
57  print(" <setape xx=\"%s\" xy=\"%s\" xz=\"%s\" yy=\"%s\" yz=\"%s\" zz=\"%s\" />" \
58  % (xx, xy, xz, yy, yz, zz))
59 
60  print("</operation>")
61  print("")
62 
63 print("</MuonAlignment>")
64 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
double split
Definition: MVATrainer.cc:139