diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h index 87907b1f12fe215207450fc63a0799036bba0c91..12c7966d6ac4eb2aced6e505585d69fbd089253a 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h @@ -38,6 +38,7 @@ namespace Trk { class ITrackSummaryTool; + class ITrackParticleCreatorTool; class IExtrapolator; class Vertex; class RecVertex; @@ -83,9 +84,13 @@ namespace InDet bool decision(const Trk::Perigee* track,const AmgSymMatrix(3)* covariancePosition) const; bool decision(const Trk::FitQuality* TrkQuality) const; bool decision(double chi2, int ndf ) const; - bool decision(const Trk::TrackSummary* summary,bool useSharedHitInfo,bool useTrtHitInfo, - const Trk::Perigee* track, - const int nHitTrt, const int nHitTrtPlusOutliers) const; + bool decision(const Trk::TrackSummary* summary, + const xAOD::TrackParticle* tp, + bool useSharedHitInfo, + bool useTrtHitInfo, + const Trk::Perigee* track, + const int nHitTrt, + const int nHitTrtPlusOutliers) const; bool preselectionBeforeExtrapolation(const Trk::Perigee & myPerigee) const; Amg::Vector3D getPosOrBeamSpot(const xAOD::Vertex*) const; @@ -151,15 +156,17 @@ namespace InDet bool m_useEtaDepententMinHitTrtWithOutliers; ToolHandle<Trk::ITrackSummaryTool> m_trackSumTool; //!< Track summary tool + ToolHandle<Trk::ITrackParticleCreatorTool> m_particleCreator; //!< TrackParticle creator tool ToolHandle<Trk::IExtrapolator> m_extrapolator; //!< Extrapolator tool SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; ToolHandle<ITrtDriftCircleCutTool> m_trtDCTool; //!< Tool to get eta dependent cut on number of TRT hits ToolHandle< InDet::IInDetTestPixelLayerTool > m_inDetTestPixelLayerTool; //Tool to test if the track crosses a dead module on the b-layer // Read handle for conditions object to get the field cache - SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; + SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}; bool m_trackSumToolAvailable; + bool m_partCreatorToolAvailable; // chnages for the pt-dependent sct cut bool m_usePtDependentCuts; diff --git a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetDetailedTrackSelectorTool.cxx b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetDetailedTrackSelectorTool.cxx index b1644f04fb42ec54d2f9d41bfe3b0d23c137c488..a6f4b796c84969ec1f34dc647254e198e5823c7b 100644 --- a/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetDetailedTrackSelectorTool.cxx +++ b/InnerDetector/InDetRecTools/InDetTrackSelectorTool/src/InDetDetailedTrackSelectorTool.cxx @@ -5,13 +5,13 @@ #include "InDetTrackSelectorTool/InDetDetailedTrackSelectorTool.h" // forward declares #include "TrkToolInterfaces/ITrackSummaryTool.h" +#include "TrkToolInterfaces/ITrackParticleCreatorTool.h" #include "TrkExInterfaces/IExtrapolator.h" #include "VxVertex/Vertex.h" #include "VxVertex/RecVertex.h" #include "TrkEventPrimitives/FitQuality.h" #include "TrkTrack/Track.h" #include "TrkTrackSummary/TrackSummary.h" -#include "TrkParticleBase/TrackParticleBase.h" #include "InDetRecToolInterfaces/ITrtDriftCircleCutTool.h" #include "InDetRecToolInterfaces/IInDetTestPixelLayerTool.h" @@ -37,6 +37,7 @@ namespace InDet InDetDetailedTrackSelectorTool::InDetDetailedTrackSelectorTool(const std::string& t, const std::string& n, const IInterface* p) : AthAlgTool(t,n,p) , m_trackSumTool("Trk::TrackSummaryTool", this) + , m_particleCreator("", this) , m_extrapolator("Trk::Extrapolator", this) , m_trtDCTool("InDet::InDetTrtDriftCircleCutTool", this) , m_inDetTestPixelLayerTool("", this) @@ -105,6 +106,7 @@ namespace InDet declareProperty("addToMinHitTrtWithOutliers" , m_addToMinHitTrtWithOutliers = 0); declareProperty("TrackSummaryTool" , m_trackSumTool); + declareProperty("TrackParticleCreatorTool", m_particleCreator); declareProperty("Extrapolator" , m_extrapolator); declareProperty("TrtDCCutTool" , m_trtDCTool); declareProperty("InDetTestPixelLayerTool", m_inDetTestPixelLayerTool); @@ -149,13 +151,23 @@ namespace InDet InDetDetailedTrackSelectorTool::initialize(){ m_trackSumToolAvailable=false; if (!m_trackSumTool.empty()) { - if(m_trackSumTool.retrieve().isFailure()){ - ATH_MSG_INFO(" Unable to retrieve. OK if running on AOD. "<<m_trackSumTool); - }else{ - ATH_MSG_INFO("Track summary tool retrieved"); - m_trackSumToolAvailable=true; - } - } + if(m_trackSumTool.retrieve().isFailure()){ + ATH_MSG_INFO(" Unable to retrieve TrackSummaryTool. OK if running on AOD. "<<m_trackSumTool); + }else{ + ATH_MSG_INFO("Track summary tool retrieved"); + m_trackSumToolAvailable=true; + } + } + + if(m_useSharedHitInfo && !m_particleCreator.empty()){ + if(m_particleCreator.retrieve().isFailure()){ + ATH_MSG_INFO(" Unable to retrieve TrackParticleCreatorTool. OK if running on AOD. "<<m_particleCreator); + }else{ + ATH_MSG_INFO("Track particle creator tool retrieved"); + m_partCreatorToolAvailable = true; + } + } + ATH_CHECK( m_extrapolator.retrieve() ); ATH_CHECK(m_beamSpotKey.initialize(!m_useEventInfoBs)); ATH_CHECK(m_eventInfo_key.initialize(m_useEventInfoBs)); @@ -302,6 +314,14 @@ namespace InDet ATH_MSG_FATAL( "Track preselection: cannot create a track summary (but useTrackSummary is true). Selection failed." ); return false; } + + // Create xAOD::TrackParticle to retrieve shared hit info + const xAOD::TrackParticle* tp = m_partCreatorToolAvailable ? m_particleCreator->createParticle(track) : nullptr; + if(m_useSharedHitInfo && tp==nullptr){ + ATH_MSG_FATAL( "Track preselection: cannot create a track particle (but useSharedHitInfo is true). Selection failed." ); + return false; + } + // get the minimum nimber of TRT hits based on eta of the track if(m_useEtaDepententMinHitTrt) { nHitTrt = m_trtDCTool->minNumberDCs( (*track.trackParameters())[0] ); @@ -311,6 +331,7 @@ namespace InDet nHitTrt = (int)((double)nHitTrt*m_scaleMinHitTrt); } } + // get the minimum nimber of TRT hits + outliers based on eta of the track if(m_useEtaDepententMinHitTrtWithOutliers) { nHitTrtPlusOutliers = m_trtDCTool->minNumberDCs( (*track.trackParameters())[0] ); @@ -320,7 +341,8 @@ namespace InDet nHitTrtPlusOutliers = (int)((double)nHitTrtPlusOutliers*m_scaleMinHitTrtWithOutliers); } } - if (!decision(summary,m_useSharedHitInfo,isInTrtAcceptance, perigeeBeforeExtrapolation, + + if (!decision(summary, tp, m_useSharedHitInfo,isInTrtAcceptance, perigeeBeforeExtrapolation, nHitTrt, nHitTrtPlusOutliers)) { return false; } @@ -365,6 +387,14 @@ namespace InDet ATH_MSG_WARNING( "Track preselection: cannot create a track summary (but useTrackSummary is true). Selection failed." ); return false; } + + + if (m_useSharedHitInfo) { + ATH_MSG_ERROR( "Use of InDetDetailedTrackSelectorTool with Trk::TrackParticleBase and useSharedHitInfo is not supported"); + return false; + } + const xAOD::TrackParticle* tp = nullptr; + if(m_useEtaDepententMinHitTrt) { nHitTrt = m_trtDCTool->minNumberDCs( (track.trackParameters())[0] ); if(m_addToMinHitTrt!=0){ @@ -373,6 +403,7 @@ namespace InDet nHitTrt = (int)((double)nHitTrt*m_scaleMinHitTrt); } } + if(m_useEtaDepententMinHitTrtWithOutliers) { nHitTrtPlusOutliers = m_trtDCTool->minNumberDCs( (track.trackParameters())[0] ); if(m_addToMinHitTrtWithOutliers!=0){ @@ -381,8 +412,9 @@ namespace InDet nHitTrtPlusOutliers = (int)((double)nHitTrtPlusOutliers*m_scaleMinHitTrtWithOutliers); } } + if ((!perigeeBeforeExtrapolation) or - (!decision(summary, m_useSharedHitInfo, isInTrtAcceptance, perigeeBeforeExtrapolation, + (!decision(summary, tp, m_useSharedHitInfo, isInTrtAcceptance, perigeeBeforeExtrapolation, nHitTrt, nHitTrtPlusOutliers))) { return false; } @@ -448,7 +480,7 @@ namespace InDet return false; } return true; - } + } Amg::Vector3D InDetDetailedTrackSelectorTool::getPosOrBeamSpot(const xAOD::Vertex* vertex) const { @@ -890,9 +922,13 @@ namespace InDet // --------------------------------------------------------------------- - bool InDetDetailedTrackSelectorTool::decision(const Trk::TrackSummary* summary,bool useSharedHitInfo,bool useTrtHitInfo, + bool InDetDetailedTrackSelectorTool::decision(const Trk::TrackSummary* summary, + const xAOD::TrackParticle* tp, + bool useSharedHitInfo, + bool useTrtHitInfo, const Trk::Perigee * track, - const int nHitTrt, const int nHitTrtPlusOutliers) const + const int nHitTrt, + const int nHitTrtPlusOutliers) const { if (summary==nullptr) { ATH_MSG_WARNING( "Null TrackSummary pointer passed. Selection failed." ); @@ -1078,8 +1114,12 @@ namespace InDet } if (useSharedHitInfo) { + if(!tp){ + ATH_MSG_DEBUG("Track rejected because xAOD::TrackParticle not available"); + return false; + } - int nbs = summary->get(Trk::numberOfInnermostPixelLayerSharedHits); + int nbs = getCount(*tp,xAOD::numberOfInnermostPixelLayerSharedHits); if(nbs < 0) nbs = 0; if (nbs>1) nbs=1; if(nbs>m_nSharedBLayer) { @@ -1087,14 +1127,14 @@ namespace InDet return false; } - int nps = summary->get(Trk::numberOfPixelSharedHits); + int nps = getCount(*tp,xAOD::numberOfPixelSharedHits); if(nps < 0) nps = 0; if(nps>m_nSharedPix) { ATH_MSG_DEBUG("Track rejected because of nSharedPix "<<nps<<" < "<<m_nSharedPix); return false; } - int nss = summary->get(Trk::numberOfSCTSharedHits); + int nss = getCount(*tp,xAOD::numberOfSCTSharedHits); if(nss < 0) nss = 0; if(nss > m_nSharedSct) { ATH_MSG_DEBUG("Track rejected because of nSharedSct "<<nss<<" < "<<m_nSharedSct);