ATLAS Offline Software
Loading...
Searching...
No Matches
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"
23#include "TrkSurfaces/Surface.h"
24
25
28
29#include "CLHEP/Geometry/Transform3D.h"
30using HepGeom::Transform3D;
31
32namespace 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)
45 : AthAlgTool(type, name, parent)
46 {
47 declareInterface<SingleTrackConversionTool>(this);
48 }
49
50 // -------------------------------------------------------
51 // not sure what this is about (Markus) ????
52 // -------------------------------------------------------
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 // -------------------------------------------------------
77 const xAOD::TrackParticle* track,
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
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
197 xAOD::Vertex* vertex = new xAOD::Vertex();
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: "
286 return false;
287 }
288 }
289
290 uint8_t nBLHits(0);
291 if( track->summaryValue(dummy,xAOD::numberOfInnermostPixelLayerHits))
292 nBLHits += dummy;
293 if( track->summaryValue(dummy, xAOD::numberOfInnermostPixelLayerOutliers))
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}
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
xAOD::Vertex * buildSingleTrackParticleConversion(const xAOD::TrackParticle *, xAOD::VertexContainer *container) const
Build single track conversion candidate.
SingleTrackConversionTool(const std::string &type, const std::string &name, const IInterface *parent)
bool selectSingleTrackParticleConversion(const xAOD::TrackParticle *) const
Select single track conversion candidates.
virtual StatusCode initialize() override
virtual const S & associatedSurface() const override final
Access to the Surface method.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
virtual constexpr SurfaceType type() const override final
Return the surface type.
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Primary Vertex Finder.
static const InterfaceID IID_ISingleTrackConversionTool("InDet::SingleTrackConversionTool", 1, 0)
CurvilinearParametersT< TrackParametersDim, Charged, PlaneSurface > CurvilinearParameters
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
@ locR
Definition ParamDefs.h:44
@ locZ
local cylindrical
Definition ParamDefs.h:42
Definition index.py:1
@ ConvVtx
Conversion vertex.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
@ expectInnermostPixelLayerHit
Do we expect a 0th-layer barrel hit for this track?
@ numberOfTRTXenonHits
number of TRT hits on track in straws with xenon [unit8_t].
@ numberOfTRTHits
number of TRT hits [unit8_t].
@ numberOfInnermostPixelLayerOutliers
number of 0th layer barrel outliers
@ eProbabilityHT
Electron probability from High Threshold (HT) information [float].
@ numberOfInnermostPixelLayerHits
these are the hits in the 0th pixel barrel layer
@ numberOfTRTOutliers
number of TRT outliers [unit8_t].
@ FirstMeasurement
Parameter defined at the position of the 1st measurement.
hold the test vectors and ease the comparison