1 #ifndef ConstrainedTreeBuilderT_H 2 #define ConstrainedTreeBuilderT_H 28 const std::vector<RefCountedKinematicParticle>& initialParticles,
31 const ROOT::Math::SMatrix<
double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> >& fCov)
37 const std::vector<RefCountedKinematicParticle>&
particles)
const;
44 const std::vector<RefCountedKinematicParticle>& rPart,
46 const ROOT::Math::SMatrix<
double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> >&
58 const std::vector<RefCountedKinematicParticle>& initialParticles,
61 const ROOT::Math::SMatrix<
double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> >&
63 if (!
vertex->vertexIsValid()) {
64 LogDebug(
"RecoVertex/ConstrainedTreeBuilder") <<
"Vertex is invalid\n";
71 AlgebraicMatrix33 vertexCov = fullCov.template Sub<ROOT::Math::SMatrix<double, 3> >(0, 0);
79 virtualPartPar(0) =
vertex->position().x();
80 virtualPartPar(1) =
vertex->position().y();
81 virtualPartPar(2) =
vertex->position().z();
86 ROOT::Math::SMatrix<double, 7, 7, ROOT::Math::MatRepStd<double, 7, 7> > aMatrix;
87 ROOT::Math::SMatrix<double, 7, 7, ROOT::Math::MatRepStd<double, 7, 7> > aMatrixT;
88 aMatrix(3, 3) = aMatrixT(3, 3) = 1;
89 aMatrix(4, 4) = aMatrixT(4, 4) = 1;
90 aMatrix(5, 5) = aMatrixT(5, 5) = 1;
91 aMatrix(6, 6) = aMatrixT(6, 6) = 1;
92 ROOT::Math::SMatrix<double, 7, 3, ROOT::Math::MatRepStd<double, 7, 3> > bMatrix;
93 ROOT::Math::SMatrix<double, 3, 7, ROOT::Math::MatRepStd<double, 3, 7> > bMatrixT;
94 bMatrix(0, 0) = bMatrixT(0, 0) = 1;
95 bMatrix(1, 1) = bMatrixT(1, 1) = 1;
96 bMatrix(2, 2) = bMatrixT(2, 2) = 1;
98 ROOT::Math::SMatrix<double, 3, 7, ROOT::Math::MatRepStd<double, 3, 7> > vtxTrackCov;
102 std::vector<RefCountedKinematicParticle>::const_iterator
i = initialParticles.begin();
103 std::vector<KinematicState>::const_iterator iStates =
finalStates.begin();
104 std::vector<RefCountedKinematicParticle> rParticles;
107 for (;
i != initialParticles.end() && iStates !=
finalStates.end(); ++
i, ++iStates) {
109 double a = -iStates->particleCharge() * iStates->magneticField()->inInverseGeV(iStates->globalPosition()).
z();
111 aMatrix(4, 0) = aMatrixT(0, 4) = -
a;
112 aMatrix(3, 1) = aMatrixT(1, 3) =
a;
113 bMatrix(4, 0) = bMatrixT(0, 4) =
a;
114 bMatrix(3, 1) = bMatrixT(1, 3) = -
a;
118 trackParCov = fullCov.template Sub<AlgebraicSymMatrix77>(3 +
n * 7, 3 +
n * 7);
119 vtxTrackCov = fullCov.template Sub<ROOT::Math::SMatrix<double, 3, 7> >(0, 3 +
n * 7);
120 ROOT::Math::AssignSym::Evaluate(nCovariance,
121 aMatrix * trackParCov * aMatrixT +
122 aMatrix * ROOT::Math::Transpose(vtxTrackCov) * bMatrixT +
123 bMatrix * vtxTrackCov * aMatrixT + bMatrix * vertexCov * bMatrixT);
135 iStates->particleCharge(),
136 iStates->magneticField());
137 rParticles.push_back((*i)->refittedParticle(stateAtVertex,
vertex->chiSquared(),
vertex->degreesOfFreedom()));
139 virtualPartPar(3) += par(3);
140 virtualPartPar(4) += par(4);
141 virtualPartPar(5) += par(5);
142 ent +=
sqrt(par(6) * par(6) + par(3) * par(3) + par(4) * par(4) + par(5) * par(5));
143 charge += iStates->particleCharge();
149 double differ = ent * ent - (virtualPartPar(3) * virtualPartPar(3) + virtualPartPar(5) * virtualPartPar(5) +
150 virtualPartPar(4) * virtualPartPar(4));
152 virtualPartPar(6) =
sqrt(differ);
154 LogDebug(
"ConstrainedTreeBuilder") <<
"Fit failed: Current precision does not allow to calculate the mass\n";
167 float ndf =
vertex->degreesOfFreedom();
176 const std::vector<RefCountedKinematicParticle>& rPart,
178 const ROOT::Math::SMatrix<
double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> >& fitCov) {
179 typedef ROOT::Math::SMatrix<double, 3 + 7 * nTrk, 3 + 7 * nTrk, ROOT::Math::MatRepSym<double, 3 + 7 * nTrk> > FitCov;
186 if (
int(rPart.size()) !=
size)
187 throw "error in ConstrainedTreeBuilderT ";
191 ROOT::Math::SMatrix<double, 3 + 7 * nTrk> jac;
195 ROOT::Math::SMatrix<double, 3, 7> upper;
196 ROOT::Math::SMatrix<double, 7> diagonal;
197 for (
int i_int = 0; i_int !=
size; ++i_int) {
200 double a_i = -(
i)->currentState().particleCharge() *
201 (
i)->
magneticField()->inInverseGeV((
i)->currentState().globalPosition()).z();
207 jac.Place_at(upper, 0, 3 + i_int * 7);
213 diagonal(1, 3) = a_i;
214 diagonal(0, 4) = -a_i;
215 jac.Place_at(diagonal, 3 + i_int * 7, 3 + i_int * 7);
225 FitCov
const& fit_cov_sym = fitCov;
234 ROOT::Math::SMatrix<double, 4 * nTrk + 3, 4 * nTrk + 3, ROOT::Math::MatRepSym<double, 4 * nTrk + 3> > reduced;
235 FitCov
transform = ROOT::Math::SimilarityT(jac, fit_cov_sym);
238 ROOT::Math::SMatrix<double, 7, 4 * nTrk + 3> jac_t;
243 double energy_global =
244 sqrt(newPar(3) * newPar(3) + newPar(4) * newPar(4) + newPar(5) * newPar(5) + newPar(6) * newPar(6));
245 for (
int il_int = 0; il_int !=
size; ++il_int) {
249 int off2 = il_int * 4 + 3;
250 jac_t(off1 + 0, off2 + 0) = 1.;
251 jac_t(off1 + 1, off2 + 1) = 1.;
252 jac_t(off1 + 2, off2 + 2) = 1.;
255 AlgebraicVector7 l_Par = (rs)->currentState().kinematicParameters().vector();
256 double energy_local =
sqrt(l_Par(6) * l_Par(6) + l_Par(3) * l_Par(3) + l_Par(4) * l_Par(4) + l_Par(5) * l_Par(5));
257 jac_t(off1 + 3, off2 + 3) = energy_global * l_Par(6) / (newPar(6) * energy_local);
258 jac_t(off1 + 3, off2 + 0) = ((energy_global * l_Par(3) / energy_local) - newPar(3)) / newPar(6);
259 jac_t(off1 + 3, off2 + 1) = ((energy_global * l_Par(4) / energy_local) - newPar(4)) / newPar(6);
260 jac_t(off1 + 3, off2 + 2) = ((energy_global * l_Par(5) / energy_local) - newPar(5)) / newPar(6);
263 for (
int i = 0;
i < 7; ++
i)
264 for (
int j = 0;
j < 7; ++
j)
267 for (
int i = 1;
i <
size;
i++) {
272 int off2 = 3 + 4 *
i;
273 for (
int l1 = 0; l1 < 3; ++l1)
274 for (
int l2 = 0; l2 < 4; ++l2)
275 reduced(off1 + l1, off2 + l2) =
transform(3 + l1, 6 + 7 *
i + l2);
278 off1 = off2 = 3 + 4 *
i;
279 for (
int l1 = 0; l1 < 4; ++l1)
280 for (
int l2 = 0; l2 < 4; ++l2)
281 reduced(off1 + l1, off2 + l2) =
transform(6 + 7 *
i + l1, 6 + 7 *
i + l2);
284 for (
int j = 1;
j <
size;
j++) {
285 off1 = 3 + 4 * (
i - 1);
287 for (
int l1 = 0; l1 < 4; ++l1)
288 for (
int l2 = 0; l2 < 4; ++l2)
289 reduced(off1 + l1, off2 + l2) =
transform(6 + 7 * (
i - 1) + l1, 6 + 7 *
j + l2);
294 ROOT::Math::AssignSym::Evaluate(
ret, jac_t * reduced * ROOT::Math::Transpose(jac_t));
~ConstrainedTreeBuilderT()
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33
VirtualKinematicParticleFactory pFactory
static AlgebraicSymMatrix77 covarianceMatrix(const std::vector< RefCountedKinematicParticle > &rPart, const AlgebraicVector7 &newPar, const ROOT::Math::SMatrix< double, 3+7 *nTrk, 3+7 *nTrk, ROOT::Math::MatRepSym< double, 3+7 *nTrk > > &fitCov)
KinematicVertexFactory vFactory
ret
prodAgent to be discontinued
ROOT::Math::SVector< double, 7 > AlgebraicVector7
RefCountedKinematicTree buildRealTree(const RefCountedKinematicParticle virtualParticle, const RefCountedKinematicVertex vtx, const std::vector< RefCountedKinematicParticle > &particles) const
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
RefCountedKinematicParticle particle(const KinematicState &kineState, float &chiSquared, float °reesOfFr, ReferenceCountingPointer< KinematicParticle > previousParticle, KinematicConstraint *lastConstraint=nullptr) const
ROOT::Math::SVector< double, 3 > AlgebraicVector3
RefCountedKinematicTree buildTree(const std::vector< RefCountedKinematicParticle > &initialParticles, const std::vector< KinematicState > &finalStates, const RefCountedKinematicVertex vtx, const ROOT::Math::SMatrix< double, 3+7 *nTrk, 3+7 *nTrk, ROOT::Math::MatRepSym< double, 3+7 *nTrk > > &fCov) const
ConstrainedTreeBuilderT()