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() = 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(returnVertex !=nullptr){
272 if(m_doSmoothing)m_Smoother->smooth(*returnVertex);
273 } else {
274 ATH_MSG_INFO( "Sequential vertex fit fails:: zero pointer returned" );
275 }
276 //here the vertex is returned. It is foreseen that a vertex is _always_
277 //returned (initial guess in worst case) unless there is a runtime crash
278 return returnVertex;
279
280 }//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 368 of file SequentialVertexFitter.cxx.

369 {
370 xAOD::Vertex constraint;
371 constraint.makePrivateStore();
372 constraint.setPosition( startingPoint );
373 constraint.setCovariancePosition( AmgSymMatrix(3)::Zero(3,3) );
374 constraint.setFitQuality( 0.,0.);
375 return fit(ctx, vectorTrk, vectorNeut, constraint);
376 }//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 379 of file SequentialVertexFitter.cxx.

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

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

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