ATLAS Offline Software
InDetIsoTrackSelectorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 // forward declares
9 #include "TrkTrack/Track.h"
12 #include "CLHEP/Units/SystemOfUnits.h"
13 
14 using CLHEP::mm;
15 
16 //_______________________________________________________________________________
17 InDet::InDetIsoTrackSelectorTool::InDetIsoTrackSelectorTool(const std::string & t, const std::string & n, const IInterface * p)
18  : AthAlgTool(t,n,p),
19  m_robustCuts(true),
20  m_applySinThetaCorrection(true),
21  m_d0max(1.5*mm),
22  m_z0stMax(1.5*mm),
23  m_d0Significance(3),
24  m_z0Significance(3),
25  m_extrapolator("Trk::Extrapolator/InDetExtrapolator"),
26  m_trackSelector("")
27 {
28  declareInterface<Trk::IIsoTrackSelectorTool>(this);
29  // properties via python binding
30  declareProperty("RobustCuts", m_robustCuts);
31  declareProperty("SinThetaCorrection", m_applySinThetaCorrection);
32  declareProperty("maxD0", m_d0max);
33  declareProperty("maxZ0", m_z0stMax);
34  declareProperty("maxD0overSigmaD0", m_d0Significance);
35  declareProperty("maxZ0overSigmaZ0", m_z0Significance);
36  // tools
37  declareProperty("Extrapolator", m_extrapolator);
38  declareProperty("TrackSelector", m_trackSelector);
39 }
40 
41 //_______________________________________________________________________________
43 = default;
44 
45 //_______________________________________________________________________________
47 {
48 
51 
52  // get the extrapolator
53  if ( m_extrapolator.retrieve().isFailure() ){
54  ATH_MSG_ERROR("Could not retrieve Extrapolator '" << m_extrapolator << "' (essential). Abort.");
55  return StatusCode::FAILURE;
56  } else
57  ATH_MSG_DEBUG("Successfully retrieved " << m_extrapolator);
58 
59  // get the track selector if needed
60  if ( !m_trackSelector.empty() && m_trackSelector.retrieve().isFailure() ){
61  ATH_MSG_ERROR("Could not retrieve TrackSelector '" << m_trackSelector <<"' although configured. Abort.");
62  return StatusCode::FAILURE;
63  }
64  // done
65  return StatusCode::SUCCESS;
66 }
67 
68 
69 //_______________________________________________________________________________
71 {
72  const Trk::Perigee* tPerigee = track.perigeeParameters();
73  if (!tPerigee){
74  ATH_MSG_DEBUG("No perigee on track, discard this one.");
75  return false;
76  }
77  // call the workhorse interface
78  bool passed = decision(atl,*tPerigee);
79  // only check if needed
80  passed = (!passed || m_trackSelector.empty()) ? passed : ( passed && m_trackSelector->decision(track) );
81  // return what you have
82  ATH_MSG_VERBOSE("Track " << ( passed ? "passed" : "did not pass") << " isolation track selector.");
83  return passed;
84 }
85 
86 
87 //_______________________________________________________________________________
89 {
90 
91  // get the paramters base
92  const Trk::TrackParameters* definintParameters = &(trackParticle.definingParameters());
93  const Trk::TrackParameters* trackParameters=
94  dynamic_cast<const Trk::Perigee*>(definintParameters);
95  if (!trackParameters){
96  ATH_MSG_DEBUG("No parameters to start from on track, discard this one.");
97  return false;
98  }
99  // call the workhorse interface
100  bool passed = decision(atl,*trackParameters);
101  // only check if needed
102  passed = (!passed || m_trackSelector.empty()) ? passed : ( passed && m_trackSelector->decision(trackParticle) );
103  // return what you have
104  ATH_MSG_VERBOSE("TrackParticle " << ( passed ? "passed" : "did not pass") << " isolation track selector.");
105  return passed;
106 }
107 
108 //_______________________________________________________________________________
110 {
111  // get the surface
112  bool passed = false;
113  const Trk::StraightLineSurface& alSurface = atl.associatedSurface();
114  // no surface: bail out
115  // get the track to the BeamLine Parameters ( given by AtaStrainghtLine)
116  const Trk::TrackParameters* trackAtBL = m_extrapolator->extrapolate(
117  Gaudi::Hive::currentContext(),
118  trackPars,
119  alSurface,
121  false).release();
122  // no parameterisation : bail out
123  if (!trackAtBL) return false;
124  // d0,z0 wrt BL for reference and track
125  double d0track_wrtBL = trackAtBL->parameters()[Trk::d0];
126  double sinTheta = m_applySinThetaCorrection ? 1. : sin(trackAtBL->parameters()[Trk::theta]);
127  double z0track_wrtBL = trackAtBL->parameters()[Trk::z0]*sinTheta;
128  double sinThetaRef = m_applySinThetaCorrection ? 1. : sin(atl.parameters()[Trk::theta]);
129  double z0ref_wrtBL = atl.parameters()[Trk::z0] * sinThetaRef;
130  if (m_robustCuts){
131  // check d0 cut with respect to BL
132  passed = std::abs(d0track_wrtBL) < m_d0max;
133  ATH_MSG_VERBOSE("TrackParameters " << ( passed ? "passed" : "did not pass" ) << " d0 cut wrt BL : "
134  << d0track_wrtBL << " (cut is : | " << m_d0max << " | ).");
135  // check z0 cut with respect to reference
136  passed = std::abs(z0track_wrtBL-z0ref_wrtBL) < m_z0stMax;
137  ATH_MSG_VERBOSE("TrackParameters " << ( passed ? "passed" : "did not pass" ) << " z0 " << ( m_applySinThetaCorrection ? "*sin(theta)" : "")
138  << " cut wrt reference :"
139  << (z0track_wrtBL-z0ref_wrtBL) << " (cut is : | " << m_z0stMax << " | ).");
140  } else {
141  // cast to measured parameters
142  if (!trackAtBL->covariance()){
143  ATH_MSG_VERBOSE("Can not apply significance cut on Parameters w/o Error. Ignore Track.");
144  return false;
145  }
146  // get the error on the track
147  double covTrackD0 = (*trackAtBL->covariance())(Trk::d0,Trk::d0);
148  double covTrackZ0 = (*trackAtBL->covariance())(Trk::z0,Trk::z0);
149  // check d0 significiance cut with respect to BL
150  double d0sig2 = (d0track_wrtBL*d0track_wrtBL)/covTrackD0;
151  passed = d0sig2 < m_d0Significance2;
152  ATH_MSG_VERBOSE("TrackParameters " << ( passed ? "passed" : "did not pass" ) << " d0 significance^2 cut wrt BL : "
153  << d0sig2 << " (cut is : | " << m_d0Significance2 << " | ).");
154  double deltaZ = z0ref_wrtBL - z0track_wrtBL;
155  double z0Err2 = covTrackZ0;
157  double covTrackTheta = (*trackAtBL->covariance())(Trk::theta,Trk::theta);
158  double covTrackZ0Theta = (*trackAtBL->covariance())(Trk::z0,Trk::theta);
159  // check z0 significance cut with respect to reference -- apply theta projection into longitudinal track frame
160  double cosTheta = cos(trackAtBL->parameters()[Trk::theta]);
161  // derivatives + apply jacobian transormation
162  double dZIPdTheta = deltaZ*cosTheta;
163  double dZIPdz0 = sinTheta;
164  double DTheta2 = dZIPdTheta*dZIPdTheta*covTrackTheta;
165  double DZ02 = dZIPdz0*dZIPdz0*covTrackZ0;
166  double DThetaZ0 = 2.*dZIPdTheta*dZIPdz0*covTrackZ0Theta;
167  // check for it
168  z0Err2 = DTheta2 + DZ02 + DThetaZ0;
169  }
170  double z0sig2 = (deltaZ*deltaZ)/(z0Err2);
171  passed = z0sig2 < m_z0Significance2;
172  ATH_MSG_VERBOSE("TrackParameters " << ( passed ? "passed" : "did not pass" ) << " z0*sin(theta) significance cut wrt BL : "
173  << z0sig2 << " (cut is : | " << m_z0Significance2 << " | ).");
174  }
175  // memory cleanup
176  delete trackAtBL;
177  return passed;
178 }
179 
InDet::InDetIsoTrackSelectorTool::m_d0Significance
double m_d0Significance
Sophisticated cut window setting : d0/z0 significance - only when robustCuts off.
Definition: InDetIsoTrackSelectorTool.h:60
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
InDet::InDetIsoTrackSelectorTool::m_applySinThetaCorrection
bool m_applySinThetaCorrection
Definition: InDetIsoTrackSelectorTool.h:56
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
StraightLineSurface.h
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
InDet::InDetIsoTrackSelectorTool::InDetIsoTrackSelectorTool
InDetIsoTrackSelectorTool(const std::string &t, const std::string &n, const IInterface *p)
Constructor / Destructor.
Definition: InDetIsoTrackSelectorTool.cxx:17
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
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
TrackParticleBase.h
Trk::z0
@ z0
Definition: ParamDefs.h:70
InDet::InDetIsoTrackSelectorTool::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: InDetIsoTrackSelectorTool.h:65
IExtrapolator.h
InDet::InDetIsoTrackSelectorTool::initialize
virtual StatusCode initialize() override
Athena AlgTool methods.
Definition: InDetIsoTrackSelectorTool.cxx:46
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Track.h
Trk::TrackParticleBase
Definition: TrackParticleBase.h:41
Trk::ParametersT::associatedSurface
virtual const S & associatedSurface() const override final
Access to the Surface method.
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
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
InDet::InDetIsoTrackSelectorTool::m_d0max
double m_d0max
Definition: InDetIsoTrackSelectorTool.h:57
Trk::ParametersBase
Definition: ParametersBase.h:55
InDet::InDetIsoTrackSelectorTool::m_d0Significance2
double m_d0Significance2
Definition: InDetIsoTrackSelectorTool.h:62
InDet::InDetIsoTrackSelectorTool::m_trackSelector
ToolHandle< Trk::ITrackSelectorTool > m_trackSelector
Extra checks on hits & holes.
Definition: InDetIsoTrackSelectorTool.h:67
Trk::d0
@ d0
Definition: ParamDefs.h:69
InDet::InDetIsoTrackSelectorTool::decision
virtual bool decision(const Trk::AtaStraightLine &, const Trk::Track &track) const override
ESD type interface.
Definition: InDetIsoTrackSelectorTool.cxx:70
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
InDet::InDetIsoTrackSelectorTool::m_z0Significance
double m_z0Significance
Definition: InDetIsoTrackSelectorTool.h:61
InDet::InDetIsoTrackSelectorTool::m_z0Significance2
double m_z0Significance2
Definition: InDetIsoTrackSelectorTool.h:63
InDet::InDetIsoTrackSelectorTool::m_z0stMax
double m_z0stMax
Definition: InDetIsoTrackSelectorTool.h:58
InDet::InDetIsoTrackSelectorTool::~InDetIsoTrackSelectorTool
~InDetIsoTrackSelectorTool()
Trk::TrackParticleBase::definingParameters
const TrackParameters & definingParameters() const
Returns the 'defining' parameter of this TrackParticle.
Definition: TrackParticleBase.h:239
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthAlgTool
Definition: AthAlgTool.h:26
makeComparison.deltaZ
int deltaZ
Definition: makeComparison.py:46
ITrackSelectorTool.h
InDetIsoTrackSelectorTool.h
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51
InDet::InDetIsoTrackSelectorTool::m_robustCuts
bool m_robustCuts
Robust cut window setting.
Definition: InDetIsoTrackSelectorTool.h:55