49 return StatusCode::SUCCESS;
55 return StatusCode::SUCCESS;
60 std::unique_ptr<PlaneSurface>
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);
105 std::unique_ptr<PlaneSurface>
109 double& distance)
const
111 ATH_MSG_DEBUG(
"Neutral particle -- propagate like a straight line");
115 std::unique_ptr<PlaneSurface>
119 double& distance)
const
127 double magnFieldVect[3];
129 if(magnFieldVect[2] == 0 ){
130 ATH_MSG_DEBUG(
"Magnetic field in the Z direction is 0 -- propagate like a straight line");
135 if (thePerigee==
nullptr)
138 " ImpactPoint3dEstimator didn't get a Perigee* as ParametersBase*: "
139 "cast not possible. Need to EXTRAPOLATE...");
141 std::unique_ptr<const Trk::TrackParameters> tmp =
143 ctx, *trackPerigee, perigeeSurface);
145 thePerigee =
static_cast<const Trk::Perigee*
>(tmp.release());
147 if (thePerigee ==
nullptr){
152 ATH_MSG_VERBOSE(
" Now running ImpactPoint3dEstimator::Estimate3dIP" );
154 double dCosPhi0=-std::sin(
phi0);
155 double dSinPhi0=std::cos(
phi0);
157 double cotTheta=1./std::tan(thePerigee->parameters()[
Trk::theta]);
158 double d0=thePerigee->parameters()[
Trk::d0];
161 double Bz=magnFieldVect[2]*299.792;
168 if (thePerigee!=trackPerigee) {
173 double xc=theVertex->x();
174 double yc=theVertex->y();
175 double zc=theVertex->z();
177 double phiActual=
phi0;
178 double dCosPhiActual=-std::sin(phiActual);
179 double dSinPhiActual=std::cos(phiActual);
181 double secderivative=0.;
182 double derivative=0.;
189#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
190 std::cout << std::setprecision(25) <<
"actual distance before cycle is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
191 y0-yc+Rt*dSinPhiActual,
192 z0-zc-Rt*cotTheta*phiActual) << std::endl;
197#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
198 ATH_MSG_VERBOSE(
"Cycle number: " << ncycle <<
" old phi: " << phiActual );
202 derivative=(x0-xc)*(-Rt*dSinPhiActual)+(y0-yc)*Rt*dCosPhiActual+(
z0-zc-Rt*phiActual*cotTheta)*(-Rt*cotTheta);
203 secderivative=Rt*(-(x0-xc)*dCosPhiActual-(y0-yc)*dSinPhiActual+Rt*cotTheta*cotTheta);
204#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
205 ATH_MSG_VERBOSE(
"derivative is: " << derivative <<
" sec derivative is: " << secderivative );
208 deltaphi=-derivative/secderivative;
210#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
211 std::cout << std::setprecision(25) <<
"deltaphi: " << deltaphi << std::endl;
215 dCosPhiActual=-std::sin(phiActual);
216 dSinPhiActual=std::cos(phiActual);
218#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
219 ATH_MSG_VERBOSE(
"derivative is: " << derivative <<
" sec derivative is: " << secderivative );
220 std::cout << std::setprecision(25) << std::hypot(x0-xc+Rt*dCosPhiActual, y0-yc+Rt*dSinPhiActual,
221 z0-zc-Rt*cotTheta*phiActual) << std::endl;
222 ATH_MSG_VERBOSE(
"actual distance is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
223 y0-yc+Rt*dSinPhiActual,
224 z0-zc-Rt*cotTheta*phiActual));
233#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
244 Amg::Vector3D DeltaR(x0-xc+Rt*dCosPhiActual,y0-yc+Rt*dSinPhiActual,
z0-zc-Rt*cotTheta*phiActual);
245 distance=DeltaR.mag();
247 ATH_MSG_WARNING(
"DeltaR is zero in ImpactPoint3dEstimator::Estimate3dIP, returning nullptr");
250 DeltaR=DeltaR.unit();
255 Amg::Vector3D DeltaRcorrected=DeltaR-(DeltaR.dot(MomentumDir))*MomentumDir;
257 if ((DeltaR-DeltaRcorrected).
mag()>1e-4)
260 ATH_MSG_DEBUG( std::setprecision(10) <<
" DeltaR-DeltaRcorrected: " << (DeltaR-DeltaRcorrected).
mag() );
268 ATH_MSG_VERBOSE(
"final minimal distance is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
269 y0-yc+Rt*dSinPhiActual,
270 z0-zc-Rt*cotTheta*phiActual));
276 ATH_MSG_VERBOSE(
"plane to which to extrapolate X " << DeltaRcorrected <<
" Y " << YDir <<
" Z " << MomentumDir );
280#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
281 std::cout <<
"the translation is, directly from Transform3d: " << thePlane.getTranslation() <<
endmsg;
283 return std::make_unique<PlaneSurface>(thePlane);
312 ATH_MSG_WARNING(
"Calling ImpactPoint3dEstimator::IP3dAtaPlane cannot return NeutralAtaPlane" );
313 std::unique_ptr<PlaneSurface> theSurfaceAtIP;
321 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance between track and vertex seed: " << err.p );
325 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance and returned 0 " );
328#ifdef ImpactPoint3dAtaPlaneFactory_DEBUG
335 *theSurfaceAtIP).release();
339 ATH_MSG_DEBUG(
"TrackParameters ptr returned from extrapolate could not be cast to Trk::AtaPlane* in IP3dAtaPlane(..)");
347 std::unique_ptr<PlaneSurface> theSurfaceAtIP;
356 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance between track and vertex seed: " << err.p );
360 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance and returned 0 " );
363#ifdef ImpactPoint3dAtaPlaneFactory_DEBUG
364 ATH_MSG_VERBOSE(
"Original neutral perigee was: " << *initNeutPerigee );
369 std::unique_ptr<const Trk::NeutralParameters> tmp =
m_extrapolator->extrapolate(*initNeutPerigee,*theSurfaceAtIP);
Scalar mag() const
mag method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::pair< std::vector< unsigned int >, bool > res
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h).
void getField(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given,...
virtual StatusCode finalize() override
virtual bool addIP3dAtaPlane(const EventContext &ctx, VxTrackAtVertex &, const Amg::Vector3D &vertex) const override
Actual estimate method, changing the state of Trk::VxTrackAtVertex.
virtual ~ImpactPoint3dEstimator()
virtual const Trk::NeutralAtaPlane * IP3dNeutralAtaPlane(const EventContext &ctx, const NeutralParameters *initNeutPerigee, const Amg::Vector3D &vertex) const override
virtual StatusCode initialize() override
virtual std::unique_ptr< PlaneSurface > Estimate3dIP(const EventContext &ctx, const Trk::TrackParameters *trackPerigee, const Amg::Vector3D *theVertex, double &distance) const override
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCacheCondObjInputKey
virtual const Trk::AtaPlane * IP3dAtaPlane(const EventContext &ctx, VxTrackAtVertex &vtxTrack, const Amg::Vector3D &vertex) const override
This method creates the ImpactPoint3dAtaPlane as the parameters of the track at the point of closest ...
std::unique_ptr< PlaneSurface > Estimate3dIPNoCurvature(const T *, const Amg::Vector3D *theVertex, double &distance) const
ImpactPoint3dEstimator(const std::string &t, const std::string &n, const IInterface *p)
Default constructor due to Athena interface.
ToolHandle< Trk::IExtrapolator > m_extrapolator
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
virtual const S & associatedSurface() const override final
Access to the Surface method.
Class describing the Line to which the Perigee refers to.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
void setImpactPoint3dAtaPlane(const AtaPlane *myIP3dAtaPlane)
Set method for ImpactPoint3dAtaPlane.
const NeutralParameters * initialNeutralPerigee(void) const
Access to the initial perigee parameters of trajectory.
const TrackParameters * initialPerigee(void) const
Access to the initial perigee parameters of trajectory.
void setImpactPoint3dNeutralAtaPlane(const NeutralAtaPlane *myIP3dNeutralAtaPlane)
Set method for ImpactPoint3dNeutralAtaPlane.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersBase< NeutralParametersDim, Neutral > NeutralParameters
ParametersT< NeutralParametersDim, Neutral, PlaneSurface > NeutralAtaPlane
ParametersBase< TrackParametersDim, Charged > TrackParameters
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane