diff --git a/Reconstruction/RecoTools/ITrackToVertex/ITrackToVertex/ITrackToVertex.h b/Reconstruction/RecoTools/ITrackToVertex/ITrackToVertex/ITrackToVertex.h index 15c890bc05acc6127fbb6676c8b745d84094d79a..6fd4f65f9655ca3c13077389e5befd986a2d817c 100755 --- a/Reconstruction/RecoTools/ITrackToVertex/ITrackToVertex/ITrackToVertex.h +++ b/Reconstruction/RecoTools/ITrackToVertex/ITrackToVertex/ITrackToVertex.h @@ -53,51 +53,90 @@ namespace Reco { /** AlgTool interface methods */ static const InterfaceID& interfaceID() { return IID_ITrackToVertex; }; - /** Use this for MT Coding */ - virtual std::unique_ptr<Trk::StraightLineSurface> GetBeamLine(const InDet::BeamSpotData*) const = 0; //In C++17 make this [[nodiscard]] - - virtual const InDet::BeamSpotData* GetBeamSpotData(const EventContext &ctx) const = 0; //In C++17 make this [[nodiscard]] - - /** Interface method for use with TrackParticle and given vertex position - AOD */ - virtual const Trk::Perigee* perigeeAtVertex(const Rec::TrackParticle& tp, const Amg::Vector3D& gp) const = 0; - - /** Interface method for use with xAOD::Trackparticle and given vertex position - xAOD */ - virtual const Trk::Perigee* perigeeAtVertex(const xAOD::TrackParticle& tp, const Amg::Vector3D& gp) const = 0; - - /** Interface method for use with TrackParticle and default primary vertex from TrackParticle - AOD */ - virtual const Trk::Perigee* perigeeAtVertex(const Rec::TrackParticle& tp) const = 0; - - /** Interface method for use with TrackParticle and default primary vertex from TrackParticle - xAOD */ - virtual const Trk::Perigee* perigeeAtVertex(const xAOD::TrackParticle& tp) const = 0; - - /** Interface method for use with Track and given vertex position - ESD */ - virtual const Trk::Perigee* perigeeAtVertex(const Trk::Track& trk, const Amg::Vector3D& gp) const = 0; - - /** Interface method for use with TrackParticle and the beamspot from the BeamSpotSvc - AOD*/ - virtual const Trk::Perigee* perigeeAtBeamspot(const Rec::TrackParticle& tp, const InDet::BeamSpotData*) const = 0; - - /** Interface method for use with TrackParticle and the beamspot from the BeamSpotSvc - xAOD*/ - virtual const Trk::Perigee* perigeeAtBeamspot(const xAOD::TrackParticle& tp, const InDet::BeamSpotData*) const = 0; - - /** Interface method for use with Track and the beamspot from the BeamSpotSvc - ESD */ - virtual const Trk::Perigee* perigeeAtBeamspot(const Trk::Track& trk, const InDet::BeamSpotData*) const = 0; - - /** Interface method for use with Track and the beamline from the BeamSpotSvc - ESD */ - virtual const Trk::Perigee* perigeeAtBeamline(const Trk::Track& trk, const InDet::BeamSpotData*) const = 0; - - /** Interface method for use with TrackParticle and the beamline from the BeamSpotSvc - AOD*/ - virtual const Trk::TrackParameters* trackAtBeamline(const Rec::TrackParticle& tp) const = 0; - - /** Interface method for use with TrackParticle and the beamline from the BeamSpotSvc - xAOD*/ - virtual const Trk::TrackParameters* trackAtBeamline(const xAOD::TrackParticle& tp, const InDet::BeamSpotData*) const = 0; - - /** Interface method for use with Track and the beamline from the BeamSpotSvc - ESD */ - virtual const Trk::TrackParameters* trackAtBeamline(const Trk::Track& trk, const Trk::StraightLineSurface*) const = 0; - - /** Interface method for use with Track and the beamline from the BeamSpotSvc - TrackParameters */ - virtual const Trk::TrackParameters* trackAtBeamline(const Trk::TrackParameters& tpars, const Trk::StraightLineSurface* ) const = 0; + /** Use this for MT Coding */ + virtual std::unique_ptr<Trk::StraightLineSurface> GetBeamLine( + const InDet::BeamSpotData*) + const = 0; // In C++17 make this [[nodiscard]] + + virtual const InDet::BeamSpotData* GetBeamSpotData( + const EventContext& ctx) const = 0; // In C++17 make this [[nodiscard]] + + /** Interface method for use with TrackParticle and given vertex position + * - AOD */ + virtual const Trk::Perigee* perigeeAtVertex( + const Rec::TrackParticle& tp, + const Amg::Vector3D& gp) const = 0; + + /** Interface method for use with xAOD::Trackparticle and given vertex + * position - xAOD */ + virtual const Trk::Perigee* perigeeAtVertex( + const xAOD::TrackParticle& tp, + const Amg::Vector3D& gp) const = 0; + + /** Interface method for use with TrackParticle and default primary + * vertex from TrackParticle - AOD */ + virtual const Trk::Perigee* perigeeAtVertex( + const Rec::TrackParticle& tp) const = 0; + + /** Interface method for use with TrackParticle and default primary + * vertex from TrackParticle - xAOD */ + virtual const Trk::Perigee* perigeeAtVertex( + const xAOD::TrackParticle& tp) const = 0; + + /** Interface method for use with Track and given vertex position - ESD + */ + virtual const Trk::Perigee* perigeeAtVertex( + const Trk::Track& trk, + const Amg::Vector3D& gp) const = 0; + + /** Interface method for use with TrackParticle and the beamspot from the + * BeamSpotSvc - AOD*/ + virtual const Trk::Perigee* perigeeAtBeamspot( + const Rec::TrackParticle& tp, + const InDet::BeamSpotData*) const = 0; + + /** Interface method for use with TrackParticle and the beamspot from the + * BeamSpotSvc - xAOD*/ + virtual const Trk::Perigee* perigeeAtBeamspot( + const xAOD::TrackParticle& tp, + const InDet::BeamSpotData*) const = 0; + + /** Interface method for use with Track and the beamspot from the + * BeamSpotSvc - ESD */ + virtual const Trk::Perigee* perigeeAtBeamspot( + const Trk::Track& trk, + const InDet::BeamSpotData*) const = 0; + + /** Interface method for use with Track and the beamline from the + * BeamSpotSvc - ESD */ + virtual const Trk::Perigee* perigeeAtBeamline( + const EventContext& ctx, + const Trk::Track& trk, + const InDet::BeamSpotData* beamSpotData) const = 0; + + /** Interface method for use with TrackParticle and the beamline from the + * BeamSpotSvc - AOD*/ + virtual const Trk::TrackParameters* trackAtBeamline( + const Rec::TrackParticle& tp) const = 0; + + /** Interface method for use with TrackParticle and the beamline from the + * BeamSpotSvc - xAOD*/ + virtual const Trk::TrackParameters* trackAtBeamline( + const xAOD::TrackParticle& tp, + const InDet::BeamSpotData*) const = 0; + + /** Interface method for use with Track and the beamline from the + * BeamSpotSvc - ESD */ + virtual const Trk::TrackParameters* trackAtBeamline( + const Trk::Track& trk, + const Trk::StraightLineSurface*) const = 0; + + /** Interface method for use with Track and the beamline from the + * BeamSpotSvc - TrackParameters */ + virtual const Trk::TrackParameters* trackAtBeamline( + const Trk::TrackParameters& tpars, + const Trk::StraightLineSurface*) const = 0; }; - } #endif // TRACKTOVERTEX_ITRACKTOVERTEX_H diff --git a/Reconstruction/RecoTools/TrackToVertex/TrackToVertex/TrackToVertex.h b/Reconstruction/RecoTools/TrackToVertex/TrackToVertex/TrackToVertex.h index 53a2313c005c3e7c01c7317223cebb248644c8e1..ad83644f4e5f341de0862e9e914daa8d7ea2305e 100755 --- a/Reconstruction/RecoTools/TrackToVertex/TrackToVertex/TrackToVertex.h +++ b/Reconstruction/RecoTools/TrackToVertex/TrackToVertex/TrackToVertex.h @@ -50,63 +50,108 @@ namespace Reco { /**Virtual destructor*/ virtual ~TrackToVertex(); - + /** AlgTool initailize method.*/ - virtual StatusCode initialize() override; + virtual StatusCode initialize() override final; /** AlgTool finalize method */ - virtual StatusCode finalize() override; - + virtual StatusCode finalize() override final; + /** Use this for MT Coding */ - virtual std::unique_ptr<Trk::StraightLineSurface> GetBeamLine(const InDet::BeamSpotData*) const override; //In C++17 make this [[nodiscard]] - - virtual const InDet::BeamSpotData* GetBeamSpotData(const EventContext &ctx) const override; //In C++17 make this [[nodiscard]] - - /** Interface method for use with TrackParticle and given vertex position - AOD */ - virtual const Trk::Perigee* perigeeAtVertex(const Rec::TrackParticle& tp, const Amg::Vector3D& gp) const override; - - /** Interface method for use with xAOD::Trackparticle and given vertex position - xAOD */ - virtual const Trk::Perigee* perigeeAtVertex(const xAOD::TrackParticle& tp, const Amg::Vector3D& gp) const override; - - /** Interface method for use with TrackParticle and default primary vertex from TrackParticle - AOD */ - virtual const Trk::Perigee* perigeeAtVertex(const Rec::TrackParticle& tp) const override; - - /** Interface method for use with TrackParticle and default primary vertex from TrackParticle - xAOD */ - virtual const Trk::Perigee* perigeeAtVertex(const xAOD::TrackParticle& tp) const override; - + virtual std::unique_ptr<Trk::StraightLineSurface> GetBeamLine( + const InDet::BeamSpotData*) + const override final; // In C++17 make this [[nodiscard]] + + virtual const InDet::BeamSpotData* GetBeamSpotData( + const EventContext& ctx) + const override final; // In C++17 make this [[nodiscard]] + + /** Interface method for use with TrackParticle and given vertex position + * - AOD */ + virtual const Trk::Perigee* perigeeAtVertex( + const Rec::TrackParticle& tp, + const Amg::Vector3D& gp) const override final; + + /** Interface method for use with xAOD::Trackparticle and given vertex + * position - xAOD */ + virtual const Trk::Perigee* perigeeAtVertex( + const xAOD::TrackParticle& tp, + const Amg::Vector3D& gp) const override final; + + /** Interface method for use with TrackParticle and default primary vertex + * from TrackParticle - AOD */ + virtual const Trk::Perigee* perigeeAtVertex( + const Rec::TrackParticle& tp) const override final; + + /** Interface method for use with TrackParticle and default primary vertex + * from TrackParticle - xAOD */ + virtual const Trk::Perigee* perigeeAtVertex( + const xAOD::TrackParticle& tp) const override final; + /** Interface method for use with Track and given vertex position - ESD */ - virtual const Trk::Perigee* perigeeAtVertex(const Trk::Track& trk, const Amg::Vector3D& gp) const override; - - /** Interface method for use with TrackParticle and the beamspot from the BeamSpotSvc - AOD*/ - virtual const Trk::Perigee* perigeeAtBeamspot(const Rec::TrackParticle& tp, const InDet::BeamSpotData*) const override; - - /** Interface method for use with TrackParticle and the beamspot from the BeamSpotSvc - xAOD*/ - virtual const Trk::Perigee* perigeeAtBeamspot(const xAOD::TrackParticle& tp, const InDet::BeamSpotData*) const override; - - /** Interface method for use with Track and the beamspot from the BeamSpotSvc - ESD */ - virtual const Trk::Perigee* perigeeAtBeamspot(const Trk::Track& trk, const InDet::BeamSpotData*) const override; - - /** Interface method for use with Track and the beamline from the BeamSpotSvc - ESD */ - virtual const Trk::Perigee* perigeeAtBeamline(const Trk::Track& trk, const InDet::BeamSpotData*) const override; - - /** Interface method for use with TrackParticle and the beamline from the BeamSpotSvc - AOD*/ - virtual const Trk::TrackParameters* trackAtBeamline(const Rec::TrackParticle& tp) const override; - - /** Interface method for use with TrackParticle and the beamline from the BeamSpotSvc - xAOD*/ - virtual const Trk::TrackParameters* trackAtBeamline(const xAOD::TrackParticle& tp, const InDet::BeamSpotData*) const override; - - /** Interface method for use with Track and the beamline from the BeamSpotSvc - ESD */ - virtual const Trk::TrackParameters* trackAtBeamline(const Trk::Track& trk, const Trk::StraightLineSurface* beamline) const override; - - /** Interface method for use with Track and the beamline from the BeamSpotSvc - TrackParameters */ - virtual const Trk::TrackParameters* trackAtBeamline(const Trk::TrackParameters& tpars, const Trk::StraightLineSurface* beamline) const override; - - - private: - ToolHandle< Trk::IExtrapolator > m_extrapolator; //!< ToolHandle for Extrapolator - - SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" }; - bool m_ForceBeamSpotZero = false; - const static Amg::Vector3D s_origin; //!< static origin + virtual const Trk::Perigee* perigeeAtVertex( + const Trk::Track& trk, + const Amg::Vector3D& gp) const override final; + + /** Interface method for use with TrackParticle and the beamspot from the + * BeamSpotSvc - AOD*/ + virtual const Trk::Perigee* perigeeAtBeamspot( + const Rec::TrackParticle& tp, + const InDet::BeamSpotData*) const override final; + + /** Interface method for use with TrackParticle and the beamspot from the + * BeamSpotSvc - xAOD*/ + virtual const Trk::Perigee* perigeeAtBeamspot( + const xAOD::TrackParticle& tp, + const InDet::BeamSpotData*) const override final; + + /** Interface method for use with Track and the beamspot from the + * BeamSpotSvc - ESD */ + virtual const Trk::Perigee* perigeeAtBeamspot( + const Trk::Track& trk, + const InDet::BeamSpotData*) const override final; + + /** Interface method for use with Track and the beamline from the + * BeamSpotSvc - ESD */ + virtual const Trk::Perigee* perigeeAtBeamline( + const EventContext& ctx, + const Trk::Track& trk, + const InDet::BeamSpotData*) const override final; + + /** Interface method for use with TrackParticle and the beamline from the + * BeamSpotSvc - AOD*/ + virtual const Trk::TrackParameters* trackAtBeamline( + const Rec::TrackParticle& tp) const override final; + + /** Interface method for use with TrackParticle and the beamline from the + * BeamSpotSvc - xAOD*/ + virtual const Trk::TrackParameters* trackAtBeamline( + const xAOD::TrackParticle& tp, + const InDet::BeamSpotData*) const override final; + + /** Interface method for use with Track and the beamline from the + * BeamSpotSvc - ESD */ + virtual const Trk::TrackParameters* trackAtBeamline( + const Trk::Track& trk, + const Trk::StraightLineSurface* beamline) const override final; + + /** Interface method for use with Track and the beamline from the + * BeamSpotSvc - TrackParameters */ + virtual const Trk::TrackParameters* trackAtBeamline( + const Trk::TrackParameters& tpars, + const Trk::StraightLineSurface* beamline) const override final; + + private: + ToolHandle<Trk::IExtrapolator> + m_extrapolator; //!< ToolHandle for Extrapolator + + SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey{ + this, + "BeamSpotKey", + "BeamSpotData", + "SG key for beam spot" + }; + bool m_ForceBeamSpotZero = false; + const static Amg::Vector3D s_origin; //!< static origin }; } // end of namespace diff --git a/Reconstruction/RecoTools/TrackToVertex/src/TrackToVertex.cxx b/Reconstruction/RecoTools/TrackToVertex/src/TrackToVertex.cxx index e67f1c6b775e20b7d7231f21d8404df10c9d4ca5..788ad1626c6d45084214963f75f0caab004c9253 100755 --- a/Reconstruction/RecoTools/TrackToVertex/src/TrackToVertex.cxx +++ b/Reconstruction/RecoTools/TrackToVertex/src/TrackToVertex.cxx @@ -196,8 +196,11 @@ const Trk::Perigee* Reco::TrackToVertex::perigeeAtBeamspot(const Trk::Track& tra return perigeeAtVertex(track, beamspot ? beamspot->beamVtx().position() : s_origin); } - -const Trk::Perigee* Reco::TrackToVertex::perigeeAtBeamline(const Trk::Track& track, const InDet::BeamSpotData* beamspotptr) const +const Trk::Perigee* +Reco::TrackToVertex::perigeeAtBeamline( + const EventContext& ctx, + const Trk::Track& track, + const InDet::BeamSpotData* beamspotptr) const { Amg::Vector3D beamspot(s_origin); @@ -218,7 +221,7 @@ const Trk::Perigee* Reco::TrackToVertex::perigeeAtBeamline(const Trk::Track& tra const Trk::Perigee* vertexPerigee = nullptr; const Trk::TrackParameters* extrapResult = - m_extrapolator->extrapolate(track, persf); + m_extrapolator->extrapolate(ctx,track, persf); if (extrapResult && extrapResult->surfaceType() == Trk::Surface::Perigee) { vertexPerigee = static_cast<const Trk::Perigee*>(extrapResult); } @@ -227,14 +230,13 @@ const Trk::Perigee* Reco::TrackToVertex::perigeeAtBeamline(const Trk::Track& tra // try again using the first track parameter set, since the current extrapolator will // use "the closest" track parameterset which is not necessarily the mostuseful one to // start the extrapolation with. - // @TODO should try to improve the extrapolator to pick the correct start parameters. const DataVector<const Trk::TrackParameters> *track_parameter_list= track.trackParameters(); if (track_parameter_list) { for(const Trk::TrackParameters *trk_params: *track_parameter_list) { if (!trk_params) { continue; } - extrapResult = m_extrapolator->extrapolate(*trk_params, persf); + extrapResult = m_extrapolator->extrapolate(ctx,*trk_params, persf); if (extrapResult && extrapResult->surfaceType() == Trk::Surface::Perigee) { vertexPerigee = static_cast<const Trk::Perigee*>(extrapResult); diff --git a/Tracking/TrkTools/TrkParticleCreator/src/TrackParticleCreatorTool.cxx b/Tracking/TrkTools/TrkParticleCreator/src/TrackParticleCreatorTool.cxx index 075e2dbbd6c0bc12b1ce901a40acb9a4ddfdc6d4..1d0a57bf43b2dee6885ea9bd9665582ed597213f 100644 --- a/Tracking/TrkTools/TrkParticleCreator/src/TrackParticleCreatorTool.cxx +++ b/Tracking/TrkTools/TrkParticleCreator/src/TrackParticleCreatorTool.cxx @@ -346,7 +346,7 @@ TrackParticleCreatorTool::TrackParticleCreatorTool(const std::string& t, } else if (m_perigeeExpression == "BeamLine"){ const Trk::Perigee* result = - m_trackToVertex->perigeeAtBeamline(*track, CacheBeamSpotData(ctx)); + m_trackToVertex->perigeeAtBeamline(ctx,*track, CacheBeamSpotData(ctx)); if (!result){ ATH_MSG_WARNING("Failed to extrapolate to Beamline"); @@ -532,7 +532,7 @@ TrackParticleCreatorTool::TrackParticleCreatorTool(const std::string& t, } else if (m_perigeeExpression == "BeamLine"){ const Trk::Perigee* result = - m_trackToVertex->perigeeAtBeamline(track, CacheBeamSpotData(ctx)); + m_trackToVertex->perigeeAtBeamline(ctx,track, CacheBeamSpotData(ctx)); if (!result){ ATH_MSG_WARNING("Failed to extrapolate to Beamline - No TrackParticle created."); return nullptr;