ATLAS Offline Software
InDetTrackSelectorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // forward declares
9 #include "VxVertex/Vertex.h"
11 #include "TrkTrack/Track.h"
12 // normal includes
14 #include "CLHEP/Matrix/Vector.h"
15 #include "CLHEP/Units/SystemOfUnits.h"
16 
17 using CLHEP::mm;
18 
19 namespace InDet
20 {
21 
22 //_______________________________________________________________________________
23 InDetTrackSelectorTool::InDetTrackSelectorTool(const std::string & t, const std::string & n, const IInterface * p)
24  : AthAlgTool(t,n,p)
25  , m_minPt(500.)
26  , m_IPz0Max(10.*mm)
27  , m_maxZ0(99999.)
28  , m_maxD0(2.*mm)
29  , m_maxD0overSigmaD0(3.)
30  , m_numberOfPixelHits(2)
31  , m_numberOfBLayerHits(1)
32  , m_trackSumToolAvailable(false)
33  , m_extrapolator("Trk::Extrapolator")
34 {
35  declareInterface<ITrackSelectorTool>(this);
36  declareProperty("minPt", m_minPt);
37  declareProperty("IPz0Max", m_IPz0Max); // cut on |z|*sin(theta)
38  declareProperty("maxZ0", m_maxZ0);
39  declareProperty("maxD0", m_maxD0);
40  declareProperty("maxD0overSigmaD0", m_maxD0overSigmaD0);
41  declareProperty("numberOfPixelHits", m_numberOfPixelHits);
42  declareProperty("numberOfInnermostPixelLayerHits", m_numberOfBLayerHits);
43  declareProperty("TrackSummaryTool", m_trackSumTool);
44  declareProperty("Extrapolator", m_extrapolator);
45 }
46 
47 //_______________________________________________________________________________
49 = default;
50 
51 //_______________________________________________________________________________
53 {
55  if (!m_trackSumTool.empty())
56  {
57  if(m_trackSumTool.retrieve().isFailure()) {
58  msg(MSG::ERROR)<<" Unable to retrieve "<<m_trackSumTool<<endmsg;
59  return StatusCode::FAILURE;
60  }
61  else {
63  }
64  }
65 
66  if ( m_extrapolator.retrieve().isFailure() ) {
67  msg(MSG::ERROR) << "Failed to retrieve tool " << m_extrapolator << endmsg;
68  return StatusCode::FAILURE;
69  }
70 
71  return StatusCode::SUCCESS;
72 }
73 
74 
75 //_______________________________________________________________________________
77 {
78  // decision based on the track parameters
79  if(!decision(track.perigeeParameters(), vertex, track.info().particleHypothesis()))
80  return false;
81 
82  // number of hits, silicon hits, b-layer
83  // first ask track for summary
84  std::unique_ptr<Trk::TrackSummary> summaryUniquePtr;
85  const Trk::TrackSummary * summary = track.trackSummary();
86  if (summary == nullptr && m_trackSumToolAvailable) {
87  summaryUniquePtr = m_trackSumTool->summary(track);
88  summary = summaryUniquePtr.get();
89  }
90 
91  if (nullptr==summary) {
92  ATH_MSG_DEBUG( "Track preselection: cannot create a track summary. This track will not pass." );
93  return false;
94  }
95 
97  int nPixelDead = summary->get(Trk::numberOfPixelDeadSensors);
98  if (nPixelDead<0)
99  nPixelDead=0;
100 
101  int nBLayerHits = summary->get(Trk::numberOfInnermostPixelLayerHits);
102 
103  if(nPixelHits+nPixelDead<m_numberOfPixelHits || nBLayerHits<m_numberOfBLayerHits )
104  return false;
105 
106  // all ok
107  return true;
108 }
109 
110 //_______________________________________________________________________________
112 {
113  if(!decision(&(track.definingParameters()), vertex, Trk::pion))
114  return false;
115 
116  const Trk::TrackSummary * summary = track.trackSummary();
117  if (summary == nullptr) {
118  ATH_MSG_INFO( "TrackParticleBase does not have a Track Summary. Rejected." );
119  return false;
120  }
122  int nPixelDead = summary->get(Trk::numberOfPixelDeadSensors);
123  if (nPixelDead<0)
124  nPixelDead=0;
125 
126  int nBLayerHits = summary->get(Trk::numberOfInnermostPixelLayerHits);
127 
128  return nPixelHits+nPixelDead>=m_numberOfPixelHits && nBLayerHits>=m_numberOfBLayerHits;
129 }
130 
131 //_______________________________________________________________________________
133 {
134  // checking pointer first
135  if(nullptr==track || !track->covariance()) {
136  ATH_MSG_WARNING( "Track preselection: Zero pointer to parameterbase* received (most likely a track without perigee). This track will not pass." );
137  return false;
138  }
139 
140  // getting the perigee parameters of the track
141  const Trk::Perigee * perigee(nullptr);
142  if(vertex == nullptr)
143  perigee = dynamic_cast<const Trk::Perigee *>(track);
144  else {
145  Trk::PerigeeSurface perigeeSurface(vertex->position());
146  std::unique_ptr<const Trk::TrackParameters> tmp =
147  m_extrapolator->extrapolate(Gaudi::Hive::currentContext(),
148  *track,
149  perigeeSurface,
151  true,
152  hyp);
153  //release only of right type
154  if (tmp && tmp->associatedSurface().type() == Trk::SurfaceType::Perigee) {
155  perigee = static_cast<const Trk::Perigee*>(tmp.release());
156  }
157  }
158 
159  if(nullptr == perigee || !perigee->covariance() ) {
160  ATH_MSG_INFO( "Track preselection: cannot make a measured perigee. This track will not pass." );
161  return false;
162  }
163 
164  AmgVector(5) trackParameters = perigee->parameters();
165 
166  // d0 and z0 cuts
167  double d0 = trackParameters[Trk::d0];
168  if(fabs(d0) > m_maxD0) { if(vertex != nullptr) { delete perigee; } return false; }
169 
170  double z0 = trackParameters[Trk::z0];
171  if (fabs(z0)*sin(trackParameters[Trk::theta]) > m_IPz0Max)
172  { if(vertex != nullptr) { delete perigee; } return false; }
173  if (fabs(z0) > m_maxZ0)
174  { if(vertex != nullptr) { delete perigee; } return false; }
175 
176  // transverse momentum
177  double pt = perigee->momentum().perp();
178  if(pt<m_minPt) { if(vertex != nullptr) { delete perigee; } return false; }
179 
180  // d0 significance
181  double d0Significance=fabs(trackParameters[Trk::d0]/sqrt( (*perigee->covariance())(Trk::d0,Trk::d0) ));
182  if (d0Significance>m_maxD0overSigmaD0)
183  { if(vertex != nullptr) { delete perigee; } return false; }
184 
185  if(vertex != nullptr) { delete perigee; }
186  return true;
187 } //end of selection method
188 
189 } //end of namespace definitions
Trk::numberOfPixelHits
@ numberOfPixelHits
number of pixel layers on track with absence of hits
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:57
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
Trk::Vertex
Definition: Tracking/TrkEvent/VxVertex/VxVertex/Vertex.h:26
InDet::InDetTrackSelectorTool::m_minPt
double m_minPt
Minimum Pt of tracks.
Definition: InDetTrackSelectorTool.h:66
ITrackSummaryTool.h
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Trk::numberOfInnermostPixelLayerHits
@ numberOfInnermostPixelLayerHits
these are the hits in the 1st pixel layer
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:53
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
TauGNNUtils::Variables::Track::nPixelHits
bool nPixelHits(const xAOD::TauJet &, const xAOD::TauTrack &track, double &out)
Definition: TauGNNUtils.cxx:542
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
InDet
DUMMY Primary Vertex Finder.
Definition: VP1ErrorUtils.h:36
InDet::InDetTrackSelectorTool::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: InDetTrackSelectorTool.h:76
TrackParticleBase.h
test_pyathena.pt
pt
Definition: test_pyathena.py:11
InDet::InDetTrackSelectorTool::m_numberOfPixelHits
int m_numberOfPixelHits
Check for silicon hits ?
Definition: InDetTrackSelectorTool.h:71
Trk::z0
@ z0
Definition: ParamDefs.h:70
IExtrapolator.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
InDet::InDetTrackSelectorTool::~InDetTrackSelectorTool
~InDetTrackSelectorTool()
InDet::InDetTrackSelectorTool::m_maxD0overSigmaD0
double m_maxD0overSigmaD0
Maximum d0/sigmad0 of tracks.
Definition: InDetTrackSelectorTool.h:70
InDet::InDetTrackSelectorTool::m_numberOfBLayerHits
int m_numberOfBLayerHits
Definition: InDetTrackSelectorTool.h:72
Track.h
InDet::InDetTrackSelectorTool::m_IPz0Max
double m_IPz0Max
max.
Definition: InDetTrackSelectorTool.h:67
Trk::TrackParticleBase
Definition: TrackParticleBase.h:41
Trk::ParticleHypothesis
ParticleHypothesis
Definition: ParticleHypothesis.h:25
InDetTrackSelectorTool.h
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:72
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AmgVector
AmgVector(4) T2BSTrackFilterTool
Definition: T2BSTrackFilterTool.cxx:114
Trk::numberOfPixelDeadSensors
@ numberOfPixelDeadSensors
number of pixel hits with broad errors (width/sqrt(12))
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:65
Trk::pion
@ pion
Definition: ParticleHypothesis.h:29
InDet::InDetTrackSelectorTool::m_trackSumToolAvailable
bool m_trackSumToolAvailable
Definition: InDetTrackSelectorTool.h:74
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
InDet::InDetTrackSelectorTool::InDetTrackSelectorTool
InDetTrackSelectorTool(const std::string &t, const std::string &n, const IInterface *p)
Definition: InDetTrackSelectorTool.cxx:23
InDet::InDetTrackSelectorTool::initialize
virtual StatusCode initialize() override
Definition: InDetTrackSelectorTool.cxx:52
TrackSummary.h
Trk::ParametersBase
Definition: ParametersBase.h:55
TRT::Track::z0
@ z0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:63
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
Trk::SurfaceType::Perigee
@ Perigee
InDet::InDetTrackSelectorTool::m_maxZ0
double m_maxZ0
Maximum z0 of tracks.
Definition: InDetTrackSelectorTool.h:68
Trk::TrackSummary
A summary of the information contained by a track.
Definition: Tracking/TrkEvent/TrkTrackSummary/TrkTrackSummary/TrackSummary.h:287
Trk::d0
@ d0
Definition: ParamDefs.h:69
Vertex.h
InDet::InDetTrackSelectorTool::m_maxD0
double m_maxD0
Maximum d0 of tracks.
Definition: InDetTrackSelectorTool.h:69
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
InDet::InDetTrackSelectorTool::decision
virtual bool decision(const Trk::Track &track, const Trk::Vertex *vertex) const override
Definition: InDetTrackSelectorTool.cxx:76
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
InDet::InDetTrackSelectorTool::m_trackSumTool
ToolHandle< Trk::ITrackSummaryTool > m_trackSumTool
Definition: InDetTrackSelectorTool.h:73
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthAlgTool
Definition: AthAlgTool.h:26
SCT_Monitoring::summary
@ summary
Definition: SCT_MonitoringNumbers.h:65