26 m_LinearizedTrackFactory(
"Trk::FullLinearizedTrackFactory/FullLinearizedTrackFactory"),
27 m_linearizedTrackFactoryIsAvailable(false)
29 declareProperty(
"LinearizedTrackFactory",m_LinearizedTrackFactory);
30 declareInterface<INeutralParticleParameterCalculator>(
this);
40 return StatusCode::SUCCESS;
50 msg(MSG::WARNING) <<
" More or less than 2 tracks in Vertex. No Neutral Perigee could be created" <<
endmsg;
56 msg(MSG::WARNING) <<
" Track Particle Element link is not valid" <<
endmsg;
66 const AmgMatrix(3,3)& vrt_cov = myVertex.covariancePosition();
67 AmgMatrix(3,3) vrt_weight = myVertex.covariancePosition().inverse().eval();
76 msg(MSG::ERROR) <<
" No LinearizedTrackFactory is defined and no ExtendedVxCandidate is provided. Cannot obtain covariance matrix of neutral particle. Failed... " <<
endmsg;
86 if (myFirstLinearizedTrack==
nullptr||mySecondLinearizedTrack==
nullptr)
88 msg(MSG::WARNING) <<
" Could not find one of the linearized tracks. No Neutral Perigee could be created" <<
endmsg;
89 if (myFirstLinearizedTrack)
delete myFirstLinearizedTrack;
90 if (mySecondLinearizedTrack)
delete mySecondLinearizedTrack;
102 delete myFirstLinearizedTrack;
103 delete mySecondLinearizedTrack;
105 msg(MSG::WARNING) <<
" getPosMomentumAndMomentumCovMatrix method failed " <<
endmsg;
109 const AmgVector(5) & myFirstPerigeeParameters=myFirstPerigee.parameters();
110 const AmgVector(5) & mySecondPerigeeParameters=mySecondPerigee.parameters();
112 AmgMatrix(3,3) FirstJacobianToPxPyPz=getPhiThetaQOverPToPxPyPzJacobian(myFirstPerigeeParameters[
Trk::qOverP],
116 AmgMatrix(3,3) SecondJacobianToPxPyPz=getPhiThetaQOverPToPxPyPzJacobian(mySecondPerigeeParameters[
Trk::qOverP],
122 AmgMatrix(3,3) posMomentumCovFirst=PosMomAndMomCovFirstTrack.first*FirstJacobianToPxPyPz.transpose();
123 AmgMatrix(3,3) posMomentumCovSecond=PosMomAndMomCovSecondTrack.first*SecondJacobianToPxPyPz.transpose();
125 AmgMatrix(3,3) momentumCovFirst=PosMomAndMomCovFirstTrack.second.similarity(FirstJacobianToPxPyPz);
126 AmgMatrix(3,3) momentumCovSecond=PosMomAndMomCovSecondTrack.second.similarity(SecondJacobianToPxPyPz);
130 AmgMatrix(3,3) covP1P2; covP1P2.setZero();
133 covP1P2=posMomentumCovFirst.transpose()*vrt_weight*posMomentumCovSecond;
137 AmgMatrix(3,3) covNewP = momentumCovFirst+momentumCovSecond+covP1P2+covP1P2.transpose();
139 AmgMatrix(3,3) covNewXP=posMomentumCovFirst+posMomentumCovSecond;
143 Amg::Vector3D newMomentum=myFirstPerigee.momentum()+mySecondPerigee.momentum();
145 ATH_MSG_VERBOSE(
" new momentum " << newMomentum <<
" new cov Momentum " << covNewP);
155 1./newMomentum.mag());
157 AmgMatrix(3,3) finalCovNewP=covNewP.similarity(JacobianToPhiThetaQOverP);
158 AmgMatrix(3,3) finalCovNewXP=covNewXP*JacobianToPhiThetaQOverP.transpose();
160 double phi=newMomentum.phi();
161 double theta=newMomentum.theta();
162 double qOverP=1./newMomentum.mag();
172 double sin_phi_v=
sin(
phi);
173 double cos_phi_v=
cos(
phi);
177 AmgMatrix(5,6) globalNeutralJacobian; globalNeutralJacobian.setZero();
178 globalNeutralJacobian(0,0) = -sin_phi_v;
179 globalNeutralJacobian(0,1) = +cos_phi_v;
180 globalNeutralJacobian(1,0) = -cos_phi_v/tan_th;
181 globalNeutralJacobian(1,1) = -sin_phi_v/tan_th;
182 globalNeutralJacobian(1,2) = 1.;
183 globalNeutralJacobian(2,3) = 1.;
184 globalNeutralJacobian(3,4) = 1.;
185 globalNeutralJacobian(4,5) = 1.;
187 AmgMatrix(6,6) fullTrkCov; fullTrkCov.setZero();
188 fullTrkCov.block<3,3>(0,3) = finalCovNewXP;
189 fullTrkCov.block<3,3>(3,0) = finalCovNewXP.transpose();
190 fullTrkCov.block<3,3>(0,0) = vrt_cov;
191 fullTrkCov.block<3,3>(3,3) = finalCovNewP;
211 const AmgMatrix(5,3) &
A = linTrack->positionJacobian();
212 const AmgMatrix(5,3) & B = linTrack->momentumJacobian();
213 const AmgSymMatrix(5) & trkParametersWeight = linTrack->expectedWeightAtPCA();
215 AmgSymMatrix(3) Sm = B.transpose()*(trkParametersWeight*B);
217 if (Sm.determinant() == 0.0) {
218 ATH_MSG_WARNING(
"S matrix can not be inverted, new type of check as part of Eigen, please monitor."
219 <<
endmsg <<
"Matrix Sm = " << Sm);
223 Sm = Sm.inverse().eval();
224 AmgMatrix(3,3) posMomentumCovariance = -vrt_cov *
A.transpose() * trkParametersWeight * B *Sm;
225 AmgMatrix(3,3) momentumCovariance = Sm + vrt_weight.similarityT(posMomentumCovariance);
227 return std::pair<AmgMatrix(3,3),AmgMatrix(3,3)>(posMomentumCovariance,momentumCovariance);