22 if (!vertex->vertexIsValid()) {
24 <<
"Vertex is invalid\n";
28 vtx(0) = vertex->position().x();
29 vtx(1) = vertex->position().y();
30 vtx(2) = vertex->position().z();
39 virtualPartPar(0) = vertex->position().x();
40 virtualPartPar(1) = vertex->position().y();
41 virtualPartPar(2) = vertex->position().z();
46 ROOT::Math::SMatrix<double,7,7,ROOT::Math::MatRepStd<double,7,7> > aMatrix;
51 ROOT::Math::SMatrix<double,7,3,ROOT::Math::MatRepStd<double,7,3> > bMatrix;
56 ROOT::Math::SMatrix<double,3,7,ROOT::Math::MatRepStd<double,3,7> > vtxTrackCov;
59 std::vector<RefCountedKinematicParticle>::const_iterator
i = initialParticles.begin();
60 std::vector<KinematicState>::const_iterator iStates = finalStates.begin();
61 std::vector<RefCountedKinematicParticle> rParticles;
63 for( ; i != initialParticles.end() && iStates != finalStates.end(); ++
i,++iStates)
66 double a = - iStates->particleCharge() *
67 iStates->magneticField()->inInverseGeV(iStates->globalPosition()).
z();
76 trackParCov = asSMatrix<7,7>(fullCov.sub(4+n*7,10+n*7,4+n*7,10+n*7));
77 vtxTrackCov = asSMatrix<3,7>(fullCov.sub(1,3,4+n*7,10+n*7));;
78 nCovariance = aMatrix * trackParCov * ROOT::Math::Transpose(aMatrix) +
79 aMatrix * ROOT::Math::Transpose(vtxTrackCov) * ROOT::Math::Transpose(bMatrix) +
80 bMatrix * vtxTrackCov * ROOT::Math::Transpose(aMatrix)+
81 bMatrix * vertexCov * ROOT::Math::Transpose(bMatrix);
85 iStates->particleCharge(), iStates->magneticField());
86 rParticles.push_back((*i)->refittedParticle(stateAtVertex, vertex->chiSquared(), vertex->degreesOfFreedom()));
88 virtualPartPar(3) += par(3);
89 virtualPartPar(4) += par(4);
90 virtualPartPar(5) += par(5);
91 ent +=
sqrt(par(6)*par(6) + par(3)*par(3)+par(4)*par(4)+par(5)*par(5) );
92 charge += iStates->particleCharge();
99 double differ = ent*ent - (virtualPartPar(3)*virtualPartPar(3) + virtualPartPar(5)*virtualPartPar(5) + virtualPartPar(4)*virtualPartPar(4));
101 virtualPartPar(6) =
sqrt(differ);
104 <<
"Fit failed: Current precision does not allow to calculate the mass\n";
114 charge, initialParticles[0]->magneticField());
117 float chi2 = vertex->chiSquared();
118 float ndf = vertex->degreesOfFreedom();
122 return buildTree(virtualParticle, vertex, rParticles);
135 resTree->addParticle(fVertex, vtx, virtualParticle);
138 for(std::vector<RefCountedKinematicParticle>::const_iterator il = particles.begin(); il != particles.end(); il++)
140 if((*il)->previousParticle()->correspondingTree() != 0)
146 resTree->addTree(cdVertex, tree);
149 resTree->addParticle(vtx,ffVertex,*il);
162 int size = rPart.size();
170 for(std::vector<RefCountedKinematicParticle>::const_iterator
i = rPart.begin();
i != rPart.end();
i++)
174 double a_i = - (*i)->currentState().particleCharge() * (*i)->magneticField()->inInverseGeV((*i)->currentState().globalPosition()).
z();
183 jac.sub(1,4+i_int*7,upper);
190 diagonal(1,5) = -a_i;
191 jac.sub(4+i_int*7,4+i_int*7,diagonal);
201 int vSize = rPart.size();
203 for(
int i = 1;
i<7*vSize+4; ++
i)
205 for(
int j = 1; j<7*vSize+4; ++j)
206 {
if(
i<=j) fit_cov_sym(
i,j) = fitCov(
i,j);}
223 for(
int i = 1;
i<8;++
i)
225 for(
int j =1; j<8; ++j)
235 reduced.sub(1,1,reduced_tm);
239 double energy_global =
sqrt(newPar(3)*newPar(3)+newPar(4)*newPar(4) + newPar(5)*newPar(5)+newPar(6)*newPar(6));
240 for(std::vector<RefCountedKinematicParticle>::const_iterator rs = rPart.begin();
241 rs!=rPart.end();rs++)
250 AlgebraicVector7 l_Par = (*rs)->currentState().kinematicParameters().vector();
251 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));
252 jc_el(4,4) = energy_global*l_Par(6)/(newPar(6)*energy_local);
253 jc_el(4,1) = ((energy_global*l_Par(3)/energy_local) - newPar(3))/newPar(6);
254 jc_el(4,2) = ((energy_global*l_Par(4)/energy_local) - newPar(4))/newPar(6);
255 jc_el(4,3) = ((energy_global*l_Par(5)/energy_local) - newPar(5))/newPar(6);
256 jac_t.sub(4,il_int*4+4,jc_el);
271 for(
int l1 = 1; l1<4;++l1)
273 for(
int l2 = 1; l2<5;++l2)
274 {transform_sub1(l1,l2) =
transform(3+l1,6+7*
i +l2);}
277 for(
int l1 = 1; l1<5;++l1)
279 for(
int l2 = 1; l2<4;++l2)
280 {transform_sub2(l1,l2) =
transform(6+7*
i+l1,3+l2);}
284 for(
int l1 = 1; l1<5;++l1)
286 for(
int l2 = 1; l2<5;++l2)
287 {transform_sub3(l1,l2) =
transform(6+7*
i+l1, 6+7*
i+l2); }
290 reduced.sub(1,4+4*
i,transform_sub1);
291 reduced.sub(4+4*
i,1,transform_sub2);
294 reduced.sub(4+4*
i,4+4*
i,transform_sub3);
297 for(
int j = 1; j<
size; j++)
301 for(
int l1 = 1; l1<5;++l1)
303 for(
int l2 = 1; l2<5;++l2)
305 transform_sub4(l1,l2) =
transform(6+7*(
i-1)+l1,6+7*j+l2);
306 transform_sub5(l1,l2) =
transform(6+7*j+l1, 6+7*(
i-1)+l2);
309 reduced.sub(4+4*(
i-1),4+4*j,transform_sub4);
310 reduced.sub(4+4*j,4+4*(
i-1),transform_sub5);
314 return jac_t*reduced*jac_t.T();
void replaceCurrentParticle(RefCountedKinematicParticle newPart) const
RefCountedKinematicParticle particle(const KinematicState &kineState, float &chiSquared, float °reesOfFr, ReferenceCountingPointer< KinematicParticle > previousParticle, KinematicConstraint *lastConstraint=0) const
KinematicVertexFactory * vFactory
RefCountedKinematicTree buildTree(const std::vector< RefCountedKinematicParticle > &initialParticles, const std::vector< KinematicState > &finalStates, const RefCountedKinematicVertex vtx, const AlgebraicMatrix &fCov) const
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepSym< double, 7 > > AlgebraicSymMatrix77
ROOT::Math::SVector< double, 7 > AlgebraicVector7
CLHEP::HepMatrix AlgebraicMatrix
void movePointerToTheTop() const
ROOT::Math::SVector< double, 3 > AlgebraicVector3
AlgebraicMatrix covarianceMatrix(const std::vector< RefCountedKinematicParticle > &rPart, const AlgebraicVector7 &newPar, const AlgebraicMatrix &fitCov) const
ROOT::Math::SMatrix< double, 7, 7, ROOT::Math::MatRepStd< double, 7, 7 > > AlgebraicMatrix77
CLHEP::HepSymMatrix AlgebraicSymMatrix
static RefCountedKinematicVertex vertex(const VertexState &state, float totalChiSq, float degreesOfFr)
VirtualKinematicParticleFactory * pFactory
~ConstrainedTreeBuilder()
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepStd< double, 3, 3 > > AlgebraicMatrix33