From 4d56bf8e8a8026a855e87566ad147d1fea030576 Mon Sep 17 00:00:00 2001 From: christos <christos@cern.ch> Date: Fri, 30 Oct 2020 14:33:45 +0100 Subject: [PATCH] TrkVertexFitter TrkExtrapolation clang tidy (llvm10) --- .../test/RungeKuttaIntersector_test.cxx | 2 +- .../src/STEP_Propagator.cxx | 6 +- .../src/SolenoidalIntersector.cxx | 26 +++---- .../test/SolenoidParametrization_test.cxx | 2 +- .../test/SolenoidalIntersector_test.cxx | 2 +- .../src/StraightLineIntersector.cxx | 2 +- .../TrkExTools/src/TimedExtrapolator.cxx | 4 +- .../TrkV0Fitter/src/TrkV0VertexFitter.cxx | 2 +- .../TrkVKalVrtCore/Propagator.h | 2 +- .../TrkVKalVrtCore/VKalVrtBMag.h | 78 +++++++++---------- .../TrkVKalVrtCore/src/CascadeDefinition.cxx | 10 +-- .../TrkVKalVrtCore/src/DummyMag.cxx | 2 +- .../TrkVKalVrtCore/src/Propagate.cxx | 2 +- .../src/GaussianTrackDensity.cxx | 4 + 14 files changed, 72 insertions(+), 72 deletions(-) diff --git a/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/test/RungeKuttaIntersector_test.cxx b/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/test/RungeKuttaIntersector_test.cxx index 27ebdcb3e8d..692fdac1f24 100644 --- a/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/test/RungeKuttaIntersector_test.cxx +++ b/Tracking/TrkExtrapolation/TrkExRungeKuttaIntersector/test/RungeKuttaIntersector_test.cxx @@ -279,7 +279,7 @@ void test_perigee (Trk::IIntersector& tool) } -std::unique_ptr<MagField::AtlasFieldMap> getFieldMap(const std::string mapFile, double sol_current, double tor_current) { +std::unique_ptr<MagField::AtlasFieldMap> getFieldMap(const std::string& mapFile, double sol_current, double tor_current) { // find the path to the map file std::string resolvedMapFile = PathResolver::find_file( mapFile.c_str(), "DATAPATH" ); assert ( !resolvedMapFile.empty() ); diff --git a/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/src/STEP_Propagator.cxx b/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/src/STEP_Propagator.cxx index d5fc579ba68..e6bcfae97a2 100755 --- a/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/src/STEP_Propagator.cxx +++ b/Tracking/TrkExtrapolation/TrkExSTEP_Propagator/src/STEP_Propagator.cxx @@ -722,8 +722,8 @@ Trk::STEP_Propagator::intersectSurface(const EventContext& ctx, ParticleHypothesis particle) const { - Amg::Vector3D origin = trackIntersection->position(); - Amg::Vector3D direction = trackIntersection->direction(); + const Amg::Vector3D& origin = trackIntersection->position(); + const Amg::Vector3D& direction = trackIntersection->direction(); PerigeeSurface* perigeeSurface = new PerigeeSurface(origin); const Trk::TrackParameters* trackParameters = perigeeSurface->createTrackParameters(0.,0., @@ -2719,7 +2719,7 @@ Trk::STEP_Propagator::propagateNeutral(const Trk::TrackParameters& parm, std::vector<std::pair<unsigned int,double> >::iterator oIter = currentDist.begin(); std::vector<DestSurf >::iterator sBeg = targetSurfaces.begin(); - Amg::Vector3D position(parm.position()); + const Amg::Vector3D& position(parm.position()); Amg::Vector3D direction(parm.momentum().normalized()); for (; sIter!=targetSurfaces.end(); sIter++) { diff --git a/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/src/SolenoidalIntersector.cxx b/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/src/SolenoidalIntersector.cxx index c90004957b8..a16fc7b5209 100755 --- a/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/src/SolenoidalIntersector.cxx +++ b/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/src/SolenoidalIntersector.cxx @@ -94,7 +94,7 @@ SolenoidalIntersector::intersectSurface(const Surface& surface, (*perigee, trackIntersection, qOverP); ATH_MSG_WARNING( " unrecognized Surface" ); - return 0; + return nullptr; } /**IIntersector interface method for specific Surface type : PerigeeSurface */ @@ -134,7 +134,7 @@ SolenoidalIntersector::intersectCylinderSurface(const CylinderSurface& surface, double radius2 = isect->position().perp2(); if (std::abs(endRadius - sqrt(radius2)) > m_surfaceTolerance - && ! extrapolateToR(*isect, radius2, *com, endRadius)) return 0; + && ! extrapolateToR(*isect, radius2, *com, endRadius)) return nullptr; return intersection(std::move(isect), *com, surface); } @@ -163,7 +163,7 @@ SolenoidalIntersector::intersectDiscSurface (const DiscSurface& surface, if (std::abs(endZ -trackIntersection->position().z()) > m_surfaceTolerance && ! extrapolateToZ(*isect, *com, endZ)) { - return 0; + return nullptr; } return intersection(std::move(isect), *com, surface); @@ -207,18 +207,18 @@ SolenoidalIntersector::intersectPlaneSurface(const PlaneSurface& surface, while (std::abs(offset) > m_surfaceTolerance*std::abs(dot)) { // take care if grazing incidence - quit if looper - if (std::abs(dot) < 0.0001) return 0; + if (std::abs(dot) < 0.0001) return nullptr; double distance = offset/dot; // extrapolate if (com->m_sinTheta < 0.9) { - if (! extrapolateToZ(*isect, *com, pos.z()+distance*dir.z())) return 0; + if (! extrapolateToZ(*isect, *com, pos.z()+distance*dir.z())) return nullptr; radius2 = pos.perp2(); } else { - if (! extrapolateToR(*isect, radius2, *com, (pos+distance*dir).perp())) return 0; + if (! extrapolateToR(*isect, radius2, *com, (pos+distance*dir).perp())) return nullptr; } // check we are getting closer to the plane, switch to RK in case of difficulty @@ -247,17 +247,13 @@ SolenoidalIntersector::isValid (Amg::Vector3D startPosition, getSolenoidParametrization(); // check cylinder bounds for valid parametrization - if (solenoidParametrization && + return solenoidParametrization && + std::abs(endPosition.z()) < solenoidParametrization->maximumZ() + && endPosition.perp() < solenoidParametrization->maximumR() - && getSolenoidParametrization()->validOrigin(startPosition)) - { - - return true; - } - - - return false; + + && getSolenoidParametrization()->validOrigin(startPosition); } /** tabulate parametrization details */ diff --git a/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/test/SolenoidParametrization_test.cxx b/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/test/SolenoidParametrization_test.cxx index 1c409cc9356..d20b85f0e20 100644 --- a/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/test/SolenoidParametrization_test.cxx +++ b/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/test/SolenoidParametrization_test.cxx @@ -61,7 +61,7 @@ void test1 (Trk::SolenoidParametrization& sol, const AtlasFieldCacheCondObj &fie assert( Athena_test::isEqual (secondIntegral, -296.768) ); } -std::unique_ptr<MagField::AtlasFieldMap> getFieldMap(const std::string mapFile, double sol_current, double tor_current) { +std::unique_ptr<MagField::AtlasFieldMap> getFieldMap(const std::string& mapFile, double sol_current, double tor_current) { // find the path to the map file std::string resolvedMapFile = PathResolver::find_file( mapFile.c_str(), "DATAPATH" ); assert ( !resolvedMapFile.empty() ); diff --git a/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/test/SolenoidalIntersector_test.cxx b/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/test/SolenoidalIntersector_test.cxx index d2b1d588daf..e660eff150f 100644 --- a/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/test/SolenoidalIntersector_test.cxx +++ b/Tracking/TrkExtrapolation/TrkExSolenoidalIntersector/test/SolenoidalIntersector_test.cxx @@ -295,7 +295,7 @@ void test_perigee (Trk::IIntersector& tool) } -std::unique_ptr<MagField::AtlasFieldMap> getFieldMap(const std::string mapFile, double sol_current, double tor_current) { +std::unique_ptr<MagField::AtlasFieldMap> getFieldMap(const std::string& mapFile, double sol_current, double tor_current) { // find the path to the map file std::string resolvedMapFile = PathResolver::find_file( mapFile.c_str(), "DATAPATH" ); assert ( !resolvedMapFile.empty() ); diff --git a/Tracking/TrkExtrapolation/TrkExStraightLineIntersector/src/StraightLineIntersector.cxx b/Tracking/TrkExtrapolation/TrkExStraightLineIntersector/src/StraightLineIntersector.cxx index 46a7d9b5361..a0865085d25 100755 --- a/Tracking/TrkExtrapolation/TrkExStraightLineIntersector/src/StraightLineIntersector.cxx +++ b/Tracking/TrkExtrapolation/TrkExStraightLineIntersector/src/StraightLineIntersector.cxx @@ -78,7 +78,7 @@ StraightLineIntersector::intersectSurface(const Surface& surface, if (perigee) return approachPerigeeSurface(*perigee,trackIntersection,qOverP); ATH_MSG_WARNING( " unrecognized Surface" ); - return 0; + return nullptr; } /**IIntersector interface method for specific Surface type : PerigeeSurface */ diff --git a/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx b/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx index d43e5c95ceb..361dc3b0aed 100644 --- a/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx +++ b/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx @@ -343,7 +343,7 @@ Trk::TimedExtrapolator::extrapolateWithPathLimit( std::map<const Trk::TrackParameters *, bool>::iterator garbageEnd = cache.m_garbageBin.end(); for (; garbageIter != garbageEnd; ++garbageIter) if (garbageIter->first) { if(garbageIter->first == returnParms) { - auto ret=returnParms->clone(); + auto *ret=returnParms->clone(); ATH_MSG_DEBUG(" [+] garbage - at " << positionOutput(garbageIter->first->position())<<" parm="<<garbageIter->first<<" is the return param. Cloning to"<<ret); returnParms=ret; } @@ -1393,7 +1393,7 @@ Trk::TimedExtrapolator::transportNeutralsWithPathLimit(const Trk::TrackParameter std::map<const Trk::TrackParameters *, bool>::iterator garbageEnd = cache.m_garbageBin.end(); for (; garbageIter != garbageEnd; ++garbageIter) if (garbageIter->first) { if(garbageIter->first == returnParms) { - auto ret=returnParms->clone(); + auto *ret=returnParms->clone(); ATH_MSG_DEBUG(" [+] garbage - at " << positionOutput(garbageIter->first->position())<<" parm="<<garbageIter->first<<" is the return param. Cloning to"<<ret); returnParms=ret; } diff --git a/Tracking/TrkVertexFitter/TrkV0Fitter/src/TrkV0VertexFitter.cxx b/Tracking/TrkVertexFitter/TrkV0Fitter/src/TrkV0VertexFitter.cxx index 0704ab2ffda..b32151c3f1f 100755 --- a/Tracking/TrkVertexFitter/TrkV0Fitter/src/TrkV0VertexFitter.cxx +++ b/Tracking/TrkVertexFitter/TrkV0Fitter/src/TrkV0VertexFitter.cxx @@ -173,7 +173,7 @@ namespace Trk } } - for (auto ptr : measuredPerigees_delete){ delete ptr; } + for (const auto *ptr : measuredPerigees_delete){ delete ptr; } return fittedVxCandidate; } diff --git a/Tracking/TrkVertexFitter/TrkVKalVrtCore/TrkVKalVrtCore/Propagator.h b/Tracking/TrkVertexFitter/TrkVKalVrtCore/TrkVKalVrtCore/Propagator.h index f82cac8ba37..ba8b7077bd2 100755 --- a/Tracking/TrkVertexFitter/TrkVKalVrtCore/TrkVKalVrtCore/Propagator.h +++ b/Tracking/TrkVertexFitter/TrkVKalVrtCore/TrkVKalVrtCore/Propagator.h @@ -54,7 +54,7 @@ class IVKalState; class vkalPropagator { public: vkalPropagator(); - ~vkalPropagator(); + ~vkalPropagator() = default; void Propagate(long int TrkID, long int Charge, diff --git a/Tracking/TrkVertexFitter/TrkVKalVrtCore/TrkVKalVrtCore/VKalVrtBMag.h b/Tracking/TrkVertexFitter/TrkVKalVrtCore/TrkVKalVrtCore/VKalVrtBMag.h index ffe195e4084..8abd7c98117 100755 --- a/Tracking/TrkVertexFitter/TrkVKalVrtCore/TrkVKalVrtCore/VKalVrtBMag.h +++ b/Tracking/TrkVertexFitter/TrkVKalVrtCore/TrkVKalVrtCore/VKalVrtBMag.h @@ -1,59 +1,59 @@ /* Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration -*/ -/* General magnetic field in any point access */ +*/ +/* General magnetic field in any point access */ /* If external magnetic field handler is provided as */ /* either an object inherited from the baseMagFld class */ /* or a function addrMagHandler - the vkalMagFld class */ /* will use it, otherwise the vkalMagFld returns */ /* the constant magnetic field. */ /* */ -/* Thread-safe implementation */ -/*---------------------------------------------------------*/ -#ifndef TRKVKALVRTCORE_VKALVRTBMAG_H -#define TRKVKALVRTCORE_VKALVRTBMAG_H +/* Thread-safe implementation */ +/*---------------------------------------------------------*/ +#ifndef TRKVKALVRTCORE_VKALVRTBMAG_H +#define TRKVKALVRTCORE_VKALVRTBMAG_H -namespace Trk { +namespace Trk { class VKalVrtControlBase; - - typedef void (*addrMagHandler)(double,double,double, double& ,double& , double& ); + + typedef void (*addrMagHandler)(double,double,double, double& ,double& , double& ); // // Base class for concrete megnetic field implementations (e.g. Athena tool) to be called by vkalMagFld -// - class baseMagFld { - public: - baseMagFld(); - virtual ~baseMagFld(); - virtual void getMagFld(const double,const double,const double,double&,double&,double&) const =0; - }; - +// + class baseMagFld { + public: + baseMagFld(); + virtual ~baseMagFld(); + virtual void getMagFld(const double,const double,const double,double&,double&,double&) const =0; + }; + // // Main magnetic field implememtation in VKalVrtCore package. // Depending on VKalVrtControlBase it either calls external magnetic field // or uses default fixed magnetic field. -// - class vkalMagFld { - public: - vkalMagFld(); - ~vkalMagFld(); - - void getMagFld(const double,const double,const double,double&,double&,double&, const VKalVrtControlBase*) const; +// + class vkalMagFld { + public: + vkalMagFld(); + ~vkalMagFld() = default; + + void getMagFld(const double,const double,const double,double&,double&,double&, const VKalVrtControlBase*) const; double getMagFld(const double xyz[3], const VKalVrtControlBase* FitControl) const; - double getCnvCst() const; - - private: - const double m_cnstBMAG; - const double m_vkalCnvMagFld; - double m_saveXpos; - double m_saveYpos; - double m_saveZpos; - double m_saveBX; - double m_saveBY; - double m_saveBZ; - }; - -} -#endif + double getCnvCst() const; + + private: + const double m_cnstBMAG; + const double m_vkalCnvMagFld; + double m_saveXpos; + double m_saveYpos; + double m_saveZpos; + double m_saveBX; + double m_saveBY; + double m_saveBZ; + }; + +} +#endif diff --git a/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/CascadeDefinition.cxx b/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/CascadeDefinition.cxx index 5048ff85065..530160e29ef 100755 --- a/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/CascadeDefinition.cxx +++ b/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/CascadeDefinition.cxx @@ -23,7 +23,7 @@ int initCascadeEngine(CascadeEvent &); VKVertex* startCascade( std::unique_ptr<VKVertex> vk) { - auto ptr = vk.get(); + auto *ptr = vk.get(); ptr->vk_fitterControl->getCascadeEvent()->cascadeNV=1; ptr->vk_fitterControl->getCascadeEvent()->nearPrmVertex=0; ptr->vk_fitterControl->getCascadeEvent()->cascadeVertexList.clear(); @@ -33,7 +33,7 @@ VKVertex* startCascade( std::unique_ptr<VKVertex> vk) VKVertex* addCascadeEntry( std::unique_ptr<VKVertex> vk) { - auto ptr = vk.get(); + auto *ptr = vk.get(); ptr->vk_fitterControl->getCascadeEvent()->cascadeNV++; ptr->vk_fitterControl->getCascadeEvent()->cascadeVertexList.push_back(std::move(vk)); return ptr->vk_fitterControl->getCascadeEvent()->cascadeVertexList.back().get(); @@ -48,7 +48,7 @@ VKVertex* addCascadeEntry( std::unique_ptr<VKVertex> vk, const std::vector<int> vk->includedVrt.push_back(predecessor); } // - auto ptr = vk.get(); + auto *ptr = vk.get(); ptr->vk_fitterControl->getCascadeEvent()->cascadeNV++; ptr->vk_fitterControl->getCascadeEvent()->cascadeVertexList.push_back(std::move(vk)); return ptr->vk_fitterControl->getCascadeEvent()->cascadeVertexList.back().get(); @@ -135,7 +135,7 @@ int makeCascade(VKalVrtControl & FitCONTROL, long int NTRK, long int *ich, doubl if(!includeNV) { // no predecessors addCascadeEntry( std::move(VRT) ); }else{ - auto vrttemp = addCascadeEntry( std::move(VRT), cascadeDefinition[iv]); + auto *vrttemp = addCascadeEntry( std::move(VRT), cascadeDefinition[iv]); for (it=0; it<includeNV ; it++) { // tracks created out of predecessing vertices vrttemp->TrackList.emplace_back(new VKTrack(-999, tmp, tmp , vrttemp, 0.)); vrttemp->tmpArr.emplace_back(new TWRK()); @@ -147,7 +147,7 @@ int makeCascade(VKalVrtControl & FitCONTROL, long int NTRK, long int *ich, doubl if(vEstimDone){ IERR = translateToFittedPos(*(FitCONTROL.getCascadeEvent()),1.); if(IERR)return IERR; for( iv=0; iv<FitCONTROL.getCascadeEvent()->cascadeNV; iv++){ - auto VRT=FitCONTROL.getCascadeEvent()->cascadeVertexList[iv].get(); + auto *VRT=FitCONTROL.getCascadeEvent()->cascadeVertexList[iv].get(); int NTv = VRT->TrackList.size(); // Number of tracks at vertex for(it=0; it<NTv; it++){ trk=VRT->TrackList[it].get(); diff --git a/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/DummyMag.cxx b/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/DummyMag.cxx index db66cb3a979..94c5c096482 100755 --- a/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/DummyMag.cxx +++ b/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/DummyMag.cxx @@ -31,7 +31,7 @@ vkalMagFld::vkalMagFld(): m_saveBZ=0.; } -vkalMagFld::~vkalMagFld() = default; + baseMagFld::baseMagFld() = default; diff --git a/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/Propagate.cxx b/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/Propagate.cxx index 5efe0060c19..d549ae2b7f0 100755 --- a/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/Propagate.cxx +++ b/Tracking/TrkVertexFitter/TrkVKalVrtCore/src/Propagate.cxx @@ -131,7 +131,7 @@ extern void cfnewpm (double*, double*, double*, double*, double*, double*, const // Propagator object // vkalPropagator::vkalPropagator()= default; - vkalPropagator::~vkalPropagator() = default; + basePropagator::basePropagator() = default; basePropagator::~basePropagator() = default; diff --git a/Tracking/TrkVertexFitter/TrkVertexSeedFinderUtils/src/GaussianTrackDensity.cxx b/Tracking/TrkVertexFitter/TrkVertexSeedFinderUtils/src/GaussianTrackDensity.cxx index 7b8596274ac..a0c3f0a231e 100644 --- a/Tracking/TrkVertexFitter/TrkVertexSeedFinderUtils/src/GaussianTrackDensity.cxx +++ b/Tracking/TrkVertexFitter/TrkVertexSeedFinderUtils/src/GaussianTrackDensity.cxx @@ -20,6 +20,8 @@ namespace Trk double GaussianTrackDensity::globalMaximum (const std::vector<const Track*>& vectorTrk) const { std::vector<const TrackParameters*> perigeeList; + perigeeList.reserve(vectorTrk.size()); + for (const Track* itrk : vectorTrk) { perigeeList.push_back(itrk->perigeeParameters()); @@ -39,6 +41,8 @@ namespace Trk std::unique_ptr<ITrackDensity>& density) const { std::vector<const TrackParameters*> perigeeList; + perigeeList.reserve(vectorTrk.size()); + for (const Track* itrk : vectorTrk) { perigeeList.push_back(itrk->perigeeParameters()); -- GitLab