1 #ifndef ConstrainedTreeBuilderT_H
2 #define ConstrainedTreeBuilderT_H
31 buildTree(
const std::vector<RefCountedKinematicParticle> & initialParticles,
32 const std::vector<KinematicState> & finalStates,
34 const ROOT::Math::SMatrix<
double,3+7*nTrk,3+7*nTrk,ROOT::Math::MatRepSym<double,3+7*nTrk> >& fCov)
const;
48 const ROOT::Math::SMatrix<
double,3+7*nTrk,3+7*nTrk,ROOT::Math::MatRepSym<double,3+7*nTrk> >& fitCov);
61 const std::vector<KinematicState> & finalStates,
63 const ROOT::Math::SMatrix<
double,3+7*nTrk,3+7*nTrk,ROOT::Math::MatRepSym<double,3+7*nTrk> >& fullCov)
const
65 if (!vertex->vertexIsValid()) {
66 LogDebug(
"RecoVertex/ConstrainedTreeBuilder")
67 <<
"Vertex is invalid\n";
71 vtx(0) = vertex->position().x();
72 vtx(1) = vertex->position().y();
73 vtx(2) = vertex->position().z();
74 AlgebraicMatrix33 vertexCov = fullCov.template Sub<ROOT::Math::SMatrix<double, 3> >(0,0);
82 virtualPartPar(0) = vertex->position().x();
83 virtualPartPar(1) = vertex->position().y();
84 virtualPartPar(2) = vertex->position().z();
89 ROOT::Math::SMatrix<double,7,7,ROOT::Math::MatRepStd<double,7,7> > aMatrix;
90 ROOT::Math::SMatrix<double,7,7,ROOT::Math::MatRepStd<double,7,7> > aMatrixT;
91 aMatrix(3,3) = aMatrixT(3,3) = 1;
92 aMatrix(4,4) = aMatrixT(4,4) = 1;
93 aMatrix(5,5) = aMatrixT(5,5) = 1;
94 aMatrix(6,6) = aMatrixT(6,6) = 1;
95 ROOT::Math::SMatrix<double,7,3,ROOT::Math::MatRepStd<double,7,3> > bMatrix;
96 ROOT::Math::SMatrix<double,3,7,ROOT::Math::MatRepStd<double,3,7> > bMatrixT;
97 bMatrix(0,0) = bMatrixT(0,0) = 1;
98 bMatrix(1,1) = bMatrixT(1,1) = 1;
99 bMatrix(2,2) = bMatrixT(2,2) = 1;
101 ROOT::Math::SMatrix<double,3,7,ROOT::Math::MatRepStd<double,3,7> > vtxTrackCov;
105 std::vector<RefCountedKinematicParticle>::const_iterator
i = initialParticles.begin();
106 std::vector<KinematicState>::const_iterator iStates = finalStates.begin();
107 std::vector<RefCountedKinematicParticle> rParticles;
110 for( ; i != initialParticles.end() && iStates != finalStates.end(); ++
i,++iStates)
113 double a = - iStates->particleCharge() *
114 iStates->magneticField()->inInverseGeV(iStates->globalPosition()).
z();
116 aMatrix(4,0) = aMatrixT(0,4) = -
a;
117 aMatrix(3,1) = aMatrixT(1,3) =
a;
118 bMatrix(4,0) = bMatrixT(0,4) =
a;
119 bMatrix(3,1) = bMatrixT(1,3) = -
a;
123 trackParCov = fullCov.template Sub<AlgebraicSymMatrix77>(3+n*7,3+n*7);
124 vtxTrackCov = fullCov.template Sub<ROOT::Math::SMatrix<double, 3, 7> >(0,3+n*7);
125 ROOT::Math::AssignSym::Evaluate(nCovariance,
126 aMatrix * trackParCov * aMatrixT
127 + aMatrix * ROOT::Math::Transpose(vtxTrackCov) * bMatrixT
128 + bMatrix * vtxTrackCov * aMatrixT
129 + bMatrix * vertexCov * bMatrixT
142 iStates->particleCharge(), iStates->magneticField());
143 rParticles.push_back((*i)->refittedParticle(stateAtVertex, vertex->chiSquared(), vertex->degreesOfFreedom()));
145 virtualPartPar(3) += par(3);
146 virtualPartPar(4) += par(4);
147 virtualPartPar(5) += par(5);
148 ent +=
sqrt(par(6)*par(6) + par(3)*par(3)+par(4)*par(4)+par(5)*par(5) );
149 charge += iStates->particleCharge();
156 double differ = ent*ent - (virtualPartPar(3)*virtualPartPar(3) + virtualPartPar(5)*virtualPartPar(5) + virtualPartPar(4)*virtualPartPar(4));
158 virtualPartPar(6) =
sqrt(differ);
161 <<
"Fit failed: Current precision does not allow to calculate the mass\n";
174 float chi2 = vertex->chiSquared();
175 float ndf = vertex->degreesOfFreedom();
186 const ROOT::Math::SMatrix<
double,3+7*nTrk,3+7*nTrk,ROOT::Math::MatRepSym<double,3+7*nTrk> >& fitCov)
189 typedef ROOT::Math::SMatrix<double,3+7*nTrk,3+7*nTrk,ROOT::Math::MatRepSym<double,3+7*nTrk> > FitCov;
196 if (
int(rPart.size())!=size)
throw "error in ConstrainedTreeBuilderT ";
200 ROOT::Math::SMatrix<double,3+7*nTrk> jac;
204 ROOT::Math::SMatrix<double,3,7>
upper;
205 ROOT::Math::SMatrix<double,7> diagonal;
206 for(
int i_int=0; i_int!=
size; ++i_int) {
209 double a_i = - (
i)->currentState().particleCharge() *
210 (
i)->
magneticField()->inInverseGeV((i)->currentState().globalPosition()).z();
216 jac.Place_at(upper,0,3+i_int*7);
223 diagonal(0,4) = -a_i;
224 jac.Place_at(diagonal,3+i_int*7,3+i_int*7);
234 FitCov
const & fit_cov_sym = fitCov;
243 ROOT::Math::SMatrix<double,4*nTrk+3,4*nTrk+3, ROOT::Math::MatRepSym<double,4*nTrk+3> > reduced;
244 FitCov
transform=ROOT::Math::SimilarityT(jac,fit_cov_sym);
247 ROOT::Math::SMatrix<double,7,4*nTrk+3> jac_t;
254 double energy_global =
sqrt(newPar(3)*newPar(3)+newPar(4)*newPar(4) + newPar(5)*newPar(5)+newPar(6)*newPar(6));
255 for(
int il_int = 0; il_int!=
size; ++il_int) {
258 int off1=3;
int off2=il_int*4+3;
259 jac_t(off1+0,off2+0) = 1.;
260 jac_t(off1+1,off2+1) = 1.;
261 jac_t(off1+2,off2+2) = 1.;
264 AlgebraicVector7 l_Par = (rs)->currentState().kinematicParameters().vector();
265 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));
266 jac_t(off1+3,off2+3) = energy_global*l_Par(6)/(newPar(6)*energy_local);
267 jac_t(off1+3,off2+0) = ((energy_global*l_Par(3)/energy_local) - newPar(3))/newPar(6);
268 jac_t(off1+3,off2+1) = ((energy_global*l_Par(4)/energy_local) - newPar(4))/newPar(6);
269 jac_t(off1+3,off2+2) = ((energy_global*l_Par(5)/energy_local) - newPar(5))/newPar(6);
272 for(
int i = 0;
i<7;++
i)
273 for(
int j =0;
j<7; ++
j)
282 for(
int l1 = 0; l1<3;++l1)
283 for(
int l2 = 0; l2<4;++l2)
284 reduced(off1+l1,off2+l2) =
transform(3+l1,6+7*
i +l2);
288 for(
int l1 = 0; l1<4;++l1)
289 for(
int l2 = 0; l2<4;++l2)
290 reduced(off1+l1,off2+l2) =
transform(6+7*
i+l1, 6+7*
i+l2);
294 off1 = 3+4*(
i-1); off2=3+4*
j;
295 for(
int l1 = 0; l1<4;++l1)
296 for(
int l2 = 0; l2<4;++l2)
297 reduced(off1+l1,off2+l2) =
transform(6+7*(
i-1)+l1,6+7*
j+l2);
303 ROOT::Math::AssignSym::Evaluate(ret, jac_t*reduced*ROOT::Math::Transpose(jac_t));
~ConstrainedTreeBuilderT()
tuple ret
prodAgent to be discontinued
VirtualKinematicParticleFactory pFactory
RefCountedKinematicParticle particle(const KinematicState &kineState, float &chiSquared, float °reesOfFr, ReferenceCountingPointer< KinematicParticle > previousParticle, KinematicConstraint *lastConstraint=0) const
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
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
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
ROOT::Math::SVector< double, 7 > AlgebraicVector7
ROOT::Math::SVector< double, 3 > AlgebraicVector3
RefCountedKinematicTree buildRealTree(const RefCountedKinematicParticle virtualParticle, const RefCountedKinematicVertex vtx, const std::vector< RefCountedKinematicParticle > &particles) const
ConstrainedTreeBuilderT()
tuple size
Write out results.
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33