ATLAS Offline Software
TrackParticleCreatorTool.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 namespace Trk {
6 inline void
7 TrackParticleCreatorTool::setFitQuality(xAOD::TrackParticle& tp, const FitQuality& fq) const
8 {
9  tp.setFitQuality(fq.chiSquared(), static_cast<float>(fq.doubleNumberDoF()));
10 }
11 
12 inline void
13 TrackParticleCreatorTool::setTrackInfo(xAOD::TrackParticle& tp,
14  const TrackInfo& trackInfo,
15  xAOD::ParticleHypothesis prtOrigin) const
16 {
17  unsigned int properties = 0;
18  for (unsigned int i = 0; i < Trk::TrackInfo::NumberOfTrackProperties; i++) {
19  if (trackInfo.trackProperties(static_cast<Trk::TrackInfo::TrackProperties>(i)))
20  properties |= (1 << i);
21  }
22  tp.setTrackProperties(static_cast<xAOD::TrackProperties>(properties));
23  uint64_t patternReco = 0;
24  const uint64_t c1 = 1;
25 
26  for (unsigned int i = 0; i < xAOD::NumberOfTrackRecoInfo; i++) {
27  if (trackInfo.patternRecoInfo(static_cast<Trk::TrackInfo::TrackPatternRecoInfo>(i))){
28  patternReco |= c1 << i;
29  }
30  }
31 
32  tp.setPatternRecognitionInfo(patternReco);
33 
34  if (prtOrigin == xAOD::noHypothesis){
35  tp.setParticleHypothesis(static_cast<xAOD::ParticleHypothesis>(trackInfo.particleHypothesis()));
36  }
37  else{
38  tp.setParticleHypothesis(prtOrigin);
39  }
40  tp.setTrackFitter(static_cast<xAOD::TrackFitter>(trackInfo.trackFitter()));
41 }
42 
43 inline void
44 TrackParticleCreatorTool::setDefiningParameters(xAOD::TrackParticle& tp,
45  const Perigee& perigee) const
46 {
47  tp.setDefiningParameters(perigee.parameters()[Trk::d0],
48  perigee.parameters()[Trk::z0],
49  perigee.parameters()[Trk::phi0],
50  perigee.parameters()[Trk::theta],
51  perigee.parameters()[Trk::qOverP]);
52  const AmgSymMatrix(5)* covMatrix = perigee.covariance();
53  // see https://its.cern.ch/jira/browse/ATLASRECTS-645 for justification to
54  // comment out the following line assert(covMatrix && covMatrix->rows()==5&&
55  // covMatrix->cols()==5);
56  std::vector<float> covMatrixVec;
57  if (!covMatrix)
58  ATH_MSG_WARNING("Setting Defining parameters without error matrix");
59  else
60  Amg::compress(*covMatrix, covMatrixVec);
61  tp.setDefiningParametersCovMatrixVec(covMatrixVec);
62  const Amg::Vector3D& surfaceCenter = perigee.associatedSurface().center();
63  tp.setParametersOrigin(surfaceCenter.x(), surfaceCenter.y(), surfaceCenter.z());
64 }
65 }
66