9 #include <analysis/ClusterUtility/ClusterUtils.h>
10 #include <framework/logging/Logger.h>
13 using namespace ROOT::Math;
22 return Get4MomentumFromCluster(cluster, XYZVector(0.0, 0.0, 0.0), hypo);
29 return Get4MomentumFromCluster(cluster, GetIPPosition(), hypo);
37 XYZVector direction(cluster->getClusterPosition().X() - vertex.X(),
38 cluster->getClusterPosition().Y() - vertex.Y(),
39 cluster->getClusterPosition().Z() - vertex.Z());
43 const double E = cluster->getEnergy(hypo);
44 const double px =
E * sin(direction.Theta()) * cos(direction.Phi());
45 const double py =
E * sin(direction.Theta()) * sin(direction.Phi());
46 const double pz =
E * cos(direction.Theta());
48 const PxPyPzEVector l(px, py, pz,
E);
57 return GetJacobiMatrix4x6FromCluster(cluster, GetIPPosition(), hypo);
67 TMatrixD jacobian(4, 6);
69 const double R = cluster->getR();
70 const double energy = cluster->getEnergy(hypo);
71 const double theta = cluster->getTheta();
72 const double phi = cluster->getPhi();
74 const double st = sin(theta);
75 const double ct = cos(theta);
76 const double sp = sin(phi);
77 const double cp = cos(phi);
79 const double clx =
R * st * cp;
80 const double cly =
R * st * sp;
81 const double clz =
R * ct;
83 const double vx = vertex.X();
84 const double vy = vertex.Y();
85 const double vz = vertex.Z();
87 const double dx = clx - vx;
88 const double dy = cly - vy;
89 const double dz = clz - vz;
90 const double dx2 = dx * dx;
91 const double dy2 = dy * dy;
92 const double dz2 = dz * dz;
94 const double r2 = (dx * dx + dy * dy + dz * dz);
95 const double r12 =
sqrt(r2);
96 const double r32 = pow(r2, 1.5);
99 jacobian(0, 0) = dx / r12;
100 jacobian(0, 1) = -energy *
R * ((dx * dy * cp) + ((dy2 + dz2) * sp)) * st / (r32);
101 jacobian(0, 2) = energy *
R * (((dy2 + dz2) * cp * ct) - (dx * dy * ct * sp) + (dx * dz * st)) / (r32);
102 jacobian(0, 3) = -energy * (dy2 + dz2) / (r32);
103 jacobian(0, 4) = energy * dx * dy / (r32);
104 jacobian(0, 5) = energy * dx * dz / (r32);
107 jacobian(1, 0) = dy / r12;
108 jacobian(1, 1) = energy *
R * (((dx2 + dz2) * cp) + (dx * dy * sp)) * st / (r32);
109 jacobian(1, 2) = energy *
R * ((-dx * dy * cp * ct) + ((dx2 + dz2) * ct * sp) + (dy * dz * st)) / (r32);
110 jacobian(1, 3) = energy * dx * dy / (r32);
111 jacobian(1, 4) = -energy * (dx2 + dz2) / (r32);
112 jacobian(1, 5) = energy * dy * dz / (r32);
115 jacobian(2, 0) = dz / r12;
116 jacobian(2, 1) = energy *
R * dz * (-dy * cp + dx * sp) * st / (r32);
117 jacobian(2, 2) = -energy *
R * ((dx * dz * cp * ct) + (dy * dz * ct * sp) + (dx2 + dy2) * st) / (r32);
118 jacobian(2, 3) = energy * dx * dz / (r32);
119 jacobian(2, 4) = energy * dy * dz / (r32);
120 jacobian(2, 5) = -energy * (dx2 + dy2) / (r32);
123 jacobian(3, 0) = 1.0;
124 jacobian(3, 1) = 0.0;
125 jacobian(3, 2) = 0.0;
126 jacobian(3, 3) = 0.0;
127 jacobian(3, 4) = 0.0;
128 jacobian(3, 5) = 0.0;
138 return GetCovarianceMatrix4x4FromCluster(cluster, GetIPPositionCovarianceMatrix(), jacobiMatrix);
142 const TMatrixD& jacobiMatrix)
146 TMatrixDSym covmatecl = cluster->getCovarianceMatrix3x3();
149 TMatrixDSym covmatcombined(6);
150 for (
int i = 0; i < 3; i++) {
151 for (
int j = 0; j <= i ; j++) {
152 covmatcombined(i, j) = covmatcombined(j, i) = covmatecl(i, j);
153 covmatcombined(i + 3, j + 3) = covmatcombined(j + 3, i + 3) = covmatvertex(i, j);
157 TMatrixDSym covmatCart(4);
158 covmatCart = covmatcombined.Similarity(jacobiMatrix);
167 return GetCovarianceMatrix7x7FromCluster(cluster, GetIPPositionCovarianceMatrix(), jacobiMatrix);
171 const TMatrixDSym& covmatvertex,
const TMatrixD& jacobiMatrix)
173 TMatrixDSym covmat4x4 = GetCovarianceMatrix4x4FromCluster(cluster, covmatvertex, jacobiMatrix);
175 TMatrixDSym covmatCart(7);
178 for (
int i = 0; i < 4; i++) {
179 for (
int j = 0; j <= i ; j++) {
180 covmatCart(i, j) = covmatCart(j, i) = covmat4x4(i, j);
185 for (
int i = 0; i < 3; i++) {
186 for (
int j = 0; j <= i ; j++) {
187 covmatCart(i + 4, j + 4) = covmatCart(j + 4, i + 4) = covmatvertex(i, j);
199 B2WARNING(
"Beamspot not available, using (0, 0, 0) as IP position instead.");
200 return XYZVector(0.0, 0.0, 0.0);
201 }
else return XYZVector(m_beamSpotDB->getIPPosition().X(), m_beamSpotDB->getIPPosition().Y(), m_beamSpotDB->getIPPosition().Z());
208 B2WARNING(
"Beam parameters not available, using ((1, 0, 0), (0, 1, 0), (0, 0, 1)) as IP covariance matrix instead.");
210 TMatrixDSym covmat(3);
211 for (
int i = 0; i < 3; ++i) {
215 }
else return m_beamSpotDB->getCovVertex();
const TMatrixDSym GetCovarianceMatrix7x7FromCluster(const ECLCluster *cluster, const TMatrixD &jacobiMatrix)
Returns 7x7 covariance matrix (px, py, pz, E, x, y, z)
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns four momentum vector.
const TMatrixD GetJacobiMatrix4x6FromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns 4x6 Jacobi matrix (px, py, pz, E)
const ROOT::Math::PxPyPzEVector GetCluster4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns cluster four momentum vector.
const TMatrixDSym GetCovarianceMatrix4x4FromCluster(const ECLCluster *cluster, const TMatrixD &jacobiMatrix)
Returns 4x4 covariance matrix (px, py, pz, E)
const TMatrixDSym GetIPPositionCovarianceMatrix()
Returns default IP position covariance matrix from beam parameters.
ClusterUtils()
Constructor.
const ROOT::Math::XYZVector GetIPPosition()
Returns default IP position from beam parameters.
EHypothesisBit
The hypothesis bits for this ECLCluster (Connected region (CR) is split using this hypothesis.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.