ATLAS Offline Software
Loading...
Searching...
No Matches
InDetAlignTrackSelTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5// InDetAlignTrackSelTool.h
6
7// Sergio Gonzalez Sevilla, started 04/7/05
8// Miguel Olivo Gomez, extended 07/6/06
9
10// AlgTool to select high quality tracks for the inner detector
11// (Pixel+SCT) alignment algorithms.
12// This AlgTool provides a track selection based on the following cut variables:
13// Momentum, pt, number of shared hits, number of holes and chi2 probability.
14// Returns 0 in case a track is not accepted, otherwise 1
15
17
20
23#include "CLHEP/GenericFunctions/CumulativeChiSquare.hh"
24
26 , const std::string& name
27 , const IInterface* parent
28 )
29 : AthAlgTool(type,name,parent),
30 m_particleCreator("Trk::TrackParticleCreatorTool/TrackParticleCreatorTool", this),
32 m_minPt(2),
33 m_maxShared(0),
34 m_maxHoles(1),
35 m_minChi2Prob(0.2)
36{
37 declareInterface<IInDetAlignTrackSelTool>(this);
38 declareProperty("MinMomentum" , m_minMomentum);
39 declareProperty("MinPt" , m_minPt);
40 declareProperty("MaxShared" , m_maxShared);
41 declareProperty("MaxHoles" , m_maxHoles);
42 declareProperty("MinChi2Prob" , m_minChi2Prob);
43
44 // Tools
45 declareProperty("TrackParticleCreatorTool", m_particleCreator,
46 "tool to build TrackParticle");
47}
48
51
55
56 // get TrackParticleCreatorTool
57 ATH_CHECK(m_particleCreator.retrieve());
58
59 ATH_MSG_DEBUG( "Cuts selected : min_Momentum(CLHEP::GeV)=" << m_minMomentum
60 << " min_pt(CLHEP::GeV)=" << m_minPt
61 << " max_shared=" << m_maxShared
62 << " max_holes=" << m_maxHoles
63 << " min_chi2Prob=" << m_minChi2Prob ) ;
64
65 ATH_MSG_DEBUG( "InDetAlignTrackSelTool initialize() successful" ) ;
66 return StatusCode::SUCCESS;
67}
68
72 ATH_MSG_DEBUG( "InDetAlignTrackSelTool finalize method called" ) ;
73 return StatusCode::SUCCESS;
74}
75
77double InDetAlignTrackSelTool::Momentum(const Trk::Track& track) const {
79 ATH_MSG_DEBUG( "in Momentum() " ) ;
80 double mom=0.;
81
82 // get measured perigee and momentum of track
83 const Trk::Perigee* perigee = track.perigeeParameters();
84
85 if ( !perigee->covariance()) {
86 ATH_MSG_ERROR( "No measured perigee parameters assigned to the track" ) ;
87 mom = -1e12; // return big value
88 }
89 else{
90 Amg::VectorX perigeeParams = perigee->parameters();
91 mom = std::abs(1./perigeeParams[Trk::qOverP]);
92 mom /= 1000.; //mom in GeV
93 }
94
95 return mom;
96}
97
99double InDetAlignTrackSelTool::Pt(const Trk::Track& track) const {
101 ATH_MSG_DEBUG( "in Pt() " ) ;
102 double pt=0.;
103
104 // get measured perigee and pt of track
105 const Trk::Perigee* perigee = track.perigeeParameters();
106
107 if (!perigee->covariance()) {
108 ATH_MSG_ERROR( "No measured perigee parameters assigned to the track" ) ;
109 pt = -1e12; // return big value
110 }
111 else{
112 Amg::VectorX perigeeParams = perigee->parameters();
113 pt = std::abs(sin(perigeeParams[Trk::theta])/perigeeParams[Trk::qOverP]);
114 pt /= 1000.; // pt in GeV
115 }
116
117 return pt;
118}
119
121int InDetAlignTrackSelTool::nShared(const EventContext& ctx, const Trk::Track& track) const {
123 ATH_MSG_DEBUG( "in nShared()" ) ;
124 int nshared=0, nshpix, nshsct;
125
126 xAOD::TrackParticle* trackPart = m_particleCreator->createParticle(ctx, track);
127 uint8_t iSummaryValue(0); // Dummy counter to retrieve summary values
128
129 if (not trackPart){
130 ATH_MSG_ERROR("Could not get xAOD::TrackParticle");
131 nshared = 1000;
132 }
133 else{
134 nshpix = trackPart->summaryValue(iSummaryValue, xAOD::numberOfPixelSharedHits) ? iSummaryValue : 0;
135 nshsct = trackPart->summaryValue(iSummaryValue, xAOD::numberOfSCTSharedHits) ? iSummaryValue : 0;
136 //At condition nhpix == -1, the following bits of nhsct are known to be unset: 8-31.
137 //The condition nhpix == -1 cannot be true.
138 //At condition nhsct == -1, the following bits of nhsct are known to be unset: 8-31.
139 //The condition nhsct == -1 cannot be true.
140
141 nshared = nshpix + nshsct;
142 }
143 return nshared;
144}
145
147int InDetAlignTrackSelTool::nHoles(const EventContext& ctx, const Trk::Track& track) const {
149 ATH_MSG_DEBUG( "in nHoles() " ) ;
150 int nholes{}, nhpix{}, nhsct{};
151
152 xAOD::TrackParticle* trackPart = m_particleCreator->createParticle(ctx, track);
153 uint8_t iSummaryValue(0); // Dummy counter to retrieve summary values
154
155 if (not trackPart){
156 ATH_MSG_ERROR("Could not get xAOD::TrackParticle");
157 nholes = 1000;
158 }
159 else{
160 nhpix = trackPart->summaryValue(iSummaryValue, xAOD::numberOfPixelHoles) ? iSummaryValue : 0;
161 nhsct = trackPart->summaryValue(iSummaryValue, xAOD::numberOfSCTHoles) ? iSummaryValue : 0;
162 //At condition nhpix == -1, the following bits of nhsct are known to be unset: 8-31.
163 //The condition nhpix == -1 cannot be true.
164 //At condition nhsct == -1, the following bits of nhsct are known to be unset: 8-31.
165 //The condition nhsct == -1 cannot be true.
166 nholes = nhpix + nhsct;
167 }
168 return nholes;
169}
170
174 ATH_MSG_DEBUG( "in chi2Prob()" ) ;
175 double chi2Prob=0.;
176
177 // get fit quality and chi2 probability of track
178 // chi2Prob = TMath::Prob(chi2,DoF) ROOT function
179 const Trk::FitQuality* fitQual = track.fitQuality();
180
181 if (fitQual==nullptr) {
182 ATH_MSG_ERROR( "No fit quality assigned to the track" ) ;
183 chi2Prob = -1e12; // return big value
184 }
185 else {
186 if (fitQual->chiSquared() > 0. && fitQual->numberDoF() > 0) {
187 Genfun::CumulativeChiSquare probabilityFunction( fitQual->numberDoF() );
188 chi2Prob = 1 - probabilityFunction( fitQual->chiSquared() );
189 }
190 }
191
192 return chi2Prob;
193}
194
196int InDetAlignTrackSelTool::getStatus(const EventContext& ctx, const Trk::Track& track) const {
198 ATH_MSG_DEBUG( "in getStatus()" ) ;
199 int stat=1, nholes, nshared;
200 double mom, pt, chi2prob;
201
202 // momentum
203 mom = Momentum(track);
204 if (mom < m_minMomentum) {
205 stat=0;
206 }
207
208 // transverse momentum
209 pt = Pt(track);
210 if (pt < m_minPt) {
211 stat=0;
212 }
213
214 // number of holes
215 nholes = nHoles(ctx, track);
216 if (nholes > m_maxHoles) {
217 stat=0;
218 }
219
220 // number of shared hits
221 nshared = nShared(ctx, track);
222 if (nshared > m_maxShared) {
223 stat=0;
224 }
225
226 // chi2 Probability
227 chi2prob = chi2Prob(track);
228 if (chi2prob < m_minChi2Prob) {
229 stat=0;
230 }
231
232 ATH_MSG_DEBUG( " momentum(CLHEP::GeV)=" << mom
233 << " pt (CLHEP::GeV)=" << pt
234 << " nshared=" << nshared
235 << " nholes=" << nholes
236 << " chi2Prob=" << chi2prob
237 ) ;
238
239 if(!stat)
240 ATH_MSG_DEBUG( "Track not accepted" ) ;
241 else
242 ATH_MSG_DEBUG( "Track accepted" ) ;
243
244 return stat;
245}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreator
Pointer to track particle creator tool.
int nHoles(const EventContext &ctx, const Trk::Track &) const
virtual int getStatus(const EventContext &ctx, const Trk::Track &) const
int m_maxShared
Maximum number of shared hits of the track.
int nShared(const EventContext &ctx, const Trk::Track &) const
double Momentum(const Trk::Track &) const
double m_minPt
Minimum value of the transverse momentum of the track.
double m_minMomentum
Minimum value of the momentum of the track.
double chi2Prob(const Trk::Track &) const
int m_maxHoles
Maximum number of holes of the track.
InDetAlignTrackSelTool(const std::string &type, const std::string &name, const IInterface *parent)
double m_minChi2Prob
Minimum value of the chi2 Probality of the track.
double Pt(const Trk::Track &) const
virtual StatusCode initialize()
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition FitQuality.h:97
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition FitQuality.h:60
double chiSquared() const
returns the of the overall track fit
Definition FitQuality.h:56
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
TrackParticle_v1 TrackParticle
Reference the current persistent version:
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
@ numberOfPixelSharedHits
number of Pixel all-layer hits shared by several tracks [unit8_t].
@ numberOfSCTSharedHits
number of SCT hits shared by several tracks [unit8_t].
@ numberOfSCTHoles
number of SCT holes [unit8_t].