CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Alignment/MuonAlignment/python/geometryCSVtoXML.py

Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # External libraries (standard in Python >= 2.4, at least)
00004 from sys import stdin
00005 from re import split, sub
00006 
00007 # Skip the first two lines (headers)
00008 stdin.next()
00009 stdin.next()
00010 
00011 print "<MuonAlignment>"
00012 print ""
00013 
00014 for line in stdin:
00015     line = sub("[ \t\n]+$", "", line)
00016     Alignable, struct1, struct2, struct3, struct4, struct5, \
00017                relativeto, x, y, z, angletype, angle1, angle2, angle3, \
00018                xx, xy, xz, yy, yz, zz = split("[ \t]*,[ \t]", line)
00019     
00020     print "<operation>"
00021     if Alignable[0:2] == "DT":
00022       print ("  <%s " % Alignable),
00023       if struct1 != "":
00024         print ("wheel=\"%s\" " % struct1),
00025       if struct2 != "":
00026         print ("station=\"%s\" " % struct2),
00027       if struct3 != "":
00028         print ("sector=\"%s\" " % struct3),
00029       if struct4 != "":
00030         print ("superlayer=\"%s\" " % struct4),
00031       if struct5 != "":
00032         print ("layer=\"%s\" " % struct5),
00033       print "/>"
00034 
00035     if Alignable[0:3] == "CSC":
00036       print ("  <%s " % Alignable),
00037       if struct1 != "":
00038         print ("endcap=\"%s\" " % struct1),
00039       if struct2 != "":
00040         print ("station=\"%s\" " % struct2),
00041       if struct3 != "":
00042         print ("ring=\"%s\" " % struct3),
00043       if struct4 != "":
00044         print ("chamber=\"%s\" " % struct4),
00045       if struct5 != "":
00046         print ("layer=\"%s\" " % struct5),
00047       print "/>"
00048 
00049     if angletype == "phixyz":
00050       print "  <setposition relativeto=\"%s\" x=\"%s\" y=\"%s\" z=\"%s\" phix=\"%s\" phiy=\"%s\" phiz=\"%s\" />" \
00051             % (relativeto, x, y, z, angle1, angle2, angle3)
00052     else:
00053       print "  <setposition relativeto=\"%s\" x=\"%s\" y=\"%s\" z=\"%s\" alpha=\"%s\" beta=\"%s\" gamma=\"%s\" />" \
00054             % (relativeto, x, y, z, angle1, angle2, angle3)
00055       
00056     print "  <setape xx=\"%s\" xy=\"%s\" xz=\"%s\" yy=\"%s\" yz=\"%s\" zz=\"%s\" />" \
00057           % (xx, xy, xz, yy, yz, zz)
00058 
00059     print "</operation>"
00060     print ""
00061 
00062 print "</MuonAlignment>"
00063