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
130 double magnFieldVect[3];
132 if(magnFieldVect[2] == 0 ){
133 ATH_MSG_DEBUG(
"Magnetic field in the Z direction is 0 -- propagate like a straight line");
138 if (thePerigee==
nullptr)
141 " ImpactPoint3dEstimator didn't get a Perigee* as ParametersBase*: "
142 "cast not possible. Need to EXTRAPOLATE...");
144 std::unique_ptr<const Trk::TrackParameters> tmp =
146 ctx, *trackPerigee, perigeeSurface);
148 thePerigee =
static_cast<const Trk::Perigee*
>(tmp.release());
150 if (thePerigee ==
nullptr){
155 ATH_MSG_VERBOSE(
" Now running ImpactPoint3dEstimator::Estimate3dIP" );
157 double dCosPhi0=-std::sin(
phi0);
158 double dSinPhi0=std::cos(
phi0);
160 double cotTheta=1./std::tan(thePerigee->parameters()[
Trk::theta]);
161 double d0=thePerigee->parameters()[
Trk::d0];
164 double Bz=magnFieldVect[2]*299.792;
171 if (thePerigee!=trackPerigee) {
176 double xc=theVertex->x();
177 double yc=theVertex->y();
178 double zc=theVertex->z();
180 double phiActual=
phi0;
181 double dCosPhiActual=-std::sin(phiActual);
182 double dSinPhiActual=std::cos(phiActual);
184 double secderivative=0.;
185 double derivative=0.;
192#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
193 std::cout << std::setprecision(25) <<
"actual distance before cycle is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
194 y0-yc+Rt*dSinPhiActual,
195 z0-zc-Rt*cotTheta*phiActual) << std::endl;
200#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
201 ATH_MSG_VERBOSE(
"Cycle number: " << ncycle <<
" old phi: " << phiActual );
205 derivative=(x0-xc)*(-Rt*dSinPhiActual)+(y0-yc)*Rt*dCosPhiActual+(
z0-zc-Rt*phiActual*cotTheta)*(-Rt*cotTheta);
206 secderivative=Rt*(-(x0-xc)*dCosPhiActual-(y0-yc)*dSinPhiActual+Rt*cotTheta*cotTheta);
207#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
208 ATH_MSG_VERBOSE(
"derivative is: " << derivative <<
" sec derivative is: " << secderivative );
211 deltaphi=-derivative/secderivative;
213#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
214 std::cout << std::setprecision(25) <<
"deltaphi: " << deltaphi << std::endl;
218 dCosPhiActual=-std::sin(phiActual);
219 dSinPhiActual=std::cos(phiActual);
221#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
222 ATH_MSG_VERBOSE(
"derivative is: " << derivative <<
" sec derivative is: " << secderivative );
223 std::cout << std::setprecision(25) << std::hypot(x0-xc+Rt*dCosPhiActual, y0-yc+Rt*dSinPhiActual,
224 z0-zc-Rt*cotTheta*phiActual) << std::endl;
225 ATH_MSG_VERBOSE(
"actual distance is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
226 y0-yc+Rt*dSinPhiActual,
227 z0-zc-Rt*cotTheta*phiActual));
236#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
247 Amg::Vector3D DeltaR(x0-xc+Rt*dCosPhiActual,y0-yc+Rt*dSinPhiActual,
z0-zc-Rt*cotTheta*phiActual);
248 distance=DeltaR.mag();
250 ATH_MSG_WARNING(
"DeltaR is zero in ImpactPoint3dEstimator::Estimate3dIP, returning nullptr");
253 DeltaR=DeltaR.unit();
258 Amg::Vector3D DeltaRcorrected=DeltaR-(DeltaR.dot(MomentumDir))*MomentumDir;
260 if ((DeltaR-DeltaRcorrected).
mag()>1e-4)
263 ATH_MSG_DEBUG( std::setprecision(10) <<
" DeltaR-DeltaRcorrected: " << (DeltaR-DeltaRcorrected).
mag() );
271 ATH_MSG_VERBOSE(
"final minimal distance is: " << std::hypot(x0-xc+Rt*dCosPhiActual,
272 y0-yc+Rt*dSinPhiActual,
273 z0-zc-Rt*cotTheta*phiActual));
279 ATH_MSG_VERBOSE(
"plane to which to extrapolate X " << DeltaRcorrected <<
" Y " << YDir <<
" Z " << MomentumDir );
283#ifdef IMPACTPOINT3DESTIMATOR_DEBUG
284 std::cout <<
"the translation is, directly from Transform3d: " << thePlane.getTranslation() <<
endmsg;
286 return std::make_unique<PlaneSurface>(thePlane);
315 ATH_MSG_WARNING(
"Calling ImpactPoint3dEstimator::IP3dAtaPlane cannot return NeutralAtaPlane" );
316 std::unique_ptr<PlaneSurface> theSurfaceAtIP;
324 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance between track and vertex seed: " << err.p );
328 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance and returned 0 " );
331#ifdef ImpactPoint3dAtaPlaneFactory_DEBUG
338 *theSurfaceAtIP).release();
342 ATH_MSG_DEBUG(
"TrackParameters ptr returned from extrapolate could not be cast to Trk::AtaPlane* in IP3dAtaPlane(..)");
350 std::unique_ptr<PlaneSurface> theSurfaceAtIP;
359 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance between track and vertex seed: " << err.p );
363 ATH_MSG_WARNING(
" ImpactPoint3dEstimator failed to find minimum distance and returned 0 " );
366#ifdef ImpactPoint3dAtaPlaneFactory_DEBUG
367 ATH_MSG_VERBOSE(
"Original neutral perigee was: " << *initNeutPerigee );
372 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