9#include <analysis/ClusterUtility/ClusterUtils.h>
10#include <framework/logging/Logger.h>
13using namespace ROOT::Math;
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);
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;
137 TMatrixDSym covmatecl = cluster->getCovarianceMatrix3x3();
144 double pTheta = cluster->getTheta();
145 double pPhi = cluster->getPhi();
148 if (energyCovarianceElement != -1) {
149 covmatecl(0, 0) = energyCovarianceElement * pEnergy * energyCovarianceElement * pEnergy;
163 const TMatrixD& jacobiMatrix)
170 TMatrixDSym covmatcombined(6);
171 for (
int i = 0; i < 3; i++) {
172 for (
int j = 0; j <= i; j++) {
173 covmatcombined(i, j) = covmatcombined(j, i) = covmatecl(i, j);
174 covmatcombined(i + 3, j + 3) = covmatcombined(j + 3, i + 3) = covmatvertex(i, j);
178 TMatrixDSym covmatCart(4);
179 covmatCart = covmatcombined.Similarity(jacobiMatrix);
192 const TMatrixDSym& covmatvertex,
const TMatrixD& jacobiMatrix)
196 TMatrixDSym covmatCart(7);
199 for (
int i = 0; i < 4; i++) {
200 for (
int j = 0; j <= i; j++) {
201 covmatCart(i, j) = covmatCart(j, i) = covmat4x4(i, j);
206 for (
int i = 0; i < 3; i++) {
207 for (
int j = 0; j <= i; j++) {
208 covmatCart(i + 4, j + 4) = covmatCart(j + 4, i + 4) = covmatvertex(i, j);
219 B2WARNING(
"Beamspot not available, using (0, 0, 0) as IP position instead.");
220 return XYZVector(0.0, 0.0, 0.0);
229 B2WARNING(
"Beam parameters not available, using ((1, 0, 0), (0, 1, 0), (0, 0, 1)) as IP covariance matrix instead.");
231 TMatrixDSym covmat(3);
232 for (
int i = 0; i < 3; ++i) {
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.
OptionalDBObjPtr< ECLPhotonEnergyResolution > m_photonEnergyResolutionDB
Photon energy resolution database object.
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)
DBObjPtr< BeamSpot > m_beamSpotDB
Beam spot database object.
const TMatrixDSym GetCovarianceMatrix3x3FromCluster(const ECLCluster *cluster)
Returns 3x3 covariance matrix (E, theta, phi)
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.
@ c_nPhotons
CR is split into n photons (N1)
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.