CMS 3D CMS Logo

Functions | Variables

geometryDiff Namespace Reference

Functions

def loopover
def matrixmult
def rotFromEuler
def rotFromPhi
def transpose

Variables

int epsilon = 1
tuple geom1 = MuonGeometry(file(args[0]))
tuple geom2 = MuonGeometry(file(args[1]))
tuple opts = dict(opts)
tuple sqrtepsilon = sqrt(epsilon)
string usage = "Usage: geometryDiff.py [-h|--help] [-e|--epsilon epsilon] geometry1.xml geometry2.xml"

Function Documentation

def geometryDiff::loopover (   which)

Definition at line 60 of file geometryDiff.py.

00061                    :
00062   if which == "DT":
00063     keys = geom1.dt.keys()
00064     keys.sort(dtorder)
00065 
00066   elif which == "CSC":
00067     keys = geom1.csc.keys()
00068     keys.sort(cscorder)
00069 
00070   else: raise Exception
00071 
00072   for key in keys:
00073     if which == "DT":
00074       g1 = geom1.dt[key]
00075       g2 = geom2.dt[key]
00076     else:
00077       g1 = geom1.csc[key]
00078       g2 = geom2.csc[key]
00079 
00080     if g1.relativeto != g2.relativeto:
00081       print "%s %s relativeto=\"%s\" versus relativeto=\"%s\"" % (which, str(key), g1.relativeto, g2.relativeto)
00082 
00083     if abs(g1.x - g2.x) > epsilon or abs(g1.y - g2.y) > epsilon or abs(g1.z - g2.z) > epsilon:
00084       print "%s %s position difference: (%g, %g, %g) - (%g, %g, %g) = (%g, %g, %g)" % \
00085             (which, str(key), g1.x, g1.y, g1.z, g2.x, g2.y, g2.z, g1.x - g2.x, g1.y - g2.y, g1.z - g2.z)
00086 
00087     if "phix" in g1.__dict__:
00088       g1type = "phi"
00089       g1a, g1b, g1c = g1.phix, g1.phiy, g1.phiz
00090       g1rot = rotFromPhi(g1)
00091     else:
00092       g1type = "euler"
00093       g1a, g1b, g1c = g1.alpha, g1.beta, g1.gamma
00094       g1rot = rotFromEuler(g1)
00095 
00096     if "phix" in g2.__dict__:
00097       g2type = "phi"
00098       g2a, g2b, g2c = g2.phix, g2.phiy, g2.phiz
00099       g2rot = rotFromPhi(g2)
00100     else:
00101       g2type = "euler"
00102       g2a, g2b, g2c = g2.alpha, g2.beta, g2.gamma
00103       g2rot = rotFromEuler(g2)
00104     
00105     diff = matrixmult(g1rot, transpose(g2rot))
00106     if abs(diff[0][0] - 1.) > sqrtepsilon or abs(diff[1][1] - 1.) > sqrtepsilon or abs(diff[2][2] - 1.) > sqrtepsilon or \
00107        abs(diff[0][1]) > epsilon or abs(diff[0][2]) > epsilon or abs(diff[1][2]) > epsilon:
00108       print "%s %s rotation difference: %s(%g, %g, %g) - %s(%g, %g, %g) = %s" % \
00109             (which, str(key), g1type, g1a, g1b, g1c, g2type, g2a, g2b, g2c, str(diff))
00110 
00111 loopover("DT")
00112 loopover("CSC")
00113 
00114 
def geometryDiff::matrixmult (   a,
  b 
)

Definition at line 34 of file geometryDiff.py.

00035                     :
00036   return [[sum([i*j for i, j in zip(row, col)]) for col in zip(*b)] for row in a]

def geometryDiff::rotFromEuler (   g)

Definition at line 53 of file geometryDiff.py.

00054                    :
00055   s1, s2, s3 = sin(g.alpha), sin(g.beta), sin(g.gamma)
00056   c1, c2, c3 = cos(g.alpha), cos(g.beta), cos(g.gamma)
00057   return [[c2 * c3,    c1 * s3 + s1 * s2 * c3,   s1 * s3 - c1 * s2 * c3,],
00058           [-c2 * s3,   c1 * c3 - s1 * s2 * s3,   s1 * c3 + c1 * s2 * s3,],
00059           [s2,        -s1 * c2,                  c1 * c2,               ]]

def geometryDiff::rotFromPhi (   g)

Definition at line 40 of file geometryDiff.py.

00041                  :
00042   phix, phiy, phiz = g.phix, g.phiy, g.phiz
00043   rotX = [[1.,         0.,         0.,       ],
00044           [0.,         cos(phix),  sin(phix),],
00045           [0.,        -sin(phix),  cos(phix),]]
00046   rotY = [[cos(phiy),  0.,        -sin(phiy),],
00047           [0.,         1.,         0.,       ],
00048           [sin(phiy),  0.,         cos(phiy),]]
00049   rotZ = [[cos(phiz),  sin(phiz),  0.,       ],
00050           [-sin(phiz), cos(phiz),  0.,       ],
00051           [0.,         0.,         1.,       ]]
00052   return matrixmult(rotX, matrixmult(rotY, rotZ))

def geometryDiff::transpose (   a)

Variable Documentation

Definition at line 24 of file geometryDiff.py.

tuple geometryDiff::geom1 = MuonGeometry(file(args[0]))

Definition at line 28 of file geometryDiff.py.

Referenced by QuadrupletSeedMerger::mySort().

tuple geometryDiff::geom2 = MuonGeometry(file(args[1]))

Definition at line 29 of file geometryDiff.py.

tuple geometryDiff::opts = dict(opts)

Definition at line 32 of file geometryDiff.py.

string geometryDiff::usage = "Usage: geometryDiff.py [-h|--help] [-e|--epsilon epsilon] geometry1.xml geometry2.xml"

Definition at line 6 of file geometryDiff.py.