12#include <TMatrixDSym.h>
15#include <Math/RotationX.h>
16#include <Math/RotationY.h>
17#include <Math/RotationZ.h>
18#include <Math/Vector3D.h>
19#include <Math/VectorUtil.h>
27 namespace RotationTools {
33 inline TMatrixD toMatrix(ROOT::Math::Rotation3D r)
36 r.GetRotationMatrix(rM);
46 inline TMatrixD getRotationMatrixZtoZp(ROOT::Math::XYZVector zPrime)
48 ROOT::Math::XYZVector zAxis(0, 0, 1);
49 double angle = ROOT::Math::VectorUtil::Angle(zAxis, zPrime);
51 ROOT::Math::XYZVector rotAxis = zAxis.Cross(zPrime).Unit();
52 double x = rotAxis.x();
53 double y = rotAxis.y();
55 double cosA = std::cos(angle);
56 double sinA = std::sin(angle);
57 double oneMinusCosA = 1 - cosA;
59 double xx = cosA + x * x * oneMinusCosA;
60 double xy = x * y * oneMinusCosA;
63 double yx = y * x * oneMinusCosA;
64 double yy = cosA + y * y * oneMinusCosA;
65 double yz = - x * sinA;
67 double zx = - y * sinA;
71 return toMatrix(ROOT::Math::Rotation3D(xx, xy, xz, yx, yy, yz, zx, zy, zz));
81 inline TMatrixD getRotationMatrixXY(
double angleX,
double angleY)
83 ROOT::Math::RotationX rX(angleX);
84 ROOT::Math::RotationY rY(angleY);
85 ROOT::Math::Rotation3D r = rX * rY;
97 inline TMatrixD rotateTensor(
const ROOT::Math::XYZVector& vTo,
const TMatrixD& orgMat)
99 TMatrixD r = getRotationMatrixZtoZp(vTo);
100 TMatrixD rT = r; rT.T();
101 return r * orgMat * rT;
110 inline TMatrixD rotateTensorInv(
const ROOT::Math::XYZVector& vTo,
const TMatrixD& orgMat)
112 TMatrixD r = getRotationMatrixZtoZp(vTo);
113 TMatrixD rT = r; rT.T();
114 return rT * orgMat * r;
124 inline TMatrixDSym toSymMatrix(
const TMatrixD& m)
126 TMatrixDSym mS(m.GetNrows());
127 for (
int i = 0; i < m.GetNrows(); ++i)
128 for (
int j = 0; j < m.GetNcols(); ++j) {
129 mS(i, j) = (m(i, j) + m(j, i)) / 2;
139 inline TVectorD toVec(ROOT::Math::XYZVector v)
141 return TVectorD(0, 2, v.X(), v.Y(), v.Z(),
"END");
148 ROOT::Math::XYZVector getUnitOrthogonal(ROOT::Math::XYZVector v)
150 return ROOT::Math::XYZVector(v.Z(), 0, -v.X()).Unit();
Abstract base class for different kinds of events.