ATLAS Offline Software
InDetAlignTrackSelTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  )
30  m_particleCreator("Trk::TrackParticleCreatorTool/TrackParticleCreatorTool", this),
31  m_minMomentum(0),
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 
50 {}
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 
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 
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 
123  ATH_MSG_DEBUG( "in nShared()" ) ;
124  int nshared=0, nshpix, nshsct;
125 
126  xAOD::TrackParticle* trackPart = m_particleCreator->createParticle(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 
137  if(nshpix==-1)
138  nshpix=0;
139 
140  if(nshsct==-1)
141  nshsct=0;
142 
143  nshared = nshpix + nshsct;
144  }
145  return nshared;
146 }
147 
151  ATH_MSG_DEBUG( "in nHoles() " ) ;
152  int nholes=0, nhpix, nhsct;
153 
154  xAOD::TrackParticle* trackPart = m_particleCreator->createParticle(track);
155  uint8_t iSummaryValue(0); // Dummy counter to retrieve summary values
156 
157  if (not trackPart){
158  ATH_MSG_ERROR("Could not get xAOD::TrackParticle");
159  nholes = 1000;
160  }
161  else{
162  nhpix = trackPart->summaryValue(iSummaryValue, xAOD::numberOfPixelHoles) ? iSummaryValue : 0;
163  nhsct = trackPart->summaryValue(iSummaryValue, xAOD::numberOfSCTHoles) ? iSummaryValue : 0;
164 
165  if(nhpix==-1)
166  nhpix = 0;
167 
168  if(nhsct==-1)
169  nhsct = 0;
170 
171  nholes = nhpix + nhsct;
172  }
173  return nholes;
174 }
175 
179  ATH_MSG_DEBUG( "in chi2Prob()" ) ;
180  double chi2Prob=0.;
181 
182  // get fit quality and chi2 probability of track
183  // chi2Prob = TMath::Prob(chi2,DoF) ROOT function
184  const Trk::FitQuality* fitQual = track.fitQuality();
185 
186  if (fitQual==nullptr) {
187  ATH_MSG_ERROR( "No fit quality assigned to the track" ) ;
188  chi2Prob = -1e12; // return big value
189  }
190  else {
191  if (fitQual->chiSquared() > 0. && fitQual->numberDoF() > 0) {
192  Genfun::CumulativeChiSquare probabilityFunction( fitQual->numberDoF() );
193  chi2Prob = 1 - probabilityFunction( fitQual->chiSquared() );
194  }
195  }
196 
197  return chi2Prob;
198 }
199 
203  ATH_MSG_DEBUG( "in getStatus()" ) ;
204  int stat=1, nholes, nshared;
205  double mom, pt, chi2prob;
206 
207  // momentum
208  mom = Momentum(track);
209  if (mom < m_minMomentum) {
210  stat=0;
211  }
212 
213  // transverse momentum
214  pt = Pt(track);
215  if (pt < m_minPt) {
216  stat=0;
217  }
218 
219  // number of holes
220  nholes = nHoles(track);
221  if (nholes > m_maxHoles) {
222  stat=0;
223  }
224 
225  // number of shared hits
226  nshared = nShared(track);
227  if (nshared > m_maxShared) {
228  stat=0;
229  }
230 
231  // chi2 Probability
232  chi2prob = chi2Prob(track);
233  if (chi2prob < m_minChi2Prob) {
234  stat=0;
235  }
236 
237  ATH_MSG_DEBUG( " momentum(CLHEP::GeV)=" << mom
238  << " pt (CLHEP::GeV)=" << pt
239  << " nshared=" << nshared
240  << " nholes=" << nholes
241  << " chi2Prob=" << chi2prob
242  ) ;
243 
244  if(!stat)
245  ATH_MSG_DEBUG( "Track not accepted" ) ;
246  else
247  ATH_MSG_DEBUG( "Track accepted" ) ;
248 
249  return stat;
250 }
xAOD::numberOfPixelHoles
@ numberOfPixelHoles
number of pixel layers on track with absence of hits [unit8_t].
Definition: TrackingPrimitives.h:261
InDetAlignTrackSelTool::m_particleCreator
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreator
Pointer to track particle creator tool.
Definition: InDetAlignTrackSelTool.h:54
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:32
TrackParameters.h
xAOD::numberOfSCTSharedHits
@ numberOfSCTSharedHits
number of SCT hits shared by several tracks [unit8_t].
Definition: TrackingPrimitives.h:272
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
InDetAlignTrackSelTool::m_maxShared
int m_maxShared
Maximum number of shared hits of the track.
Definition: InDetAlignTrackSelTool.h:58
InDetAlignTrackSelTool::~InDetAlignTrackSelTool
virtual ~InDetAlignTrackSelTool()
Definition: InDetAlignTrackSelTool.cxx:49
InDetAlignTrackSelTool::Momentum
double Momentum(const Trk::Track &) const
Definition: InDetAlignTrackSelTool.cxx:77
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
ITrackParticleCreatorTool.h
test_pyathena.pt
pt
Definition: test_pyathena.py:11
InDetAlignTrackSelTool::chi2Prob
double chi2Prob(const Trk::Track &) const
Definition: InDetAlignTrackSelTool.cxx:177
InDetAlignTrackSelTool::m_minChi2Prob
double m_minChi2Prob
Minimum value of the chi2 Probality of the track.
Definition: InDetAlignTrackSelTool.h:60
xAOD::numberOfPixelSharedHits
@ numberOfPixelSharedHits
number of Pixel all-layer hits shared by several tracks [unit8_t].
Definition: TrackingPrimitives.h:262
ParticleGun_EoverP_Config.mom
mom
Definition: ParticleGun_EoverP_Config.py:63
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::theta
@ theta
Definition: ParamDefs.h:72
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
InDetAlignTrackSelTool::nShared
int nShared(const Trk::Track &) const
Definition: InDetAlignTrackSelTool.cxx:121
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::FitQuality
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
Definition: FitQuality.h:97
xAOD::numberOfSCTHoles
@ numberOfSCTHoles
number of SCT holes [unit8_t].
Definition: TrackingPrimitives.h:270
InDetAlignTrackSelTool::m_minPt
double m_minPt
Minimum value of the transverse momentum of the track.
Definition: InDetAlignTrackSelTool.h:57
InDetAlignTrackSelTool::Pt
double Pt(const Trk::Track &) const
Definition: InDetAlignTrackSelTool.cxx:99
beamspotman.stat
stat
Definition: beamspotman.py:266
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
InDetAlignTrackSelTool::nHoles
int nHoles(const Trk::Track &) const
Definition: InDetAlignTrackSelTool.cxx:149
InDetAlignTrackSelTool::InDetAlignTrackSelTool
InDetAlignTrackSelTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: InDetAlignTrackSelTool.cxx:25
TrackParticle.h
InDetAlignTrackSelTool.h
InDetAlignTrackSelTool::finalize
virtual StatusCode finalize()
Definition: InDetAlignTrackSelTool.cxx:70
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:73
InDetAlignTrackSelTool::getStatus
virtual int getStatus(const Trk::Track &) const
Definition: InDetAlignTrackSelTool.cxx:201
InDetAlignTrackSelTool::m_maxHoles
int m_maxHoles
Maximum number of holes of the track.
Definition: InDetAlignTrackSelTool.h:59
Trk::FitQuality::chiSquared
double chiSquared() const
returns the of the overall track fit
Definition: FitQuality.h:56
Trk::FitQuality::numberDoF
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition: FitQuality.h:60
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthAlgTool
Definition: AthAlgTool.h:26
FitQuality.h
InDetAlignTrackSelTool::m_minMomentum
double m_minMomentum
Minimum value of the momentum of the track.
Definition: InDetAlignTrackSelTool.h:56
InDetAlignTrackSelTool::initialize
virtual StatusCode initialize()
Definition: InDetAlignTrackSelTool.cxx:53