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 sys import stdin
5 from re import split, sub
6 
7 # Skip the first two lines (headers)
8 next(stdin)
9 next(stdin)
10 
11 print "<MuonAlignment>"
12 print ""
13 
14 for line in stdin:
15  line = sub("[ \t\n]+$", "", line)
16  Alignable, struct1, struct2, struct3, struct4, struct5, \
17  relativeto, x, y, z, angletype, angle1, angle2, angle3, \
18  xx, xy, xz, yy, yz, zz = split("[ \t]*,[ \t]", line)
19 
20  print "<operation>"
21  if Alignable[0:2] == "DT":
22  print (" <%s " % Alignable),
23  if struct1 != "":
24  print ("wheel=\"%s\" " % struct1),
25  if struct2 != "":
26  print ("station=\"%s\" " % struct2),
27  if struct3 != "":
28  print ("sector=\"%s\" " % struct3),
29  if struct4 != "":
30  print ("superlayer=\"%s\" " % struct4),
31  if struct5 != "":
32  print ("layer=\"%s\" " % struct5),
33  print "/>"
34 
35  if Alignable[0:3] == "CSC":
36  print (" <%s " % Alignable),
37  if struct1 != "":
38  print ("endcap=\"%s\" " % struct1),
39  if struct2 != "":
40  print ("station=\"%s\" " % struct2),
41  if struct3 != "":
42  print ("ring=\"%s\" " % struct3),
43  if struct4 != "":
44  print ("chamber=\"%s\" " % struct4),
45  if struct5 != "":
46  print ("layer=\"%s\" " % struct5),
47  print "/>"
48 
49  if angletype == "phixyz":
50  print " <setposition relativeto=\"%s\" x=\"%s\" y=\"%s\" z=\"%s\" phix=\"%s\" phiy=\"%s\" phiz=\"%s\" />" \
51  % (relativeto, x, y, z, angle1, angle2, angle3)
52  else:
53  print " <setposition relativeto=\"%s\" x=\"%s\" y=\"%s\" z=\"%s\" alpha=\"%s\" beta=\"%s\" gamma=\"%s\" />" \
54  % (relativeto, x, y, z, angle1, angle2, angle3)
55 
56  print " <setape xx=\"%s\" xy=\"%s\" xz=\"%s\" yy=\"%s\" yz=\"%s\" zz=\"%s\" />" \
57  % (xx, xy, xz, yy, yz, zz)
58 
59  print "</operation>"
60  print ""
61 
62 print "</MuonAlignment>"
63 
double split
Definition: MVATrainer.cc:139