diff --git a/Tracking/TrkTools/TrkParticleCreator/TrkParticleCreator/TrackParticleCreatorTool.h b/Tracking/TrkTools/TrkParticleCreator/TrkParticleCreator/TrackParticleCreatorTool.h index dd2a055675c52fe35df9ce8edefad0c07628046a..daf0cc404714034f92f40bb74917c3e5c05ef120 100644 --- a/Tracking/TrkTools/TrkParticleCreator/TrkParticleCreator/TrackParticleCreatorTool.h +++ b/Tracking/TrkTools/TrkParticleCreator/TrkParticleCreator/TrackParticleCreatorTool.h @@ -240,8 +240,6 @@ private: bool m_checkConversion; int m_minSiHits; double m_minPt; - - bool castPerigeeAndCheck(const Trk::Track* track, const Trk::Perigee*& aPer) const; }; } // end of namespace Trk diff --git a/Tracking/TrkTools/TrkParticleCreator/src/TrackParticleCreatorTool.cxx b/Tracking/TrkTools/TrkParticleCreator/src/TrackParticleCreatorTool.cxx index f6d3392d56b023bc47bf55eb9761cf51e2fdf2fb..3cfad1df30fe154ad8daf28751266315cd1b1b68 100644 --- a/Tracking/TrkTools/TrkParticleCreator/src/TrackParticleCreatorTool.cxx +++ b/Tracking/TrkTools/TrkParticleCreator/src/TrackParticleCreatorTool.cxx @@ -287,17 +287,14 @@ TrackParticleCreatorTool::TrackParticleCreatorTool(const std::string& t, const s // the default way; I left it as it was because it is working fine!! if ( m_perigeeExpression == "Origin") { - if ( (castPerigeeAndCheck(track, aPer) ) ) - { - // aMeasPer clone will be created later if all perigee option selected - if (m_keepAllPerigee) - { - aPer = nullptr; - } - else - { - aPer = aPer->clone(); - } + aPer = track->perigeeParameters(); + if (aPer) { + // aMeasPer clone will be created later if all perigee option selected + if (m_keepAllPerigee) { + aPer = nullptr; + } else { + aPer = aPer->clone(); + } } else { const Amg::Vector3D persf(0,0,0); @@ -336,8 +333,8 @@ TrackParticleCreatorTool::TrackParticleCreatorTool(const std::string& t, const s return nullptr; } } else { - if ( (castPerigeeAndCheck(track, aPer) ) ) - { + aPer = track->perigeeParameters(); + if (aPer) { aPer = aPer->clone(); } else { @@ -448,12 +445,14 @@ TrackParticleCreatorTool::TrackParticleCreatorTool(const std::string& t, const s continue; } if (!tsos->type(TrackStateOnSurface::Perigee) || - !dynamic_cast<const Perigee*>(tsos->trackParameters())) { + !(tsos->trackParameters()->surfaceType() == + Trk::Surface::Perigee) || + !(tsos->trackParameters()->type() == Trk::AtaSurface)) { continue; } if (!aPer) { aPer = - dynamic_cast<const Perigee*>(tsos->trackParameters()->clone()); + static_cast<const Perigee*>(tsos->trackParameters()->clone()); } else { parameters.push_back(tsos->trackParameters()->clone()); } @@ -484,10 +483,13 @@ TrackParticleCreatorTool::TrackParticleCreatorTool(const std::string& t, const s const Trk::TrackParameters* parsToBeDeleted = nullptr; // the default way; I left it as it was because it is working fine!! if ( m_perigeeExpression == "Origin") { - if ( (castPerigeeAndCheck(&track, aPer) ) ) { + aPer = track.perigeeParameters(); + if (aPer) { // aMeasPer clone will be created later if all perigee option selected - if (m_keepAllPerigee) aPer = nullptr; - }else{ + if (m_keepAllPerigee) { + aPer = nullptr; + } + } else { const Amg::Vector3D persf(0,0,0); const Trk::Perigee* result = m_trackToVertex->perigeeAtVertex(track, persf); if (result != nullptr) { @@ -761,10 +763,14 @@ TrackParticleCreatorTool::TrackParticleCreatorTool(const std::string& t, const s parameterPositions.push_back(xAOD::FirstMeasurement); continue; } - if (! tsos->type(TrackStateOnSurface::Perigee) - || ! dynamic_cast<const Perigee*>(tsos->trackParameters())) continue; + if (!tsos->type(TrackStateOnSurface::Perigee) || + !(tsos->trackParameters()->surfaceType() == + Trk::Surface::Perigee) || + !(tsos->trackParameters()->type() == Trk::AtaSurface)) { + continue; + } if (! aPer) { - aPer = dynamic_cast<const Perigee*>(tsos->trackParameters()); + aPer = static_cast<const Perigee*>(tsos->trackParameters()); } else { parameters.push_back(tsos->trackParameters()); } @@ -936,20 +942,6 @@ TrackParticleCreatorTool::TrackParticleCreatorTool(const std::string& t, const s return trackparticle; } - //W.L. 2013-10-29: Since no dcast is needed any more the whole function could be removed - bool TrackParticleCreatorTool::castPerigeeAndCheck( - const Trk::Track* track, - const Trk::Perigee* &aPer) const - { - aPer = track->perigeeParameters(); - if (aPer==nullptr) - { - ATH_MSG_VERBOSE ("Track has no perigee parameters."); - return false; - } - return true; - } - void TrackParticleCreatorTool::compare( const TrackParameters& tp1, const TrackParameters& tp2 ) const { int index = Amg::compare(tp1.parameters(),tp2.parameters(),1e-6,true); if ( index != -1 ){