63 double& distance)
const
65 const Amg::Vector3D momentumUnit = thePerigee->momentum().unit();
66 double pathLength = ( *theVertex - thePerigee->position() ).dot( momentumUnit )
67 / ( momentumUnit.dot( momentumUnit )) ;
71 Amg::Vector3D POCA = thePerigee->position() + pathLength * momentumUnit;
73 distance=DeltaR.mag();
79 Amg::Vector3D DeltaRcorrected=DeltaR-(DeltaR.dot(momentumUnit))*momentumUnit;
81 if ((DeltaR-DeltaRcorrected).
mag()>1e-4)
84 ATH_MSG_DEBUG( std::setprecision(10) <<
" DeltaR-DeltaRcorrected: " << (DeltaR-DeltaRcorrected).
mag() );
93 ATH_MSG_VERBOSE(
"plane to which to extrapolate X " << DeltaRcorrected <<
" Y " << YDir <<
" Z " << momentumUnit);
97#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
98 std::cout <<
"the translation is, directly from Transform3d: " << thePlane->getTranslation() <<
endmsg;
101 return std::make_unique<PlaneSurface>(thePlane);
117 double& distance)
const
125 double magnFieldVect[3];
127 if(magnFieldVect[2] == 0 ){
128 ATH_MSG_DEBUG(
"Magnetic field in the Z direction is 0 -- propagate like a straight line");
133 if (thePerigee==
nullptr)
136 " ImpactPoint3dEstimator didn't get a Perigee* as ParametersBase*: "
137 "cast not possible. Need to EXTRAPOLATE...");
139 std::unique_ptr<const Trk::TrackParameters> tmp =
141 Gaudi::Hive::currentContext(), *trackPerigee, perigeeSurface);
143 thePerigee =
static_cast<const Trk::Perigee*
>(tmp.release());
145 if (thePerigee ==
nullptr){
150 ATH_MSG_VERBOSE(
" Now running ImpactPoint3dEstimator::Estimate3dIP" );
152 double dCosPhi0=-std::sin(
phi0);
153 double dSinPhi0=std::cos(
phi0);
155 double cotTheta=1./std::tan(thePerigee->parameters()[
Trk::theta]);
156 double d0=thePerigee->parameters()[
Trk::d0];
159 double Bz=magnFieldVect[2]*299.792;
166 if (thePerigee!=trackPerigee) {
171 double xc=theVertex->x();
172 double yc=theVertex->y();
173 double zc=theVertex->z();
175 double phiActual=
phi0;
176 double dCosPhiActual=-std::sin(phiActual);
177 double dSinPhiActual=std::cos(phiActual);
179 double secderivative=0.;
180 double derivative=0.;
187#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
188 std::cout << std::setprecision(25) <<
"actual distance before cycle is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
189 y0-yc+Rt*dSinPhiActual,
190 z0-zc-Rt*cotTheta*phiActual) << std::endl;
195#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
196 ATH_MSG_VERBOSE(
"Cycle number: " << ncycle <<
" old phi: " << phiActual );
200 derivative=(x0-xc)*(-Rt*dSinPhiActual)+(y0-yc)*Rt*dCosPhiActual+(
z0-zc-Rt*phiActual*cotTheta)*(-Rt*cotTheta);
201 secderivative=Rt*(-(x0-xc)*dCosPhiActual-(y0-yc)*dSinPhiActual+Rt*cotTheta*cotTheta);
202#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
203 ATH_MSG_VERBOSE(
"derivative is: " << derivative <<
" sec derivative is: " << secderivative );
206 deltaphi=-derivative/secderivative;
208#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
209 std::cout << std::setprecision(25) <<
"deltaphi: " << deltaphi << std::endl;
213 dCosPhiActual=-std::sin(phiActual);
214 dSinPhiActual=std::cos(phiActual);
216#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
217 ATH_MSG_VERBOSE(
"derivative is: " << derivative <<
" sec derivative is: " << secderivative );
218 std::cout << std::setprecision(25) << std::hypot(x0-xc+Rt*dCosPhiActual, y0-yc+Rt*dSinPhiActual,
219 z0-zc-Rt*cotTheta*phiActual) << std::endl;
220 ATH_MSG_VERBOSE(
"actual distance is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
221 y0-yc+Rt*dSinPhiActual,
222 z0-zc-Rt*cotTheta*phiActual));
231#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
242 Amg::Vector3D DeltaR(x0-xc+Rt*dCosPhiActual,y0-yc+Rt*dSinPhiActual,
z0-zc-Rt*cotTheta*phiActual);
243 distance=DeltaR.mag();
245 ATH_MSG_WARNING(
"DeltaR is zero in ImpactPoint3dEstimator::Estimate3dIP, returning nullptr");
248 DeltaR=DeltaR.unit();
253 Amg::Vector3D DeltaRcorrected=DeltaR-(DeltaR.dot(MomentumDir))*MomentumDir;
255 if ((DeltaR-DeltaRcorrected).
mag()>1e-4)
258 ATH_MSG_DEBUG( std::setprecision(10) <<
" DeltaR-DeltaRcorrected: " << (DeltaR-DeltaRcorrected).
mag() );
266 ATH_MSG_VERBOSE(
"final minimal distance is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
267 y0-yc+Rt*dSinPhiActual,
268 z0-zc-Rt*cotTheta*phiActual));
274 ATH_MSG_VERBOSE(
"plane to which to extrapolate X " << DeltaRcorrected <<
" Y " << YDir <<
" Z " << MomentumDir );
278#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
279 std::cout <<
"the translation is, directly from Transform3d: " << thePlane.getTranslation() <<
endmsg;
281 return std::make_unique<PlaneSurface>(thePlane);