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

An iterative vertex fitter, updating the vertex estimate with a single at the time. More...

#include <SequentialVertexFitter.h>

Inheritance diagram for Trk::SequentialVertexFitter:
Collaboration diagram for Trk::SequentialVertexFitter:

Public Member Functions

virtual StatusCode initialize () override
virtual StatusCode finalize () override
 SequentialVertexFitter (const std::string &t, const std::string &n, const IInterface *p)
 constructor
virtual ~SequentialVertexFitter ()
 destructor
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeut, const Amg::Vector3D &startingPoint) const override
 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 Amg::Vector3D &startingPoint) const override
 Interface for xAOD::TrackParticle 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 * > &vectorNeut, const xAOD::Vertex &constraint) const override
 Interface for xAOD::TrackParticle and xAOD::NeutralParticle with vertex constraint the position of the constraint is ALWAYS the starting point.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const xAOD::Vertex &constraint) const override
 Interface for xAOD::TrackParticle with vertex constraint the position of the constraint is ALWAYS the starting point.
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 override
 Vertex fit from list of track and neutral parameters and a starting point.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &paramList, const Amg::Vector3D &startingPoint) const override
 Vertex fit from list of track and parameters and a starting point.
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 override
 Vertex fit from the vector of track and neutral parameters with a preliminary knowledge (vertex constraint).
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint) const override
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList) const override
 Additional fit methods.
virtual std::unique_ptr< xAOD::Vertexfit (const EventContext &ctx, const std::vector< const Trk::TrackParameters * > &perigeeList) const override

Private Member Functions

std::vector< Trk::VxTrackAtVertexlinearizeTracks (const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const xAOD::Vertex &vrt) const
 Internal method related to the linearization of tracks (initial linearization).
void reLinearizeTracks (std::vector< Trk::VxTrackAtVertex > &tracks, const Amg::Vector3D &vrt) const
 Relinearization on iterations.

Private Attributes

ToolHandle< IVertexUpdatorm_Updator
ToolHandle< IVertexSmootherm_Smoother
ToolHandle< Trk::IVertexLinearizedTrackFactorym_LinTrkFactory
bool m_doSmoothing
 Flag controlling optional smoothing.
unsigned int m_maxStep
 Max number of iterations to perform (in case of no convergence).
float m_maxShift
 Max shift (represents the convergence criterion).
bool m_useLooseConvergence
 Use loose convergence criterium (maxShift) or hard (+maxDeltaChi2).
float m_maxDeltaChi2
 Max DeltaChi2 allowed in hard convergence criterium.
double m_maxR
double m_maxZ

Detailed Description

An iterative vertex fitter, updating the vertex estimate with a single at the time.

The measurement equation is relinearized with the position of the resulting estimate and the vertex is refit The iterations are performed until the vertex position improves or the maximal niumber of iterations is reached. Smoothing (refit of tracks with the knowledge of the vertex position) is then performed on request.

The fitter can be used with arbitrary VertexUpdator, VertexSmoother and LinearizedTrackFactory

Author
Kirill Prokofiev, November 2005

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 55 of file SequentialVertexFitter.h.

Constructor & Destructor Documentation

◆ SequentialVertexFitter()

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

constructor

Definition at line 58 of file SequentialVertexFitter.cxx.

58 :
59 base_class(t,n,p),
60 m_Updator("Trk::KalmanVertexUpdator", this),
61
62// m_Smoother("Trk::KalmanVertexSmoother"),
63 m_Smoother("Trk::DummyVertexSmoother",this),
64 m_LinTrkFactory("Trk::FullPerigeeLinearizedTrackFactory",this),
65 m_doSmoothing(true),
66 m_maxStep(20),
67 m_maxShift(0.0001),
69 m_maxDeltaChi2(1e-3),
70 m_maxR(1150.),//max R of ID
71 m_maxZ(2727.)
72{
73//convergence stuff
74 declareProperty("MaxIterations",m_maxStep);
75 declareProperty("MaxShift",m_maxShift);
76 declareProperty("useLooseConvergence",m_useLooseConvergence);
77 declareProperty("maxDeltaChi2",m_maxDeltaChi2);
78
79//updator-related stuff
80 declareProperty("VertexUpdator",m_Updator);
81
82//smoother-related stuff
83 declareProperty("DoSmoothing",m_doSmoothing);
84 declareProperty("VertexSmoother",m_Smoother);
85
86 declareProperty("ID_maxR",m_maxR);
87 declareProperty("ID_maxZ",m_maxZ);
88
89//linearizedTrackFactory-related stuff
90 declareProperty("LinearizedTrackFactory", m_LinTrkFactory);
91 }
bool m_doSmoothing
Flag controlling optional smoothing.
bool m_useLooseConvergence
Use loose convergence criterium (maxShift) or hard (+maxDeltaChi2).
unsigned int m_maxStep
Max number of iterations to perform (in case of no convergence).
ToolHandle< IVertexUpdator > m_Updator
ToolHandle< IVertexSmoother > m_Smoother
float m_maxShift
Max shift (represents the convergence criterion).
float m_maxDeltaChi2
Max DeltaChi2 allowed in hard convergence criterium.
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_LinTrkFactory

◆ ~SequentialVertexFitter()

Trk::SequentialVertexFitter::~SequentialVertexFitter ( )
virtualdefault

destructor

Member Function Documentation

◆ finalize()

StatusCode Trk::SequentialVertexFitter::finalize ( )
overridevirtual

Definition at line 52 of file SequentialVertexFitter.cxx.

53 {
54 return StatusCode::SUCCESS;
55 }

◆ fit() [1/10]

virtual std::unique_ptr< xAOD::Vertex > Trk::SequentialVertexFitter::fit ( const EventContext & ctx,
const std::vector< const Trk::TrackParameters * > & paramList,
const Amg::Vector3D & startingPoint ) const
inlineoverridevirtual

Vertex fit from list of track and parameters and a starting point.

Definition at line 122 of file SequentialVertexFitter.h.

125 {return fit(ctx, paramList, std::vector<const Trk::NeutralParameters*>(), startingPoint);};
virtual std::unique_ptr< xAOD::Vertex > fit(const EventContext &ctx, const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &vectorNeut, const Amg::Vector3D &startingPoint) const override
Interface for xAOD::TrackParticle and xAOD::NeutralParticle with starting point.

◆ fit() [2/10]

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

Definition at line 154 of file SequentialVertexFitter.h.

157 {return fit(ctx, perigeeList, std::vector<const Trk::NeutralParameters*>());};

◆ fit() [3/10]

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

Additional fit methods.

These will later work with selected finder.. So far these methods work with default (0,0,0) starting point and "huge" diagonal error matrix

Definition at line 136 of file SequentialVertexFitter.cxx.

139 {
140
141 //this method will later be modifyed to use the a finder
142 //uses a default starting point so far.
143 const Amg::Vector3D start_point(0.,0.,0.);
144 return fit(ctx, perigeeList, neutralPerigeeList, start_point);
145
146 }
Eigen::Matrix< double, 3, 1 > Vector3D

◆ fit() [4/10]

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

Vertex fit from list of track and neutral parameters and a starting point.

Definition at line 98 of file SequentialVertexFitter.cxx.

102 {
103 xAOD::Vertex constraint;
104 constraint.makePrivateStore();
105 constraint.setPosition( startingPoint );
106 constraint.setCovariancePosition( AmgSymMatrix(3)::Zero(3,3) );
107 constraint.setFitQuality( 0.,0.);
108 std::unique_ptr<xAOD::Vertex> FittedVertex = fit(ctx, perigeeList, neutralPerigeeList, constraint);
109
110 //setting the initial perigees
111 if(FittedVertex !=nullptr )
112 {
113 if(FittedVertex->vxTrackAtVertexAvailable())
114 {
115 if(!FittedVertex->vxTrackAtVertex().empty())
116 {
117 for(unsigned int i = 0; i <perigeeList.size(); ++i)
118 {
119 const Trk::TrackParameters* iPer = perigeeList[i];
120 (FittedVertex->vxTrackAtVertex())[i].setInitialPerigee(iPer);
121 }
122 //same for neutrals
123 for(unsigned int i = 0; i <neutralPerigeeList.size(); ++i) {
124 const Trk::NeutralParameters* iPer = neutralPerigeeList[i];
125 (FittedVertex->vxTrackAtVertex())[perigeeList.size()+i].setInitialPerigee(iPer);
126 }
127 } //end of protection against unsuccessfull updates (no tracks or neutrals were added)
128 }
129 }
130
131 return FittedVertex;
132
133 }
#define AmgSymMatrix(dim)
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.
ParametersBase< NeutralParametersDim, Neutral > NeutralParameters
ParametersBase< TrackParametersDim, Charged > TrackParameters
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ fit() [5/10]

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

Vertex fit from the vector of track and neutral parameters with a preliminary knowledge (vertex constraint).

Definition at line 150 of file SequentialVertexFitter.cxx.

154 {
155
156 //security check
157 if(perigeeList.empty())
158 {
159 ATH_MSG_INFO( "Empty vector of tracks passed, returning 0" );
160 return nullptr;
161 }
162
163 //identifying the input parameters of the fit
164 //and making initial xAOD::Vertex to be updated with tracks
165 const Amg::Vector3D& priorVertexPosition = constraint.position();
166 const AmgSymMatrix(3)& initialVertexError = constraint.covariancePosition();
167 AmgSymMatrix(3) priorErrorMatrix;
168
169 double in_chi = 0.;
170 double in_ndf = 0.;
171
172 bool priorInfo=false;
173
174 //checking whether the prior information has a defined error matrix:
175 if(initialVertexError.trace() == 0.)
176 {
177
178 //no prior estimate, using the huge error method
179 //creating a covariance matrix:
180 float diag = 1000000.0;
181 AmgSymMatrix(3) in_m;
182 in_m.setIdentity();
183 priorErrorMatrix = in_m * diag;
184
185 // we're now working without prior knowledge,
186 // so the effective ndf is reduced by 3.
187 in_ndf-=3.;
188
189 } else {
190 priorInfo=true;
191 priorErrorMatrix = initialVertexError;
192 }
193 // creating an initial vertex to update
194 std::unique_ptr<xAOD::Vertex> returnVertex = std::make_unique<xAOD::Vertex>();
195 returnVertex->makePrivateStore(); // xAOD::VertexContainer will take ownership of AuxStore when returnVertex is added to it
196 returnVertex->setPosition( priorVertexPosition );
197 returnVertex->setCovariancePosition( priorErrorMatrix );
198 returnVertex->setFitQuality( in_chi, in_ndf );
199 returnVertex->setVertexType( xAOD::VxType::NotSpecified ); // to mimic the initialization present in the old EDM constructor
200
201 //converting the input perigee to the Vertex tracks
202 std::vector<Trk::VxTrackAtVertex> tracks_to_fit = linearizeTracks(perigeeList, neutralPerigeeList, *returnVertex);
203 std::vector<Trk::VxTrackAtVertex> fittedTracks(0);
204 returnVertex->vxTrackAtVertex() = std::move(fittedTracks);
205
206 //the actual fitting loop
207 Amg::Vector3D newPosition = returnVertex->position();
208 Amg::Vector3D previousPreviousPosition = newPosition;
209 Amg::Vector3D previousPosition = newPosition;
210 double newChi2= returnVertex->chiSquared();
211 double previousChi2{};
212 unsigned int n_iter = 0;
213 double deltaR{};
214 bool fitFailed{false};
215
216 std::vector<Trk::VxTrackAtVertex>::iterator tracksBegin = tracks_to_fit.begin();
217 std::vector<Trk::VxTrackAtVertex>::iterator tracksEnd = tracks_to_fit.end();
218 auto deltaChi2 = [](double chi1, double chi0){
219 return std::abs((chi1-chi0)*2./(chi1+chi0+2.));
220 };
221 do {
222 if (!priorInfo){
223 returnVertex->setPosition( newPosition );
224 returnVertex->setCovariancePosition( priorErrorMatrix );
225 returnVertex->setFitQuality( in_chi, in_ndf );
226 } else {
227 returnVertex->setPosition( priorVertexPosition );
228 returnVertex->setCovariancePosition( priorErrorMatrix );
229 returnVertex->setFitQuality( in_chi, in_ndf );
230 }
231
232 //optional relinearization
233 if(n_iter !=0) {
234 reLinearizeTracks(tracks_to_fit, returnVertex->position());
235 }
236 //loop over available tracks
237
238 for(std::vector<Trk::VxTrackAtVertex>::iterator i = tracksBegin; i != tracksEnd;++i)
239 {
240 xAOD::Vertex *new_vertex = m_Updator->add(*returnVertex, *i);
241 if (new_vertex != returnVertex.get()) {
242 returnVertex.reset( new_vertex );
243 }
244 }//end of loop over available tracks
245
246 //now the updated state that is stored in returnVertex
247 previousPreviousPosition = previousPosition;
248 previousPosition = newPosition;
249 previousChi2 = newChi2;
250 newPosition = returnVertex->position();
251 newChi2 = returnVertex->chiSquared();
252 ++n_iter;
253 //the fit always fails if a negative chisquared was returned at some point or the z-coordinate of the vertex was outside ID
254 fitFailed = (n_iter == m_maxStep) or (newChi2 <0.) or std::abs(returnVertex->z())>m_maxZ;
255 deltaR = (previousPosition - newPosition).perp();
256 // the rest after 'fitFailed' won't be evaluated if the fit failed,
257 // so hopefully no more FPE in the division
258 } while ( (not fitFailed) &&
260 || ( !m_useLooseConvergence && deltaChi2(newChi2, previousChi2) > m_maxDeltaChi2 ) ) );
261
262 if (fitFailed) {
263 ATH_MSG_DEBUG( " Fit failed. " );
264 ATH_MSG_DEBUG( " Fit didn't converge after " << n_iter );
265 ATH_MSG_DEBUG( " steps. Deltachi2: " << deltaChi2(newChi2, previousChi2) );
266 ATH_MSG_DEBUG( " DeltaR " << deltaR);
267 returnVertex.reset();
268 return nullptr;
269 }
270 //smoothing and related
271 if(m_doSmoothing)m_Smoother->smooth(*returnVertex);
272
273 //here the vertex is returned. It is foreseen that a vertex is _always_
274 //returned (initial guess in worst case) unless there is a runtime crash
275 return returnVertex;
276
277 }//end of the actual fit method
Scalar perp() const
perp method - perpendicular length
Scalar deltaR(const MatrixBase< Derived > &vec) const
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
if(pathvar)
void reLinearizeTracks(std::vector< Trk::VxTrackAtVertex > &tracks, const Amg::Vector3D &vrt) const
Relinearization on iterations.
std::vector< Trk::VxTrackAtVertex > linearizeTracks(const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList, const xAOD::Vertex &vrt) const
Internal method related to the linearization of tracks (initial linearization).
const Amg::Vector3D & position() const
Returns the 3-pos.
bool fitFailed
@ NotSpecified
Default value, no explicit type set.

◆ fit() [6/10]

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

Definition at line 136 of file SequentialVertexFitter.h.

139 {return fit(ctx, perigeeList, std::vector<const Trk::NeutralParameters*>(), constraint);};

◆ fit() [7/10]

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

Interface for xAOD::TrackParticle with starting point.

Definition at line 86 of file SequentialVertexFitter.h.

89 {return fit(ctx, vectorTrk, std::vector<const xAOD::NeutralParticle*>(), startingPoint);};

◆ fit() [8/10]

std::unique_ptr< xAOD::Vertex > Trk::SequentialVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & vectorNeut,
const Amg::Vector3D & startingPoint ) const
overridevirtual

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

Definition at line 365 of file SequentialVertexFitter.cxx.

366 {
367 xAOD::Vertex constraint;
368 constraint.makePrivateStore();
369 constraint.setPosition( startingPoint );
370 constraint.setCovariancePosition( AmgSymMatrix(3)::Zero(3,3) );
371 constraint.setFitQuality( 0.,0.);
372 return fit(ctx, vectorTrk, vectorNeut, constraint);
373 }//end of the xAOD starting point fit method

◆ fit() [9/10]

std::unique_ptr< xAOD::Vertex > Trk::SequentialVertexFitter::fit ( const EventContext & ctx,
const std::vector< const xAOD::TrackParticle * > & vectorTrk,
const std::vector< const xAOD::NeutralParticle * > & vectorNeut,
const xAOD::Vertex & constraint ) const
overridevirtual

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

Definition at line 376 of file SequentialVertexFitter.cxx.

377 {
378
379 if(vectorTrk.empty())
380 {
381 ATH_MSG_INFO( "Empty vector of tracks passed" );
382 return nullptr;
383 }
384
385 if(vectorNeut.empty())
386 {
387 ATH_MSG_INFO( "Empty vector of neutrals passed" );
388 }
389
390 //making a list of perigee out of the vector of tracks
391 //Also check for duplicate tracks (will otherwise be discarded by the fit); they do not
392 // fit the hypothesis of statistically independent tracks. Print a warning and discard the duplicate
393 // it this happens.
394 std::vector<const Trk::TrackParameters*> measuredPerigees;
395 std::vector<const xAOD::TrackParticle*> trkToFit;
396
397 for(std::vector<const xAOD::TrackParticle*>::const_iterator i = vectorTrk.begin(); i!= vectorTrk.end();++i)
398 {
399 //check for duplicates
400 bool foundDuplicate(false);
401 for (std::vector<const xAOD::TrackParticle*>::const_iterator j = vectorTrk.begin(); j!= i; ++j) {
402 if (*i == *j) {
403 ATH_MSG_WARNING( "Duplicate track given as input to the fitter. Ignored." );
404 foundDuplicate = true;
405 break;
406 }
407 }
408 if (foundDuplicate) continue; //skip track
409
410 const Trk::TrackParameters * tmpMeasPer = &((*i)->perigeeParameters());
411
412 if(tmpMeasPer!=nullptr) {
413 trkToFit.push_back(*i);
414 measuredPerigees.push_back(tmpMeasPer);
415 } else {
416 ATH_MSG_INFO( "Failed to dynamic_cast this track parameters to perigee" ); //TODO: Failed to implicit cast the perigee parameters to track parameters?
417 }
418 }
419
420 //making a list of perigee out of the vector of neutrals
421 std::vector<const Trk::NeutralParameters*> measuredNeutralPerigees;
422 std::vector<const xAOD::NeutralParticle*> neutToFit;
423 for(std::vector<const xAOD::NeutralParticle*>::const_iterator i = vectorNeut.begin(); i!= vectorNeut.end();++i)
424 {
425 //check for duplicates
426 bool foundDuplicate(false);
427 for (std::vector<const xAOD::NeutralParticle*>::const_iterator j = vectorNeut.begin(); j!= i; ++j) {
428 if (*i == *j) {
429 ATH_MSG_WARNING( "Duplicate neutral given as input to the fitter. Ignored." );
430 foundDuplicate = true;
431 break;
432 }
433 }
434 if (foundDuplicate) continue; //skip track
435
436 const Trk::NeutralParameters * tmpMeasPer = &((*i)->perigeeParameters());
437
438 if(tmpMeasPer!=nullptr) {
439 neutToFit.push_back(*i);
440 measuredNeutralPerigees.push_back(tmpMeasPer);
441 } else {
442 ATH_MSG_INFO( "Failed to dynamic_cast this neutral parameters to perigee" ); //TODO: Failed to implicit cast the perigee parameters to neutral parameters?
443 }
444 }
445
446
447 std::unique_ptr<xAOD::Vertex> fittedVertex = fit( ctx, measuredPerigees, measuredNeutralPerigees, constraint );
448
449
450 //assigning the input tracks to the fitted vertex through vxTrackAtVertices
451 if(fittedVertex ==nullptr)
452 {
453 return fittedVertex;
454 }
455
456 if( fittedVertex->vxTrackAtVertexAvailable() ) // TODO: I don't think vxTrackAtVertexAvailable() does the same thing as a null pointer check!
457 {
458 if(!fittedVertex->vxTrackAtVertex().empty())
459 {
460 for(unsigned int i = 0; i <trkToFit.size(); ++i)
461 {
462
463 LinkToXAODTrackParticle* linkTT= new LinkToXAODTrackParticle();
464 const xAOD::TrackParticleContainer* cont = dynamic_cast< const xAOD::TrackParticleContainer* >( trkToFit[ i ]->container() );
465 if( cont )
466 {
467 if( ! linkTT->toIndexedElement( *cont, trkToFit[ i ]->index() ) )
468 {
469 ATH_MSG_WARNING( "Failed to set the EL for this particle correctly" );
470 }
471 } else{
472 ATH_MSG_WARNING( "Failed to identify a container for this TP" );
473 }//end of the dynamic cast check
474
475
476 // vxtrackatvertex takes ownership!
477 ( fittedVertex->vxTrackAtVertex() )[i].setOrigTrack(linkTT);
478 }//end of loop for setting orig tracks in.
479
480 for(unsigned int i = 0; i <neutToFit.size(); ++i)
481 {
482 LinkToXAODNeutralParticle* linkTT = new LinkToXAODNeutralParticle();
483 const xAOD::NeutralParticleContainer* cont = dynamic_cast< const xAOD::NeutralParticleContainer* >( neutToFit[ i ]->container() );
484 if( cont )
485 {
486 if( ! linkTT->toIndexedElement( *cont, neutToFit[ i ]->index() ) )
487 {
488 ATH_MSG_WARNING( "Failed to set the EL for this particle correctly" );
489 }
490 } else{
491 ATH_MSG_WARNING( "Failed to identify a container for this NP" );
492 }//end of the dynamic cast check
493
494 // vxtrackatvertex takes ownership!
495 ( fittedVertex->vxTrackAtVertex() )[trkToFit.size()+i].setOrigTrack(linkTT);
496 }//end of loop for setting orig neutrals in.
497
498 }//end of protection against unsuccessfull updates (no tracks were added)
499 }//end of vector of tracks check
500
501
502 //now set links to xAOD::TrackParticles directly in the xAOD::Vertex
503 unsigned int VTAVsize = (fittedVertex && fittedVertex->vxTrackAtVertexAvailable()) ? fittedVertex->vxTrackAtVertex().size() : 0 ;
504 for (unsigned int i = 0 ; i < VTAVsize ; ++i)
505 {
506 Trk::VxTrackAtVertex* VTAV = &( fittedVertex->vxTrackAtVertex().at(i) );
507 //TODO: Will this pointer really hold 0 if no VxTrackAtVertex is found?
508 if (not VTAV){
509 ATH_MSG_WARNING( "Trying to set link to xAOD::TrackParticle. The VxTrackAtVertex is not found" );
510 continue;
511 }
512
513 Trk::ITrackLink* trklink = VTAV->trackOrParticleLink();
514
515 // See if the trklink is to an xAOD::TrackParticle
516 Trk::LinkToXAODTrackParticle* linkToXAODTP = dynamic_cast<Trk::LinkToXAODTrackParticle*>(trklink);
517 if (linkToXAODTP)
518 {
519
520 //Now set the new link to the xAOD vertex
521 fittedVertex->addTrackAtVertex(*linkToXAODTP, VTAV->weight());
522
523 } else {
524
525 // See if the trklink is to an xAOD::NeutralParticle
526 Trk::LinkToXAODNeutralParticle* linkToXAODTPneutral = dynamic_cast<Trk::LinkToXAODNeutralParticle*>(trklink);
527 if (!linkToXAODTPneutral) {
528 ATH_MSG_WARNING( "Skipping track. Trying to set link to something else than xAOD::TrackParticle or xAOD::NeutralParticle." );
529 } else {
530 //Now set the new link to the new xAOD vertex
531 fittedVertex->addNeutralAtVertex(*linkToXAODTPneutral, VTAV->weight());
532 }
533
534 }
535 } //end of loop
536
537 return fittedVertex;
538
539 }//end of the xAOD constrained fit method
#define ATH_MSG_WARNING(x)
mapped_type at(key_type key) const
Look up an element in the map.
NeutralParticleContainer_v1 NeutralParticleContainer
Definition of the current "NeutralParticle container version".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".

◆ fit() [10/10]

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

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

Definition at line 103 of file SequentialVertexFitter.h.

106 {return fit(ctx, vectorTrk, std::vector<const xAOD::NeutralParticle*>(), constraint);};

◆ initialize()

StatusCode Trk::SequentialVertexFitter::initialize ( )
overridevirtual

Definition at line 35 of file SequentialVertexFitter.cxx.

36 {
37
38//uploading the corresponding tools
39
40//updator
41 ATH_CHECK( m_Updator.retrieve() );
42
43//smoother
44 ATH_CHECK( m_Smoother.retrieve( EnableTool {m_doSmoothing} ) );
45
46//Linearized Track Factory
47 ATH_CHECK( m_LinTrkFactory.retrieve() );
48 return StatusCode::SUCCESS;
49 }//end of initialize method
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ linearizeTracks()

std::vector< Trk::VxTrackAtVertex > Trk::SequentialVertexFitter::linearizeTracks ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const std::vector< const Trk::NeutralParameters * > & neutralPerigeeList,
const xAOD::Vertex & vrt ) const
private

Internal method related to the linearization of tracks (initial linearization).

Definition at line 280 of file SequentialVertexFitter.cxx.

283 {
284
285 //defining the output vector
286 std::vector<Trk::VxTrackAtVertex> out_tracks(0);
287 for(const auto *i : perigeeList)
288 {
289
290 //creating new meas perigees, since the will be deleted
291 //by VxTrackAtVertex in destructor
292 const Trk::Perigee * loc_per = dynamic_cast<const Trk::Perigee *>(i);
293 if( loc_per != nullptr)
294 {
295 Trk::Perigee * mPer = new Trk::Perigee(*loc_per);
296 const Trk::Perigee * inPer = loc_per;
297 //new MeasuredPerigee(*loc_per);
298 Trk::VxTrackAtVertex * vTrack = new Trk::VxTrackAtVertex(0., mPer, nullptr, inPer, nullptr);
299
300 //linearization itself
301 m_LinTrkFactory->linearize( *vTrack, vrt.position() );
302 vTrack->setWeight(1.);
303
304 out_tracks.push_back(*vTrack);
305
306 // Added the following line during EDM Migration
307 delete vTrack; //TODO: is this ok?
308 } else {
309 ATH_MSG_WARNING( "Cannot linearize tracks; treatment of neutrals not yet supported" );
310 }
311 }//end of loop over all the perigee states
312
313 //same for neutrals
314 for(const auto *i : neutralPerigeeList)
315 {
316
317 //creating new meas perigees, since the will be deleted
318 //by VxTrackAtVertex in destructor
319 const Trk::NeutralPerigee * loc_per = dynamic_cast<const Trk::NeutralPerigee *>(i);
320 if( loc_per != nullptr)
321 {
322 Trk::NeutralPerigee * mPer = new Trk::NeutralPerigee(*loc_per);
323 const Trk::NeutralPerigee * inPer = loc_per;
324 Trk::VxTrackAtVertex * vTrack = new Trk::VxTrackAtVertex(0., nullptr, mPer, nullptr, inPer);
325
326 //linearization itself
327 m_LinTrkFactory->linearize( *vTrack, vrt.position() );
328 vTrack->setWeight(1.);
329
330 out_tracks.push_back(*vTrack);
331
332 // Added the following line during EDM Migration
333 delete vTrack; //TODO: is this ok?
334 } else {
335 ATH_MSG_WARNING( "Cannot linearize tracks; treatment of neutrals not yet supported" );
336 }
337 }//end of loop over all the neutral perigee states
338
339 return out_tracks;
340 }//end of linearize method
void setWeight(const double)
Set method for a weight.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersT< NeutralParametersDim, Neutral, PerigeeSurface > NeutralPerigee

◆ reLinearizeTracks()

void Trk::SequentialVertexFitter::reLinearizeTracks ( std::vector< Trk::VxTrackAtVertex > & tracks,
const Amg::Vector3D & vrt ) const
private

Relinearization on iterations.

Definition at line 343 of file SequentialVertexFitter.cxx.

344 {
345 Amg::Vector3D linVertexPos = vrt;
346 if ( linVertexPos.perp() > m_maxR || std::abs(linVertexPos.z()) > m_maxZ )
347 {
348 ATH_MSG_DEBUG( " Linearization position outside ID. Setting back to (0,0,0) " );
349 linVertexPos.x()=0;
350 linVertexPos.y()=0;
351 linVertexPos.z()=0;
352 }
353
354 std::vector<Trk::VxTrackAtVertex>& out_tracks = tracks;
355 std::vector<Trk::VxTrackAtVertex>::iterator i_end = out_tracks.end();
356 for(std::vector<Trk::VxTrackAtVertex>::iterator i = out_tracks.begin(); i!=i_end; ++i)
357 {
358 m_LinTrkFactory->linearize(*i,linVertexPos);
359 }//end of loop over all tracks
360 }//end of relinearize method

Member Data Documentation

◆ m_doSmoothing

bool Trk::SequentialVertexFitter::m_doSmoothing
private

Flag controlling optional smoothing.

Definition at line 185 of file SequentialVertexFitter.h.

◆ m_LinTrkFactory

ToolHandle< Trk::IVertexLinearizedTrackFactory > Trk::SequentialVertexFitter::m_LinTrkFactory
private

Definition at line 179 of file SequentialVertexFitter.h.

◆ m_maxDeltaChi2

float Trk::SequentialVertexFitter::m_maxDeltaChi2
private

Max DeltaChi2 allowed in hard convergence criterium.

Definition at line 209 of file SequentialVertexFitter.h.

◆ m_maxR

double Trk::SequentialVertexFitter::m_maxR
private

Definition at line 215 of file SequentialVertexFitter.h.

◆ m_maxShift

float Trk::SequentialVertexFitter::m_maxShift
private

Max shift (represents the convergence criterion).

Definition at line 197 of file SequentialVertexFitter.h.

◆ m_maxStep

unsigned int Trk::SequentialVertexFitter::m_maxStep
private

Max number of iterations to perform (in case of no convergence).

Definition at line 191 of file SequentialVertexFitter.h.

◆ m_maxZ

double Trk::SequentialVertexFitter::m_maxZ
private

Definition at line 216 of file SequentialVertexFitter.h.

◆ m_Smoother

ToolHandle< IVertexSmoother > Trk::SequentialVertexFitter::m_Smoother
private

Definition at line 178 of file SequentialVertexFitter.h.

◆ m_Updator

ToolHandle< IVertexUpdator > Trk::SequentialVertexFitter::m_Updator
private

Definition at line 177 of file SequentialVertexFitter.h.

◆ m_useLooseConvergence

bool Trk::SequentialVertexFitter::m_useLooseConvergence
private

Use loose convergence criterium (maxShift) or hard (+maxDeltaChi2).

Definition at line 203 of file SequentialVertexFitter.h.


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