Belle II Software light-2406-ragdoll
ClusterUtils Class Reference

Class to provide momentum-related information from ECLClusters. More...

#include <ClusterUtils.h>

Collaboration diagram for ClusterUtils:

Public Member Functions

 ClusterUtils ()
 Constructor.
 
const ROOT::Math::PxPyPzEVector GetCluster4MomentumFromCluster (const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
 Returns cluster four momentum vector.
 
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster (const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
 Returns four momentum vector.
 
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster (const ECLCluster *cluster, const ROOT::Math::XYZVector &vertex, 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 TMatrixD GetJacobiMatrix4x6FromCluster (const ECLCluster *cluster, const ROOT::Math::XYZVector &vertex, ECLCluster::EHypothesisBit hypo)
 Returns 4x6 Jacobi matrix (px, py, pz, E)
 
const TMatrixDSym GetCovarianceMatrix3x3FromCluster (const ECLCluster *cluster)
 Returns 3x3 covariance matrix (E, theta, phi)
 
const TMatrixDSym GetCovarianceMatrix4x4FromCluster (const ECLCluster *cluster, const TMatrixD &jacobiMatrix)
 Returns 4x4 covariance matrix (px, py, pz, E)
 
const TMatrixDSym GetCovarianceMatrix4x4FromCluster (const ECLCluster *cluster, const TMatrixDSym &covmatvertex, const TMatrixD &jacobiMatrix)
 Returns 4x4 covariance matrix (px, py, pz, E)
 
const TMatrixDSym GetCovarianceMatrix7x7FromCluster (const ECLCluster *cluster, const TMatrixD &jacobiMatrix)
 Returns 7x7 covariance matrix (px, py, pz, E, x, y, z)
 
const TMatrixDSym GetCovarianceMatrix7x7FromCluster (const ECLCluster *cluster, const TMatrixDSym &covmatvertex, const TMatrixD &jacobiMatrix)
 Returns 7x7 covariance matrix (px, py, pz, E, x, y, z)
 
const ROOT::Math::XYZVector GetIPPosition ()
 Returns default IP position from beam parameters.
 
const TMatrixDSym GetIPPositionCovarianceMatrix ()
 Returns default IP position covariance matrix from beam parameters.
 

Private Attributes

DBObjPtr< BeamSpotm_beamSpotDB
 Beam spot database object.
 
OptionalDBObjPtr< ECLPhotonEnergyResolutionm_photonEnergyResolutionDB
 Photon energy resolution database object.
 

Detailed Description

Class to provide momentum-related information from ECLClusters.

This requires the prior knowledge of the particle type (e.g., photon), and a vertex hypothesis. The default vertex hypothesis is taken from the beamparameters.

Definition at line 36 of file ClusterUtils.h.

Member Function Documentation

◆ Get4MomentumFromCluster() [1/2]

const PxPyPzEVector Get4MomentumFromCluster ( const ECLCluster cluster,
const ROOT::Math::XYZVector &  vertex,
ECLCluster::EHypothesisBit  hypo 
)

Returns four momentum vector.

Returns
const four momentum vector

Definition at line 32 of file ClusterUtils.cc.

34{
35
36 // Get particle direction from vertex and reconstructed cluster position.
37 XYZVector direction(cluster->getClusterPosition().X() - vertex.X(),
38 cluster->getClusterPosition().Y() - vertex.Y(),
39 cluster->getClusterPosition().Z() - vertex.Z());
40
41 // Always ignore mass here (even for neutral hadrons) therefore the magnitude
42 // of the momentum is equal to the cluster energy under this hypo.
43 const double E = cluster->getEnergy(hypo); // must not be changed or clusterE getters will be wrong
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());
47
48 const PxPyPzEVector l(px, py, pz, E);
49 return l;
50}

◆ Get4MomentumFromCluster() [2/2]

const PxPyPzEVector Get4MomentumFromCluster ( const ECLCluster cluster,
ECLCluster::EHypothesisBit  hypo 
)

Returns four momentum vector.

Returns
const four momentum vector

Definition at line 25 of file ClusterUtils.cc.

26{
27
28 // Use the default vertex from the beam parameters if none is given.
29 return Get4MomentumFromCluster(cluster, GetIPPosition(), hypo);
30}
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns four momentum vector.
Definition: ClusterUtils.cc:25
const ROOT::Math::XYZVector GetIPPosition()
Returns default IP position from beam parameters.

◆ GetCluster4MomentumFromCluster()

const PxPyPzEVector GetCluster4MomentumFromCluster ( const ECLCluster cluster,
ECLCluster::EHypothesisBit  hypo 
)

Returns cluster four momentum vector.

Returns
const cluster four momentum vector

Definition at line 19 of file ClusterUtils.cc.

20{
21 // Use the geometry origin (0,0,0) and *not* the IP position
22 return Get4MomentumFromCluster(cluster, XYZVector(0.0, 0.0, 0.0), hypo);
23}

◆ GetCovarianceMatrix3x3FromCluster()

const TMatrixDSym GetCovarianceMatrix3x3FromCluster ( const ECLCluster cluster)

Returns 3x3 covariance matrix (E, theta, phi)

Returns
const TMatrixDSym

Replace fixed energy resolution value by derived value from the DB if present

Definition at line 134 of file ClusterUtils.cc.

135{
136 // Get the covariance matrix (energy, phi, theta) from the ECL cluster.
137 TMatrixDSym covmatecl = cluster->getCovarianceMatrix3x3();
138
142 if (m_photonEnergyResolutionDB.isValid() and cluster->hasHypothesis(ECLCluster::EHypothesisBit::c_nPhotons)) {
143 double pEnergy = cluster->getEnergy(ECLCluster::EHypothesisBit::c_nPhotons);
144 double pTheta = cluster->getTheta();
145 double pPhi = cluster->getPhi();
146
147 double energyCovarianceElement = m_photonEnergyResolutionDB->getRelativeEnergyResolution(pEnergy, pTheta, pPhi);
148 if (energyCovarianceElement != -1) {
149 covmatecl(0, 0) = energyCovarianceElement * pEnergy * energyCovarianceElement * pEnergy;
150 }
151 }
152
153 return covmatecl;
154}
OptionalDBObjPtr< ECLPhotonEnergyResolution > m_photonEnergyResolutionDB
Photon energy resolution database object.
Definition: ClusterUtils.h:130
@ c_nPhotons
CR is split into n photons (N1)

◆ GetCovarianceMatrix4x4FromCluster() [1/2]

const TMatrixDSym GetCovarianceMatrix4x4FromCluster ( const ECLCluster cluster,
const TMatrixD &  jacobiMatrix 
)

Returns 4x4 covariance matrix (px, py, pz, E)

Returns
const TMatrixDSym

Definition at line 156 of file ClusterUtils.cc.

157{
158
160}
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.

◆ GetCovarianceMatrix4x4FromCluster() [2/2]

const TMatrixDSym GetCovarianceMatrix4x4FromCluster ( const ECLCluster cluster,
const TMatrixDSym &  covmatvertex,
const TMatrixD &  jacobiMatrix 
)

Returns 4x4 covariance matrix (px, py, pz, E)

Returns
const TMatrixDSym

Definition at line 162 of file ClusterUtils.cc.

164{
165
166 // Get the covariance matrix (energy, phi, theta)
167 TMatrixDSym covmatecl = GetCovarianceMatrix3x3FromCluster(cluster);
168
169 // Combine into the total covariance matrix from the ECL cluster (0..2) and the IP(3..5) as two 3x3 block matrices.
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);
175 }
176 }
177
178 TMatrixDSym covmatCart(4);
179 covmatCart = covmatcombined.Similarity(jacobiMatrix);
180 return covmatCart;
181}
const TMatrixDSym GetCovarianceMatrix3x3FromCluster(const ECLCluster *cluster)
Returns 3x3 covariance matrix (E, theta, phi)

◆ GetCovarianceMatrix7x7FromCluster() [1/2]

const TMatrixDSym GetCovarianceMatrix7x7FromCluster ( const ECLCluster cluster,
const TMatrixD &  jacobiMatrix 
)

Returns 7x7 covariance matrix (px, py, pz, E, x, y, z)

Returns
const TMatrixDSym

Definition at line 185 of file ClusterUtils.cc.

186{
187
189}
const TMatrixDSym GetCovarianceMatrix7x7FromCluster(const ECLCluster *cluster, const TMatrixD &jacobiMatrix)
Returns 7x7 covariance matrix (px, py, pz, E, x, y, z)

◆ GetCovarianceMatrix7x7FromCluster() [2/2]

const TMatrixDSym GetCovarianceMatrix7x7FromCluster ( const ECLCluster cluster,
const TMatrixDSym &  covmatvertex,
const TMatrixD &  jacobiMatrix 
)

Returns 7x7 covariance matrix (px, py, pz, E, x, y, z)

Returns
const TMatrixDSym

Definition at line 191 of file ClusterUtils.cc.

193{
194 TMatrixDSym covmat4x4 = GetCovarianceMatrix4x4FromCluster(cluster, covmatvertex, jacobiMatrix);
195
196 TMatrixDSym covmatCart(7);
197
198 // px, py, pz, E
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);
202 }
203 }
204
205 // x, y, z
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);
209 }
210 }
211
212 return covmatCart;
213}

◆ GetIPPosition()

const XYZVector GetIPPosition ( )

Returns default IP position from beam parameters.

Returns
const XYZVector

Definition at line 216 of file ClusterUtils.cc.

217{
218 if (!m_beamSpotDB) {
219 B2WARNING("Beamspot not available, using (0, 0, 0) as IP position instead.");
220 return XYZVector(0.0, 0.0, 0.0);
221 } else
222 return XYZVector(m_beamSpotDB->getIPPosition().X(), m_beamSpotDB->getIPPosition().Y(), m_beamSpotDB->getIPPosition().Z());
223}
DBObjPtr< BeamSpot > m_beamSpotDB
Beam spot database object.
Definition: ClusterUtils.h:125

◆ GetIPPositionCovarianceMatrix()

const TMatrixDSym GetIPPositionCovarianceMatrix ( )

Returns default IP position covariance matrix from beam parameters.

Returns
const TMatrixDSym

Definition at line 226 of file ClusterUtils.cc.

227{
228 if (!m_beamSpotDB) {
229 B2WARNING("Beam parameters not available, using ((1, 0, 0), (0, 1, 0), (0, 0, 1)) as IP covariance matrix instead.");
230
231 TMatrixDSym covmat(3);
232 for (int i = 0; i < 3; ++i) {
233 covmat(i, i) = 1.0; // 1.0*1.0 cm^2
234 }
235 return covmat;
236 } else
237 return m_beamSpotDB->getCovVertex();
238}

◆ GetJacobiMatrix4x6FromCluster() [1/2]

const TMatrixD GetJacobiMatrix4x6FromCluster ( const ECLCluster cluster,
const ROOT::Math::XYZVector &  vertex,
ECLCluster::EHypothesisBit  hypo 
)

Returns 4x6 Jacobi matrix (px, py, pz, E)

Returns
const TMatrixD

Definition at line 60 of file ClusterUtils.cc.

62{
63
64 // Calculate the Jacobi matrix J = dpx/dE dpx/dphi dpx/dtheta dpx/dx dpy/dy dpz/dz
65 // ...
66 // dpx/dE dE/dphi dE/dtheta dpx/dx dE/dy dE/dz
67 TMatrixD jacobian(4, 6);
68
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();
73
74 const double st = sin(theta);
75 const double ct = cos(theta);
76 const double sp = sin(phi);
77 const double cp = cos(phi);
78
79 const double clx = R * st * cp; // cluster position x
80 const double cly = R * st * sp; // cluster position y
81 const double clz = R * ct; // cluster position z
82
83 const double vx = vertex.X(); // vertex position x
84 const double vy = vertex.Y(); // vertex position y
85 const double vz = vertex.Z(); // vertex position z
86
87 const double dx = clx - vx; // direction vector x
88 const double dy = cly - vy; // direction vector y
89 const double dz = clz - vz; // direction vector z
90 const double dx2 = dx * dx; // direction vector x squared
91 const double dy2 = dy * dy; // direction vector y squared
92 const double dz2 = dz * dz; // direction vector z squared
93
94 const double r2 = (dx * dx + dy * dy + dz * dz);
95 const double r12 = sqrt(r2);
96 const double r32 = pow(r2, 1.5);
97
98 // px = E * dx/r
99 jacobian(0, 0) = dx / r12; // dpx/dE
100 jacobian(0, 1) = -energy * R * ((dx * dy * cp) + ((dy2 + dz2) * sp)) * st / (r32); // dpx/dphi
101 jacobian(0, 2) = energy * R * (((dy2 + dz2) * cp * ct) - (dx * dy * ct * sp) + (dx * dz * st)) / (r32); // dpx/dtheta
102 jacobian(0, 3) = -energy * (dy2 + dz2) / (r32); // dpx/dvx
103 jacobian(0, 4) = energy * dx * dy / (r32); // dpx/dvy
104 jacobian(0, 5) = energy * dx * dz / (r32); // dpx/dvz
105
106 // py = E * dy/r
107 jacobian(1, 0) = dy / r12; // dpy/dE
108 jacobian(1, 1) = energy * R * (((dx2 + dz2) * cp) + (dx * dy * sp)) * st / (r32); // dpy/dphi
109 jacobian(1, 2) = energy * R * ((-dx * dy * cp * ct) + ((dx2 + dz2) * ct * sp) + (dy * dz * st)) / (r32); // dpz/dtheta
110 jacobian(1, 3) = energy * dx * dy / (r32); // dpy/dvx
111 jacobian(1, 4) = -energy * (dx2 + dz2) / (r32); // dpy/dvy
112 jacobian(1, 5) = energy * dy * dz / (r32); // dpy/dvz
113
114 // pz = E * dz/r
115 jacobian(2, 0) = dz / r12; // dpz/dE
116 jacobian(2, 1) = energy * R * dz * (-dy * cp + dx * sp) * st / (r32); // dpz/dphi
117 jacobian(2, 2) = -energy * R * ((dx * dz * cp * ct) + (dy * dz * ct * sp) + (dx2 + dy2) * st) / (r32); // dpz/dtheta
118 jacobian(2, 3) = energy * dx * dz / (r32); // dpz/dvx
119 jacobian(2, 4) = energy * dy * dz / (r32); // dpz/dvy
120 jacobian(2, 5) = -energy * (dx2 + dy2) / (r32); // dpz/ydvz
121
122 // E
123 jacobian(3, 0) = 1.0; // dE/dE
124 jacobian(3, 1) = 0.0; // dE/dphi
125 jacobian(3, 2) = 0.0; // dE/dtheta
126 jacobian(3, 3) = 0.0; // dE/dvx
127 jacobian(3, 4) = 0.0; // dE/dvy
128 jacobian(3, 5) = 0.0; // dE/dvz
129
130 // jacobian.Print();
131 return jacobian;
132}

◆ GetJacobiMatrix4x6FromCluster() [2/2]

const TMatrixD GetJacobiMatrix4x6FromCluster ( const ECLCluster cluster,
ECLCluster::EHypothesisBit  hypo 
)

Returns 4x6 Jacobi matrix (px, py, pz, E)

Returns
const TMatrixD

Definition at line 54 of file ClusterUtils.cc.

55{
56
57 return GetJacobiMatrix4x6FromCluster(cluster, GetIPPosition(), hypo);
58}
const TMatrixD GetJacobiMatrix4x6FromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns 4x6 Jacobi matrix (px, py, pz, E)
Definition: ClusterUtils.cc:54

Member Data Documentation

◆ m_beamSpotDB

DBObjPtr<BeamSpot> m_beamSpotDB
private

Beam spot database object.

Definition at line 125 of file ClusterUtils.h.

◆ m_photonEnergyResolutionDB

OptionalDBObjPtr<ECLPhotonEnergyResolution> m_photonEnergyResolutionDB
private

Photon energy resolution database object.

Definition at line 130 of file ClusterUtils.h.


The documentation for this class was generated from the following files: