ATLAS Offline Software
InDetJetFitterUtils.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  InDetJetFitterUtils.cxx - Description
7  -------------------
8 
9  begin : December 2007
10  authors: Giacinto Piacquadio (University of Freiburg)
11  email : nicola.giacinto.piacquadio@cern.ch
12  changes: new!
13 
14  2007 (c) Atlas Detector Software
15 
16  Look at the header file for more information.
17 
18  ***************************************************************************/
19 
21 
23 #include "VxVertex/VxCandidate.h"
30 
31 #include <TMath.h>
32 //#include "TrkExInterfaces/IExtrapolator.h"
33 
34 //#include "TrkVertexFitterInterfaces/IVertexLinearizedTrackFactory.h"
35 #include "CLHEP/Vector/ThreeVector.h"
38 
39 
40 #if 0
41 namespace
42 {
43  CLHEP::HepMatrix getPhiThetaQOverPToPxPyPzJacobian(double qOverP,double theta,double phi) {
44  CLHEP::HepMatrix transform(3,3,0);
45  const double sinTheta(sin(theta));
46  const double sinPhi(sin(phi));
47  const double cosTheta(cos(theta));
48  const double cosPhi(cos(phi));
49  const double absQoP(fabs(qOverP));
50  //
51  transform[0][0]=-1./absQoP*sinTheta*sinPhi;
52  transform[0][1]=1./absQoP*sinTheta*cosPhi;
53  transform[0][2]=0.;
54  transform[1][0]=1./absQoP*cosTheta*cosPhi;
55  transform[1][1]=1./absQoP*cosTheta*sinPhi;
56  transform[1][2]=-1./absQoP*sinTheta;
57  transform[2][0]=-1./qOverP/absQoP*sinTheta*cosPhi; //?? why not just take sign of qOverP
58  transform[2][1]=-1./qOverP/absQoP*sinTheta*sinPhi; //??
59  transform[2][2]=-1./qOverP/absQoP*cosTheta; //??
60  return transform.T();
61  }
62 
63 }
64 #endif
65 
66 namespace InDet
67 {
68 
69  InDetJetFitterUtils::InDetJetFitterUtils(const std::string& t, const std::string& n, const IInterface* p) :
70  AthAlgTool(t,n,p),
71  m_linearizedTrackFactoryIsAvailable(false)
72  {
73 
74  declareInterface< InDetJetFitterUtils >(this) ;
75 
76  }
77 
78 
80 
81 
83 
84  if (!m_LinearizedTrackFactory.empty())
85  {
87  if (sc.isFailure()) {
88  msg(MSG::FATAL) << "Could not find TrackLinearizer tool." << endmsg;
89  return StatusCode::FAILURE;
90  }
91  else
92  {
94  }
95 
96  }
97 
98  if (!m_extrapolator.empty())
99  {
100  StatusCode sc=m_extrapolator.retrieve();
101  if (sc.isFailure()) {
102  msg(MSG::FATAL) << "Could not find Extrapolator tool." << endmsg;
103  return StatusCode::FAILURE;
104  }
105  }
106 
107  return StatusCode::SUCCESS;
108  }
109 
110 
112  const AmgSymMatrix(3) & vrt_cov,
113  const AmgSymMatrix(3) & vrt_weight) const
114  {
115 
116  const AmgMatrix(5,3) & A = linTrack->positionJacobian();
117  const AmgMatrix(5,3) & B = linTrack->momentumJacobian();
118  const AmgSymMatrix(5) & trkParametersWeight = linTrack->expectedWeightAtPCA();
119  AmgSymMatrix(3) Sm = B.transpose() * trkParametersWeight * B;
120  //using determinant as protection - better solution to come...
121  Sm = Sm.inverse().eval();
122  if(Sm.determinant()==0){
123  msg(MSG::WARNING) << "Inversion of S matrix fails in track refit" << endmsg;
124  msg(MSG::WARNING) << " This track is returned not refitted" << endmsg;
125  throw std::string("Inversion of S matrix fails in track parameters refit");
126  }
127  AmgMatrix(3,3) posMomentumCovariance = -vrt_cov * A.transpose() * trkParametersWeight * B *Sm;
128  AmgSymMatrix(3) momentumCovariance = Sm + vrt_weight.similarityT(posMomentumCovariance);
129 
130  return std::pair<AmgMatrix(3,3),AmgSymMatrix(3)>(posMomentumCovariance,momentumCovariance);
131  }
132 
133  // std::pair<double,double> InDetJetFitterUtils::compatibility(const Trk::ParametersBase<5,Trk::Charged> & measPerigee,
134  //const Trk::RecVertex & vertex) const
135  std::pair<double,double> InDetJetFitterUtils::compatibility(const Trk::TrackParameters & measPerigee,
136  const Trk::RecVertex & vertex) const
137  {
138 
140  {
141  msg(MSG::ERROR) << " No LinearizedTrackFactory defined. Cannot calculate compatibility. 0 compatibility returned" << endmsg;
142  return std::pair<double,double>(0,0);
143  }
144 
145 
146  Trk::LinearizedTrack* myLinearizedTrack=m_LinearizedTrackFactory->linearizedTrack(&measPerigee,vertex.position());
147 
148  Amg::Vector3D vertexPosition;
149  vertexPosition[0]=vertex.position()[0];
150  vertexPosition[1]=vertex.position()[1];
151  vertexPosition[2]=vertex.position()[2];
152  // CLHEP::HepVector residual=myLinearizedTrack->positionJacobian()*vertexPosition+
153  // myLinearizedTrack->momentumJacobian()*myLinearizedTrack->expectedMomentumAtPCA()+
154  // myLinearizedTrack->constantTerm()-measPerigee.parameters();
155 
156 
157  const AmgSymMatrix(5) & ExpectedCovariance=myLinearizedTrack->expectedCovarianceAtPCA();
158 
159  AmgSymMatrix(2) weightReduced=ExpectedCovariance.block<2,2>(0,0);
160 
161  AmgSymMatrix(2) errorVertexReduced=vertex.covariancePosition().similarity(myLinearizedTrack->positionJacobian()).block<2,2>(0,0);
162 
163  weightReduced+=errorVertexReduced;
164 
165  weightReduced.inverse().eval();
166 
167  //using determinant as protection - better solution to come...
168  if(weightReduced.determinant()==0)
169  {
170  msg(MSG::WARNING) << " Problem inverting cov matrix in compatibility method" << endmsg;
171  }
172  //double returnv2=weightReduced.similarity(myLinearizedTrack->expectedParametersAtPCA().block<2,2>(0,0));
173 
174  Amg::Vector2D paramsReduced((myLinearizedTrack->expectedParametersAtPCA())[0],(myLinearizedTrack->expectedParametersAtPCA())[1]);
175 
176  double returnv2= paramsReduced.transpose() * weightReduced.inverse() * paramsReduced;
177 
178  delete myLinearizedTrack;
179  myLinearizedTrack=nullptr;
180 
181  return std::pair<double,double>(returnv2,0);
182  }
183 
184  std::pair<double,double> InDetJetFitterUtils::compatibility(const Trk::ParametersBase<5,Trk::Neutral> & measPerigee,
185  const Trk::RecVertex & vertex) const
186  {
187 
189  {
190  msg(MSG::ERROR) << " No LinearizedTrackFactory defined. Cannot calculate compatibility. 0 compatibility returned" << endmsg;
191  return std::pair<double,double>(0,0);
192  }
193 
194 
195  Trk::LinearizedTrack* myLinearizedTrack=m_LinearizedTrackFactory->linearizedTrack(&measPerigee,vertex.position());
196  Amg::Vector3D vertexPosition(3);
197  vertexPosition[0]=vertex.position()[0];
198  vertexPosition[1]=vertex.position()[1];
199  vertexPosition[2]=vertex.position()[2];
200  // CLHEP::HepVector residual=myLinearizedTrack->positionJacobian()*vertexPosition+
201  // myLinearizedTrack->momentumJacobian()*myLinearizedTrack->expectedMomentumAtPCA()+
202  // myLinearizedTrack->constantTerm()-measPerigee.parameters();
203 
204  const AmgSymMatrix(5) & ExpectedCovariance=myLinearizedTrack->expectedCovarianceAtPCA();
205 
206  AmgSymMatrix(2) weightReduced=ExpectedCovariance.block<2,2>(0,0);
207 
208  AmgSymMatrix(2) errorVertexReduced=vertex.covariancePosition().similarity(myLinearizedTrack->positionJacobian()).block<2,2>(0,0);
209 
210  weightReduced+=errorVertexReduced;
211 
212  weightReduced.inverse().eval();
213  //using determinant as protection - better solution to come...
214  if(weightReduced.determinant()==0)
215  {
216  msg(MSG::WARNING) << " Problem inverting cov matrix in compatibility method" << endmsg;
217  }
218  Amg::Vector2D paramsReduced((myLinearizedTrack->expectedParametersAtPCA())[0],(myLinearizedTrack->expectedParametersAtPCA())[1]);
219 
220  double returnv2= paramsReduced.transpose() * weightReduced * paramsReduced;
221 
222 
223  delete myLinearizedTrack;
224  myLinearizedTrack=nullptr;
225 
226  return std::pair<double,double>(returnv2,0);
227  }
228 
229 
231  const Amg::Vector3D & jetMomentum,
232  const Trk::RecVertex & primaryVertex)
233  {
234  //the formula in the end is VERY simple!
235  //(the calculation to get this result a bit harder!!!)
236  //This is also equivalent to the calculaton implemented in the IP3D Tagger
237  //but it is expressed in a MUCH MUCH MUCH simpler way!!!
238  const Amg::Vector3D & primaryPos=primaryVertex.position();
239  const Amg::Vector3D & trackPos=track.position();
240  const Amg::Vector3D & trackMom=track.momentum();
241 
242  double sign=(jetMomentum.cross(trackMom)).dot(trackMom.cross(primaryPos-trackPos));
243  return sign>=0.?1.:-1;
244  }
245 
246  int InDetJetFitterUtils::getTwoTrackVtxCharge(const Trk::VxCandidate & myVxCandidate) const
247  {
248 
249  //now obtain the daughters of the two vertex
250  std::vector<Trk::VxTrackAtVertex*>::const_iterator vtxIter=myVxCandidate.vxTrackAtVertex()->begin();
251 
252  //obtain first track
253  Trk::VxTrackAtVertex* firstTrack(*vtxIter);
254 
255  //obtain second track
256  ++vtxIter;
257  Trk::VxTrackAtVertex* secondTrack(*vtxIter);
258 
259  //now obtain the momentum at the track (refitted)
260  const Trk::TrackParameters* firstTrackPerigee=firstTrack->perigeeAtVertex();
261 
262  //second
263  const Trk::TrackParameters* secondTrackPerigee=secondTrack->perigeeAtVertex();
264 
265  if (firstTrackPerigee==nullptr ||secondTrackPerigee==nullptr)
266  {
267  ATH_MSG_DEBUG( "No Perigee in one of the two tracks at vertex. No sensible charge returned." );
268  return -100;
269  }
270 
271  return (int)(
272  std::floor(
273  firstTrackPerigee->parameters()[Trk::qOverP]/
274  fabs(firstTrackPerigee->parameters()[Trk::qOverP])+
275  secondTrackPerigee->parameters()[Trk::qOverP]/
276  fabs(secondTrackPerigee->parameters()[Trk::qOverP])+0.5 )
277  );
278  }
279 
280 
281  int InDetJetFitterUtils::getTwoTrackVtxCharge(const xAOD::Vertex & myVxCandidate) const
282  {
283 
284  //now obtain the daughters of the two vertex
285  std::vector<Trk::VxTrackAtVertex>::const_iterator vtxIter=myVxCandidate.vxTrackAtVertex().begin();
286 
287  //obtain first track
288  Trk::VxTrackAtVertex firstTrack(*vtxIter);
289 
290  //obtain second track
291  ++vtxIter;
292  Trk::VxTrackAtVertex secondTrack(*vtxIter);
293 
294  //now obtain the momentum at the track (refitted)
295  const Trk::TrackParameters* firstTrackPerigee=firstTrack.perigeeAtVertex();
296 
297  //second
298  const Trk::TrackParameters* secondTrackPerigee=secondTrack.perigeeAtVertex();
299 
300  if (firstTrackPerigee==nullptr ||secondTrackPerigee==nullptr)
301  {
302  ATH_MSG_DEBUG( "No Perigee in one of the two tracks at vertex. No sensible charge returned." );
303  return -100;
304  }
305 
306  return (int)(
307  std::floor(
308  firstTrackPerigee->parameters()[Trk::qOverP]/
309  fabs(firstTrackPerigee->parameters()[Trk::qOverP])+
310  secondTrackPerigee->parameters()[Trk::qOverP]/
311  fabs(secondTrackPerigee->parameters()[Trk::qOverP])+0.5 )
312  );
313  }
314 
315 
316  double InDetJetFitterUtils::getTwoTrackVtxMass(const Trk::VxCandidate & myVxCandidate,
317  double highestMomMass,
318  double lowestMomMass) const
319  {
320 
321 
322  //now obtain the daughters of the two vertex
323  std::vector<Trk::VxTrackAtVertex*>::const_iterator vtxIter=myVxCandidate.vxTrackAtVertex()->begin();
324 
325  //obtain first track
326  Trk::VxTrackAtVertex* firstTrack(*vtxIter);
327 
328  //obtain second track
329  ++vtxIter;
330  Trk::VxTrackAtVertex* secondTrack(*vtxIter);
331 
332  //now obtain the momentum at the track (refitted)
333  const Trk::TrackParameters* firstTrackPerigee=firstTrack->perigeeAtVertex();
334 
335  //second
336  const Trk::TrackParameters* secondTrackPerigee=secondTrack->perigeeAtVertex();
337 
338  if (firstTrackPerigee==nullptr ||secondTrackPerigee==nullptr)
339  {
340  ATH_MSG_DEBUG( "No Perigee in one of the two tracks at vertex. No sensible mass returned." );
341  return -100;
342  }
343 
344  Amg::Vector3D firstMomentum=firstTrackPerigee->momentum();
345  Amg::Vector3D secondMomentum=secondTrackPerigee->momentum();
346 
347 
348  CLHEP::HepLorentzVector first4Mom;
349  CLHEP::HepLorentzVector second4Mom;
350 
351  if (firstMomentum.mag2()>secondMomentum.mag2())
352  {
353  first4Mom=CLHEP::HepLorentzVector(firstMomentum.x(),firstMomentum.y(),firstMomentum.z(),TMath::Sqrt(highestMomMass*highestMomMass+firstMomentum.mag()*firstMomentum.mag()));
354  second4Mom=CLHEP::HepLorentzVector(secondMomentum.x(),secondMomentum.y(),secondMomentum.z(),TMath::Sqrt(lowestMomMass*lowestMomMass+secondMomentum.mag()*secondMomentum.mag()));
355  }
356  else
357  {
358  first4Mom=CLHEP::HepLorentzVector(firstMomentum.x(),firstMomentum.y(),firstMomentum.z(),TMath::Sqrt(lowestMomMass*highestMomMass+firstMomentum.mag()*firstMomentum.mag()));
359  second4Mom=CLHEP::HepLorentzVector(secondMomentum.x(),secondMomentum.y(),secondMomentum.z(),TMath::Sqrt(highestMomMass*lowestMomMass+secondMomentum.mag()*secondMomentum.mag()));
360  }
361 
362  return (first4Mom+second4Mom).mag();
363  }
364 
365 
366 
367 
368  double InDetJetFitterUtils::getTwoTrackVtxMass(const xAOD::Vertex & myVxCandidate,
369  double highestMomMass,
370  double lowestMomMass) const
371  {
372 
373 
374  //now obtain the daughters of the two vertex
375  std::vector<Trk::VxTrackAtVertex>::const_iterator vtxIter=myVxCandidate.vxTrackAtVertex().begin();
376 
377  //obtain first track
378  Trk::VxTrackAtVertex firstTrack(*vtxIter);
379 
380  //obtain second track
381  ++vtxIter;
382  Trk::VxTrackAtVertex secondTrack(*vtxIter);
383 
384  //now obtain the momentum at the track (refitted)
385  const Trk::TrackParameters* firstTrackPerigee=firstTrack.perigeeAtVertex();
386 
387  //second
388  const Trk::TrackParameters* secondTrackPerigee=secondTrack.perigeeAtVertex();
389 
390  if (firstTrackPerigee==nullptr ||secondTrackPerigee==nullptr)
391  {
392  ATH_MSG_DEBUG( "No Perigee in one of the two tracks at vertex. No sensible mass returned." );
393  return -100;
394  }
395 
396  Amg::Vector3D firstMomentum=firstTrackPerigee->momentum();
397  Amg::Vector3D secondMomentum=secondTrackPerigee->momentum();
398 
399 
400  CLHEP::HepLorentzVector first4Mom;
401  CLHEP::HepLorentzVector second4Mom;
402 
403  if (firstMomentum.mag2()>secondMomentum.mag2())
404  {
405  first4Mom=CLHEP::HepLorentzVector(firstMomentum.x(),firstMomentum.y(),firstMomentum.z(),TMath::Sqrt(highestMomMass*highestMomMass+firstMomentum.mag()*firstMomentum.mag()));
406  second4Mom=CLHEP::HepLorentzVector(secondMomentum.x(),secondMomentum.y(),secondMomentum.z(),TMath::Sqrt(lowestMomMass*lowestMomMass+secondMomentum.mag()*secondMomentum.mag()));
407  }
408  else
409  {
410  first4Mom=CLHEP::HepLorentzVector(firstMomentum.x(),firstMomentum.y(),firstMomentum.z(),TMath::Sqrt(lowestMomMass*highestMomMass+firstMomentum.mag()*firstMomentum.mag()));
411  second4Mom=CLHEP::HepLorentzVector(secondMomentum.x(),secondMomentum.y(),secondMomentum.z(),TMath::Sqrt(highestMomMass*lowestMomMass+secondMomentum.mag()*secondMomentum.mag()));
412  }
413 
414  return (first4Mom+second4Mom).mag();
415  }
416 
417 
418 
420  const Trk::RecVertex & second) const
421  {
422 
423  Amg::Vector3D difference=second.position()-first.position();
424 
425  double distance=difference.mag();
426 
427  AmgSymMatrix(3) sumErrorsThenInverted=first.covariancePosition()+
428  second.covariancePosition();
429 
430 
431  sumErrorsThenInverted.inverse().eval();
432  //using determinant as protection - better solution to come...
433  Amg::Vector3D differenceUnit(difference);
434  differenceUnit.normalize();
435 
436  double error=1000;
437 
438  if (sumErrorsThenInverted.determinant()>0 && distance>0)
439  {
440  double temp=differenceUnit.transpose() * sumErrorsThenInverted * differenceUnit;
441  if (temp>0)
442  {
443  error=1./std::sqrt(temp );
444  }
445  else
446  {
447  ATH_MSG_DEBUG( "The significance of the distance to the PV is negative or zero definite: " << temp );
448  //MU msg(MSG::WARNING) << std::scientific << temp << " two-trk vertex : " << first << " PV " << second << std::fixed << endmsg;
449  }
450  }
451  else
452  {
453  if (sumErrorsThenInverted.determinant()<=0)
454  {
455  ATH_MSG_DEBUG( "Sum of cov matrices of PV + single vertex fit is zero or negative. Error on distance is returned as 1000mm." );
456  }
457  else
458  {
459  ATH_MSG_DEBUG( "The distance between the vertices is: " << distance );
460  }
461  }
462  return std::pair<double,double>(distance,error);
463  }
464 
465  std::pair<double,double> InDetJetFitterUtils::getD0andZ0IP(const Trk::TrackParameters & trackPerigee,
466  const Trk::Vertex & vertexToExtrapolateTo) const
467  {
468  const EventContext& ctx = Gaudi::Hive::currentContext();
470  {
471  msg(MSG::ERROR) << "Cannot perform requested extrapolation. No extrapolator defined...Returning 0 compatibility..." << endmsg;
472  return std::pair<double,double>(0,0);
473  }
474 
475 
476  Trk::PerigeeSurface mySurface(vertexToExtrapolateTo.position());
477  const Trk::TrackParameters* newMeasPerigee= m_extrapolator->extrapolateDirectly(ctx,
478  trackPerigee,
479  mySurface).release();
480  if (newMeasPerigee==nullptr)
481  {
482  msg(MSG::WARNING) << " Extrapolation failed. Wrong d0 and z0 returned " << endmsg;
483  return std::pair<double,double>
484  (trackPerigee.parameters()[Trk::d0],
485  trackPerigee.parameters()[Trk::z0]*sin(trackPerigee.parameters()[Trk::theta]));
486  }
487 
488  double IPd0=newMeasPerigee->parameters()[Trk::d0];
489  double IPz0=newMeasPerigee->parameters()[Trk::z0]*
490  sin(newMeasPerigee->parameters()[Trk::theta]);
491 
492  delete newMeasPerigee;
493  newMeasPerigee=nullptr;
494 
495  return std::pair<double,double>(IPd0,IPz0);
496  }
497 
498 
499  std::pair<double,double> InDetJetFitterUtils::getD0andZ0IPSig(const Trk::TrackParameters & trackPerigee,
500  const Trk::RecVertex & vertex) const
501  {
502 
504  {
505  ATH_MSG_ERROR( "Cannot perform requested extrapolation. No extrapolator defined...Returning 0 compatibility..." );
506  return std::pair<double,double>(0,0);
507  }
508 
509  Trk::LinearizedTrack* myLinearizedTrack=m_LinearizedTrackFactory->linearizedTrack(&trackPerigee,vertex.position());
510  Amg::Vector3D vertexPosition;
511  vertexPosition[0]=vertex.position()[0];
512  vertexPosition[1]=vertex.position()[1];
513  vertexPosition[2]=vertex.position()[2];
514 
515  const AmgSymMatrix(5) & ExpectedCovariance=myLinearizedTrack->expectedCovarianceAtPCA();
516  AmgSymMatrix(2) weightReduced=ExpectedCovariance.block<2,2>(0,0);
517  //AmgSymMatrix(2) errorVertexReduced=vertex.covariancePosition().similarity(myLinearizedTrack->positionJacobian()).block<2,2>(0,0);
518  //weightReduced+=errorVertexReduced;
519 
520  double IPd0Sig=(myLinearizedTrack->expectedParametersAtPCA())[0]/sqrt( weightReduced(0,0) );
521  double IPz0Sig=(myLinearizedTrack->expectedParametersAtPCA())[1]/sqrt( weightReduced(1,1) );
522 
523  /*
524  std::cout << " " << std::endl;
525  std::cout << " --> ExpectedCovariance : " << sqrt( weightReduced(0,0)) << " , " << sqrt( weightReduced(1,1)) << std::endl;
526  std::cout << " --> Covarianceposition : " << sqrt(vertex.covariancePosition()(0,0)) << " , " << sqrt(vertex.covariancePosition()(1,1)) << std::endl;
527  std::cout << " --> d0/z0 : " << myLinearizedTrack->expectedParametersAtPCA()[0] << " , " << myLinearizedTrack->expectedParametersAtPCA()[1] << std::endl;
528  std::cout << " --> d0Sig/z0Sig : " << IPd0Sig << " , " << IPz0Sig << std::endl;
529  */
530 
531  delete myLinearizedTrack;
532  myLinearizedTrack=nullptr;
533 
534  return std::pair<double,double>(IPd0Sig,IPz0Sig);
535  }
536 
537 
538 
539  const Trk::LinkToTrackParticleBase* InDetJetFitterUtils::findNeutralTrackParticleBase(const std::vector<const Trk::LinkToTrackParticleBase*> & /*neutralTracks*/,
540  const xAOD::Vertex & /*myVxCandidate*/)
541  {
542  //THIS WILL ANYWAY NOT WORK WITH NEW EDM! NEEDS TO BE FIXED!
543  /*
544  std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator neutralsBegin=neutralTracks.begin();
545  std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator neutralsEnd=neutralTracks.end();
546 
547  for (std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator neutralsIter=neutralsBegin;
548  neutralsIter!=neutralsEnd;++neutralsIter)
549  {
550  if ((****neutralsIter).reconstructedVertex()==&myVxCandidate)
551  {
552  return *neutralsIter;
553  }
554  }
555  //if not found, returns 0
556  */
557  return nullptr;
558  }
559 
561  const std::vector<const Trk::ITrackLink*> & vectorOfTracks)
562  {
563 
564  std::vector<const Trk::ITrackLink*>::const_iterator vectorOfTracksBegin=vectorOfTracks.begin();
565  std::vector<const Trk::ITrackLink*>::const_iterator vectorOfTracksEnd=vectorOfTracks.end();
566 
567  for (std::vector<const Trk::ITrackLink*>::const_iterator vectorOfTracksIter=vectorOfTracksBegin;
568  vectorOfTracksIter!=vectorOfTracksEnd;++vectorOfTracksIter)
569  {
570  if (*vectorOfTracksIter==trackToCheck)
571  {
572  return true;
573  }
574  }
575  return false;
576  }
577 
579  const std::vector<const Trk::LinkToTrackParticleBase*> & vectorOfTracks)
580  {
581 
582  std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator vectorOfTracksBegin=vectorOfTracks.begin();
583  std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator vectorOfTracksEnd=vectorOfTracks.end();
584 
585  for (std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator vectorOfTracksIter=vectorOfTracksBegin;
586  vectorOfTracksIter!=vectorOfTracksEnd;++vectorOfTracksIter)
587  {
588  if (*vectorOfTracksIter==trackToCheck)
589  {
590  return true;
591  }
592  }
593  return false;
594  }
595 
597  const std::vector<const Trk::LinkToTrackParticleBase*> & /*vectorOfNeutrals*/)
598  {
599  //W
600  /*
601  std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator vectorOfNeutralsBegin=vectorOfNeutrals.begin();
602  std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator vectorOfNeutralsEnd=vectorOfNeutrals.end();
603 
604  for (std::vector<const Trk::LinkToTrackParticleBase*>::const_iterator vectorOfNeutralsIter=vectorOfNeutralsBegin;
605  vectorOfNeutralsIter!=vectorOfNeutralsEnd;
606  ++vectorOfNeutralsIter)
607  {
608  const Trk::LinkToTrackParticleBase* myTPBlink=*vectorOfNeutralsIter;
609 
610  if (myTPBlink==0)
611  {
612  msg(MSG::WARNING) << " null pointer (TPBlink). Skipping neutral candidate... " << endmsg;
613  continue;
614  }
615 
616  const Trk::TrackParticleBase* myTPB=**myTPBlink;
617 
618  if (myTPB==0)
619  {
620  msg(MSG::WARNING) << " null pointer (TPB). Skipping neutral candidate... " << endmsg;
621  continue;
622  }
623 
624  const Trk::VxCandidate* myV0Candidate=myTPB->reconstructedVertex();
625 
626  if (myV0Candidate==0)
627  {
628  msg(MSG::WARNING) << " neutral TP Base has no original Vx Candidate " << endmsg;
629  continue;
630  }
631 
632  const Trk::VxTrackAtVertex* firstTrack((*(myV0Candidate->vxTrackAtVertex()))[0]);
633  const Trk::VxTrackAtVertex* secondTrack((*(myV0Candidate->vxTrackAtVertex()))[1]);
634 
635  const Trk::ITrackLink* trackLink1=firstTrack->trackOrParticleLink();
636  const Trk::ITrackLink* trackLink2=secondTrack->trackOrParticleLink();
637 
638  if (trackLink1==trackToCheck || trackLink2==trackToCheck )
639  {
640  return true;
641  }
642  }
643  */
644  return false;
645  }
646 
647 
649  const std::vector<const xAOD::Vertex*> & vectorOfCandidates)
650  {
651 
652  std::vector<const xAOD::Vertex*>::const_iterator vectorOfCandidatesBegin=vectorOfCandidates.begin();
653  std::vector<const xAOD::Vertex*>::const_iterator vectorOfCandidatesEnd=vectorOfCandidates.end();
654 
655  for (std::vector<const xAOD::Vertex*>::const_iterator vectorOfCandidatesIter=vectorOfCandidatesBegin;
656  vectorOfCandidatesIter!=vectorOfCandidatesEnd;
657  ++vectorOfCandidatesIter)
658  {
659  if (*vectorOfCandidatesIter==vertexToCheck)
660  {
661  return true;
662  }
663  }
664  return false;
665  }
666 
668  const std::vector<const xAOD::Vertex*> & vectorOfVxCandidates)
669  {
670 
671  std::vector<const xAOD::Vertex*>::const_iterator verticesToVetoBegin=vectorOfVxCandidates.begin();
672  std::vector<const xAOD::Vertex*>::const_iterator verticesToVetoEnd=vectorOfVxCandidates.end();
673 
674  for (std::vector<const xAOD::Vertex*>::const_iterator verticesToVetoIter=verticesToVetoBegin;
675  verticesToVetoIter!=verticesToVetoEnd;++verticesToVetoIter)
676  {
677 
678  Trk::VxTrackAtVertex firstTrack((((*verticesToVetoIter)->vxTrackAtVertex()))[0]);
679  Trk::VxTrackAtVertex secondTrack((((*verticesToVetoIter)->vxTrackAtVertex()))[1]);
680 
681  const Trk::ITrackLink* linkToTP1= firstTrack.trackOrParticleLink();
682  const Trk::ITrackLink* linkToTP2=secondTrack.trackOrParticleLink();
683 
684  if (trackToCheck==linkToTP1||
685  trackToCheck==linkToTP2)
686  {
687  return true;
688  }
689  }
690 
691  return false;
692 
693  }
694 
695  CLHEP::HepLorentzVector InDetJetFitterUtils::fourMomentumAtVertex(const Trk::VxVertexOnJetAxis & myVxVertexOnJetAxis)
696  {
697 
698 
699  const double s_pion=139.57018;
700  //hard coded pion mass
701 
702  CLHEP::HepLorentzVector massVector(0,0,0,0);
703 
704  const std::vector<Trk::VxTrackAtVertex*> & tracksOfVertex=myVxVertexOnJetAxis.getTracksAtVertex();
705  std::vector<Trk::VxTrackAtVertex*>::const_iterator clustersOfTrackBegin=tracksOfVertex.begin();
706  std::vector<Trk::VxTrackAtVertex*>::const_iterator clustersOfTrackEnd=tracksOfVertex.end();
707  for (std::vector<Trk::VxTrackAtVertex*>::const_iterator clustersOfTrackIter=clustersOfTrackBegin;
708  clustersOfTrackIter!=clustersOfTrackEnd;
709  ++clustersOfTrackIter)
710  {
711  if (dynamic_cast<const Trk::Perigee*>((*clustersOfTrackIter)->perigeeAtVertex())!=nullptr)
712  {
713 
714  const Trk::TrackParameters* aMeasPer=(*clustersOfTrackIter)->perigeeAtVertex();
715  Amg::Vector3D mytrack(aMeasPer->momentum());
716  massVector+=CLHEP::HepLorentzVector(mytrack.x(),mytrack.y(),mytrack.z(),TMath::Sqrt(s_pion*s_pion+mytrack.mag()*mytrack.mag()));
717  }
718  }
719 
720  return massVector;
721  }
722 
723 
724 }
725 //end namespace InDet
Trk::Vertex
Definition: Tracking/TrkEvent/VxVertex/VxVertex/Vertex.h:26
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
InDet::InDetJetFitterUtils
Definition: InDetJetFitterUtils.h:56
Trk::VxTrackAtVertex
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Definition: VxTrackAtVertex.h:77
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
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
PerigeeSurface.h
Trk::VxVertexOnJetAxis::getTracksAtVertex
const std::vector< VxTrackAtVertex * > & getTracksAtVertex(void) const
get Tracks At Vertex Method
Definition: VxVertexOnJetAxis.cxx:102
InDet::InDetJetFitterUtils::initialize
virtual StatusCode initialize() override
Definition: InDetJetFitterUtils.cxx:95
InDet::InDetJetFitterUtils::compatibility
std::pair< double, double > compatibility(const Trk::TrackParameters &measPerigee, const Trk::RecVertex &vertex) const
Definition: InDetJetFitterUtils.cxx:148
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
TrackParticleBase.h
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
VxVertexOnJetAxis.h
InDet::InDetJetFitterUtils::checkIfTrackIsInVector
static bool checkIfTrackIsInVector(const Trk::ITrackLink *trackToCheck, const std::vector< const Trk::ITrackLink * > &vectorOfTracks)
Definition: InDetJetFitterUtils.cxx:573
InDetJetFitterUtils.h
Trk::VxVertexOnJetAxis
VxVertexOnJetAxis inherits from Vertex.
Definition: VxVertexOnJetAxis.h:79
Trk::z0
@ z0
Definition: ParamDefs.h:64
InDet::InDetJetFitterUtils::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: InDetJetFitterUtils.h:140
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
InDet::InDetJetFitterUtils::~InDetJetFitterUtils
~InDetJetFitterUtils()
Trk::VxTrackAtVertex::trackOrParticleLink
const ITrackLink * trackOrParticleLink(void) const
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
InDetAccessor::qOverP
@ qOverP
perigee
Definition: InDetAccessor.h:35
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
InDet::InDetJetFitterUtils::checkIfTrackIsInNeutralTrackVector
static bool checkIfTrackIsInNeutralTrackVector(const Trk::ITrackLink *trackToCheck, const std::vector< const Trk::LinkToTrackParticleBase * > &vectorOfNeutrals)
Definition: InDetJetFitterUtils.cxx:609
InDet::InDetJetFitterUtils::checkIfVxCandidateIsInVector
static bool checkIfVxCandidateIsInVector(const xAOD::Vertex *vertexToCheck, const std::vector< const xAOD::Vertex * > &vectorOfCandidates)
Definition: InDetJetFitterUtils.cxx:661
ParamDefs.h
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
AmgMatrix
#define AmgMatrix(rows, cols)
Definition: EventPrimitives.h:49
normalize
Double_t normalize(TF1 *func, Double_t *rampl=NULL, Double_t from=0., Double_t to=0., Double_t step=1.)
Definition: LArPhysWaveHECTool.cxx:825
Trk::RecVertex
Trk::RecVertex inherits from Trk::Vertex.
Definition: RecVertex.h:44
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
similarity
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarity(const MatrixBase< OtherDerived > &m) const
similarity method : yields ms = m*s*m^T
Definition: AmgMatrixBasePlugin.h:133
xAOD::TrackParameters
TrackParameters_v1 TrackParameters
Definition: Event/xAOD/xAODTracking/xAODTracking/TrackParameters.h:11
A
InDet::InDetJetFitterUtils::m_LinearizedTrackFactory
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_LinearizedTrackFactory
Definition: InDetJetFitterUtils.h:139
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Trk::VxCandidate::vxTrackAtVertex
std::vector< Trk::VxTrackAtVertex * > * vxTrackAtVertex(void)
Unconst pointer to the vector of tracks Required by some of the vertex fitters.
Definition: VxCandidate.h:144
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:66
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
MuonR4::inverse
CalibratedSpacePoint::Covariance_t inverse(const CalibratedSpacePoint::Covariance_t &mat)
Inverts the parsed matrix.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/UtilFunctions.cxx:65
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDet::InDetJetFitterUtils::getDistanceAndErrorBetweenTwoVertices
std::pair< double, double > getDistanceAndErrorBetweenTwoVertices(const xAOD::Vertex &, const Trk::RecVertex &) const
Definition: InDetJetFitterUtils.cxx:432
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
sign
int sign(int a)
Definition: TRT_StrawNeighbourSvc.h:107
InDet::InDetJetFitterUtils::getD0andZ0IP
std::pair< double, double > getD0andZ0IP(const Trk::TrackParameters &trackPerigee, const Trk::Vertex &vertexToExtrapolateTo) const
Definition: InDetJetFitterUtils.cxx:478
VxTrackAtVertex.h
InDet::InDetJetFitterUtils::getTwoTrackVtxCharge
int getTwoTrackVtxCharge(const Trk::VxCandidate &myVxCandidate) const
Definition: InDetJetFitterUtils.cxx:259
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::Vertex::position
const Amg::Vector3D & position() const
return position of vertex
Definition: Vertex.cxx:72
JacobianPxyzToPhiThetaQoverPspherical.h
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
InDet::InDetJetFitterUtils::m_linearizedTrackFactoryIsAvailable
bool m_linearizedTrackFactoryIsAvailable
Definition: InDetJetFitterUtils.h:142
InDet::InDetJetFitterUtils::InDetJetFitterUtils
InDetJetFitterUtils(const std::string &t, const std::string &n, const IInterface *p)
Definition: InDetJetFitterUtils.cxx:82
LinkToTrackParticleBase.h
VxCandidate.h
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::VxTrackAtVertex::perigeeAtVertex
const TrackParameters * perigeeAtVertex(void) const
Perigee parameters with respect to fitted vertex d_0 and z_0 are equal to 0 in case the trajectory wa...
Trk::d0
@ d0
Definition: ParamDefs.h:63
InDet::InDetJetFitterUtils::fourMomentumAtVertex
static CLHEP::HepLorentzVector fourMomentumAtVertex(const Trk::VxVertexOnJetAxis &)
Definition: InDetJetFitterUtils.cxx:708
InDet::InDetJetFitterUtils::get3DLifetimeSignOfTrack
static double get3DLifetimeSignOfTrack(const Trk::TrackParameters &track, const Amg::Vector3D &jetMomentum, const Trk::RecVertex &primaryVertex)
Definition: InDetJetFitterUtils.cxx:243
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
similarityT
Matrix< Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime > similarityT(const MatrixBase< OtherDerived > &m) const
similarityT method : yields ms = m^T*s*m
Definition: AmgMatrixBasePlugin.h:141
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
calibdata.delete
list delete
Definition: calibdata.py:46
InDet::InDetJetFitterUtils::getTwoTrackVtxMass
double getTwoTrackVtxMass(const Trk::VxCandidate &myVxCandidate, double highestMomMass, double lowestMomMass) const
Definition: InDetJetFitterUtils.cxx:329
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
InDet::InDetJetFitterUtils::getD0andZ0IPSig
std::pair< double, double > getD0andZ0IPSig(const Trk::TrackParameters &trackPerigee, const Trk::RecVertex &vertex) const
Definition: InDetJetFitterUtils.cxx:512
Trk::VxCandidate
Definition: VxCandidate.h:27
DeMoScan.first
bool first
Definition: DeMoScan.py:536
InDet::InDetJetFitterUtils::getPosMomentumAndMomentumCovMatrix
std::pair< AmgMatrix(3, 3), AmgSymMatrix(3)> getPosMomentumAndMomentumCovMatrix(const Trk::LinearizedTrack *linTrack, const AmgSymMatrix(3) &vrt_cov, const AmgSymMatrix(3) &vrt_weight) const
Definition: InDetJetFitterUtils.cxx:124
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
ExtendedVxCandidate.h
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
InDet::InDetJetFitterUtils::checkIfTrackIsInV0CandidatesVector
static bool checkIfTrackIsInV0CandidatesVector(const Trk::ITrackLink *trackToCheck, const std::vector< const xAOD::Vertex * > &vectorOfVxCandidates)
Definition: InDetJetFitterUtils.cxx:680
InDet::InDetJetFitterUtils::findNeutralTrackParticleBase
const Trk::LinkToTrackParticleBase * findNeutralTrackParticleBase(const std::vector< const Trk::LinkToTrackParticleBase * > &, const Trk::VxCandidate &) const
LinearizedTrack.h
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
xAOD::Vertex_v1::vxTrackAtVertex
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
Definition: Vertex_v1.cxx:181
AthAlgTool
Definition: AthAlgTool.h:26
error
Definition: IImpactPoint3dEstimator.h:70
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
Trk::LinearizedTrack
Definition: LinearizedTrack.h:43