ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::FastVertexFitter Class Reference

This class implements a fast vertex fitting algorithm as proposed by P. More...

#include <FastVertexFitter.h>

Inheritance diagram for Trk::FastVertexFitter:
Collaboration diagram for Trk::FastVertexFitter:

Public Member Functions

virtual StatusCode initialize () override
 FastVertexFitter (const std::string &t, const std::string &n, const IInterface *p)
virtual ~FastVertexFitter ()
 standard destructor
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const Amg::Vector3D &startingPoint) const override
 Interface for ParametersBase with starting point.
virtual xAOD::Vertexfit (const std::vector< const TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &, const Amg::Vector3D &startingPoint) const override
 Interface for TrackParameters and NeutralParameters with starting point.
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint) const override
 Interface for ParametersBase with vertex constraint.
virtual xAOD::Vertexfit (const std::vector< const TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &, const xAOD::Vertex &constraint) const override
 Interface for TrackParameters and NeutralParameters with RecVertex starting point.
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList) const override
 Fit interface with no starting point or constraint.
virtual xAOD::Vertexfit (const std::vector< const TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &) const override
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const Amg::Vector3D &startingPoint) const override
 *Interface for xAOD::TrackParticle with starting point
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &, const Amg::Vector3D &startingPoint) const override
 *Interface for xAOD::TrackParticle and NeutralParticle with starting point
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const xAOD::Vertex &constraint) const override
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &, const xAOD::Vertex &constraint) const override
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const Amg::Vector3D &startingPoint) const
 Interface for xAOD::TrackParticle with starting point Event Context aware interface.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeu, const Amg::Vector3D &startingPoint) const
 Interface for xAOD::TrackParticle and xAOD::NeutralParticle with starting point.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeu, const xAOD::Vertex &constraint) const
 Interface for xAOD::TrackParticle and xAOD::NeutralParticle with vertex constraint the position of the constraint is ALWAYS the starting point Event Context aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const xAOD::Vertex &constraint) const
 Interface for xAOD::TrackParticle with vertex constraint the position of the constraint is ALWAYS the starting point Event Context aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const Amg::Vector3D &startingPoint) const
 Interface for TrackParameters and NeutralParameters with starting point Event Context aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const Amg::Vector3D &startingPoint) const
 Interface for TrackParameters with starting point Event Context aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const xAOD::Vertex &constraint) const
 Interface for TrackParameters and NeutralParameters with vertex constraint the position of the constraint is ALWAYS the starting point EventContext aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint) const
 Interface for TrackParameters with vertex constraint the position of the constraint is ALWAYS the starting point EventContext aware method.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList) const
 Fit method using the VertexSeedFinder to estimate initial position of the vertex and taking it as a first linearization point (in iterative fitters).
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList) const
 Fit method using the VertexSeedFinder to estimate initial position of the vertex and taking it as a first linearization point (in iterative fitters).

Private Attributes

unsigned int m_maxIterations
double m_maxDchi2PerNdf
ToolHandle< Trk::IExtrapolatorm_extrapolator {this, "Extrapolator", "Trk::Extrapolator"}
ToolHandle< Trk::IVertexLinearizedTrackFactorym_linFactory {this, "LinearizedTrackFactory", "Trk::FullLinearizedTrackFactory"}

Detailed Description

This class implements a fast vertex fitting algorithm as proposed by P.

Billoir. this algorithm tries to estimate the vertex position without refitting the track parameters. It therefore only needs to vary two of five perigee parameters (namely d0, z0) to estimate the vertex position.

Changes:

David Shope david.nosp@m..ric.nosp@m.hard..nosp@m.shop.nosp@m.e@cer.nosp@m.n.ch (2016-04-19)

EDM Migration to xAOD - from Trk::VxCandidate to xAOD::Vertex, from Trk::RecVertex to xAOD::Vertex, from Trk::Vertex to Amg::Vector3D

Definition at line 38 of file FastVertexFitter.h.

Constructor & Destructor Documentation

◆ FastVertexFitter()

Trk::FastVertexFitter::FastVertexFitter ( const std::string & t,
const std::string & n,
const IInterface * p )

Definition at line 82 of file FastVertexFitter.cxx.

82 : base_class ( t,n,p ),
83 m_maxIterations ( 3 ),
84 m_maxDchi2PerNdf ( 0.000001 )
85
86
87 {
88 declareProperty ( "MaxIterations", m_maxIterations );
89 declareProperty ( "MaxChi2PerNdf", m_maxDchi2PerNdf );
90 declareInterface<IVertexFitter> ( this );
91 }

◆ ~FastVertexFitter()

Trk::FastVertexFitter::~FastVertexFitter ( )
virtualdefault

standard destructor

Member Function Documentation

◆ fit() [1/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList ) const
inline

Fit method using the VertexSeedFinder to estimate initial position of the vertex and taking it as a first linearization point (in iterative fitters).

EventContext aware method.

Definition at line 215 of file IVertexFitter.h.

218 {
219 (void)(ctx);
220 return std::unique_ptr<xAOD::Vertex>(fit(perigeeList));
221 }
virtual xAOD::Vertex * fit(const std::vector< const Trk::TrackParameters * > &perigeeList, const Amg::Vector3D &startingPoint) const override
Interface for ParametersBase with starting point.

◆ fit() [2/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const Amg::Vector3D & startingPoint ) const
inline

Interface for TrackParameters with starting point Event Context aware method.

Definition at line 154 of file IVertexFitter.h.

158 {
159 (void)(ctx);
160 return std::unique_ptr<xAOD::Vertex>(fit(perigeeList, startingPoint));
161 }

◆ fit() [3/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList ) const
inline

Fit method using the VertexSeedFinder to estimate initial position of the vertex and taking it as a first linearization point (in iterative fitters).

EventContext aware method.

Definition at line 200 of file IVertexFitter.h.

204 {
205 (void)(ctx);
206 return std::unique_ptr<xAOD::Vertex>(fit(perigeeList, neutralPerigeeList));
207 }

◆ fit() [4/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList,
const Amg::Vector3D & startingPoint ) const
inline

Interface for TrackParameters and NeutralParameters with starting point Event Context aware method.

Definition at line 138 of file IVertexFitter.h.

143 {
144 (void)(ctx);
145 return std::unique_ptr<xAOD::Vertex>(
146 fit(perigeeList, neutralPerigeeList, startingPoint));
147 }

◆ fit() [5/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList,
const xAOD::Vertex & constraint ) const
inline

Interface for TrackParameters and NeutralParameters with vertex constraint the position of the constraint is ALWAYS the starting point EventContext aware method.

Definition at line 169 of file IVertexFitter.h.

174 {
175 (void)(ctx);
176 return std::unique_ptr<xAOD::Vertex>(
177 fit(perigeeList, neutralPerigeeList, constraint));
178 }

◆ fit() [6/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex & constraint ) const
inline

Interface for TrackParameters with vertex constraint the position of the constraint is ALWAYS the starting point EventContext aware method.

Definition at line 185 of file IVertexFitter.h.

189 {
190 (void)(ctx);
191 return std::unique_ptr<xAOD::Vertex>(fit(perigeeList, constraint));
192 }

◆ fit() [7/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const Amg::Vector3D & startingPoint ) const
inline

Interface for xAOD::TrackParticle with starting point Event Context aware interface.

Definition at line 77 of file IVertexFitter.h.

81 {
82 (void)(ctx);
83 return std::unique_ptr<xAOD::Vertex>(fit(vectorTrk, startingPoint));
84 }

◆ fit() [8/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & vectorNeu,
const Amg::Vector3D & startingPoint ) const
inline

Interface for xAOD::TrackParticle and xAOD::NeutralParticle with starting point.

Event Context aware method

Definition at line 91 of file IVertexFitter.h.

96 {
97 (void)(ctx);
98 return std::unique_ptr<xAOD::Vertex>(
99 fit(vectorTrk, vectorNeu, startingPoint));
100 }

◆ fit() [9/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & vectorNeu,
const xAOD::Vertex & constraint ) const
inline

Interface for xAOD::TrackParticle and xAOD::NeutralParticle with vertex constraint the position of the constraint is ALWAYS the starting point Event Context aware method.

Definition at line 108 of file IVertexFitter.h.

113 {
114 (void)(ctx);
115 return std::unique_ptr<xAOD::Vertex>(fit(vectorTrk, vectorNeu, constraint));
116 }

◆ fit() [10/20]

virtual std::unique_ptr< xAOD::Vertex > Trk::IVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const xAOD::Vertex & constraint ) const
inline

Interface for xAOD::TrackParticle with vertex constraint the position of the constraint is ALWAYS the starting point Event Context aware method.

Definition at line 124 of file IVertexFitter.h.

128 {
129 (void)(ctx);
130 return std::unique_ptr<xAOD::Vertex>(fit(vectorTrk, constraint));
131 }

◆ fit() [11/20]

virtual xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > &  ) const
inlineoverridevirtual

Definition at line 100 of file FastVertexFitter.h.

104 {
105 msg(MSG::WARNING) << "FastVertexFitter::fit(fit(const std::vector<const "
106 "TrackParameters*>&,const std::vector<const "
107 "Trk::NeutralParameters*>&) ignoring neutrals"
108 << endmsg;
109 return fit(perigeeList);
110 };
#define endmsg
MsgStream & msg
Definition testRead.cxx:32

◆ fit() [12/20]

virtual xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & ,
const Amg::Vector3D & startingPoint ) const
inlineoverridevirtual

Interface for TrackParameters and NeutralParameters with starting point.

Definition at line 59 of file FastVertexFitter.h.

63 {
64 msg(MSG::WARNING)
65 << "FastVertexFitter::fit(fit(const std::vector<const "
66 "TrackParameters*>&,const std::vector<const "
67 "Trk::NeutralParameters*>&,const Amg::Vector3D&) ignoring neutrals"
68 << endmsg;
69 return fit(perigeeList, startingPoint);
70 };

◆ fit() [13/20]

virtual xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & ,
const xAOD::Vertex & constraint ) const
inlineoverridevirtual

Interface for TrackParameters and NeutralParameters with RecVertex starting point.

Definition at line 80 of file FastVertexFitter.h.

84 {
85 msg(MSG::WARNING)
86 << "FastVertexFitter::fit(fit(const std::vector<const "
87 "TrackParameters*>&,const std::vector<const "
88 "Trk::NeutralParameters*>&,const xAOD::Vertex&) ignoring neutrals"
89 << endmsg;
90 return fit(perigeeList, constraint);
91 };

◆ fit() [14/20]

xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & perigeeList) const
overridevirtual

Fit interface with no starting point or constraint.

(0,0,0) will be assumed.

Definition at line 335 of file FastVertexFitter.cxx.

336 {
337 Amg::Vector3D tmpVtx(0.,0.,0.);
338 return fit ( perigeeList, tmpVtx );
339 }
Eigen::Matrix< double, 3, 1 > Vector3D

◆ fit() [15/20]

xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & originalPerigees,
const Amg::Vector3D & firstStartingPoint ) const
overridevirtual

Interface for ParametersBase with starting point.

Interface for Track with vertex constraint.

the position of the constraint is ALWAYS the starting point Interface for MeasuredPerigee with starting point

Definition at line 100 of file FastVertexFitter.cxx.

102 {
103 xAOD::Vertex constraint;
104 constraint.makePrivateStore();
105 constraint.setPosition( firstStartingPoint );
106 constraint.setCovariancePosition( AmgSymMatrix(3)::Zero(3,3) );
107 constraint.setFitQuality( 0.,0.);
108 return fit ( originalPerigees, constraint );
109 }
#define AmgSymMatrix(dim)
void makePrivateStore()
Create a new (empty) private store for this object.
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ fit() [16/20]

xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > & originalPerigees,
const xAOD::Vertex & firstStartingPoint ) const
overridevirtual

Interface for ParametersBase with vertex constraint.

Interface for MeasuredPerigee with vertex constraint.

the position of the constraint is ALWAYS the starting point

Definition at line 113 of file FastVertexFitter.cxx.

115 {
116 if ( originalPerigees.empty() )
117 {
118 ATH_MSG_VERBOSE("No tracks to fit in this event.");
119 return nullptr;
120 }
121
122 /* Initialisation of variables */
123 double chi2 = 2000000000000.;
124 unsigned int nRP = originalPerigees.size(); // Number of tracks to fit
125 int ndf = nRP * ( 5-3 ) - 3; // Number of degrees of freedom
126 if ( ndf == -1 ) ndf = 1;
127
128 /* Determine if we are doing a constraint fit.*/
129 bool constraint = false;
130 if ( firstStartingPoint.covariancePosition().trace() != 0. )
131 {
132 constraint = true;
133 ndf += 3;
134 ATH_MSG_DEBUG("Fitting with constraint.");
135 ATH_MSG_VERBOSE(firstStartingPoint.covariancePosition().inverse().eval());
136 }
137
138 double chi2New=0.;double chi2Old=0.;
139
140 Amg::Vector3D linPoint ( firstStartingPoint.position() ); // linearization point for track parameters (updated for every iteration)
141
142 auto fittedVertex = std::make_unique<xAOD::Vertex>();
143 fittedVertex->makePrivateStore(); // xAOD::VertexContainer will take ownership of AuxStore when ActualVertex is added to it
144
145 std::vector<VxTrackAtVertex> tracksAtVertex;
146 std::vector<BilloirTrack> billoirTracks;
147
148 /* Iterate fits until the fit criteria are met, or the number of max
149 iterations is reached. */
150 for ( unsigned int niter=0; niter < m_maxIterations; ++niter )
151 {
152 // msg(MSG::VERBOSE) << "Start of iteration " << niter << ", starting point ("
153 // << linPoint [0] << ", " << linPoint [1] << ", " << linPoint [2]
154 // << ") and " << originalPerigees.size() << " tracks." << endmsg;
155
156 billoirTracks.clear();
157 chi2Old = chi2New;
158 chi2New = 0.;
159
160 AmgMatrix(2,3) D;
161
162 /* Linearize the track parameters wrt. starting point of the fit */
163 Amg::Vector3D globalPosition = linPoint;
164 Trk::PerigeeSurface perigeeSurface ( globalPosition );
165
166 BilloirVertex billoirVertex;
167 // unsigned int count(0);
168 for (const auto *originalPerigee : originalPerigees)
169 {
170 LinearizedTrack* linTrack = m_linFactory->linearizedTrack ( originalPerigee, linPoint );
171 if ( linTrack==nullptr )
172 {
173 ATH_MSG_DEBUG("Could not linearize track! Skipping this track!");
174 }
175 else
176 {
177 // local position
178 Amg::Vector3D locXpVec = linTrack->expectedPositionAtPCA();
179 locXpVec[0] = locXpVec[0] - linPoint[0];
180 locXpVec[1] = locXpVec[1] - linPoint[1];
181 locXpVec[2] = locXpVec[2] - linPoint[2];
182
183 // msg(MSG::VERBOSE) << "Track: " << count << endmsg;
184 // count++;
185 // const Trk::MeasuredPerigee* tmpPerigee = dynamic_cast<const Trk::MeasuredPerigee*>(*iter);
186 //AmgVector(5) expParameters = linTrack->expectedParametersAtPCA();
187
188 // msg(MSG::VERBOSE) << "locXp: " << locXpVec[0] << "\t" << locXpVec[1] << "\t" << locXpVec[2] << endmsg;
189
190 // first get the cov 2x2 sub matrix and then invert (don't get the 2x2 sub matrix of the 5x5 already inverted cov matrix)
191 AmgMatrix(2,2) billoirCovMat = linTrack->expectedCovarianceAtPCA().block<2,2>(0,0);
192 // msg(MSG::VERBOSE) << "CovMatrix: " << billoirCovMat[0][0] << "\t" << billoirCovMat[0][1] << endmsg;
193 // msg(MSG::VERBOSE) << " " << billoirCovMat[1][0] << "\t" << billoirCovMat[1][1] << endmsg;
194 AmgMatrix(2,2) billoirWeightMat = billoirCovMat.inverse().eval();
195 // msg(MSG::VERBOSE) << "WeightMatrix: " << billoirWeightMat[0][0] << "\t" << billoirWeightMat[0][1] << endmsg;
196 // msg(MSG::VERBOSE) << " " << billoirWeightMat[1][0] << "\t" << billoirWeightMat[1][1] << endmsg;
197 // D matrix for d0 and z0
198 D = linTrack->positionJacobian().block<2,3>(0,0);
199 // msg(MSG::VERBOSE) << "DMatrix: " << D[0][0] << "\t" << D[0][1] << endmsg;
200 // msg(MSG::VERBOSE) << " " << D[1][0] << "\t" << D[1][1] << endmsg;
201
202 // Calculate DtWD and DtWD*x and sum them
203 BilloirTrack locBilloirTrack;
204 locBilloirTrack.xpVec = locXpVec;
205 locBilloirTrack.DtWD = (D.transpose())*billoirWeightMat*D;
206 locBilloirTrack.chi2 = -1.0;
207 billoirVertex.DtWD_Sum += locBilloirTrack.DtWD;
208 locBilloirTrack.DtWDx = ((D.transpose())*billoirWeightMat*D)*locXpVec;
209 billoirVertex.DtWDx_Sum += locBilloirTrack.DtWDx;
210 locBilloirTrack.originalPerigee = originalPerigee;
211 billoirTracks.push_back ( locBilloirTrack );
212 }
213 delete linTrack; linTrack=nullptr;
214 }
215 if ( billoirTracks.empty() )
216 {
217 ATH_MSG_DEBUG("No linearized tracks left after linearization! Should not happen!");
218 return nullptr;
219 }
220 if ( constraint )
221 {
222 // add V_del += wgtconst * (linPoint.position() - Vconst) and V_wgt +=wgtconst
223 Amg::Vector3D constraintPosInBilloirFrame;
224 constraintPosInBilloirFrame.setZero();
225 // this will be 0 for first iteration but != 0 from second on
226 constraintPosInBilloirFrame[0] = firstStartingPoint.position() [0]-linPoint [0];
227 constraintPosInBilloirFrame[1] = firstStartingPoint.position() [1]-linPoint [1];
228 constraintPosInBilloirFrame[2] = firstStartingPoint.position() [2]-linPoint [2];
229 billoirVertex.DtWDx_Sum += firstStartingPoint.covariancePosition().inverse().eval() *constraintPosInBilloirFrame;
230 billoirVertex.DtWD_Sum += firstStartingPoint.covariancePosition().inverse().eval();
231 }
232
233 AmgMatrix(3,3) cov_delta_V_mat = billoirVertex.DtWD_Sum.inverse( ) ;
234
235 Amg::Vector3D delta_V = cov_delta_V_mat * billoirVertex.DtWDx_Sum;
236
237 std::vector<BilloirTrack>::iterator BTIter;
238 for ( BTIter = billoirTracks.begin(); BTIter != billoirTracks.end() ; ++BTIter )
239 {
240 // calculate chi2PerTrack = (xpVec - vtxPosInBilloirFrame).T * DtWD(track) * (xpVec - vtxPosInBilloirFrame); )
242 diff.setZero();
243 diff[0] = ( *BTIter ).xpVec[0] - delta_V[0];
244 diff[1] = ( *BTIter ).xpVec[1] - delta_V[1];
245 diff[2] = ( *BTIter ).xpVec[2] - delta_V[2];
246 ( *BTIter ).chi2 = diff.dot(( *BTIter ).DtWD* diff );
247 if ( ( *BTIter ).chi2 < 0 )
248 {
249 std::cout << "VxFastFit::calculate: error in chi2_per_track: "<<( *BTIter ).chi2<<"\n";
250 return nullptr;
251 }
252 chi2New += ( *BTIter ).chi2;
253 }
254
255 if ( constraint )
256 {
257 Amg::Vector3D deltaTrk;
258 deltaTrk.setZero();
259 // last term will also be 0 again but only in the first iteration
260 // = calc. vtx in billoir frame - ( constraint pos. in billoir frame )
261 deltaTrk[0] = delta_V[0] - ( firstStartingPoint.position() [0] - linPoint [0] );
262 deltaTrk[1] = delta_V[1] - ( firstStartingPoint.position() [1] - linPoint [1] );
263 deltaTrk[2] = delta_V[2] - ( firstStartingPoint.position() [2] - linPoint [2] );
264 chi2New += Amg::chi2(firstStartingPoint.covariancePosition().inverse().eval(), deltaTrk);
265 }
266
267 /* assign new linearization point (= new vertex position in global frame) */
268 Amg::Vector3D tmpPos ( linPoint );
269 tmpPos[0] += delta_V[0]; tmpPos[1] += delta_V[1]; tmpPos[2] += delta_V[2];
270 linPoint = tmpPos;
271
272 // msg(MSG::VERBOSE) << "Vertex of Iteration " << niter << " with chi2: " << chi2New << "\t old chi2: " << chi2 << endmsg;
273 // msg(MSG::VERBOSE) << "deltaV: (" << delta_V[0] << ", " << delta_V[1] << ", " << delta_V[2] << ")" << endmsg;
274 // msg(MSG::VERBOSE) << linPoint << endmsg;
275
276 if ( chi2New < chi2 )
277 {
278 /* Store the vertex */
279 chi2 = chi2New;
280 //const AmgMatrix(3,3) * newCovarianceMatrix = &cov_delta_V_mat ;
281 //const AmgMatrix(3,3) newErrorMatrix = newCovarianceMatrix->inverse().eval();
282 //fittedVertex = RecVertex ( linPoint.position(), newErrorMatrix, ndf, chi2 );
283
284 // The cov_delta_V_mat does not need to be inverted. -katy 2/3/16
285 fittedVertex->setPosition( linPoint );
286 fittedVertex->setCovariancePosition( cov_delta_V_mat );
287 fittedVertex->setFitQuality( chi2, ndf );
288
289 /* new go through vector and delete entries */
290 /* // TODO: not needed anymore, tracksAtVertex doesn't store pointers - just the objects themselves <David Shope> (EDM Migration) 03/21/16
291 for ( std::vector<Trk::VxTrackAtVertex*>::const_iterator itr = tracksAtVertex.begin();
292 itr != tracksAtVertex.end(); ++itr )
293 {
294 delete ( *itr );
295 }
296 */
297
298 tracksAtVertex.clear();
299
300 Amg::Vector3D pointToExtrapolateTo ( linPoint [0], linPoint [1], linPoint [2] );
301 Trk::PerigeeSurface perigeeSurface ( pointToExtrapolateTo );
302 for ( BTIter = billoirTracks.begin(); BTIter != billoirTracks.end() ; ++BTIter )
303 {
304 // you need to extrapolate the original perigee ((*BTIter).originalPerigee) really to the
305 // found vertex. The first propagation above is only to the starting point. But here we
306 // want to store it wrt. to the last fitted vertex
307 auto extrapolatedPerigee = std::unique_ptr<const Trk::TrackParameters> ( m_extrapolator->extrapolate (
308 Gaudi::Hive::currentContext(),
309 * ( *BTIter ).originalPerigee,
310 perigeeSurface ) );
311 if ( extrapolatedPerigee==nullptr )
312 {
313 extrapolatedPerigee = std::unique_ptr<const Trk::TrackParameters>(((*BTIter).originalPerigee)->clone());
314 ATH_MSG_DEBUG("Could not extrapolate these track parameters to final vertex position! Storing original position as final one ...");
315 }
316 //VxTrackAtVertex will own the clone of the extrapolatedPerigee
317 Trk::VxTrackAtVertex* tmpVxTrkAtVtx = new Trk::VxTrackAtVertex ( ( *BTIter ).chi2, extrapolatedPerigee->clone(),
318 ( *BTIter ).originalPerigee ) ;
319 tracksAtVertex.push_back ( *tmpVxTrkAtVtx );
320 // TODO: here is where the vxTracksAtVertex pointers are deleted
321 delete tmpVxTrkAtVtx; // TODO: is this ok?
322 }
323 }
324
325 if ( fabs ( chi2Old-chi2New ) < m_maxDchi2PerNdf * ndf )
326 {
327 break;
328 }
329 } // end of iteration
330 fittedVertex->vxTrackAtVertex() = tracksAtVertex;
331 //ATH_MSG_VERBOSE("Final Vertex Fitted: " << fittedVxCandidate->recVertex()); // TODO: can no longer print vertex after converting to xAOD
332 return fittedVertex.release();
333 }
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define AmgMatrix(rows, cols)
if(febId1==febId2)
void diff(const Jet &rJet1, const Jet &rJet2, std::map< std::string, double > varDiff)
Difference between jets - Non-Class function required by trigger.
Definition Jet.cxx:631
Eigen::Matrix< double, 3, 1 > Vector3D
static const Attributes_t empty
ToolHandle< Trk::IExtrapolator > m_extrapolator
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_linFactory
const Amg::Vector3D & position() const
Returns the 3-pos.
double chi2(TH1 *h0, TH1 *h1)
double chi2(const T &precision, const U &residual, const int sign=1)

◆ fit() [17/20]

xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const Amg::Vector3D & startingPoint ) const
overridevirtual

*Interface for xAOD::TrackParticle with starting point

Definition at line 343 of file FastVertexFitter.cxx.

344 {
345 xAOD::Vertex constraint;
346 constraint.makePrivateStore();
347 constraint.setPosition( startingPoint );
348 constraint.setCovariancePosition( AmgSymMatrix(3)::Zero(3,3) );
349 constraint.setFitQuality( 0.,0.);
350 return fit(vectorTrk, constraint);
351 }//end of the xAOD starting point fit method

◆ fit() [18/20]

virtual xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & ,
const Amg::Vector3D & startingPoint ) const
inlineoverridevirtual

*Interface for xAOD::TrackParticle and NeutralParticle with starting point

Definition at line 119 of file FastVertexFitter.h.

123 {
124 msg(MSG::WARNING)
125 << "FastVertexFitter::fit(fit(const std::vector<const "
126 "TrackParticle*>&,const std::vector<const "
127 "Trk::NeutralParticle*>&,const Amg::Vector3D&) ignoring neutrals"
128 << endmsg;
129 return fit(vectorTrk, startingPoint);
130 };

◆ fit() [19/20]

virtual xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & ,
const xAOD::Vertex & constraint ) const
inlineoverridevirtual

Definition at line 141 of file FastVertexFitter.h.

145 {
146 msg(MSG::WARNING)
147 << "FastVertexFitter::fit(fit(const std::vector<const "
148 "TrackParticle*>&,const std::vector<const "
149 "Trk::NeutralParticle*>&,const xAOD::Vertex&) ignoring neutrals"
150 << endmsg;
151 return fit(vectorTrk, constraint);
152 };

◆ fit() [20/20]

xAOD::Vertex * Trk::FastVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const xAOD::Vertex & constraint ) const
overridevirtual

Definition at line 354 of file FastVertexFitter.cxx.

355 {
356 if(vectorTrk.empty())
357 {
358 msg(MSG::INFO)<<"Empty vector of tracks passed"<<endmsg;
359 return nullptr;
360 }
361
362 //making a list of perigee out of the vector of tracks
363 std::vector<const Trk::TrackParameters*> measuredPerigees;
364
365 for(const auto *i : vectorTrk)
366 {
367 const Trk::TrackParameters * tmpMeasPer = &(i->perigeeParameters());
368
369 if(tmpMeasPer!=nullptr) measuredPerigees.push_back(tmpMeasPer);
370 else msg(MSG::INFO)<<"Failed to dynamic_cast this track parameters to perigee"<<endmsg; //TODO: Failed to implicit cast the perigee parameters to track parameters?
371 }
372
373
374 xAOD::Vertex* fittedVertex = fit( measuredPerigees, constraint );
375 // fit() may return nullptr, need to protect
376 if (fittedVertex == nullptr){
377 ATH_MSG_WARNING("Failed fit, returning null vertex");
378 return nullptr;
379 }
380 //assigning the input tracks to the fitted vertex through VxTrackAtVertices
381 {
382 if( fittedVertex->vxTrackAtVertexAvailable() ) // TODO: I don't think vxTrackAtVertexAvailable() does the same thing as a null pointer check!
383 // Regretful Hindsight 8 years later: No, it doesn't!
384 {
385 if(!fittedVertex->vxTrackAtVertex().empty())
386 {
387 for(unsigned int i = 0; i <vectorTrk.size(); ++i)
388 {
389
390 LinkToXAODTrackParticle * linkTT = new LinkToXAODTrackParticle;
391 linkTT->setElement(vectorTrk[i]);
392
393 // vxtrackatvertex takes ownership!
394 ( fittedVertex->vxTrackAtVertex() )[i].setOrigTrack(linkTT);
395 }//end of loop for setting orig tracks in.
396 }//end of protection against unsuccessfull updates (no tracks were added)
397 }//end of vector of tracks check
398 }//end of pointer check
399
400 //now set links to xAOD::TrackParticles directly in the xAOD::Vertex
401 unsigned int VTAVsize = fittedVertex->vxTrackAtVertex().size();
402 for (unsigned int i = 0 ; i < VTAVsize ; ++i)
403 {
404 Trk::VxTrackAtVertex* VTAV = &( fittedVertex->vxTrackAtVertex().at(i) );
405 //TODO: Will this pointer really hold 0 if no VxTrackAtVertex is found?
406 if (not VTAV){
407 ATH_MSG_WARNING (" Trying to set link to xAOD::TrackParticle. The VxTrackAtVertex is not found");
408 continue;
409 }
410
411 Trk::ITrackLink* trklink = VTAV->trackOrParticleLink();
412
413 // See if the trklink is to an xAOD::TrackParticle
414 Trk::LinkToXAODTrackParticle* linkToXAODTP = dynamic_cast<Trk::LinkToXAODTrackParticle*>(trklink);
415 if (linkToXAODTP)
416 {
417
418 //Now set the new link to the xAOD vertex
419 fittedVertex->addTrackAtVertex(*linkToXAODTP, VTAV->weight());
420
421 } else {
422 ATH_MSG_WARNING ("Skipping track. Trying to set link to something else than xAOD::TrackParticle. Neutrals not supported.");
423 }
424 } //end of loop
425
426 return fittedVertex;
427
428 }//end of the xAOD constrained fit method
#define ATH_MSG_WARNING(x)
void addTrackAtVertex(const ElementLink< TrackParticleContainer > &tr, float weight=1.0)
Add a new track to the vertex.
bool vxTrackAtVertexAvailable() const
Check if VxTrackAtVertices are attached to the object.
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ initialize()

StatusCode Trk::FastVertexFitter::initialize ( )
overridevirtual

Definition at line 55 of file FastVertexFitter.cxx.

56 {
57
58 if ( m_extrapolator.retrieve().isFailure() )
59 {
60 msg(MSG::FATAL) << "Failed to retrieve tool " << m_extrapolator << endmsg;
61 return StatusCode::FAILURE;
62 }
63
64
65 msg(MSG::INFO) << "Retrieved tool " << m_extrapolator << endmsg;
66
67
68 if ( m_linFactory.retrieve().isFailure() )
69 {
70 msg(MSG::FATAL) << "Failed to retrieve tool " << m_linFactory << endmsg;
71 return StatusCode::FAILURE;
72 }
73
74
75 msg(MSG::INFO) << "Retrieved tool " << m_linFactory << endmsg;
76
77
78 return StatusCode::SUCCESS;
79 }

Member Data Documentation

◆ m_extrapolator

ToolHandle<Trk::IExtrapolator> Trk::FastVertexFitter::m_extrapolator {this, "Extrapolator", "Trk::Extrapolator"}
private

Definition at line 158 of file FastVertexFitter.h.

158{this, "Extrapolator", "Trk::Extrapolator"};

◆ m_linFactory

ToolHandle<Trk::IVertexLinearizedTrackFactory> Trk::FastVertexFitter::m_linFactory {this, "LinearizedTrackFactory", "Trk::FullLinearizedTrackFactory"}
private

Definition at line 159 of file FastVertexFitter.h.

159{this, "LinearizedTrackFactory", "Trk::FullLinearizedTrackFactory"};

◆ m_maxDchi2PerNdf

double Trk::FastVertexFitter::m_maxDchi2PerNdf
private

Definition at line 156 of file FastVertexFitter.h.

◆ m_maxIterations

unsigned int Trk::FastVertexFitter::m_maxIterations
private

Definition at line 155 of file FastVertexFitter.h.


The documentation for this class was generated from the following files: