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

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

#include <FullVertexFitter.h>

Inheritance diagram for Trk::FullVertexFitter:
Collaboration diagram for Trk::FullVertexFitter:

Public Types

enum  FitError {
  FITOK, MATINV, NEGTRCHI2, MAXCHI2,
  MAXTRCHI2, NOTRKS, NOFIT
}
 

Public Member Functions

virtual StatusCode initialize () override
 
 FullVertexFitter (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~FullVertexFitter ()
 standard destructor More...
 
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const Amg::Vector3D &startingPoint) const override
 Interface for ParametersBase with starting point. More...
 
virtual xAOD::Vertexfit (const std::vector< const TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &, const Amg::Vector3D &startingPoint) const override
 Interface for TrackParameters and NeutralParameters with starting point. More...
 
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex &constraint) const override
 Interface for ParametersBase with vertex constraint. More...
 
virtual xAOD::Vertexfit (const std::vector< const TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &, const xAOD::Vertex &constraint) const override
 Interface for TrackParameters and NeutralParameters with RecVertex starting point. More...
 
virtual xAOD::Vertexfit (const std::vector< const Trk::TrackParameters * > &perigeeList) const override
 Fit interface with no starting point or constraint. More...
 
virtual xAOD::Vertexfit (const std::vector< const TrackParameters * > &perigeeList, const std::vector< const Trk::NeutralParameters * > &) const override
 
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const Amg::Vector3D &startingPoint) const override
 *Interface for xAOD::TrackParticle with starting point
More...
 
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &, const Amg::Vector3D &startingPoint) const override
 *Interface for xAOD::TrackParticle and NeutralParticle with starting point
More...
 
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const xAOD::Vertex &constraint) const override
 
virtual xAOD::Vertexfit (const std::vector< const xAOD::TrackParticle * > &vectorTrk, const std::vector< const xAOD::NeutralParticle * > &, const xAOD::Vertex &constraint) const override
 

Private Attributes

unsigned int m_maxIterations
 
double m_maxDchi2PerNdf
 
ToolHandle< Trk::IVertexLinearizedTrackFactorym_linFactory
 Data members to store the results. More...
 

Detailed Description

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

Billoir. this algorithm tries to estimate the vertex position with refitting the track parameters.

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 37 of file FullVertexFitter.h.

Member Enumeration Documentation

◆ FitError

Enumerator
FITOK 
MATINV 
NEGTRCHI2 
MAXCHI2 
MAXTRCHI2 
NOTRKS 
NOFIT 

Definition at line 46 of file FullVertexFitter.h.

47  {
48  FITOK,
49  MATINV,
50  NEGTRCHI2,
51  MAXCHI2,
52  MAXTRCHI2,
53  NOTRKS,
54  NOFIT
55  };

Constructor & Destructor Documentation

◆ FullVertexFitter()

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

Definition at line 107 of file FullVertexFitter.cxx.

107  : base_class ( t,n,p ),
108  m_maxIterations ( 5 ),
109  m_maxDchi2PerNdf ( 0.000001 )
110 
111  {
112  declareProperty ( "MaxIterations", m_maxIterations );
113  declareProperty ( "MaxChi2PerNdf", m_maxDchi2PerNdf );
114  declareProperty ( "LinearizedTrackFactory", m_linFactory );
115  declareInterface<IVertexFitter> ( this );
116  }

◆ ~FullVertexFitter()

Trk::FullVertexFitter::~FullVertexFitter ( )
virtualdefault

standard destructor

Member Function Documentation

◆ fit() [1/10]

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

Definition at line 109 of file FullVertexFitter.h.

113  {
114  msg(MSG::WARNING) << "FullVertexFitter::fit(fit(const std::vector<const "
115  "TrackParameters*>&,const std::vector<const "
116  "Trk::NeutralParameters*>&) ignoring neutrals"
117  << endmsg;
118  return fit(perigeeList);
119  };

◆ fit() [2/10]

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

Interface for TrackParameters and NeutralParameters with starting point.

Definition at line 68 of file FullVertexFitter.h.

72  {
73  msg(MSG::WARNING)
74  << "FullVertexFitter::fit(fit(const std::vector<const "
75  "TrackParameters*>&,const std::vector<const "
76  "Trk::NeutralParameters*>&,const Amg::Vector3D&) ignoring neutrals"
77  << endmsg;
78  return fit(perigeeList, startingPoint);
79  };

◆ fit() [3/10]

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

Interface for TrackParameters and NeutralParameters with RecVertex starting point.

Definition at line 89 of file FullVertexFitter.h.

93  {
94  msg(MSG::WARNING)
95  << "FullVertexFitter::fit(fit(const std::vector<const "
96  "TrackParameters*>&,const std::vector<const "
97  "Trk::NeutralParameters*>&,const xAOD::Vertex&) ignoring neutrals"
98  << endmsg;
99  return fit(perigeeList, constraint);
100  };

◆ fit() [4/10]

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

Fit interface with no starting point or constraint.

(0,0,0) will be assumed.

Definition at line 478 of file FullVertexFitter.cxx.

479  {
480  Amg::Vector3D tmpVtx(0.,0.,0.);
481  return fit ( perigeeList, tmpVtx );
482  }

◆ fit() [5/10]

xAOD::Vertex * Trk::FullVertexFitter::fit ( const std::vector< const Trk::TrackParameters * > &  perigeeList,
const Amg::Vector3D startingPoint 
) const
overridevirtual

Interface for ParametersBase with starting point.

Definition at line 121 of file FullVertexFitter.cxx.

123  {
124  xAOD::Vertex constraint;
125  constraint.makePrivateStore();
126  constraint.setPosition( firstStartingPoint );
127  constraint.setCovariancePosition( AmgSymMatrix(3)(3,3) );
128  constraint.setFitQuality( 0.,0.);
129  return fit ( originalPerigees, constraint );
130  }

◆ fit() [6/10]

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

Interface for ParametersBase with vertex constraint.

the position of the constraint is ALWAYS the starting point

Definition at line 134 of file FullVertexFitter.cxx.

136  {
137  if ( originalPerigees.empty() )
138  {
139  ATH_MSG_VERBOSE("No tracks to fit in this event.");
140  return nullptr;
141  }
142 
143  /* Initialisation of variables */
144  double chi2 = 2000000000000.;
145  unsigned int nRP = originalPerigees.size(); // Number of tracks to fit
146  int ndf = nRP * ( 5-3 ) - 3; // Number of degrees of freedom
147  if ( ndf < 0 ) {ndf = 1;}
148 
149  /* Determine if we are doing a constraint fit.*/
150  bool constraint = false;
151  if ( firstStartingPoint.covariancePosition().trace() != 0. )
152  {
153  constraint = true;
154  ndf += 3;
155  ATH_MSG_DEBUG("Fitting with constraint.");
156  ATH_MSG_VERBOSE(firstStartingPoint.covariancePosition().inverse());
157  }
158 
159  double chi2New=0.;
160 
161  Amg::Vector3D linPoint ( firstStartingPoint.position() ); // linearization point for track parameters (updated for every iteration)
162 
163  Amg::Vector3D p0;
164 
165  std::vector<Amg::Vector3D> mom_at_Origin;
166 
167  xAOD::Vertex * fittedVertex = new xAOD::Vertex;
168  fittedVertex->makePrivateStore(); // xAOD::VertexContainer will take ownership of AuxStore when ActualVertex is added to it
169 
170  std::vector<VxTrackAtVertex> tracksAtVertex;
171  std::vector<BilloirTrack> billoirTracks;
172 
173  /* Iterate fits until the fit criteria are met, or the number of max
174  iterations is reached. */
175  for ( unsigned int niter=0; niter < m_maxIterations; ++niter )
176  {
177  ATH_MSG_VERBOSE("Start of iteration " << niter << ", starting point ("
178  << linPoint [0] << ", " << linPoint [1] << ", " << linPoint [2]
179  << ") and " << originalPerigees.size() << " tracks.");
180 
181  billoirTracks.clear();
182  chi2New = 0.;
183 
184  AmgMatrix(2,3) D;
185  BilloirVertex billoirVertex;
186 
187  /* Linearize the track parameters wrt. starting point of the fit */
188  Amg::Vector3D globalPosition = linPoint;
189  Trk::PerigeeSurface perigeeSurface ( globalPosition );
190 
191  /* Extrapolate the perigees to the startpoint of the fit */
192  unsigned int count(0);
193  for (const auto *originalPerigee : originalPerigees)
194  {
195 
196  if ( niter == 0 )
197  {
198  // need to cast to access parameters() (this is to guarantee that the code knows if it is neutrals or charged parameters)
199  const Trk::TrackParameters* chargedParameters ( nullptr );
200  chargedParameters = dynamic_cast<const Trk::TrackParameters*> ( originalPerigee );
201  if ( chargedParameters==nullptr )
202  {
203  ATH_MSG_ERROR("Track parameters are not charged tracks ... full fit aborted (this will be handled correctly soon)");
204  return nullptr;
205  }
206 
207 
208  p0.x() = chargedParameters->parameters() [Trk::phi];
209  p0.y() = chargedParameters->parameters() [Trk::theta];
210  p0.z() = chargedParameters->parameters() [Trk::qOverP] ;
211  mom_at_Origin.push_back ( p0 );
212 
213  }
214 
215  // FOR NOW THE ONLY WAY TO CHECK IF EXTRAPOLATION WORKED IS TO CHECK THE RETURN POINTER
216  // if it is ZERO then take the original perigee
217  // there is a tiny tiny chance that the extrapolation fails because of a non converging runge kutta procedure
218  // in all other cases it did not extrapolate because the reference surface of the original perigee
219  // is already given to the extrapolation point (or very close nearby)
220 
221  LinearizedTrack* linTrack = m_linFactory->linearizedTrack ( originalPerigee, linPoint );
222  if ( linTrack==nullptr )
223  {
224  ATH_MSG_DEBUG("Could not linearize track! Skipping this track!");
225  }
226  else
227  {
228  BilloirTrack locBilloirTrack;
229 
230  locBilloirTrack.originalPerigee = originalPerigee;
231  locBilloirTrack.linTrack = linTrack;
232  double d0 = linTrack->expectedParametersAtPCA()[Trk::d0];
233  double z0 = linTrack->expectedParametersAtPCA()[Trk::z0];
234  double phi = linTrack->expectedParametersAtPCA()[Trk::phi];
235  double theta = linTrack->expectedParametersAtPCA()[Trk::theta];
236  double qOverP = linTrack->expectedParametersAtPCA()[Trk::qOverP];
237 
238  // calculate f(V_0,p_0) f_d0 = f_z0 = 0
239  double f_phi = mom_at_Origin[count] ( 0 );
240  double f_theta = mom_at_Origin[count] ( 1 );
241  double f_qOverP = mom_at_Origin[count] ( 2 );
242 
243  //calculate Dper[i]
244  locBilloirTrack.Dper[0] = d0;
245  locBilloirTrack.Dper[1] = z0;
246  locBilloirTrack.Dper[2] = phi - f_phi;
247  locBilloirTrack.Dper[3] = theta - f_theta;
248  locBilloirTrack.Dper[4] = qOverP -f_qOverP;
249 
250  // the D matrix
251  AmgMatrix(5,3) D_mat;
252  D_mat.setZero();
253  D_mat = linTrack->positionJacobian();
254 
255  // calculate the E matrix
256  AmgMatrix(5,3) E_mat;
257  E_mat.setZero();
258  E_mat = linTrack->momentumJacobian();
259 
260  // and cache martix operations related to these matrices
261  AmgMatrix(3,5) Dt_W_mat;
262  Dt_W_mat.setZero();
263  AmgMatrix(3,5) Et_W_mat;
264  Et_W_mat.setZero();
265  Dt_W_mat = D_mat.transpose() * ( linTrack->expectedWeightAtPCA() );
266  Et_W_mat = E_mat.transpose() * ( linTrack->expectedWeightAtPCA() );
267 
268  // these are the Billoir computed results
269  locBilloirTrack.Di_mat = D_mat;
270  locBilloirTrack.Ei_mat = E_mat;
271  locBilloirTrack.Gi_mat = Et_W_mat*E_mat;
272  locBilloirTrack.Bi_mat = Dt_W_mat * E_mat; // Di.T * Wi * Ei
273  locBilloirTrack.Ui_vec = Et_W_mat * locBilloirTrack.Dper; // Ei.T * Wi * dqi
274  locBilloirTrack.Ci_inv = Et_W_mat * E_mat ; // (Ei.T * Wi * Ei)^-1
275  // we need the inverse matrix here
276  locBilloirTrack.Ci_inv = locBilloirTrack.Ci_inv.inverse().eval();
277  // sum up over all tracks
278  billoirVertex.T_vec += Dt_W_mat * locBilloirTrack.Dper; // sum{Di.T * Wi * dqi}
279  billoirVertex.A_mat = billoirVertex.A_mat + Dt_W_mat * D_mat ; // sum{Di.T * Wi * Di}
280 
281  // remember those results for all tracks
282  locBilloirTrack.BCi_mat = locBilloirTrack.Bi_mat * locBilloirTrack.Ci_inv; // BCi = Bi * Ci^-1
283 
284  // and some summed results
285  billoirVertex.BCU_vec += locBilloirTrack.BCi_mat * locBilloirTrack.Ui_vec; // sum{Bi * Ci^-1 * Ui}
286  billoirVertex.BCB_mat = billoirVertex.BCB_mat + locBilloirTrack.BCi_mat * locBilloirTrack.Bi_mat.transpose() ;// sum{Bi * Ci^-1 * Bi.T}
287  billoirTracks.push_back ( locBilloirTrack );
288  count++;
289 
290  }
291  }
292 
293  // calculate delta (billoirFrameOrigin-position), might be changed by the beam-const
294  Amg::Vector3D V_del = billoirVertex.T_vec - billoirVertex.BCU_vec; // V_del = T-sum{Bi*Ci^-1*Ui}
295  AmgMatrix(3,3) V_wgt_mat = billoirVertex.A_mat - billoirVertex.BCB_mat; // V_wgt = A-sum{Bi*Ci^-1*Bi.T}
296 
297  if ( constraint )
298  {
299  // add V_del += wgtconst * (billoirFrameOrigin - Vconst) and V_wgt +=wgtconst
300  Amg::Vector3D constraintPosInBilloirFrame;
301  constraintPosInBilloirFrame.setZero();
302  // this will be 0 for first iteration but != 0 from second on
303  constraintPosInBilloirFrame[0] = firstStartingPoint.position() [0]-linPoint [0];
304  constraintPosInBilloirFrame[1] = firstStartingPoint.position() [1]-linPoint [1];
305  constraintPosInBilloirFrame[2] = firstStartingPoint.position() [2]-linPoint [2];
306 
307  V_del += firstStartingPoint.covariancePosition().inverse() *constraintPosInBilloirFrame;
308  V_wgt_mat += firstStartingPoint.covariancePosition().inverse();
309  }
310  // cov(delta_V) = V_wgt^-1
311  AmgMatrix(3,3) cov_delta_V_mat = V_wgt_mat.inverse().eval() ;
312 
313  // delta_V = cov_(delta_V) * V_del;
314  Amg::Vector3D delta_V = cov_delta_V_mat * V_del;
315  /* Momentum Calculation follows here. */
316  /* ---------------------------------------------------------------------------------------- */
317  std::vector<AmgMatrix(5,5)> cov_delta_P_mat ( nRP );
318  std::vector<double> chi2PerTrack;
319  chi2PerTrack.clear();
320 
321  // ===> loop over tracks
322  std::vector<BilloirTrack>::iterator BTIter;
323  int iRP =0;
324  for ( BTIter = billoirTracks.begin(); BTIter != billoirTracks.end() ; ++BTIter )
325  {
326  // delta_P calculation
327  BilloirTrack locP ( ( *BTIter ) );
328  Amg::Vector3D delta_P = ( locP.Ci_inv ) * ( ( locP.Ui_vec )- ( locP.Bi_mat.transpose() ) *delta_V );
329  mom_at_Origin[iRP] ( 0 ) += delta_P[0];
330  if ( fabs ( mom_at_Origin[iRP] ( 0 ) ) > 10*M_PI )
331  { // protect while loop
332  if (msgLvl(MSG::WARNING))
333  {
334  msg(MSG::WARNING) << " Track direction angles have numerical problems, stop perigee parameter update." << endmsg;
335  msg(MSG::WARNING) << " Phi value: "<<mom_at_Origin[iRP] ( 0 ) <<endmsg;
336  }
337  return nullptr;
338  }
339  mom_at_Origin[iRP] ( 1 ) += delta_P[1];
340  if ( fabs ( mom_at_Origin[iRP] ( 0 ) ) > 5*M_PI )
341  { // protect while loop
342  if (msgLvl(MSG::WARNING))
343  {
344  msg(MSG::WARNING) << " Track direction angles have numerical problems, stop perigee parameter update." << endmsg;
345  msg(MSG::WARNING) << " Theta value: "<<mom_at_Origin[iRP] ( 1 ) <<endmsg;
346  }
347  return nullptr;
348  }
349  mom_at_Origin[iRP] ( 2 ) += delta_P[2];
350  // mom_at_Origin[iRP](0) -= M_PI > M_PI ? M_PI : 0;
351  // mom_at_Origin[iRP](0) += M_PI < -M_PI ? M_PI : 0;
352  //correct phi, theta coordinates
353  while ( fabs ( mom_at_Origin[iRP] ( 0 ) ) > M_PI ) mom_at_Origin[iRP] ( 0 ) += ( mom_at_Origin[iRP] ( 0 ) > 0 ) ? -2*M_PI : 2*M_PI;
354  while ( mom_at_Origin[iRP] ( 1 ) > 2*M_PI ) mom_at_Origin[iRP] ( 1 ) -= 2*M_PI;
355  while ( mom_at_Origin[iRP] ( 1 ) < -M_PI ) mom_at_Origin[iRP] ( 1 ) += M_PI;
356  if ( mom_at_Origin[iRP] ( 1 ) > M_PI )
357  {
358  mom_at_Origin[iRP] ( 1 ) = 2*M_PI - mom_at_Origin[iRP] ( 1 );
359  // cppcheck-suppress identicalInnerCondition; false positive
360  if ( mom_at_Origin[iRP] ( 0 ) >= 0 ) mom_at_Origin[iRP] ( 0 ) += ( mom_at_Origin[iRP] ( 0 ) >0 ) ? -M_PI : M_PI;
361  }
362  if ( mom_at_Origin[iRP] ( 1 ) < 0.0 )
363  {
364  mom_at_Origin[iRP] ( 1 ) = - mom_at_Origin[iRP] ( 1 );
365  // cppcheck-suppress identicalInnerCondition; false positive
366  if ( mom_at_Origin[iRP] ( 0 ) >= 0 ) mom_at_Origin[iRP] ( 0 ) += ( mom_at_Origin[iRP] ( 0 ) >0 ) ? -M_PI : M_PI;
367  }
368 
369  //calculate 5x5 cov_delta_P matrix
370  // d(d0,z0,phi,theta,qOverP)/d(x,y,z,phi,theta,qOverP)-transformation matrix
371  AmgMatrix(5,6) trans_mat;
372  trans_mat.setZero();
373  trans_mat ( 0,0 ) = locP.Di_mat ( 0,0 ); trans_mat ( 0,1 ) = locP.Di_mat ( 0,1 );
374  trans_mat ( 1,0 ) = locP.Di_mat ( 1,0 ); trans_mat ( 1,1 ) = locP.Di_mat ( 1,1 ); trans_mat ( 1,2 ) = 1.;
375  trans_mat ( 2,3 ) = 1.; trans_mat ( 3,4 ) = 1.; trans_mat ( 4,5 ) = 1.;
376 
377  //some intermediate calculations to get 5x5 matrix
378  //cov(V,V)
379  AmgMatrix(3,3) V_V_mat; V_V_mat.setZero(); V_V_mat = cov_delta_V_mat ;
380  // std::cout<<"V_V_mat = "<<V_V_mat<<std::endl;
381  //cov(V,P)
382  AmgMatrix(3,3) V_P_mat; V_P_mat.setZero(); V_P_mat = -cov_delta_V_mat*locP.Gi_mat*locP.Ci_inv ;
383  // std::cout<<"V_P_mat = "<<V_P_mat<<std::endl;
384  //cov(P,P)
385  AmgMatrix(3,3) P_P_mat; P_P_mat.setZero(); P_P_mat = locP.Ci_inv + locP.BCi_mat.transpose() *cov_delta_V_mat*locP.BCi_mat ;
386  // std::cout<<"P_P_mat = "<<P_P_mat<<std::endl;
387 
388  AmgMatrix(6,6) cov_mat;
389  cov_mat.setZero();
390  cov_mat.block<3,3>(0,3) = V_P_mat;
391  cov_mat.block<3,3>(3,0) = V_P_mat.transpose() ;
392  cov_mat.block<3,3>(0,0) = V_V_mat ;
393  cov_mat.block<3,3>(3,3) = P_P_mat ;
394 
395  // cov_delta_P calculation
396  // std::cout<<"trans_mat = "<<trans_mat<<std::endl;
397  cov_delta_P_mat[iRP] = trans_mat*cov_mat*trans_mat.transpose() ;
398  // std::cout<<"cov_delta_P_mat[iRP] = "<<cov_delta_P_mat[iRP]<<std::endl;
399 
400  ++iRP;
401 
402  /* Calculate chi2 per track. */
403  ( *BTIter ).chi2= ( ( ( *BTIter ).Dper- ( *BTIter ).Di_mat*delta_V - ( *BTIter ).Ei_mat*delta_P ).transpose() * ( *BTIter ).linTrack->expectedWeightAtPCA() * ( ( *BTIter ).Dper - ( *BTIter ).Di_mat*delta_V - ( *BTIter ).Ei_mat*delta_P ) ) [0];
404 
405  if ( ( *BTIter ).chi2 < 0 )
406  {
407  ATH_MSG_WARNING( "FullVertexFitter::calculate: error in chi2_per_track" );
408  return nullptr;
409  }
410  chi2New += ( *BTIter ).chi2;
411  }
412 
413  if ( constraint )
414  {
415  Amg::Vector3D deltaTrk;
416  deltaTrk.setZero();
417  // last term will also be 0 again but only in the first iteration
418  // = calc. vtx in billoir frame - ( constraint pos. in billoir frame )
419  deltaTrk[0] = delta_V[0] - ( firstStartingPoint.position() [0] - linPoint [0] );
420  deltaTrk[1] = delta_V[1] - ( firstStartingPoint.position() [1] - linPoint [1] );
421  deltaTrk[2] = delta_V[2] - ( firstStartingPoint.position() [2] - linPoint [2] );
422  chi2New += ( deltaTrk.transpose() * firstStartingPoint.covariancePosition().inverse() * deltaTrk ) [0];
423  }
424 
425  /* assign new linearization point (= new vertex position in global frame) */
426  Amg::Vector3D tmpPos ( linPoint );
427  tmpPos[0] += delta_V[0]; tmpPos[1] += delta_V[1]; tmpPos[2] += delta_V[2];
428  linPoint = tmpPos;
429 
430  if ( chi2New < chi2 )
431  {
432  /* Store the vertex */
433  chi2 = chi2New;
434  //const AmgMatrix(3,3) * newCovarianceMatrix = &cov_delta_V_mat ;
435  //const AmgMatrix(3,3) newErrorMatrix = newCovarianceMatrix->inverse().eval();
436  //fittedVertex = RecVertex ( linPoint.position(), newErrorMatrix, ndf, chi2 );
437 
438  //the cov_delta_V_mat is already the inverted form. -katy 2/2/16
439  fittedVertex->setPosition( linPoint );
440  fittedVertex->setCovariancePosition( cov_delta_V_mat );
441  fittedVertex->setFitQuality( chi2, ndf );
442 
443  // new go through vector and delete entries
444  /* // TODO: not needed anymore, tracksAtVertex doesn't store pointers - just the objects themselves <David Shope> (EDM Migration) 03/21/16
445  for ( std::vector<Trk::VxTrackAtVertex*>::const_iterator itr = tracksAtVertex.begin();
446  itr != tracksAtVertex.end(); ++itr )
447  {
448  delete ( *itr );
449  }
450  */
451 
452  tracksAtVertex.clear();
453  /* Store the tracks at vertex */
454  Amg::Vector3D Vertex(linPoint[0], linPoint[1], linPoint[2]);
456  TrackParameters * refittedPerigee ( nullptr );
457  unsigned int iter= 0;
459  for ( BTIter = billoirTracks.begin(); BTIter != billoirTracks.end() ; ++BTIter )
460  {
461  const AmgMatrix(5,5) * newTrackCovarianceMatrix = &cov_delta_P_mat[iter] ;
462  //Covariance matrix does not need to be inverted:
463  // AmgMatrix(5,5) newTrackErrorMatrix = (AmgMatrix(5,5)) newTrackCovarianceMatrix->inverse().eval();
464  AmgMatrix(5,5) newTrackErrorMatrix = (AmgMatrix(5,5)) newTrackCovarianceMatrix->eval();
465  refittedPerigee = new Trk::Perigee ( 0.,0.,mom_at_Origin[iter][0],mom_at_Origin[iter][1],mom_at_Origin[iter][2],
466  Surface, std::move(newTrackErrorMatrix) );
467  Trk::VxTrackAtVertex* tmpVxTrkAtVtx = new Trk::VxTrackAtVertex ( ( *BTIter ).chi2, refittedPerigee, ( *BTIter ).originalPerigee );
468  tracksAtVertex.push_back ( *tmpVxTrkAtVtx );
469  iter ++;
470  }
471  }
472  } // end of iteration
473  fittedVertex->vxTrackAtVertex() = tracksAtVertex;
474  //ATH_MSG_VERBOSE("Final Vertex Fitted: " << fittedVxCandidate->recVertex()); // TODO: can no longer print vertex after converting to xAOD
475  return fittedVertex;
476  }

◆ fit() [7/10]

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

*Interface for xAOD::TrackParticle with starting point

Definition at line 487 of file FullVertexFitter.cxx.

488  {
489  xAOD::Vertex constraint;
490  constraint.makePrivateStore();
491  constraint.setPosition( startingPoint );
492  constraint.setCovariancePosition( AmgSymMatrix(3)(3,3) );
493  constraint.setFitQuality( 0.,0.);
494  return fit(vectorTrk, constraint);
495  }//end of the xAOD starting point fit method

◆ fit() [8/10]

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

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

Definition at line 128 of file FullVertexFitter.h.

132  {
133  msg(MSG::WARNING)
134  << "FullVertexFitter::fit(fit(const std::vector<const "
135  "TrackParticle*>&,const std::vector<const "
136  "Trk::NeutralParticle*>&,const Amg::Vector3D&) ignoring neutrals"
137  << endmsg;
138  return fit(vectorTrk, startingPoint);
139  };

◆ fit() [9/10]

virtual xAOD::Vertex* Trk::FullVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > &  vectorTrk,
const std::vector< const xAOD::NeutralParticle * > &  ,
const xAOD::Vertex constraint 
) const
inlineoverridevirtual
  • Interface for xAOD::TrackParticle and NeutralParticle with vertex constraint the position of the constraint is ALWAYS the starting point

Definition at line 150 of file FullVertexFitter.h.

154  {
155  msg(MSG::WARNING)
156  << "FullVertexFitter::fit(fit(const std::vector<const "
157  "TrackParticle*>&,const std::vector<const "
158  "Trk::NeutralParticle*>&,const xAOD::Vertex&) ignoring neutrals"
159  << endmsg;
160  return fit(vectorTrk, constraint);
161  };

◆ fit() [10/10]

xAOD::Vertex * Trk::FullVertexFitter::fit ( const std::vector< const xAOD::TrackParticle * > &  vectorTrk,
const xAOD::Vertex constraint 
) const
overridevirtual
  • Interface for xAOD::TrackParticle with vertex constraint the position of the constraint is ALWAYS the starting point

Definition at line 498 of file FullVertexFitter.cxx.

499  {
500  if(vectorTrk.empty())
501  {
502  msg(MSG::INFO)<<"Empty vector of tracks passed"<<endmsg;
503  return nullptr;
504  }
505 
506  //making a list of perigee out of the vector of tracks
507  std::vector<const Trk::TrackParameters*> measuredPerigees;
508 
509  for(const auto *i : vectorTrk)
510  {
511  const Trk::TrackParameters * tmpMeasPer = &(i->perigeeParameters());
512 
513  if(tmpMeasPer!=nullptr) measuredPerigees.push_back(tmpMeasPer);
514  else msg(MSG::INFO)<<"Failed to dynamic_cast this track parameters to perigee"<<endmsg; //TODO: Failed to implicit cast the perigee parameters to track parameters?
515  }
516 
517 
518  xAOD::Vertex* fittedVertex = fit( measuredPerigees, constraint );
519 
520  //assigning the input tracks to the fitted vertex through VxTrackAtVertices
521  {
522  if( fittedVertex->vxTrackAtVertexAvailable() ) // TODO: I don't think vxTrackAtVertexAvailable() does the same thing as a null pointer check!
523  {
524  if(!fittedVertex->vxTrackAtVertex().empty())
525  {
526  for(unsigned int i = 0; i <vectorTrk.size(); ++i)
527  {
528 
529  LinkToXAODTrackParticle * linkTT = new LinkToXAODTrackParticle;
530  linkTT->setElement(vectorTrk[i]);
531 
532  // vxtrackatvertex takes ownership!
533  ( fittedVertex->vxTrackAtVertex() )[i].setOrigTrack(linkTT);
534  }//end of loop for setting orig tracks in.
535  }//end of protection against unsuccessfull updates (no tracks were added)
536  }//end of vector of tracks check
537  }//end of pointer check
538 
539  //now set links to xAOD::TrackParticles directly in the xAOD::Vertex
540  unsigned int VTAVsize = fittedVertex->vxTrackAtVertex().size();
541  for (unsigned int i = 0 ; i < VTAVsize ; ++i)
542  {
543  Trk::VxTrackAtVertex* VTAV = &( fittedVertex->vxTrackAtVertex().at(i) );
544  //TODO: Will this pointer really hold 0 if no VxTrackAtVertex is found?
545  if (not VTAV){
546  ATH_MSG_WARNING (" Trying to set link to xAOD::TrackParticle. The VxTrackAtVertex is not found");
547  continue;
548  }
549 
550  Trk::ITrackLink* trklink = VTAV->trackOrParticleLink();
551 
552  // See if the trklink is to an xAOD::TrackParticle
553  Trk::LinkToXAODTrackParticle* linkToXAODTP = dynamic_cast<Trk::LinkToXAODTrackParticle*>(trklink);
554  if (linkToXAODTP)
555  {
556 
557  //Now set the new link to the xAOD vertex
558  fittedVertex->addTrackAtVertex(*linkToXAODTP, VTAV->weight());
559 
560  } else {
561  ATH_MSG_WARNING ("Skipping track. Trying to set link to something else than xAOD::TrackParticle. Neutrals not supported.");
562  }
563  } //end of loop
564 
565  return fittedVertex;
566 
567  }//end of the xAOD constrained fit method

◆ initialize()

StatusCode Trk::FullVertexFitter::initialize ( )
overridevirtual

Definition at line 90 of file FullVertexFitter.cxx.

91  {
92 
93 
94  if ( m_linFactory.retrieve().isFailure() )
95  {
96  msg(MSG::FATAL)<< "Failed to retrieve tool " << m_linFactory << endmsg;
97  return StatusCode::FAILURE;
98  }
99 
100 
101  msg(MSG::INFO) << "Retrieved tool " << m_linFactory << endmsg;
102 
103 
104  return StatusCode::SUCCESS;
105  }

Member Data Documentation

◆ m_linFactory

ToolHandle<Trk::IVertexLinearizedTrackFactory> Trk::FullVertexFitter::m_linFactory
private

Data members to store the results.

Definition at line 169 of file FullVertexFitter.h.

◆ m_maxDchi2PerNdf

double Trk::FullVertexFitter::m_maxDchi2PerNdf
private

Definition at line 165 of file FullVertexFitter.h.

◆ m_maxIterations

unsigned int Trk::FullVertexFitter::m_maxIterations
private

Definition at line 164 of file FullVertexFitter.h.


The documentation for this class was generated from the following files:
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
covarianceTool.ndf
ndf
Definition: covarianceTool.py:678
Trk::AmgMatrix
AmgMatrix(3, 3) NeutralParticleParameterCalculator
Definition: NeutralParticleParameterCalculator.cxx:233
xAOD::Vertex_v1::setPosition
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
xAOD::Vertex_v1::setFitQuality
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
Definition: Vertex_v1.cxx:150
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Trk::VxTrackAtVertex
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Definition: VxTrackAtVertex.h:77
Trk::FullVertexFitter::m_maxDchi2PerNdf
double m_maxDchi2PerNdf
Definition: FullVertexFitter.h:165
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition: Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
Surface
Definition: Trigger/TrigAccel/TrigCudaFitter/src/Surface.h:7
M_PI
#define M_PI
Definition: ActiveFraction.h:11
Trk::Perigee
ParametersT< 5, Charged, PerigeeSurface > Perigee
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:29
Trk::z0
@ z0
Definition: ParamDefs.h:70
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
Trk::FullVertexFitter::MATINV
@ MATINV
Definition: FullVertexFitter.h:49
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
Trk::TrackParameters
ParametersBase< 5, Charged > TrackParameters
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:24
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
Trk::FullVertexFitter::NOTRKS
@ NOTRKS
Definition: FullVertexFitter.h:53
Trk::AmgSymMatrix
AmgSymMatrix(5) &GXFTrackState
Definition: GXFTrackState.h:156
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::FullVertexFitter::NEGTRCHI2
@ NEGTRCHI2
Definition: FullVertexFitter.h:50
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::FullVertexFitter::MAXCHI2
@ MAXCHI2
Definition: FullVertexFitter.h:51
lumiFormat.i
int i
Definition: lumiFormat.py:92
Trk::FullVertexFitter::m_maxIterations
unsigned int m_maxIterations
Definition: FullVertexFitter.h:161
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:72
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
vector
Definition: MultiHisto.h:13
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
Trk::LinkToXAODTrackParticle
Element link to XAOD TrackParticle.
Definition: LinkToXAODTrackParticle.h:33
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::FullVertexFitter::FITOK
@ FITOK
Definition: FullVertexFitter.h:48
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Trk::d0
@ d0
Definition: ParamDefs.h:69
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:172
Trk::FullVertexFitter::m_linFactory
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_linFactory
Data members to store the results.
Definition: FullVertexFitter.h:169
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:73
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
Trk::FullVertexFitter::MAXTRCHI2
@ MAXTRCHI2
Definition: FullVertexFitter.h:52
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
Trk::phi
@ phi
Definition: ParamDefs.h:81
Trk::FullVertexFitter::fit
virtual xAOD::Vertex * fit(const std::vector< const Trk::TrackParameters * > &perigeeList, const Amg::Vector3D &startingPoint) const override
Interface for ParametersBase with starting point.
Definition: FullVertexFitter.cxx:121
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
xAOD::Vertex_v1::setCovariancePosition
void setCovariancePosition(const AmgSymMatrix(3)&covariancePosition)
Sets the vertex covariance matrix.
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
Trk::FullVertexFitter::NOFIT
@ NOFIT
Definition: FullVertexFitter.h:54