ATLAS Offline Software
SingleTrackConversionTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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  , m_minInitR(70.)
47  , m_minInitR_noBLay(120.)
48  , m_singleThreshold(0.1)
49  , m_maxBLhits(0)
50  // m_maxPhiVtxTrk(0.2)
51  {
52  declareInterface<SingleTrackConversionTool>(this);
53  declareProperty("MinInitialHitRadius" , m_minInitR);
54  declareProperty("MinInitialHitRadius_noBlay" , m_minInitR_noBLay);
55  declareProperty("MinRatioOfHLhits" , m_singleThreshold);
56  //declareProperty("MaxPhiVtxTrk" , m_maxPhiVtxTrk);
57  declareProperty("MaxBLayerHits" , m_maxBLhits);
58  declareProperty("PIDonlyForXe" , m_PIDonlyForXe = false,
59  "Only check TRT PID if all hits are Xe hits");
60  }
61 
62  // -------------------------------------------------------
63  // destructor
64  // -------------------------------------------------------
66 
67  // -------------------------------------------------------
68  // not sure what this is about (Markus) ????
69  // -------------------------------------------------------
71  return IID_ISingleTrackConversionTool;
72  }
73 
74  // -------------------------------------------------------
75  // init method
76  // -------------------------------------------------------
78  return StatusCode::SUCCESS;
79  }
80 
81  // -------------------------------------------------------
82  // finalize method
83  // -------------------------------------------------------
85  return StatusCode::SUCCESS;
86  }
87 
88 
89  // -------------------------------------------------------
90  // building single track conversions from a particle
91  // -------------------------------------------------------
95  xAOD::VertexContainer* container) const
96  {
98 
99  unsigned int index(0);
100  if (!track->indexOfParameterAtPosition(index, xAOD::FirstMeasurement)) {
101  ATH_MSG_WARNING("TrackParticle has no first measurement");
102  return nullptr;
103  }
104 
105  const Trk::CurvilinearParameters trkPar =
106  track->curvilinearParameters(index);
107 
108  const Amg::Vector3D& gp = trkPar.position();
109  const AmgSymMatrix(5) em = *(trkPar.covariance());
110 
111  // ME: this is nuts, those values are 0, 0
112  // double chi2 = track->fitQuality()->chiSquared();
113  // int Ndf = track->fitQuality()->numberDoF();
114 
116  const Amg::Transform3D& T = trkPar.associatedSurface().transform();
117  AmgSymMatrix(3) nCovVtx;
118 
119  // Should use eigen to do all of this
120 
121  // ME: use the surface to find out what we do, do not hardcode the geoemtry
122  if (Trk::SurfaceType::Plane == trkPar.associatedSurface().type()) {
123 
125  double p11 = em(Trk::locX, Trk::locX);
126  double p12 = em(Trk::locX, Trk::locY);
127  double p21 = em(Trk::locY, Trk::locX);
128  double p22 = em(Trk::locY, Trk::locY);
129 
131  double Ax[3] = { T(0, 0), T(1, 0), T(2, 0) };
132  double Ay[3] = { T(0, 1), T(1, 1), T(2, 1) };
133  double a11 = Ax[0];
134  double a12 = Ay[0];
135  double a21 = Ax[1];
136  double a22 = Ay[1];
137  double a31 = Ax[2];
138  double a32 = Ay[2];
139 
141  double A11 = a11 * p11 + a12 * p21;
142  double A12 = a11 * p12 + a12 * p22;
143  double A21 = a21 * p11 + a22 * p21;
144  double A22 = a21 * p12 + a22 * p22;
145  double A31 = a31 * p11 + a32 * p21;
146  double A32 = a31 * p12 + a32 * p22;
147 
149  double P11 = a11 * A11 + A12 * a12;
150  double P12 = A11 * a21 + A12 * a22;
151  double P13 = A11 * a31 + A12 * a32;
152  double P21 = A21 * a11 + A22 * a12;
153  double P22 = A21 * a21 + A22 * a22;
154  double P23 = A21 * a31 + A22 * a32;
155  double P31 = A31 * a11 + A32 * a12;
156  double P32 = A31 * a21 + A32 * a22;
157  double P33 = A31 * a31 + A32 * a32;
158 
160  nCovVtx(0, 0) = P11;
161  nCovVtx(0, 1) = P12;
162  nCovVtx(0, 2) = P13;
163  nCovVtx(1, 0) = P21;
164  nCovVtx(1, 1) = P22;
165  nCovVtx(1, 2) = P23;
166  nCovVtx(2, 0) = P31;
167  nCovVtx(2, 1) = P32;
168  nCovVtx(2, 2) = P33;
169 
170  } else if (Trk::SurfaceType::Line == trkPar.associatedSurface().type()) {
171 
173  double p11 = em(Trk::locR, Trk::locR);
174  double p12 = em(Trk::locR, Trk::locZ);
175  double p21 = em(Trk::locZ, Trk::locR);
176  double p22 = em(Trk::locZ, Trk::locZ);
177 
179  double A[3] = {T(0,2),T(1,2),T(2,2)};
180 
182  double Px = trkPar.momentum().x();
183  double Py = trkPar.momentum().y();
184  double Pz = trkPar.momentum().z();
185 
187  double Bx = A[1]*Pz-A[2]*Py;
188  double By = A[2]*Px-A[0]*Pz;
189  double Bz = A[0]*Py-A[1]*Px;
190  double Bn = 1./sqrt(Bx*Bx+By*By+Bz*Bz); Bx*=Bn; By*=Bn; Bz*=Bn;
191  double a11 = Bx; double a12 = A[0];
192  double a21 = By; double a22 = A[1];
193  double a31 = Bz; double a32 = A[2];
194 
196  double A11 = a11*p11 + a12*p21; double A12 = a11*p12 + a12*p22;
197  double A21 = a21*p11 + a22*p21; double A22 = a21*p12 + a22*p22;
198  double A31 = a31*p11 + a32*p21; double A32 = a31*p12 + a32*p22;
199 
201  double P11 = a11*A11 + A12*a12; double P12 = A11*a21 + A12*a22; double P13 = A11*a31 + A12*a32;
202  double P21 = A21*a11 + A22*a12; double P22 = A21*a21 + A22*a22; double P23 = A21*a31 + A22*a32;
203  double P31 = A31*a11 + A32*a12; double P32 = A31*a21 + A32*a22; double P33 = A31*a31 + A32*a32;
204 
206  nCovVtx(0,0) = P11; nCovVtx(0,1) = P12; nCovVtx(0,2) = P13;
207  nCovVtx(1,0) = P21; nCovVtx(1,1) = P22; nCovVtx(1,2) = P23;
208  nCovVtx(2,0) = P31; nCovVtx(2,1) = P32; nCovVtx(2,2) = P33;
209  }
210 
211  // now construct the vertex from the global position, cov. put NdF and chi2 to zero (Markus)
212 
213 
215  container->push_back( vertex );
216 
217  vertex->setPosition(gp);
218  vertex->setCovariancePosition(nCovVtx);
219  vertex->setVertexType(xAOD::VxType::ConvVtx);
220  vertex->setFitQuality( 0, 0);
221 
222  return vertex;
223  }
224 
225  // -------------------------------------------------------
226  // preselection cuts on track particles
227  // -------------------------------------------------------
229 
230  //Position of first hit in track particle
231 
232  int index(-1);
233  for(unsigned int i(0); i< track->numberOfParameters() ; ++i ){
234  if( xAOD::FirstMeasurement == track->parameterPosition(i) ){
235  index = i;
236  break;
237  }
238  }
239  if(index ==-1){
240  ATH_MSG_WARNING("Track Particle does not contain first Measurement track parameters");
241  return false;
242  }
243 
244  const Trk::CurvilinearParameters trk_meas = track->curvilinearParameters(index);
245 
246  uint8_t dummy;
247 
248  uint8_t expectedHitInBLayer(0);
249  if( track->summaryValue(dummy,xAOD::expectInnermostPixelLayerHit) )
250  expectedHitInBLayer = dummy;
251 
252  float Rfirst = trk_meas.position().perp();
253  if (expectedHitInBLayer)
254  {
255  // ME: cut on minInitR if blayer is ok
256  if (Rfirst < m_minInitR)
257  {
258  ATH_MSG_DEBUG("BLayer hit expected. Radius of first hit (" <<
259  Rfirst << ") below minimum: " << m_minInitR);
260  return false;
261  }
262  }
263  else
264  {
265  // ME: cut on minInitR_NBLay if blayer is off
266  if(Rfirst < m_minInitR_noBLay)
267  {
268  ATH_MSG_DEBUG("No BLayer hit expected. Radius of first hit (" <<
269  Rfirst << ") below minimum: " << m_minInitR_noBLay);
270  return false;
271  }
272  }
273 
274 
275  uint8_t nTrtHits(0);
276  if( track->summaryValue(dummy, xAOD::numberOfTRTHits))
277  nTrtHits = dummy;
278 
279  uint8_t nTrtOutliers(0);
280  if(track->summaryValue(dummy, xAOD::numberOfTRTOutliers))
281  nTrtOutliers = dummy;
282 
283  uint8_t ntrt = nTrtHits + nTrtOutliers;
284 
285  uint8_t nTrtXenonHits(0);
286  if( track->summaryValue(dummy, xAOD::numberOfTRTXenonHits) )
287  nTrtXenonHits = dummy;
288 
289 
290 
291  if(ntrt > 0 && (!m_PIDonlyForXe || nTrtXenonHits==ntrt) ) {
292  // only check TRT PID if m_PIDonlyForXe is false or all TRT hits are Xenon hits
293  float prob = 1.0;
294  if( !track->summaryValue(prob,xAOD::eProbabilityHT) )
295  {
296  ATH_MSG_WARNING("Could not retrieve TR probability");
297  return false;
298  }
299  if (prob < m_singleThreshold)
300  {
301  ATH_MSG_DEBUG("Probability (" << prob << ") below threshold: "
302  << m_singleThreshold);
303  return false;
304  }
305  }
306 
307  uint8_t nBLHits(0);
309  nBLHits += dummy;
311  nBLHits += dummy;
312  if(nBLHits > m_maxBLhits)
313  {
314  ATH_MSG_DEBUG("BLayer hits (" << nBLHits << ") above maximum: " << m_maxBLhits);
315  return false;
316  }
317 
318  return true;
319  }
320 }
LinkToTrack.h
ITrackSummaryTool.h
StraightLineSurface.h
TrackParameters.h
InDet::SingleTrackConversionTool::initialize
virtual StatusCode initialize() override
Definition: SingleTrackConversionTool.cxx:77
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:575
Trk::locX
@ locX
Definition: ParamDefs.h:43
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:44
Surface.h
Trk::ParametersBase::position
const Amg::Vector3D & position() const
Access method for the position.
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
InDet
DUMMY 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_PIDonlyForXe
bool m_PIDonlyForXe
Maximum number of blayer hits.
Definition: SingleTrackConversionTool.h:58
InDet::SingleTrackConversionTool::selectSingleTrackParticleConversion
bool selectSingleTrackParticleConversion(const xAOD::TrackParticle *) const
Select single track conversion candidates.
Definition: SingleTrackConversionTool.cxx:228
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:50
covarianceTool.prob
prob
Definition: covarianceTool.py:678
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:52
InDet::SingleTrackConversionTool::interfaceID
static const InterfaceID & interfaceID()
Definition: SingleTrackConversionTool.cxx:70
Track.h
InDet::SingleTrackConversionTool::~SingleTrackConversionTool
virtual ~SingleTrackConversionTool()
xAOD::numberOfInnermostPixelLayerOutliers
@ numberOfInnermostPixelLayerOutliers
number of 0th layer barrel outliers
Definition: TrackingPrimitives.h:238
InDet::SingleTrackConversionTool::m_maxBLhits
int m_maxBLhits
Minimum ratio of HL hits for a track to be labeled as electron.
Definition: SingleTrackConversionTool.h:56
Trk::locZ
@ locZ
local cylindrical
Definition: ParamDefs.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:92
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:93
InDet::SingleTrackConversionTool::m_singleThreshold
double m_singleThreshold
Minimum initial hit radius in order to consider track as coming from photon conversion.
Definition: SingleTrackConversionTool.h:54
Trk::CurvilinearParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
Py
Definition: PyDataStore.h:24
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
InDet::SingleTrackConversionTool::m_minInitR
double m_minInitR
Definition: SingleTrackConversionTool.h:50
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
InDet::SingleTrackConversionTool::m_minInitR_noBLay
double m_minInitR_noBLay
Minimum initial hit radius in order to consider track as coming from photon conversion.
Definition: SingleTrackConversionTool.h:52
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:362
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
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:84
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