3 from __future__
import print_function
4 from builtins
import range
5 from Alignment.MuonAlignment.geometryXMLparser
import MuonGeometry, dtorder, cscorder
8 usage =
"Usage: geometryDiff.py [-h|--help] [-e|--epsilon epsilon] geometry1.xml geometry2.xml" 11 opts, args = getopt.getopt(sys.argv[1:],
"he:", [
"help",
"epsilon="])
12 except getopt.GetoptError
as msg:
17 print(usage, file=sys.stderr)
22 if "-h" in opts
or "--help" in opts:
27 if "-e" in opts: epsilon =
float(opts[
"-e"])
28 if "--epsilon" in opts: epsilon =
float(opts[
"--epsilon"])
30 geom1 = MuonGeometry(
file(args[0]))
31 geom2 = MuonGeometry(
file(args[1]))
33 from math
import sin, cos, sqrt
34 sqrtepsilon =
sqrt(epsilon)
37 return [[sum([i*j
for i, j
in zip(row, col)])
for col
in zip(*b)]
for row
in a]
40 return [[a[j][i]
for j
in range(len(a[i]))]
for i
in range(len(a))]
43 phix, phiy, phiz = g.phix, g.phiy, g.phiz
44 rotX = [[1., 0., 0., ],
45 [0.,
cos(phix),
sin(phix),],
46 [0., -
sin(phix),
cos(phix),]]
47 rotY = [[
cos(phiy), 0., -
sin(phiy),],
49 [
sin(phiy), 0.,
cos(phiy),]]
50 rotZ = [[
cos(phiz),
sin(phiz), 0., ],
51 [-
sin(phiz),
cos(phiz), 0., ],
56 s1, s2, s3 =
sin(g.alpha),
sin(g.beta),
sin(g.gamma)
57 c1, c2, c3 =
cos(g.alpha),
cos(g.beta),
cos(g.gamma)
58 return [[c2 * c3, c1 * s3 + s1 * s2 * c3, s1 * s3 - c1 * s2 * c3,],
59 [-c2 * s3, c1 * c3 - s1 * s2 * s3, s1 * c3 + c1 * s2 * s3,],
60 [s2, -s1 * c2, c1 * c2, ]]
64 keys = geom1.dt.keys()
68 keys = geom1.csc.keys()
81 if g1.relativeto != g2.relativeto:
82 print(
"%s %s relativeto=\"%s\" versus relativeto=\"%s\"" % (which,
str(key), g1.relativeto, g2.relativeto))
84 if abs(g1.x - g2.x) > epsilon
or abs(g1.y - g2.y) > epsilon
or abs(g1.z - g2.z) > epsilon:
85 print(
"%s %s position difference: (%g, %g, %g) - (%g, %g, %g) = (%g, %g, %g)" % \
86 (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))
88 if "phix" in g1.__dict__:
90 g1a, g1b, g1c = g1.phix, g1.phiy, g1.phiz
94 g1a, g1b, g1c = g1.alpha, g1.beta, g1.gamma
97 if "phix" in g2.__dict__:
99 g2a, g2b, g2c = g2.phix, g2.phiy, g2.phiz
103 g2a, g2b, g2c = g2.alpha, g2.beta, g2.gamma
107 if abs(diff[0][0] - 1.) > sqrtepsilon
or abs(diff[1][1] - 1.) > sqrtepsilon
or abs(diff[2][2] - 1.) > sqrtepsilon
or \
108 abs(diff[0][1]) > epsilon
or abs(diff[0][2]) > epsilon
or abs(diff[1][2]) > epsilon:
109 print(
"%s %s rotation difference: %s(%g, %g, %g) - %s(%g, %g, %g) = %s" % \
110 (which,
str(key), g1type, g1a, g1b, g1c, g2type, g2a, g2b, g2c,
str(diff)))
Sin< T >::type sin(const T &t)
S & print(S &os, JobReport::InputFile const &f)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)