ATLAS Offline Software
SingleTrackConversionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /***************************************************************************
6  SingleTrackConversionTool.cxx - Description
7  -------------------
8  begin : 01-01-2008
9  authors : Tatjana Lenz, Thomas Koffas
10  email : tatjana.lenz@cern.ch, Thomas.Koffas@cern.ch
11  changes : Markus Elsing
12 ***************************************************************************/
14 #include "TrkTrack/Track.h"
16 #include "AthLinks/ElementLink.h"
17 #include "TrkTrack/LinkToTrack.h"
23 #include "TrkSurfaces/Surface.h"
24 
25 
28 
29 #include "CLHEP/Geometry/Transform3D.h"
31 
32 namespace InDet {
33 
34  // -------------------------------------------------------
35  // athena interface definition
36  // -------------------------------------------------------
37  static const InterfaceID IID_ISingleTrackConversionTool("InDet::SingleTrackConversionTool", 1, 0);
38 
39  // -------------------------------------------------------
40  // constructor
41  // -------------------------------------------------------
43  const std::string& name,
44  const IInterface* parent)
46  {
47  declareInterface<SingleTrackConversionTool>(this);
48  }
49 
50  // -------------------------------------------------------
51  // not sure what this is about (Markus) ????
52  // -------------------------------------------------------
54  return IID_ISingleTrackConversionTool;
55  }
56 
57  // -------------------------------------------------------
58  // init method
59  // -------------------------------------------------------
61  return StatusCode::SUCCESS;
62  }
63 
64  // -------------------------------------------------------
65  // finalize method
66  // -------------------------------------------------------
68  return StatusCode::SUCCESS;
69  }
70 
71 
72  // -------------------------------------------------------
73  // building single track conversions from a particle
74  // -------------------------------------------------------
78  xAOD::VertexContainer* container) const
79  {
81 
82  unsigned int index(0);
83  if (!track->indexOfParameterAtPosition(index, xAOD::FirstMeasurement)) {
84  ATH_MSG_WARNING("TrackParticle has no first measurement");
85  return nullptr;
86  }
87 
88  const Trk::CurvilinearParameters trkPar =
89  track->curvilinearParameters(index);
90 
91  const Amg::Vector3D& gp = trkPar.position();
92  const AmgSymMatrix(5) em = *(trkPar.covariance());
93 
94  // ME: this is nuts, those values are 0, 0
95  // double chi2 = track->fitQuality()->chiSquared();
96  // int Ndf = track->fitQuality()->numberDoF();
97 
99  const Amg::Transform3D& T = trkPar.associatedSurface().transform();
100  AmgSymMatrix(3) nCovVtx;
101 
102  // Should use eigen to do all of this
103 
104  // ME: use the surface to find out what we do, do not hardcode the geoemtry
105  if (Trk::SurfaceType::Plane == trkPar.associatedSurface().type()) {
106 
108  double p11 = em(Trk::locX, Trk::locX);
109  double p12 = em(Trk::locX, Trk::locY);
110  double p21 = em(Trk::locY, Trk::locX);
111  double p22 = em(Trk::locY, Trk::locY);
112 
114  double Ax[3] = { T(0, 0), T(1, 0), T(2, 0) };
115  double Ay[3] = { T(0, 1), T(1, 1), T(2, 1) };
116  double a11 = Ax[0];
117  double a12 = Ay[0];
118  double a21 = Ax[1];
119  double a22 = Ay[1];
120  double a31 = Ax[2];
121  double a32 = Ay[2];
122 
124  double A11 = a11 * p11 + a12 * p21;
125  double A12 = a11 * p12 + a12 * p22;
126  double A21 = a21 * p11 + a22 * p21;
127  double A22 = a21 * p12 + a22 * p22;
128  double A31 = a31 * p11 + a32 * p21;
129  double A32 = a31 * p12 + a32 * p22;
130 
132  double P11 = a11 * A11 + A12 * a12;
133  double P12 = A11 * a21 + A12 * a22;
134  double P13 = A11 * a31 + A12 * a32;
135  double P21 = A21 * a11 + A22 * a12;
136  double P22 = A21 * a21 + A22 * a22;
137  double P23 = A21 * a31 + A22 * a32;
138  double P31 = A31 * a11 + A32 * a12;
139  double P32 = A31 * a21 + A32 * a22;
140  double P33 = A31 * a31 + A32 * a32;
141 
143  nCovVtx(0, 0) = P11;
144  nCovVtx(0, 1) = P12;
145  nCovVtx(0, 2) = P13;
146  nCovVtx(1, 0) = P21;
147  nCovVtx(1, 1) = P22;
148  nCovVtx(1, 2) = P23;
149  nCovVtx(2, 0) = P31;
150  nCovVtx(2, 1) = P32;
151  nCovVtx(2, 2) = P33;
152 
153  } else if (Trk::SurfaceType::Line == trkPar.associatedSurface().type()) {
154 
156  double p11 = em(Trk::locR, Trk::locR);
157  double p12 = em(Trk::locR, Trk::locZ);
158  double p21 = em(Trk::locZ, Trk::locR);
159  double p22 = em(Trk::locZ, Trk::locZ);
160 
162  double A[3] = {T(0,2),T(1,2),T(2,2)};
163 
165  double Px = trkPar.momentum().x();
166  double Py = trkPar.momentum().y();
167  double Pz = trkPar.momentum().z();
168 
170  double Bx = A[1]*Pz-A[2]*Py;
171  double By = A[2]*Px-A[0]*Pz;
172  double Bz = A[0]*Py-A[1]*Px;
173  double Bn = 1./sqrt(Bx*Bx+By*By+Bz*Bz); Bx*=Bn; By*=Bn; Bz*=Bn;
174  double a11 = Bx; double a12 = A[0];
175  double a21 = By; double a22 = A[1];
176  double a31 = Bz; double a32 = A[2];
177 
179  double A11 = a11*p11 + a12*p21; double A12 = a11*p12 + a12*p22;
180  double A21 = a21*p11 + a22*p21; double A22 = a21*p12 + a22*p22;
181  double A31 = a31*p11 + a32*p21; double A32 = a31*p12 + a32*p22;
182 
184  double P11 = a11*A11 + A12*a12; double P12 = A11*a21 + A12*a22; double P13 = A11*a31 + A12*a32;
185  double P21 = A21*a11 + A22*a12; double P22 = A21*a21 + A22*a22; double P23 = A21*a31 + A22*a32;
186  double P31 = A31*a11 + A32*a12; double P32 = A31*a21 + A32*a22; double P33 = A31*a31 + A32*a32;
187 
189  nCovVtx(0,0) = P11; nCovVtx(0,1) = P12; nCovVtx(0,2) = P13;
190  nCovVtx(1,0) = P21; nCovVtx(1,1) = P22; nCovVtx(1,2) = P23;
191  nCovVtx(2,0) = P31; nCovVtx(2,1) = P32; nCovVtx(2,2) = P33;
192  }
193 
194  // now construct the vertex from the global position, cov. put NdF and chi2 to zero (Markus)
195 
196 
198  container->push_back( vertex );
199 
200  vertex->setPosition(gp);
201  vertex->setCovariancePosition(nCovVtx);
202  vertex->setVertexType(xAOD::VxType::ConvVtx);
203  vertex->setFitQuality( 0, 0);
204 
205  return vertex;
206  }
207 
208  // -------------------------------------------------------
209  // preselection cuts on track particles
210  // -------------------------------------------------------
212 
213  //Position of first hit in track particle
214 
215  int index(-1);
216  for(unsigned int i(0); i< track->numberOfParameters() ; ++i ){
217  if( xAOD::FirstMeasurement == track->parameterPosition(i) ){
218  index = i;
219  break;
220  }
221  }
222  if(index ==-1){
223  ATH_MSG_WARNING("Track Particle does not contain first Measurement track parameters");
224  return false;
225  }
226 
227  const Trk::CurvilinearParameters trk_meas = track->curvilinearParameters(index);
228 
229  uint8_t dummy;
230 
231  uint8_t expectedHitInBLayer(0);
232  if( track->summaryValue(dummy,xAOD::expectInnermostPixelLayerHit) )
233  expectedHitInBLayer = dummy;
234 
235  float Rfirst = trk_meas.position().perp();
236  if (expectedHitInBLayer)
237  {
238  // ME: cut on minInitR if blayer is ok
239  if (Rfirst < m_minInitR)
240  {
241  ATH_MSG_DEBUG("BLayer hit expected. Radius of first hit (" <<
242  Rfirst << ") below minimum: " << m_minInitR);
243  return false;
244  }
245  }
246  else
247  {
248  // ME: cut on minInitR_NBLay if blayer is off
249  if(Rfirst < m_minInitR_noBLay)
250  {
251  ATH_MSG_DEBUG("No BLayer hit expected. Radius of first hit (" <<
252  Rfirst << ") below minimum: " << m_minInitR_noBLay);
253  return false;
254  }
255  }
256 
257 
258  uint8_t nTrtHits(0);
259  if( track->summaryValue(dummy, xAOD::numberOfTRTHits))
260  nTrtHits = dummy;
261 
262  uint8_t nTrtOutliers(0);
263  if(track->summaryValue(dummy, xAOD::numberOfTRTOutliers))
264  nTrtOutliers = dummy;
265 
266  uint8_t ntrt = nTrtHits + nTrtOutliers;
267 
268  uint8_t nTrtXenonHits(0);
269  if( track->summaryValue(dummy, xAOD::numberOfTRTXenonHits) )
270  nTrtXenonHits = dummy;
271 
272 
273 
274  if(ntrt > 0 && (!m_PIDonlyForXe || nTrtXenonHits==ntrt) ) {
275  // only check TRT PID if m_PIDonlyForXe is false or all TRT hits are Xenon hits
276  float prob = 1.0;
277  if( !track->summaryValue(prob,xAOD::eProbabilityHT) )
278  {
279  ATH_MSG_WARNING("Could not retrieve TR probability");
280  return false;
281  }
282  if (prob < m_singleThreshold)
283  {
284  ATH_MSG_DEBUG("Probability (" << prob << ") below threshold: "
285  << m_singleThreshold);
286  return false;
287  }
288  }
289 
290  uint8_t nBLHits(0);
292  nBLHits += dummy;
294  nBLHits += dummy;
295  if(nBLHits > m_maxBLhits)
296  {
297  ATH_MSG_DEBUG("BLayer hits (" << nBLHits << ") above maximum: " << m_maxBLhits);
298  return false;
299  }
300 
301  return true;
302  }
303 }
LinkToTrack.h
ITrackSummaryTool.h
StraightLineSurface.h
TrackParameters.h
InDet::SingleTrackConversionTool::initialize
virtual StatusCode initialize() override
Definition: SingleTrackConversionTool.cxx:60
xAOD::Vertex
Vertex_v1 Vertex
Define the latest version of the vertex class.
Definition: Event/xAOD/xAODTracking/xAODTracking/Vertex.h:16
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
Surface.h
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
index
Definition: index.py:1
InDet
Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
xAOD::numberOfTRTXenonHits
@ numberOfTRTXenonHits
number of TRT hits on track in straws with xenon [unit8_t].
Definition: TrackingPrimitives.h:284
ConversionFinderUtils.h
InDet::SingleTrackConversionTool::m_minInitR_noBLay
DoubleProperty m_minInitR_noBLay
Definition: SingleTrackConversionTool.h:54
InDet::SingleTrackConversionTool::selectSingleTrackParticleConversion
bool selectSingleTrackParticleConversion(const xAOD::TrackParticle *) const
Select single track conversion candidates.
Definition: SingleTrackConversionTool.cxx:211
xAOD::expectInnermostPixelLayerHit
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
Definition: TrackingPrimitives.h:236
xAOD::numberOfTRTHits
@ numberOfTRTHits
number of TRT hits [unit8_t].
Definition: TrackingPrimitives.h:275
Trk::locR
@ locR
Definition: ParamDefs.h:44
covarianceTool.prob
prob
Definition: covarianceTool.py:678
InDet::SingleTrackConversionTool::m_maxBLhits
IntegerProperty m_maxBLhits
Definition: SingleTrackConversionTool.h:60
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
InDet::SingleTrackConversionTool::interfaceID
static const InterfaceID & interfaceID()
Definition: SingleTrackConversionTool.cxx:53
Track.h
xAOD::numberOfInnermostPixelLayerOutliers
@ numberOfInnermostPixelLayerOutliers
number of 0th layer barrel outliers
Definition: TrackingPrimitives.h:238
A
InDet::SingleTrackConversionTool::m_minInitR
DoubleProperty m_minInitR
Definition: SingleTrackConversionTool.h:51
Trk::locZ
@ locZ
local cylindrical
Definition: ParamDefs.h:42
lumiFormat.i
int i
Definition: lumiFormat.py:85
xAOD::FirstMeasurement
@ FirstMeasurement
Parameter defined at the position of the 1st measurement.
Definition: TrackingPrimitives.h:213
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
SingleTrackConversionTool.h
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VxTrackAtVertex.h
python.xAODType.dummy
dummy
Definition: xAODType.py:4
Trk::CurvilinearParametersT
Definition: CurvilinearParametersT.h:48
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
InDet::SingleTrackConversionTool::buildSingleTrackParticleConversion
xAOD::Vertex * buildSingleTrackParticleConversion(const xAOD::TrackParticle *, xAOD::VertexContainer *container) const
Build single track conversion candidate.
Definition: SingleTrackConversionTool.cxx:76
Trk::CurvilinearParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
xAOD::numberOfTRTOutliers
@ numberOfTRTOutliers
number of TRT outliers [unit8_t].
Definition: TrackingPrimitives.h:276
TrackParticle.h
Trk::ParametersBase::momentum
const Amg::Vector3D & momentum() const
Access method for the momentum.
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
DeMoScan.index
string index
Definition: DeMoScan.py:364
VertexContainer.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
PlaneSurface.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::eProbabilityHT
@ eProbabilityHT
Electron probability from High Threshold (HT) information [float].
Definition: TrackingPrimitives.h:301
Trk::SurfaceType::Plane
@ Plane
InDet::SingleTrackConversionTool::m_singleThreshold
DoubleProperty m_singleThreshold
Definition: SingleTrackConversionTool.h:57
xAOD::VxType::ConvVtx
@ ConvVtx
Conversion vertex.
Definition: TrackingPrimitives.h:574
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
AthAlgTool
Definition: AthAlgTool.h:26
Trk::SurfaceType::Line
@ Line
InDet::SingleTrackConversionTool::finalize
virtual StatusCode finalize() override
Definition: SingleTrackConversionTool.cxx:67
InDet::SingleTrackConversionTool::m_PIDonlyForXe
BooleanProperty m_PIDonlyForXe
Definition: SingleTrackConversionTool.h:62
InDet::SingleTrackConversionTool::SingleTrackConversionTool
SingleTrackConversionTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SingleTrackConversionTool.cxx:42
xAOD::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
Definition: TrackingPrimitives.h:237