CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.

References funct.abs(), matrixmult(), rotFromEuler(), rotFromPhi(), and transpose().

60 
61 def loopover(which):
62  if which == "DT":
63  keys = geom1.dt.keys()
64  keys.sort(dtorder)
65 
66  elif which == "CSC":
67  keys = geom1.csc.keys()
68  keys.sort(cscorder)
69 
70  else: raise Exception
71 
72  for key in keys:
73  if which == "DT":
74  g1 = geom1.dt[key]
75  g2 = geom2.dt[key]
76  else:
77  g1 = geom1.csc[key]
78  g2 = geom2.csc[key]
79 
80  if g1.relativeto != g2.relativeto:
81  print "%s %s relativeto=\"%s\" versus relativeto=\"%s\"" % (which, str(key), g1.relativeto, g2.relativeto)
82 
83  if abs(g1.x - g2.x) > epsilon or abs(g1.y - g2.y) > epsilon or abs(g1.z - g2.z) > epsilon:
84  print "%s %s position difference: (%g, %g, %g) - (%g, %g, %g) = (%g, %g, %g)" % \
85  (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)
86 
87  if "phix" in g1.__dict__:
88  g1type = "phi"
89  g1a, g1b, g1c = g1.phix, g1.phiy, g1.phiz
90  g1rot = rotFromPhi(g1)
91  else:
92  g1type = "euler"
93  g1a, g1b, g1c = g1.alpha, g1.beta, g1.gamma
94  g1rot = rotFromEuler(g1)
95 
96  if "phix" in g2.__dict__:
97  g2type = "phi"
98  g2a, g2b, g2c = g2.phix, g2.phiy, g2.phiz
99  g2rot = rotFromPhi(g2)
100  else:
101  g2type = "euler"
102  g2a, g2b, g2c = g2.alpha, g2.beta, g2.gamma
103  g2rot = rotFromEuler(g2)
104 
105  diff = matrixmult(g1rot, transpose(g2rot))
106  if abs(diff[0][0] - 1.) > sqrtepsilon or abs(diff[1][1] - 1.) > sqrtepsilon or abs(diff[2][2] - 1.) > sqrtepsilon or \
107  abs(diff[0][1]) > epsilon or abs(diff[0][2]) > epsilon or abs(diff[1][2]) > epsilon:
108  print "%s %s rotation difference: %s(%g, %g, %g) - %s(%g, %g, %g) = %s" % \
109  (which, str(key), g1type, g1a, g1b, g1c, g2type, g2a, g2b, g2c, str(diff))
110 
111 loopover("DT")
112 loopover("CSC")
113 
114 
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
def geometryDiff.matrixmult (   a,
  b 
)

Definition at line 34 of file geometryDiff.py.

References archive.zip.

Referenced by loopover(), and rotFromPhi().

34 
35 def matrixmult(a, b):
36  return [[sum([i*j for i, j in zip(row, col)]) for col in zip(*b)] for row in a]
tuple zip
Definition: archive.py:476
def geometryDiff.rotFromEuler (   g)

Definition at line 53 of file geometryDiff.py.

References funct.cos(), and funct.sin().

Referenced by loopover().

53 
54 def rotFromEuler(g):
55  s1, s2, s3 = sin(g.alpha), sin(g.beta), sin(g.gamma)
56  c1, c2, c3 = cos(g.alpha), cos(g.beta), cos(g.gamma)
57  return [[c2 * c3, c1 * s3 + s1 * s2 * c3, s1 * s3 - c1 * s2 * c3,],
58  [-c2 * s3, c1 * c3 - s1 * s2 * s3, s1 * c3 + c1 * s2 * s3,],
59  [s2, -s1 * c2, c1 * c2, ]]
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def geometryDiff.rotFromPhi (   g)

Definition at line 40 of file geometryDiff.py.

References funct.cos(), matrixmult(), and funct.sin().

Referenced by loopover().

40 
41 def rotFromPhi(g):
42  phix, phiy, phiz = g.phix, g.phiy, g.phiz
43  rotX = [[1., 0., 0., ],
44  [0., cos(phix), sin(phix),],
45  [0., -sin(phix), cos(phix),]]
46  rotY = [[cos(phiy), 0., -sin(phiy),],
47  [0., 1., 0., ],
48  [sin(phiy), 0., cos(phiy),]]
49  rotZ = [[cos(phiz), sin(phiz), 0., ],
50  [-sin(phiz), cos(phiz), 0., ],
51  [0., 0., 1., ]]
52  return matrixmult(rotX, matrixmult(rotY, rotZ))
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
def geometryDiff.transpose (   a)

Definition at line 37 of file geometryDiff.py.

Referenced by AlignmentCorrelationsStore.correlations(), AlignmentExtendedCorrelationsStore.correlations(), AlignmentCorrelationsStore.correlationsAvailable(), AlignmentExtendedCorrelationsStore.correlationsAvailable(), AlignmentExtendedCorrelationsStore.getCorrelations(), loopover(), AlignmentCorrelationsStore.setCorrelations(), AlignmentExtendedCorrelationsStore.setCorrelations(), and npstat::ArrayND< Numeric, StackLen, StackDim >.transpose().

37 
38 def transpose(a):
39  return [[a[j][i] for j in range(len(a[i]))] for i in range(len(a))]

Variable Documentation

int geometryDiff.epsilon = 1

Definition at line 24 of file geometryDiff.py.

Referenced by initBarrel(), initCylinder(), initNegative(), and initPositive().

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

Definition at line 28 of file geometryDiff.py.

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

Definition at line 29 of file geometryDiff.py.

tuple geometryDiff.opts = dict(opts)

Definition at line 18 of file geometryDiff.py.

Referenced by RFIOStorageMaker.stagein(), edm::StreamSchedule.StreamSchedule(), and edm::service::TriggerNamesService.TriggerNamesService().

tuple geometryDiff.sqrtepsilon = sqrt(epsilon)

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.