ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::SequentialVertexFitter Class Reference

#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 More...
 
virtual ~SequentialVertexFitter ()
 destructor More...
 
virtual xAOD::Vertexfit (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. More...
 
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const Amg::Vector3D &startingPoint) const override
 Interface for xAOD::TrackParticle with starting point. More...
 
virtual xAOD::Vertexfit (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. More...
 
virtual xAOD::Vertexfit (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. More...
 
virtual xAOD::Vertexfit (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. More...
 
virtual xAOD::Vertexfit (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. More...
 
virtual xAOD::Vertexfit (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) More...
 
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint) const override
 
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &neutralPerigeeList) const override
 Additional fit methods. More...
 
virtual xAOD::Vertexfit (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) More...
 
void reLinearizeTracks (std::vector< Trk::VxTrackAtVertex > &tracks, const Amg::Vector3D &vrt) const
 Relinearization on iterations. More...
 

Private Attributes

ToolHandle< IVertexUpdatorm_Updator
 
ToolHandle< IVertexSmootherm_Smoother
 
ToolHandle< Trk::IVertexLinearizedTrackFactorym_LinTrkFactory
 
bool m_doSmoothing
 Flag controlling optional smoothing. More...
 
unsigned int m_maxStep
 Max number of iterations to perform (in case of no convergence) More...
 
float m_maxShift
 Max shift (represents the convergence criterion) More...
 
bool m_useLooseConvergence
 Use loose convergence criterium (maxShift) or hard (+maxDeltaChi2) More...
 
float m_maxDeltaChi2
 Max DeltaChi2 allowed in hard convergence criterium. More...
 
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),
68  m_useLooseConvergence(false),
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  }

◆ ~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 xAOD::Vertex* Trk::SequentialVertexFitter::fit ( 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 117 of file SequentialVertexFitter.h.

119  {return fit(paramList, std::vector<const Trk::NeutralParameters*>(), startingPoint);};

◆ fit() [2/10]

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

Definition at line 143 of file SequentialVertexFitter.h.

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

◆ fit() [3/10]

xAOD::Vertex * Trk::SequentialVertexFitter::fit ( 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 135 of file SequentialVertexFitter.cxx.

137  {
138 
139  //this method will later be modifyed to use the a finder
140  //uses a default starting point so far.
141  const Amg::Vector3D start_point(0.,0.,0.);
142  return fit(perigeeList, neutralPerigeeList, start_point);
143 
144  }

◆ fit() [4/10]

xAOD::Vertex * Trk::SequentialVertexFitter::fit ( 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.

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

◆ fit() [5/10]

xAOD::Vertex * Trk::SequentialVertexFitter::fit ( 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 148 of file SequentialVertexFitter.cxx.

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

◆ fit() [6/10]

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

Definition at line 128 of file SequentialVertexFitter.h.

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

◆ fit() [7/10]

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

Interface for xAOD::TrackParticle with starting point.

Definition at line 85 of file SequentialVertexFitter.h.

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

◆ fit() [8/10]

xAOD::Vertex * Trk::SequentialVertexFitter::fit ( 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(vectorTrk, vectorNeut, constraint);
373  }//end of the xAOD starting point fit method

◆ fit() [9/10]

xAOD::Vertex * Trk::SequentialVertexFitter::fit ( 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  xAOD::Vertex* fittedVertex = fit( 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

◆ fit() [10/10]

virtual xAOD::Vertex* Trk::SequentialVertexFitter::fit ( 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 100 of file SequentialVertexFitter.h.

102  {return fit(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

◆ 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

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

◆ m_LinTrkFactory

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

Definition at line 167 of file SequentialVertexFitter.h.

◆ m_maxDeltaChi2

float Trk::SequentialVertexFitter::m_maxDeltaChi2
private

Max DeltaChi2 allowed in hard convergence criterium.

Definition at line 197 of file SequentialVertexFitter.h.

◆ m_maxR

double Trk::SequentialVertexFitter::m_maxR
private

Definition at line 203 of file SequentialVertexFitter.h.

◆ m_maxShift

float Trk::SequentialVertexFitter::m_maxShift
private

Max shift (represents the convergence criterion)

Definition at line 185 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 179 of file SequentialVertexFitter.h.

◆ m_maxZ

double Trk::SequentialVertexFitter::m_maxZ
private

Definition at line 204 of file SequentialVertexFitter.h.

◆ m_Smoother

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

Definition at line 166 of file SequentialVertexFitter.h.

◆ m_Updator

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

Definition at line 165 of file SequentialVertexFitter.h.

◆ m_useLooseConvergence

bool Trk::SequentialVertexFitter::m_useLooseConvergence
private

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

Definition at line 191 of file SequentialVertexFitter.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
xAOD::Vertex_v1::setPosition
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
Trk::SequentialVertexFitter::m_Updator
ToolHandle< IVertexUpdator > m_Updator
Definition: SequentialVertexFitter.h:165
xAOD::Vertex_v1::setFitQuality
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
Definition: Vertex_v1.cxx:150
Trk::VxTrackAtVertex
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Definition: VxTrackAtVertex.h:77
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::SequentialVertexFitter::m_maxDeltaChi2
float m_maxDeltaChi2
Max DeltaChi2 allowed in hard convergence criterium.
Definition: SequentialVertexFitter.h:197
perp
Scalar perp() const
perp method - perpenticular length
Definition: AmgMatrixBasePlugin.h:44
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
Trk::SequentialVertexFitter::m_Smoother
ToolHandle< IVertexSmoother > m_Smoother
Definition: SequentialVertexFitter.h:166
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::Perigee
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:33
Trk::VxTrackAtVertex::setWeight
void setWeight(const double)
Set method for a weight.
Trk::SequentialVertexFitter::m_LinTrkFactory
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_LinTrkFactory
Definition: SequentialVertexFitter.h:167
Trk::AmgSymMatrix
AmgSymMatrix(5) &GXFTrackState
Definition: GXFTrackState.h:156
xAOD::Vertex_v1::setVertexType
void setVertexType(VxType::VertexType vType)
Set the type of the vertex.
xAOD::Vertex_v1::addTrackAtVertex
void addTrackAtVertex(const ElementLink< TrackParticleContainer > &tr, float weight=1.0)
Add a new track to the vertex.
Definition: Vertex_v1.cxx:314
Trk::SequentialVertexFitter::fit
virtual xAOD::Vertex * fit(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.
Definition: SequentialVertexFitter.cxx:365
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::SequentialVertexFitter::m_maxZ
double m_maxZ
Definition: SequentialVertexFitter.h:204
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Trk::SequentialVertexFitter::m_maxR
double m_maxR
Definition: SequentialVertexFitter.h:203
Trk::NeutralPerigee
ParametersT< NeutralParametersDim, Neutral, PerigeeSurface > NeutralPerigee
Definition: NeutralParameters.h:31
Trk::LinkToXAODTrackParticle
Element link to XAOD TrackParticle.
Definition: LinkToXAODTrackParticle.h:33
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
fitFailed
bool fitFailed
Definition: fbtTestToyMC.cxx:116
Trk::ParametersBase
Definition: ParametersBase.h:55
xAOD::Vertex_v1::z
float z() const
Returns the z position.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::LinkToXAODNeutralParticle
Element link to XAOD NeutralParticle.
Definition: LinkToXAODNeutralParticle.h:32
Trk::SequentialVertexFitter::m_useLooseConvergence
bool m_useLooseConvergence
Use loose convergence criterium (maxShift) or hard (+maxDeltaChi2)
Definition: SequentialVertexFitter.h:191
xAOD::Vertex_v1::addNeutralAtVertex
void addNeutralAtVertex(const ElementLink< NeutralParticleContainer > &tr, float weight=1.0)
Add a new neutral to the vertex.
Definition: Vertex_v1.cxx:323
xAOD::Vertex_v1::chiSquared
float chiSquared() const
Returns the of the vertex fit as float.
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
Trk::SequentialVertexFitter::m_doSmoothing
bool m_doSmoothing
Flag controlling optional smoothing.
Definition: SequentialVertexFitter.h:173
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::SequentialVertexFitter::reLinearizeTracks
void reLinearizeTracks(std::vector< Trk::VxTrackAtVertex > &tracks, const Amg::Vector3D &vrt) const
Relinearization on iterations.
Definition: SequentialVertexFitter.cxx:343
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
Trk::SequentialVertexFitter::linearizeTracks
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)
Definition: SequentialVertexFitter.cxx:280
Trk::SequentialVertexFitter::m_maxShift
float m_maxShift
Max shift (represents the convergence criterion)
Definition: SequentialVertexFitter.h:185
xAOD::Vertex_v1::vxTrackAtVertex
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
Definition: Vertex_v1.cxx:181
xAOD::Vertex_v1::vxTrackAtVertexAvailable
bool vxTrackAtVertexAvailable() const
Check if VxTrackAtVertices are attached to the object.
Definition: Vertex_v1.cxx:209
makeComparison.deltaR
float deltaR
Definition: makeComparison.py:36
xAOD::VxType::NotSpecified
@ NotSpecified
Default value, no explicit type set.
Definition: TrackingPrimitives.h:577
xAOD::Vertex_v1::setCovariancePosition
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
Trk::SequentialVertexFitter::m_maxStep
unsigned int m_maxStep
Max number of iterations to perform (in case of no convergence)
Definition: SequentialVertexFitter.h:179