33 return StatusCode::FAILURE;
39 return StatusCode::FAILURE;
46 return StatusCode::FAILURE;
49 return StatusCode::SUCCESS;
57 return estimate(&(track->perigeeParameters()),&(track->perigeeParameters()),vtx,doRemoval);
59 ATH_MSG_INFO(
"Empty TrackParticle or Vertex pointer passed. Returning zero " );
70 ATH_MSG_INFO(
"Empty TrackParticle or Vertex pointer passed. Returning zero " );
81 return estimate(track,track,vtx,doRemoval);
83 ATH_MSG_INFO(
"Empty TrackParticle or Vertex pointer passed. Returning zero " );
94 ATH_MSG_WARNING(
"Vertex is zero pointer. Will not estimate IP of track.");
102 if (newVertex ==
nullptr) {
103 ATH_MSG_WARNING(
"Unbiasing of vertex failed. Will not estimate IP of track.");
108 std::unique_ptr<ImpactParametersAndSigma> IPandSigma=
calculate(newtrack,*newVertex);
132 ->extrapolate(Gaudi::Hive::currentContext(), *track, perigeeSurface)
134 if (extrapolatedParameters && extrapolatedParameters->covariance()) {
137 const AmgVector(5) & par = extrapolatedParameters->parameters();
143 AmgSymMatrix(2) vrtXYCov = vtx.covariancePosition().block<2,2>(0,0);
145 const AmgSymMatrix(5) & perigeeCov = *(extrapolatedParameters->covariance());
152 auto newIPandSigma=std::make_unique<ImpactParametersAndSigma>();
153 newIPandSigma->IPd0=
d0;
154 double d0_PVcontrib=d0JacXY.transpose()*(vrtXYCov*d0JacXY);
157 newIPandSigma->sigmad0=sqrt(d0_PVcontrib+perigeeCov(
Trk::d0,
Trk::d0));
158 newIPandSigma->PVsigmad0=sqrt(d0_PVcontrib);
162 msg(MSG::WARNING) <<
" The contribution to d0_err: " << d0_PVcontrib <<
" from PV is negative: critical error in PV error matrix! Removing contribution from PV ... " <<
endmsg;
164 newIPandSigma->PVsigmad0=0;
173 double vrtZZCov = vtx.covariancePosition()(
Trk::z,
Trk::z);
178 newIPandSigma->IPz0SinTheta=
z0*sin(
theta);
179 newIPandSigma->sigmaz0SinTheta=
180 sqrt(IPz0JacZ0Theta.transpose()*(covPerigeeZ0Theta*IPz0JacZ0Theta)+sin(
theta)*vrtZZCov*sin(
theta));
181 newIPandSigma->PVsigmaz0SinTheta=sqrt(sin(
theta)*vrtZZCov*sin(
theta));
182 newIPandSigma->IPz0 =
z0;
183 newIPandSigma->sigmaz0 = std::sqrt( vrtZZCov + perigeeCov(
Trk::z0,
Trk::z0) );
184 newIPandSigma->PVsigmaz0 = std::sqrt( vrtZZCov );
188 ATH_MSG_WARNING(
" The contribution to z0_err: " << vrtZZCov <<
" from PV is negative: critical error in PV error matrix! Removing contribution from PV ... ");
189 newIPandSigma->IPz0SinTheta=
z0*sin(
theta);
190 double temp = (IPz0JacZ0Theta.transpose()*(covPerigeeZ0Theta*IPz0JacZ0Theta));
191 newIPandSigma->sigmaz0SinTheta=sqrt(
temp);
192 newIPandSigma->PVsigmaz0SinTheta=0;
194 newIPandSigma->IPz0 =
z0;
195 newIPandSigma->sigmaz0 = std::sqrt( perigeeCov(
Trk::z0,
Trk::z0) );
196 newIPandSigma->PVsigmaz0 = 0;
200 delete extrapolatedParameters;
201 return newIPandSigma;
203 ATH_MSG_DEBUG (
"Cannot extrapolate the trajectory state. Returning null. ");
214 const CLHEP::Hep3Vector & jetMomentum,
217 Amg::Vector3D eigenJetMomentum(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
228 std::unique_ptr<const Trk::TrackParameters> extrapolatedParameters =
230 Gaudi::Hive::currentContext(), track, perigeeSurface);
232 if (!extrapolatedParameters)
return 0.;
235 const Amg::Vector3D & trackPos=extrapolatedParameters->position();
236 const Amg::Vector3D & trackMom=extrapolatedParameters->momentum();
238 double sign=(jetMomentum.cross(trackMom)).dot(trackMom.cross(primaryPos-trackPos));
240 return sign>=0.?1.:-1;
246 const CLHEP::Hep3Vector & jetMomentum,
249 Amg::Vector3D eigenJetMomentum(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
260 std::unique_ptr<const Trk::TrackParameters> extrapolatedParameters =
262 Gaudi::Hive::currentContext(), track, perigeeSurface);
264 if (!extrapolatedParameters)
return 0.;
266 double trackD0 = extrapolatedParameters->parameters()[
Trk::d0];
267 double trackPhi = extrapolatedParameters->parameters()[
Trk::phi];
268 double vs = sinf( atan2(jetMomentum.y(),jetMomentum.x()) - trackPhi )*trackD0;
270 return (vs>=0. ? 1. : -1.);
277 const CLHEP::Hep3Vector & jetMomentum,
280 Amg::Vector3D eigenJetMomentum(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
292 std::unique_ptr<const Trk::TrackParameters> extrapolatedParameters =
294 Gaudi::Hive::currentContext(), track, perigeeSurface);
296 if (!extrapolatedParameters)
return 0.;
298 double trackTheta = extrapolatedParameters->parameters()[
Trk::theta];
299 double trackZ0 = extrapolatedParameters->parameters()[
Trk::z0];
300 double trackEta = -logf(tanf(trackTheta/2.));
301 double jetEta = jetMomentum.eta();
302 double zs = (jetEta - trackEta)*trackZ0;
303 return (zs>=0. ? 1. : -1.);
315 msg(MSG::INFO) <<
"Empty xAOD::TrackParticle pointer passed. Returning zero " <<
endmsg;
323 msg(MSG::INFO) <<
"Empty Trk::TrackParameter pointer passed. Returning zero " <<
endmsg;
327 msg(MSG::INFO) <<
"Empty xAOD::Vertex pointer passed. Returning zero " <<
endmsg;
333 ATH_MSG_DEBUG(
"This vertex has no associated tracks. Normal if beam spot is used. Vertex already unbiased");
342 bool tmpLinTrack =
false;
352 double trackWeight(0.0);
365 ATH_MSG_INFO(
"Failing to linearized track. Returning biased vertex.");
379 double trk_chi =
m_Updator->trackParametersChi2( reducedVertex, linTrack );
380 chi2 += -1 * (
m_Updator->vertexPositionChi2(*vtx, reducedVertex) + trackWeight * trk_chi);
384 ndf += -1 * trackWeight * (2.0);
393 if (tmpLinTrack)
delete linTrack;
413 return estimate( &(track->perigeeParameters()), vtx);
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
Class describing the Line to which the Perigee refers to.
~TrackToVertexIPEstimator()
virtual double get2DLifetimeSignOfTrack(const TrackParameters &track, const Amg::Vector3D &jetDirection, const xAOD::Vertex &primaryVertex) const override
ToolHandle< Trk::IVertexUpdator > m_Updator
virtual double getZLifetimeSignOfTrack(const TrackParameters &track, const Amg::Vector3D &jetDirection, const xAOD::Vertex &primaryVertex) const override
std::unique_ptr< ImpactParametersAndSigma > calculate(const TrackParameters *track, const xAOD::Vertex &vtx) const
A method calculating the do and its error.
virtual StatusCode initialize() override
Default Athena interface methods.
virtual xAOD::Vertex * getUnbiasedVertex(const xAOD::TrackParticle *track, const xAOD::Vertex *vtx) const override
ToolHandle< Trk::IExtrapolator > m_extrapolator
virtual std::unique_ptr< ImpactParametersAndSigma > estimate(const xAOD::TrackParticle *track, const xAOD::Vertex *vtx, bool doRemoval) const override
Estimate methods returning a d0 and its calculated sigma.
virtual double get3DLifetimeSignOfTrack(const TrackParameters &track, const Amg::Vector3D &jetDirection, const xAOD::Vertex &primaryVertex) const override
TrackToVertexIPEstimator(const std::string &t, const std::string &n, const IInterface *p)
Default Athena interface constructor and destructor.
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_linFactory
const Trk::Perigee & perigeeParameters() const
Returns the Trk::MeasuredPerigee track parameters.
size_t nTrackParticles() const
Get the number of tracks associated with this vertex.
void clearTracks()
Remove all tracks from the vertex.
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
void addTrackAtVertex(const ElementLink< TrackParticleContainer > &tr, float weight=1.0)
Add a new track to the vertex.
const TrackParticleLinks_t & trackParticleLinks() const
Get all the particles associated with the vertex.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
float numberDoF() const
Returns the number of degrees of freedom of the vertex fit as float.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
bool vxTrackAtVertexAvailable() const
Check if VxTrackAtVertices are attached to the object.
float chiSquared() const
Returns the of the vertex fit as float.
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
const Amg::Vector3D & position() const
Returns the 3-pos.
float trackWeight(size_t i) const
Get the weight of a given track in the vertex reconstruction.
double chi2(TH1 *h0, TH1 *h1)
static std::string release
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ z
global position (cartesian)
ParametersBase< TrackParametersDim, Charged > TrackParameters
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.