From e28a8cee0971bbd69d0a02b05bfd17f7b90f0a7c Mon Sep 17 00:00:00 2001
From: Adam Edward Barton <adam.edward.barton@cern.ch>
Date: Wed, 4 Mar 2020 10:46:17 +0000
Subject: [PATCH] BoundarySurface: Copying vector of shared_ptr is expensive,
 use reference instead

---
 .../src/TrackingVolumeHelper.cxx              |  4 ++--
 .../TrkGeometry/src/TrackingGeometry.cxx      |  4 ++--
 .../TrkGeometry/src/TrackingVolume.cxx        |  2 +-
 .../TrkDigTools/src/PlanarModuleStepper.cxx   |  2 +-
 .../TrkExEngine/TrkExEngine/StepEngine.icc    |  4 ++--
 .../TrkExEngine/src/StepEngine.cxx            |  2 +-
 .../TrkExTools/src/Extrapolator.cxx           | 24 +++++++++----------
 .../TrkExTools/src/Navigator.cxx              |  4 ++--
 .../TrkExTools/src/TimedExtrapolator.cxx      | 20 ++++++++--------
 .../TrkExUtils/src/TargetSurfaces.cxx         |  2 +-
 10 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx b/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx
index f1e954d6bbe..be59a07251c 100755
--- a/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx
+++ b/Tracking/TrkDetDescr/TrkDetDescrTools/src/TrackingVolumeHelper.cxx
@@ -103,8 +103,8 @@ void Trk::TrackingVolumeHelper::glueTrackingVolumes(const Trk::TrackingVolume& f
     // ----------------------------------------------------------------------------------------
     // create a MaterialLayer as a boundary
     if (buildBoundaryLayer){
-        auto bSurfacesFirst  =  firstVol.boundarySurfaces();
-        auto bSurfacesSecond =  secondVol.boundarySurfaces();
+        const auto& bSurfacesFirst  =  firstVol.boundarySurfaces();
+        const auto& bSurfacesSecond =  secondVol.boundarySurfaces();
         // get the boundary surfaces
         const Trk::Surface& firstFaceSurface  = bSurfacesFirst[firstFace]->surfaceRepresentation(); 
         const Trk::Surface& secondFaceSurface  = bSurfacesSecond[secondFace]->surfaceRepresentation(); 
diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/TrackingGeometry.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/TrackingGeometry.cxx
index bf607cc8ffb..5203d243159 100755
--- a/Tracking/TrkDetDescr/TrkGeometry/src/TrackingGeometry.cxx
+++ b/Tracking/TrkDetDescr/TrkGeometry/src/TrackingGeometry.cxx
@@ -204,7 +204,7 @@ bool Trk::TrackingGeometry::atVolumeBoundary( const Amg::Vector3D& gp, const Trk
 {
     bool isAtBoundary = false;
     if (!vol) return isAtBoundary;
-    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = vol->boundarySurfaces();
+    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = vol->boundarySurfaces();
     for (unsigned int ib=0; ib< bounds.size(); ib++) {
         const Trk::Surface& surf = (bounds[ib].get())->surfaceRepresentation();
         if ( surf.isOnSurface(gp,true,tol,tol)  ) isAtBoundary = true;
@@ -219,7 +219,7 @@ bool Trk::TrackingGeometry::atVolumeBoundary(const Amg::Vector3D& gp, const Amg:
     bool isAtBoundary = false;
     nextVol = nullptr;
     if (!vol) return isAtBoundary;
-    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = vol->boundarySurfaces();
+    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = vol->boundarySurfaces();
     for (unsigned int ib=0; ib< bounds.size(); ib++) {
         const Trk::Surface& surf = (bounds[ib].get())->surfaceRepresentation();
         if ( surf.isOnSurface(gp,true,tol,tol) ) {
diff --git a/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx b/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx
index 3d75e77c446..3e9420a2dd7 100755
--- a/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx
+++ b/Tracking/TrkDetDescr/TrkGeometry/src/TrackingVolume.cxx
@@ -650,7 +650,7 @@ const Trk::TrackingVolume* Trk::TrackingVolume::nextVolume(const Amg::Vector3D&
     Amg::Vector3D cDir = dirScalor*dir;
     double pathLength = 10e10;
     // now loop through the and find the closest 
-    auto bSurfaces = boundarySurfaces();
+    const auto &bSurfaces = boundarySurfaces();
     for (auto& bSurfIter : bSurfaces ){
         // get the intersection soltuion
         Trk::Intersection sfI = (*bSurfIter).surfaceRepresentation().straightLineIntersection(gp, cDir, forceDir, true);
diff --git a/Tracking/TrkDigitization/TrkDigTools/src/PlanarModuleStepper.cxx b/Tracking/TrkDigitization/TrkDigTools/src/PlanarModuleStepper.cxx
index 63ef96c6688..5810f3c473e 100644
--- a/Tracking/TrkDigitization/TrkDigTools/src/PlanarModuleStepper.cxx
+++ b/Tracking/TrkDigitization/TrkDigTools/src/PlanarModuleStepper.cxx
@@ -94,7 +94,7 @@ std::vector<Trk::DigitizationStep> Trk::PlanarModuleStepper::cellSteps(const Trk
 
     
     // first, intersect the boundary surfaces
-    auto boundarySurfaces =  dmodule.boundarySurfaces();
+    const auto &boundarySurfaces =  dmodule.boundarySurfaces();
     // intersect them - fast exit for cases where readout and counter readout are hit
     Amg::Vector3D intersection3D(moduleIntersection.x(),moduleIntersection.y(),0.);
     size_t attempts = 0;
diff --git a/Tracking/TrkExtrapolation/TrkExEngine/TrkExEngine/StepEngine.icc b/Tracking/TrkExtrapolation/TrkExEngine/TrkExEngine/StepEngine.icc
index 136da256796..f132acceff4 100644
--- a/Tracking/TrkExtrapolation/TrkExEngine/TrkExEngine/StepEngine.icc
+++ b/Tracking/TrkExtrapolation/TrkExEngine/TrkExEngine/StepEngine.icc
@@ -35,7 +35,7 @@ template<class T> Trk::ExtrapolationCode Trk::StepEngine::targetSurfacesT(Trk::E
     }
 
     // static frame boundaries
-    const std::vector< Trk::SharedObject< const Trk::BoundarySurface< Trk::TrackingVolume> > > bounds = eCell.leadVolume->boundarySurfaces();
+    const std::vector< Trk::SharedObject< const Trk::BoundarySurface< Trk::TrackingVolume> > > &bounds = eCell.leadVolume->boundarySurfaces();
     // count number of non-trivial solutions
     unsigned int iInt=0;
     for (unsigned int ib=0; ib< bounds.size(); ib++ ){
@@ -77,7 +77,7 @@ template<class T> Trk::ExtrapolationCode Trk::StepEngine::targetSurfacesT(Trk::E
 template<class T> Trk::ExtrapolationCode Trk::StepEngine::resolveFrameBoundaryT(Trk::ExtrapolationCell<T>& eCell, Amg::Vector3D gp,
                                                                                 unsigned int bIndex ) const
 {                                                                                                                    
-   const std::vector< Trk::SharedObject< const Trk::BoundarySurface< Trk::TrackingVolume> > > bounds = eCell.leadVolume->boundarySurfaces();
+   const std::vector< Trk::SharedObject< const Trk::BoundarySurface< Trk::TrackingVolume> > > &bounds = eCell.leadVolume->boundarySurfaces();
 
    EX_MSG_VERBOSE(eCell.navigationStep, "navigation", "","current lead volume:"<<eCell.leadVolume->volumeName());
    
diff --git a/Tracking/TrkExtrapolation/TrkExEngine/src/StepEngine.cxx b/Tracking/TrkExtrapolation/TrkExEngine/src/StepEngine.cxx
index d5e12c9d19a..b6b4db329fa 100644
--- a/Tracking/TrkExtrapolation/TrkExEngine/src/StepEngine.cxx
+++ b/Tracking/TrkExtrapolation/TrkExEngine/src/StepEngine.cxx
@@ -215,7 +215,7 @@ Trk::ExtrapolationCode Trk::StepEngine::extrapolate(ExCellNeutral& ecNeutral,
   
     ////// STEP ACROSS FRAME BOUNDARY  ///////////////  TO DO:TEMPLATE //////////////////////////
     if ( ts[ii].sfType == Trk::SurfNavigType::BoundaryFrame ) {  
-      const std::vector< Trk::SharedObject< const Trk::BoundarySurface< Trk::TrackingVolume> > > bounds = ecNeutral.leadVolume->boundarySurfaces();
+      const std::vector< Trk::SharedObject< const Trk::BoundarySurface< Trk::TrackingVolume> > > &bounds = ecNeutral.leadVolume->boundarySurfaces();
       const Trk::TrackingVolume* nextVolume = bounds[ts[ii].index].get()->attachedVolume(ts[ii].intersection, 
 											    ecNeutral.leadParameters->momentum(), 
 											    ecNeutral.propDirection);  
diff --git a/Tracking/TrkExtrapolation/TrkExTools/src/Extrapolator.cxx b/Tracking/TrkExtrapolation/TrkExTools/src/Extrapolator.cxx
index 80510334d4d..2bf985c6413 100755
--- a/Tracking/TrkExtrapolation/TrkExTools/src/Extrapolator.cxx
+++ b/Tracking/TrkExtrapolation/TrkExTools/src/Extrapolator.cxx
@@ -696,7 +696,7 @@ Trk::Extrapolator::extrapolateToNextMaterialLayer(Cache& cache,
   if (staticVol && (staticVol != cache.m_currentStatic || resolveActive != m_resolveActive)) {    // retrieve boundaries
     cache.m_currentStatic = staticVol;
     cache.m_staticBoundaries.clear();
-    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = staticVol->boundarySurfaces();
+    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = staticVol->boundarySurfaces();
     for (unsigned int ib = 0; ib < bounds.size(); ib++) {
       const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
       cache.m_staticBoundaries.emplace_back(&surf, true);
@@ -716,7 +716,7 @@ Trk::Extrapolator::extrapolateToNextMaterialLayer(Cache& cache,
         // active station ?
         const Trk::Layer *layR = (*iTer)->layerRepresentation();
         bool active = layR && layR->layerType();
-        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  detBounds =
+        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  &detBounds =
           (*iTer)->trackingVolume()->boundarySurfaces();
         if (active) {
           if (resolveActive) {
@@ -947,7 +947,7 @@ Trk::Extrapolator::extrapolateToNextMaterialLayer(Cache& cache,
     if (!active && !confinedDense && !confinedLays) {
       continue;
     }
-    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = dVol->boundarySurfaces();
+    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = dVol->boundarySurfaces();
     if (!active && !confinedDense && confinedLays->size() <= bounds.size()) {
       continue;
     }
@@ -961,7 +961,7 @@ Trk::Extrapolator::extrapolateToNextMaterialLayer(Cache& cache,
       if (confinedDense) {
         std::vector<const Trk::TrackingVolume *>::const_iterator vIter = confinedDense->begin();
         for (; vIter != confinedDense->end(); vIter++) {
-          const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds =
+          const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds =
             (*vIter)->boundarySurfaces();
           cache.m_denseVols.emplace_back(*vIter, bounds.size());
           for (unsigned int ib = 0; ib < bounds.size(); ib++) {
@@ -998,7 +998,7 @@ Trk::Extrapolator::extrapolateToNextMaterialLayer(Cache& cache,
         vExit = false;
       }
       if (!vExit) {
-        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = detVol->boundarySurfaces();
+        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = detVol->boundarySurfaces();
         cache.m_navigVolsInt.emplace_back(detVol, bounds.size());
         for (unsigned int ib = 0; ib < bounds.size(); ib++) {
           const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
@@ -1660,7 +1660,7 @@ Trk::Extrapolator::extrapolateInAlignableTV(Cache& cache,
   // assume new static volume, retrieve boundaries
   cache.m_currentStatic = staticVol;
   cache.m_staticBoundaries.clear();
-  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = staticVol->boundarySurfaces();
+  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = staticVol->boundarySurfaces();
   for (unsigned int ib = 0; ib < bounds.size(); ib++) {
     const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
     cache.m_staticBoundaries.emplace_back(&surf, true);
@@ -1876,7 +1876,7 @@ std::pair<const Trk::TrackParameters *, const Trk::Layer *> Trk::Extrapolator::e
   cache.m_navigVols.clear();
 
   // retrieve static volume boundary
-  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = currVol->boundarySurfaces();
+  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = currVol->boundarySurfaces();
   for (unsigned int ib = 0; ib < bounds.size(); ib++) {
     const Trk::Surface *nextSurface = &((bounds[ib].get())->surfaceRepresentation());
     cache.m_navigSurfs.emplace_back(nextSurface, true);
@@ -4693,7 +4693,7 @@ Trk::Extrapolator::extrapolateToVolumeWithPathLimit(
   // update if new static volume
   if (updateStatic) {    // retrieve boundaries
     cache.m_staticBoundaries.clear();
-    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds =
+    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds =
       cache.m_currentStatic->boundarySurfaces();
     for (unsigned int ib = 0; ib < bounds.size(); ib++) {
       const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
@@ -4715,7 +4715,7 @@ Trk::Extrapolator::extrapolateToVolumeWithPathLimit(
         // active station ?
         const Trk::Layer *layR = (*iTer)->layerRepresentation();
         bool active = layR && layR->layerType();
-        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  detBounds =
+        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  &detBounds =
           (*iTer)->trackingVolume()->boundarySurfaces();
         if (active) {
           cache.m_detachedVols.emplace_back(*iTer,
@@ -4818,7 +4818,7 @@ Trk::Extrapolator::extrapolateToVolumeWithPathLimit(
     if (!active && !confinedDense && !confinedLays) {
       continue;
     }
-    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = dVol->boundarySurfaces();
+    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = dVol->boundarySurfaces();
     if (!active && !confinedDense && confinedLays->size() <= bounds.size()) {
       continue;
     }
@@ -4832,7 +4832,7 @@ Trk::Extrapolator::extrapolateToVolumeWithPathLimit(
       if (confinedDense) {
         std::vector<const Trk::TrackingVolume *>::const_iterator vIter = confinedDense->begin();
         for (; vIter != confinedDense->end(); vIter++) {
-          const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds =
+          const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds =
             (*vIter)->boundarySurfaces();
           cache.m_denseVols.emplace_back(*vIter, bounds.size());
           for (unsigned int ib = 0; ib < bounds.size(); ib++) {
@@ -4869,7 +4869,7 @@ Trk::Extrapolator::extrapolateToVolumeWithPathLimit(
         vExit = false;
       }
       if (!vExit) {
-        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = detVol->boundarySurfaces();
+        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = detVol->boundarySurfaces();
         navigVols.emplace_back(detVol, bounds.size());
         for (unsigned int ib = 0; ib < bounds.size(); ib++) {
           const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
diff --git a/Tracking/TrkExtrapolation/TrkExTools/src/Navigator.cxx b/Tracking/TrkExtrapolation/TrkExTools/src/Navigator.cxx
index 7b390a96b40..68fd8fa6de6 100755
--- a/Tracking/TrkExtrapolation/TrkExTools/src/Navigator.cxx
+++ b/Tracking/TrkExtrapolation/TrkExTools/src/Navigator.cxx
@@ -370,7 +370,7 @@ Trk::Navigator::nextDenseTrackingVolume(
     surfaces->push_back(std::pair<const Trk::Surface *, Trk::BoundaryCheck>(destinationSurface, false));
   }
 
-  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = vol.boundarySurfaces();
+  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = vol.boundarySurfaces();
   for (unsigned int ib = 0; ib < bounds.size(); ib++) {
     const Trk::Surface *nextSurface = &((bounds[ib].get())->surfaceRepresentation());
     surfaces->push_back(std::pair<const Trk::Surface *, Trk::BoundaryCheck>(nextSurface, true));
@@ -412,7 +412,7 @@ Trk::Navigator::atVolumeBoundary(const Trk::TrackParameters *parms, const Trk::T
   if (!vol) {
     return isAtBoundary;
   }
-  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = vol->boundarySurfaces();
+  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = vol->boundarySurfaces();
   for (unsigned int ib = 0; ib < bounds.size(); ib++) {
     const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
     if (surf.isOnSurface(parms->position(), true, tol, tol)) {
diff --git a/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx b/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx
index 2d0d2020d25..2e25e63d7fb 100644
--- a/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx
+++ b/Tracking/TrkExtrapolation/TrkExTools/src/TimedExtrapolator.cxx
@@ -483,7 +483,7 @@ Trk::TimedExtrapolator::extrapolateToVolumeWithPathLimit(
   // update if new static volume
   if (updateStatic) {    // retrieve boundaries
     m_staticBoundaries.clear();
-    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds =
+    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds =
       m_currentStatic->boundarySurfaces();
     for (unsigned int ib = 0; ib < bounds.size(); ib++) {
       const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
@@ -523,7 +523,7 @@ Trk::TimedExtrapolator::extrapolateToVolumeWithPathLimit(
         // active station ?
         const Trk::Layer *layR = (*iTer)->layerRepresentation();
         bool active = layR && layR->layerType();
-        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  detBounds =
+        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  &detBounds =
           (*iTer)->trackingVolume()->boundarySurfaces();
         if (active) {
           m_detachedVols.emplace_back(*iTer,
@@ -628,7 +628,7 @@ Trk::TimedExtrapolator::extrapolateToVolumeWithPathLimit(
     if (!active && !confinedDense && !confinedLays) {
       continue;
     }
-    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = dVol->boundarySurfaces();
+    const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = dVol->boundarySurfaces();
     if (!active && !confinedDense && confinedLays->size() <= bounds.size()) {
       continue;
     }
@@ -642,7 +642,7 @@ Trk::TimedExtrapolator::extrapolateToVolumeWithPathLimit(
       if (confinedDense) {
         std::vector<const Trk::TrackingVolume *>::const_iterator vIter = confinedDense->begin();
         for (; vIter != confinedDense->end(); vIter++) {
-          const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds =
+          const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds =
             (*vIter)->boundarySurfaces();
           m_denseVols.emplace_back(*vIter, bounds.size());
           for (unsigned int ib = 0; ib < bounds.size(); ib++) {
@@ -679,7 +679,7 @@ Trk::TimedExtrapolator::extrapolateToVolumeWithPathLimit(
         vExit = false;
       }
       if (!vExit) {
-        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = detVol->boundarySurfaces();
+        const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = detVol->boundarySurfaces();
         navigVols.emplace_back(detVol, bounds.size());
         for (unsigned int ib = 0; ib < bounds.size(); ib++) {
           const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
@@ -1545,7 +1545,7 @@ Trk::TimedExtrapolator::transportToVolumeWithPathLimit(const Trk::TrackParameter
   // distance to static volume boundaries recalculated
   // retrieve boundaries along path
   m_trStaticBounds.clear();
-  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds =
+  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds =
     m_currentStatic->boundarySurfaces();
   for (unsigned int ib = 0; ib < bounds.size(); ib++) {
     const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
@@ -1690,7 +1690,7 @@ Trk::TimedExtrapolator::transportToVolumeWithPathLimit(const Trk::TrackParameter
              (*iTer)->trackingVolume()->confinedDenseVolumes()->empty())
             && (!(*iTer)->trackingVolume()->confinedArbitraryLayers() ||
                 (*iTer)->trackingVolume()->confinedArbitraryLayers()->empty())) {
-          const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  detBounds =
+          const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  &detBounds =
             (*iTer)->trackingVolume()->boundarySurfaces();
           int newB = 0;
           for (unsigned int ibb = 0; ibb < detBounds.size(); ibb++) {
@@ -1722,7 +1722,7 @@ Trk::TimedExtrapolator::transportToVolumeWithPathLimit(const Trk::TrackParameter
         if (confinedDense && !confinedDense->empty()) {
           std::vector<const Trk::TrackingVolume *>::const_iterator vIter = confinedDense->begin();
           for (; vIter != confinedDense->end(); vIter++) {
-            const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  bounds =
+            const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > >  &bounds =
               (*vIter)->boundarySurfaces();
             int newB = 0;
             for (unsigned int ibb = 0; ibb < bounds.size(); ibb++) {
@@ -2248,7 +2248,7 @@ Trk::TimedExtrapolator::transportInAlignableTV(const Trk::TrackParameters &parm,
   // resolve exit from the volume
 
   m_trStaticBounds.clear();
-  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = aliTV->boundarySurfaces();
+  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = aliTV->boundarySurfaces();
   for (unsigned int ib = 0; ib < bounds.size(); ib++) {
     const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
     Trk::DistanceSolution distSol = surf.straightLineDistanceEstimate(currPar->position(),
@@ -2543,7 +2543,7 @@ Trk::TimedExtrapolator::extrapolateInAlignableTV(const Trk::TrackParameters &par
   // assume new static volume, retrieve boundaries
   m_currentStatic = staticVol;
   m_staticBoundaries.clear();
-  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > bounds = staticVol->boundarySurfaces();
+  const std::vector< SharedObject<const BoundarySurface<TrackingVolume> > > &bounds = staticVol->boundarySurfaces();
   for (unsigned int ib = 0; ib < bounds.size(); ib++) {
     const Trk::Surface &surf = (bounds[ib].get())->surfaceRepresentation();
     m_staticBoundaries.emplace_back(&surf, true);
diff --git a/Tracking/TrkExtrapolation/TrkExUtils/src/TargetSurfaces.cxx b/Tracking/TrkExtrapolation/TrkExUtils/src/TargetSurfaces.cxx
index f9712bfdb3b..7701ca9a542 100755
--- a/Tracking/TrkExtrapolation/TrkExUtils/src/TargetSurfaces.cxx
+++ b/Tracking/TrkExtrapolation/TrkExUtils/src/TargetSurfaces.cxx
@@ -110,7 +110,7 @@ bool Trk::TargetSurfaces::initFrameVolume(const Amg::Vector3D& pos, const Amg::V
   m_tempSurfaces.clear();
 
   // static frame boundaries
-  const std::vector< Trk::SharedObject< const Trk::BoundarySurface< Trk::TrackingVolume> > > bounds = fVol->boundarySurfaces();
+  const std::vector< Trk::SharedObject< const Trk::BoundarySurface< Trk::TrackingVolume> > > &bounds = fVol->boundarySurfaces();
   for (unsigned int ib=0; ib< bounds.size(); ib++ ){
     const Trk::Surface& surf = (bounds[ib].get())->surfaceRepresentation();
     Trk::TargetSurface bb(&surf,true,Trk::SurfNavigType::BoundaryFrame,ib,fVol,Trk::TVNavigType::Frame);
-- 
GitLab