From 9161e015bdb09ed512727876b0431e566c1ae11d Mon Sep 17 00:00:00 2001 From: Carlo Varni Date: Tue, 14 Mar 2023 14:48:07 +0100 Subject: [PATCH 01/14] move quality --- CMakeLists.txt | 4 +-- Core/include/Acts/Seeding/BinnedSPGroup.ipp | 6 ++-- .../Acts/Seeding/InternalSpacePoint.hpp | 21 +++++------- Core/include/Acts/Seeding/SeedFilter.hpp | 10 ++++-- Core/include/Acts/Seeding/SeedFilter.ipp | 34 ++++++++++++------- Core/include/Acts/Seeding/SeedFinder.hpp | 9 +++++ Core/include/Acts/Seeding/SeedFinder.ipp | 5 +-- .../Acts/Seeding/SeedFinderOrthogonal.ipp | 14 +++++--- .../TrackFinding/src/SeedingAlgorithm.cpp | 3 ++ 9 files changed, 67 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 618b0a85056..48d8a7ec612 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,14 +53,14 @@ option(ACTS_BUILD_FATRAS_GEANT4 "Build Geant4 Fatras package" OFF) # alignment related options option(ACTS_BUILD_ALIGNMENT "Build Alignment package" OFF) # examples related options -option(ACTS_BUILD_EXAMPLES "Build standalone examples" OFF) +option(ACTS_BUILD_EXAMPLES "Build standalone examples" ON) option(ACTS_BUILD_EXAMPLES_DD4HEP "Build DD4hep-based code in the examples" OFF) option(ACTS_BUILD_EXAMPLES_EDM4HEP "Build EDM4hep-based code in the examples" OFF) option(ACTS_BUILD_EXAMPLES_EXATRKX "Build the Exa.TrkX example code" OFF) option(ACTS_BUILD_EXAMPLES_GEANT4 "Build Geant4-based code in the examples" OFF) option(ACTS_BUILD_EXAMPLES_HEPMC3 "Build HepMC3-based code in the examples" OFF) option(ACTS_BUILD_EXAMPLES_PYTHIA8 "Build Pythia8-based code in the examples" OFF) -option(ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS "Build python bindings for the examples" OFF) +option(ACTS_BUILD_EXAMPLES_PYTHON_BINDINGS "Build python bindings for the examples" ON) option(ACTS_BUILD_EXAMPLES_BINARIES "Build the examples binaries (deprecated)" OFF) option(ACTS_USE_SYSTEM_PYBIND11 "Use a system installation of pybind11" ${ACTS_USE_SYSTEM_LIBS} ) option(ACTS_USE_EXAMPLES_TBB "Use Threading Building Blocks library in the examples" ON) diff --git a/Core/include/Acts/Seeding/BinnedSPGroup.ipp b/Core/include/Acts/Seeding/BinnedSPGroup.ipp index 13bbb818fe4..a6e2e33f038 100644 --- a/Core/include/Acts/Seeding/BinnedSPGroup.ipp +++ b/Core/include/Acts/Seeding/BinnedSPGroup.ipp @@ -1,3 +1,4 @@ +// -*- C++ -*- // This file is part of the Acts project. // // Copyright (C) 2023 CERN for the benefit of the Acts project @@ -154,7 +155,8 @@ Acts::BinnedSPGroup::BinnedSPGroup( // keep track of changed bins while sorting boost::container::flat_set rBinsIndex; - for (spacepoint_iterator_t it = spBegin; it != spEnd; it++) { + std::size_t counter = 0; + for (spacepoint_iterator_t it = spBegin; it != spEnd; it++, ++counter) { if (*it == nullptr) { continue; } @@ -177,7 +179,7 @@ Acts::BinnedSPGroup::BinnedSPGroup( continue; } - auto isp = std::make_unique>( + auto isp = std::make_unique>(counter, sp, spPosition, options.beamPos, variance); // calculate r-Bin index and protect against overflow (underflow not // possible) diff --git a/Core/include/Acts/Seeding/InternalSpacePoint.hpp b/Core/include/Acts/Seeding/InternalSpacePoint.hpp index 39f19647e22..a33f005281f 100644 --- a/Core/include/Acts/Seeding/InternalSpacePoint.hpp +++ b/Core/include/Acts/Seeding/InternalSpacePoint.hpp @@ -23,7 +23,8 @@ class InternalSpacePoint { public: InternalSpacePoint() = delete; - InternalSpacePoint(const SpacePoint& sp, const Acts::Vector3& globalPos, + InternalSpacePoint(std::size_t index, + const SpacePoint& sp, const Acts::Vector3& globalPos, const Acts::Vector2& offsetXY, const Acts::Vector2& variance); @@ -33,6 +34,7 @@ class InternalSpacePoint { InternalSpacePoint& operator=( const InternalSpacePoint&) = delete; + std::size_t index() const { return m_index; } const float& x() const { return m_x; } const float& y() const { return m_y; } const float& z() const { return m_z; } @@ -41,16 +43,11 @@ class InternalSpacePoint { const float& varianceR() const { return m_varianceR; } const float& varianceZ() const { return m_varianceZ; } const float& deltaR() const { return m_deltaR; } - const float& quality() const { return m_quality; } void setDeltaR(float deltaR) { m_deltaR = deltaR; } - void setQuality(float quality) { - if (quality >= m_quality) { - m_quality = quality; - } - } const SpacePoint& sp() const { return m_sp; } protected: + std::size_t m_index; float m_x; // x-coordinate in beam system coordinates float m_y; // y-coordinate in beam system coordinates float m_z; // z-coordinate in beam system coordinetes @@ -58,10 +55,6 @@ class InternalSpacePoint { float m_varianceR; // float m_varianceZ; // float m_deltaR; // - float m_quality = -std::numeric_limits< - double>::infinity(); // Quality score of the seed the space point is used - // for. Quality can be changed if the space point is - // used for a better quality seed. const SpacePoint& m_sp; // external space point }; @@ -71,9 +64,11 @@ class InternalSpacePoint { template inline InternalSpacePoint::InternalSpacePoint( - const SpacePoint& sp, const Acts::Vector3& globalPos, + std::size_t index, + const SpacePoint& sp, const Acts::Vector3& globalPos, const Acts::Vector2& offsetXY, const Acts::Vector2& variance) - : m_sp(sp) { + : m_index(index), + m_sp(sp) { m_x = globalPos.x() - offsetXY.x(); m_y = globalPos.y() - offsetXY.y(); m_z = globalPos.z(); diff --git a/Core/include/Acts/Seeding/SeedFilter.hpp b/Core/include/Acts/Seeding/SeedFilter.hpp index 070c191a679..c6d65b1552d 100644 --- a/Core/include/Acts/Seeding/SeedFilter.hpp +++ b/Core/include/Acts/Seeding/SeedFilter.hpp @@ -20,6 +20,10 @@ #include #include +namespace Acts { + struct SpacePointInfo; +} + namespace Acts { struct SeedFilterState { // longitudinal impact parameter as defined by bottom and middle space point @@ -55,7 +59,7 @@ class SeedFilter { /// @param impactParametersVec vector containing the impact parameters /// @param seedFilterState holds quantities used in seed filter /// @param candidates_collector container for the seed candidates - virtual void filterSeeds_2SpFixed( + virtual void filterSeeds_2SpFixed(std::vector& spacePointInfo, InternalSpacePoint& bottomSP, InternalSpacePoint& middleSP, std::vector*>& topSpVec, @@ -70,7 +74,7 @@ class SeedFilter { /// @param numQualitySeeds number of high quality seeds in seed confirmation /// @param outIt Output iterator for the seeds /// for all seeds with the same middle space point - virtual void filterSeeds_1SpFixed( + virtual void filterSeeds_1SpFixed(std::vector& spacePointInfo, CandidatesForMiddleSp>& candidates_collector, std::size_t& numQualitySeeds, @@ -82,7 +86,7 @@ class SeedFilter { /// @param numQualitySeeds number of high quality seeds in seed confirmation /// @param outIt Output iterator for the seeds /// for all seeds with the same middle space point - virtual void filterSeeds_1SpFixed( + virtual void filterSeeds_1SpFixed(std::vector& spacePointInfo, std::vector>::value_type>& candidates, std::size_t& numQualitySeeds, diff --git a/Core/include/Acts/Seeding/SeedFilter.ipp b/Core/include/Acts/Seeding/SeedFilter.ipp index 9f67a79f46d..73ecf8b6d62 100644 --- a/Core/include/Acts/Seeding/SeedFilter.ipp +++ b/Core/include/Acts/Seeding/SeedFilter.ipp @@ -1,3 +1,4 @@ +// -*- C++ -*- // This file is part of the Acts project. // // Copyright (C) 2018 CERN for the benefit of the Acts project @@ -26,7 +27,7 @@ SeedFilter::SeedFilter( // middle-spacepoint. // return vector must contain weight of each seed template -void SeedFilter::filterSeeds_2SpFixed( +void SeedFilter::filterSeeds_2SpFixed(std::vector& spacePointInfo, InternalSpacePoint& bottomSP, InternalSpacePoint& middleSP, std::vector*>& topSpVec, @@ -178,8 +179,9 @@ void SeedFilter::filterSeeds_2SpFixed( // skip a bad quality seed if any of its constituents has a weight larger // than the seed weight - if (weight < bottomSP.quality() and weight < middleSP.quality() and - weight < topSpVec[topSPIndex]->quality()) { + if (weight < spacePointInfo[bottomSP.index()].quality and + weight < spacePointInfo[middleSP.index()].quality and + weight < spacePointInfo[topSpVec[topSPIndex]->index()].quality) { continue; } @@ -235,7 +237,7 @@ void SeedFilter::filterSeeds_2SpFixed( // after creating all seeds with a common middle space point, filter again template -void SeedFilter::filterSeeds_1SpFixed( +void SeedFilter::filterSeeds_1SpFixed(std::vector& spacePointInfo, CandidatesForMiddleSp>& candidates_collector, std::size_t& numQualitySeeds, @@ -245,11 +247,11 @@ void SeedFilter::filterSeeds_1SpFixed( // this collection is alredy sorted // higher weights first auto extended_collection = candidates_collector.storage(); - filterSeeds_1SpFixed(extended_collection, numQualitySeeds, outIt); + filterSeeds_1SpFixed(spacePointInfo, extended_collection, numQualitySeeds, outIt); } template -void SeedFilter::filterSeeds_1SpFixed( +void SeedFilter::filterSeeds_1SpFixed(std::vector& spacePointInfo, std::vector>::value_type>& candidates, std::size_t& numQualitySeeds, @@ -269,7 +271,7 @@ void SeedFilter::filterSeeds_1SpFixed( // ordering by weight by filterSeeds_2SpFixed means these are the lowest // weight seeds unsigned int numTotalSeeds = 0; - for (auto& [bottom, medium, top, bestSeedQuality, zOrigin, qualitySeed] : + for (const auto& [bottom, medium, top, bestSeedQuality, zOrigin, qualitySeed] : candidates) { // stop if we reach the maximum number of seeds if (numTotalSeeds >= maxSeeds) { @@ -281,17 +283,23 @@ void SeedFilter::filterSeeds_1SpFixed( if (numQualitySeeds > 0 and not qualitySeed) { continue; } - if (bestSeedQuality < bottom->quality() and - bestSeedQuality < medium->quality() and - bestSeedQuality < top->quality()) { + if (bestSeedQuality < spacePointInfo[bottom->index()].quality and + bestSeedQuality < spacePointInfo[medium->index()].quality and + bestSeedQuality < spacePointInfo[top->index()].quality) { continue; } } // set quality of seed components - bottom->setQuality(bestSeedQuality); - medium->setQuality(bestSeedQuality); - top->setQuality(bestSeedQuality); + if (bestSeedQuality > spacePointInfo[bottom->index()].quality) { + spacePointInfo[bottom->index()].quality = bestSeedQuality; + } + if (bestSeedQuality > spacePointInfo[medium->index()].quality) { + spacePointInfo[medium->index()].quality = bestSeedQuality; + } + if (bestSeedQuality > spacePointInfo[top->index()].quality) { + spacePointInfo[top->index()].quality = bestSeedQuality; + } outIt = Seed{bottom->sp(), medium->sp(), top->sp(), zOrigin, bestSeedQuality}; diff --git a/Core/include/Acts/Seeding/SeedFinder.hpp b/Core/include/Acts/Seeding/SeedFinder.hpp index 45e61d92bd2..3e0a9fc9cfb 100644 --- a/Core/include/Acts/Seeding/SeedFinder.hpp +++ b/Core/include/Acts/Seeding/SeedFinder.hpp @@ -27,9 +27,15 @@ #include #include #include +#include namespace Acts { + struct SpacePointInfo { + float quality = -std::numeric_limits::infinity(); + float deltaR = 0; + }; + template class SeedFinder { /////////////////////////////////////////////////////////////////// @@ -63,6 +69,9 @@ class SeedFinder { bottomNeighbours; boost::container::small_vector, 9> topNeighbours; + + // Adding space point info + std::vector spacePointInfo; }; /// The only constructor. Requires a config object. diff --git a/Core/include/Acts/Seeding/SeedFinder.ipp b/Core/include/Acts/Seeding/SeedFinder.ipp index 099b07539f7..eeaa231957d 100644 --- a/Core/include/Acts/Seeding/SeedFinder.ipp +++ b/Core/include/Acts/Seeding/SeedFinder.ipp @@ -1,3 +1,4 @@ +// -*- C++ -*- // This file is part of the Acts project. // // Copyright (C) 2023 CERN for the benefit of the Acts project @@ -160,7 +161,7 @@ void SeedFinder::createSeedsForGroup( // filter candidates filterCandidates(*spM.get(), options, seedFilterState, state); - m_config.seedFilter->filterSeeds_1SpFixed( + m_config.seedFilter->filterSeeds_1SpFixed(state.spacePointInfo, state.candidates_collector, seedFilterState.numQualitySeeds, outIt); } // loop on mediums @@ -591,7 +592,7 @@ void SeedFinder::filterCandidates( continue; } - m_config.seedFilter->filterSeeds_2SpFixed( + m_config.seedFilter->filterSeeds_2SpFixed(state.spacePointInfo, *state.compatBottomSP[b], spM, state.topSpVec, state.curvatures, state.impactParameters, seedFilterState, state.candidates_collector); } // loop on bottoms diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index 7ed59aa7002..4d45a39e104 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -1,3 +1,4 @@ +// -*- C++ -*- // This file is part of the Acts project. // // Copyright (C) 2022 CERN for the benefit of the Acts project @@ -17,6 +18,8 @@ #include #include +#include "Acts/Seeding/SeedFinder.hpp" + namespace Acts { template auto SeedFinderOrthogonal::validTupleOrthoRangeLH( @@ -431,8 +434,9 @@ void SeedFinderOrthogonal::filterCandidates( } } + std::vector vec; if (!top_valid.empty()) { - m_config.seedFilter->filterSeeds_2SpFixed( + m_config.seedFilter->filterSeeds_2SpFixed(vec, *bottom[b], middle, top_valid, curvatures, impactParameters, seedFilterState, candidates_collector); } @@ -593,7 +597,8 @@ void SeedFinderOrthogonal::processFromMiddleSP( // TODO: add seed confirmation SeedFilterState seedFilterState; - + std::vector spacePointInfo; + /* * If we have candidates for increasing z tracks, we try to combine them. */ @@ -611,7 +616,7 @@ void SeedFinderOrthogonal::processFromMiddleSP( /* * Run a seed filter, just like in other seeding algorithms. */ - m_config.seedFilter->filterSeeds_1SpFixed(candidates_collector, + m_config.seedFilter->filterSeeds_1SpFixed(spacePointInfo, candidates_collector, seedFilterState.numQualitySeeds, std::back_inserter(out_cont)); } @@ -670,10 +675,11 @@ void SeedFinderOrthogonal::createSeeds( * point, and save it in a vector. */ Acts::Extent rRangeSPExtent; + std::size_t counter = 0; std::vector internalSpacePoints; for (const external_spacepoint_t *p : spacePoints) { auto [position, variance] = extract_coordinates(p); - internalSpacePoints.push_back(new InternalSpacePoint( + internalSpacePoints.push_back(new InternalSpacePoint(counter++, *p, position, options.beamPos, variance)); // store x,y,z values in extent rRangeSPExtent.extend(position); diff --git a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp index 914bf26666c..fd6d00cf674 100644 --- a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp @@ -252,6 +252,9 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithm::execute( seeds.clear(); static thread_local decltype(m_seedFinder)::SeedingState state; + state.spacePointInfo.clear(); + state.spacePointInfo.resize(spacePointPtrs.size()); + for (const auto [bottom, middle, top] : spacePointsGrouping) { m_seedFinder.createSeedsForGroup( m_cfg.seedFinderOptions, state, spacePointsGrouping.grid(), From 3326cfc82219dca1dc2f35fd23c8a836e39dea7a Mon Sep 17 00:00:00 2001 From: Carlo Varni Date: Tue, 14 Mar 2023 15:07:14 +0100 Subject: [PATCH 02/14] move deltaR as well --- .../Acts/Seeding/InternalSpacePoint.hpp | 24 +++++++++---------- Core/include/Acts/Seeding/SeedFilter.ipp | 8 +++---- Core/include/Acts/Seeding/SeedFinder.ipp | 4 ++-- .../Acts/Seeding/SeedFinderOrthogonal.ipp | 5 ++-- Core/include/Acts/Seeding/SeedFinderUtils.hpp | 3 ++- Core/include/Acts/Seeding/SeedFinderUtils.ipp | 13 +++++----- 6 files changed, 30 insertions(+), 27 deletions(-) diff --git a/Core/include/Acts/Seeding/InternalSpacePoint.hpp b/Core/include/Acts/Seeding/InternalSpacePoint.hpp index a33f005281f..1eaae2ec118 100644 --- a/Core/include/Acts/Seeding/InternalSpacePoint.hpp +++ b/Core/include/Acts/Seeding/InternalSpacePoint.hpp @@ -42,8 +42,8 @@ class InternalSpacePoint { float phi() const { return atan2f(m_y, m_x); } const float& varianceR() const { return m_varianceR; } const float& varianceZ() const { return m_varianceZ; } - const float& deltaR() const { return m_deltaR; } - void setDeltaR(float deltaR) { m_deltaR = deltaR; } + // const float& deltaR() const { return m_deltaR; } + // void setDeltaR(float deltaR) { m_deltaR = deltaR; } const SpacePoint& sp() const { return m_sp; } protected: @@ -54,7 +54,7 @@ class InternalSpacePoint { float m_r; // radius in beam system coordinates float m_varianceR; // float m_varianceZ; // - float m_deltaR; // + // float m_deltaR; // const SpacePoint& m_sp; // external space point }; @@ -68,15 +68,15 @@ inline InternalSpacePoint::InternalSpacePoint( const SpacePoint& sp, const Acts::Vector3& globalPos, const Acts::Vector2& offsetXY, const Acts::Vector2& variance) : m_index(index), - m_sp(sp) { - m_x = globalPos.x() - offsetXY.x(); - m_y = globalPos.y() - offsetXY.y(); - m_z = globalPos.z(); - m_r = std::sqrt(m_x * m_x + m_y * m_y); - m_varianceR = variance.x(); - m_varianceZ = variance.y(); - m_deltaR = 0; -} + m_x(globalPos.x() - offsetXY.x()), + m_y(globalPos.y() - offsetXY.y()), + m_z(globalPos.z()), + m_r(std::sqrt(m_x * m_x + m_y * m_y)), + m_varianceR(variance.x()), + m_varianceZ(variance.y()), + m_sp(sp) +{} + ///////////////////////////////////////////////////////////////////////////////// // Copy constructor diff --git a/Core/include/Acts/Seeding/SeedFilter.ipp b/Core/include/Acts/Seeding/SeedFilter.ipp index 73ecf8b6d62..87ad32dc514 100644 --- a/Core/include/Acts/Seeding/SeedFilter.ipp +++ b/Core/include/Acts/Seeding/SeedFilter.ipp @@ -85,8 +85,8 @@ void SeedFilter::filterSeeds_2SpFixed(std::vectordeltaR() - : topSpVec[topSPIndex]->radius(); + ? spacePointInfo[topSpVec[topSPIndex]->index()].deltaR + : topSpVec[topSPIndex]->radius(); float impact = impactParametersVec[topSPIndex]; float weight = -(impact * m_cfg.impactWeightFactor); @@ -99,8 +99,8 @@ void SeedFilter::filterSeeds_2SpFixed(std::vectordeltaR() - : topSpVec[compatibleTopSPIndex]->radius(); + ? spacePointInfo[topSpVec[compatibleTopSPIndex]->index()].deltaR + : topSpVec[compatibleTopSPIndex]->radius(); // curvature difference within limits? if (invHelixDiameterVec[compatibleTopSPIndex] < lowerLimitCurv) { diff --git a/Core/include/Acts/Seeding/SeedFinder.ipp b/Core/include/Acts/Seeding/SeedFinder.ipp index eeaa231957d..81ea6e6b234 100644 --- a/Core/include/Acts/Seeding/SeedFinder.ipp +++ b/Core/include/Acts/Seeding/SeedFinder.ipp @@ -309,10 +309,10 @@ void SeedFinder::filterCandidates( state.linCircleBottom.reserve(numBottomSP); state.linCircleTop.reserve(numTopSP); - auto sorted_bottoms = transformCoordinates(state.compatBottomSP, spM, true, + auto sorted_bottoms = transformCoordinates(state.spacePointInfo, state.compatBottomSP, spM, true, state.linCircleBottom); auto sorted_tops = - transformCoordinates(state.compatTopSP, spM, false, state.linCircleTop); + transformCoordinates(state.spacePointInfo, state.compatTopSP, spM, false, state.linCircleTop); // Reserve enough space, in case current capacity is too little state.topSpVec.reserve(numTopSP); diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index 4d45a39e104..29d4a0a4cff 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -280,9 +280,10 @@ void SeedFinderOrthogonal::filterCandidates( std::vector linCircleTop; linCircleTop.reserve(top.size()); + std::vector spacePointInfo; auto sorted_bottoms = - transformCoordinates(bottom, middle, true, linCircleBottom); - auto sorted_tops = transformCoordinates(top, middle, false, linCircleTop); + transformCoordinates(spacePointInfo, bottom, middle, true, linCircleBottom); + auto sorted_tops = transformCoordinates(spacePointInfo, top, middle, false, linCircleTop); std::vector tanLM; std::vector tanMT; diff --git a/Core/include/Acts/Seeding/SeedFinderUtils.hpp b/Core/include/Acts/Seeding/SeedFinderUtils.hpp index f134ca98e84..ead9bc57bc1 100644 --- a/Core/include/Acts/Seeding/SeedFinderUtils.hpp +++ b/Core/include/Acts/Seeding/SeedFinderUtils.hpp @@ -58,12 +58,13 @@ LinCircle transformCoordinates(const external_spacepoint_t& sp, /// @returns Vector of sorted indexes for the vectors (vec and linCircleVec) template std::vector transformCoordinates( + std::vector& spacePointInfo, std::vector*>& vec, const InternalSpacePoint& spM, bool bottom, std::vector& linCircleVec); template -std::vector transformCoordinates( +std::vector transformCoordinates(std::vector& spacePointInfo, std::vector& vec, const external_spacepoint_t& spM, bool bottom, std::vector& linCircleVec, callable_t&& extractFunction); diff --git a/Core/include/Acts/Seeding/SeedFinderUtils.ipp b/Core/include/Acts/Seeding/SeedFinderUtils.ipp index cd1aa71be67..0b9c54db540 100644 --- a/Core/include/Acts/Seeding/SeedFinderUtils.ipp +++ b/Core/include/Acts/Seeding/SeedFinderUtils.ipp @@ -1,3 +1,4 @@ +// -*- C++ -*- // This file is part of the Acts project. // // Copyright (C) 2019 CERN for the benefit of the Acts project @@ -60,7 +61,7 @@ inline LinCircle transformCoordinates(const external_spacepoint_t& sp, } template -inline std::vector transformCoordinates( +inline std::vector transformCoordinates(std::vector& spacePointInfo, std::vector*>& vec, const InternalSpacePoint& spM, bool bottom, std::vector& linCircleVec) { @@ -72,12 +73,12 @@ inline std::vector transformCoordinates( return output; }; - return transformCoordinates>( + return transformCoordinates>(spacePointInfo, vec, spM, bottom, linCircleVec, extractFunction); } template -inline std::vector transformCoordinates( +inline std::vector transformCoordinates(std::vector& spacePointInfo, std::vector& vec, const external_spacepoint_t& spM, bool bottom, std::vector& linCircleVec, callable_t&& extractFunction) { @@ -90,8 +91,8 @@ inline std::vector transformCoordinates( float cosPhiM = xM / rM; float sinPhiM = yM / rM; - for (auto sp : vec) { - auto [xSP, ySP, zSP, rSP, varianceRSP, varianceZSP] = extractFunction(*sp); + for (const auto* sp : vec) { + const auto [xSP, ySP, zSP, rSP, varianceRSP, varianceZSP] = extractFunction(*sp); float deltaX = xSP - xM; float deltaY = ySP - yM; @@ -134,7 +135,7 @@ inline std::vector transformCoordinates( l.r = sp->radius(); linCircleVec.push_back(l); - sp->setDeltaR(std::sqrt((x * x) + (y * y) + (deltaZ * deltaZ))); + spacePointInfo[sp->index()].deltaR = std::sqrt((x * x) + (y * y) + (deltaZ * deltaZ)); } // sort the SP in order of cotTheta std::sort( From 06c6c326929f8f55fc0f69bdd1cac3747c56fac2 Mon Sep 17 00:00:00 2001 From: Carlo Varni Date: Tue, 14 Mar 2023 15:19:53 +0100 Subject: [PATCH 03/14] Move to const candidates --- Core/include/Acts/Seeding/IExperimentCuts.hpp | 4 ++-- Core/include/Acts/Seeding/SeedFilter.hpp | 6 +++--- Core/include/Acts/Seeding/SeedFilter.ipp | 6 +++--- Core/include/Acts/Seeding/SeedFinder.hpp | 2 +- Core/include/Acts/Seeding/SeedFinderOrthogonal.hpp | 2 +- Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp | 4 ++-- Core/include/Acts/Seeding/SeedFinderUtils.hpp | 4 ++-- Core/include/Acts/Seeding/SeedFinderUtils.ipp | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Core/include/Acts/Seeding/IExperimentCuts.hpp b/Core/include/Acts/Seeding/IExperimentCuts.hpp index d1e1ecd57e3..be03c6bd810 100644 --- a/Core/include/Acts/Seeding/IExperimentCuts.hpp +++ b/Core/include/Acts/Seeding/IExperimentCuts.hpp @@ -46,9 +46,9 @@ class IExperimentCuts { /// space point in a std::tuple format /// @return vector of seed candidates that pass the cut virtual std::vector>::value_type> + const InternalSpacePoint>::value_type> cutPerMiddleSP(std::vector>::value_type> + const InternalSpacePoint>::value_type> seedCandidates) const = 0; }; } // namespace Acts diff --git a/Core/include/Acts/Seeding/SeedFilter.hpp b/Core/include/Acts/Seeding/SeedFilter.hpp index c6d65b1552d..70ccf60ab62 100644 --- a/Core/include/Acts/Seeding/SeedFilter.hpp +++ b/Core/include/Acts/Seeding/SeedFilter.hpp @@ -66,7 +66,7 @@ class SeedFilter { const std::vector& invHelixDiameterVec, const std::vector& impactParametersVec, SeedFilterState& seedFilterState, - CandidatesForMiddleSp>& + CandidatesForMiddleSp>& candidates_collector) const; /// Filter seeds once all seeds for one middle space point have been created @@ -75,7 +75,7 @@ class SeedFilter { /// @param outIt Output iterator for the seeds /// for all seeds with the same middle space point virtual void filterSeeds_1SpFixed(std::vector& spacePointInfo, - CandidatesForMiddleSp>& + CandidatesForMiddleSp>& candidates_collector, std::size_t& numQualitySeeds, std::back_insert_iterator>> outIt) @@ -88,7 +88,7 @@ class SeedFilter { /// for all seeds with the same middle space point virtual void filterSeeds_1SpFixed(std::vector& spacePointInfo, std::vector>::value_type>& candidates, + const InternalSpacePoint>::value_type>& candidates, std::size_t& numQualitySeeds, std::back_insert_iterator>> outIt) const; diff --git a/Core/include/Acts/Seeding/SeedFilter.ipp b/Core/include/Acts/Seeding/SeedFilter.ipp index 87ad32dc514..dae5c478091 100644 --- a/Core/include/Acts/Seeding/SeedFilter.ipp +++ b/Core/include/Acts/Seeding/SeedFilter.ipp @@ -34,7 +34,7 @@ void SeedFilter::filterSeeds_2SpFixed(std::vector& invHelixDiameterVec, const std::vector& impactParametersVec, SeedFilterState& seedFilterState, - CandidatesForMiddleSp>& + CandidatesForMiddleSp>& candidates_collector) const { // seed confirmation SeedConfirmationRangeConfig seedConfRange; @@ -238,7 +238,7 @@ void SeedFilter::filterSeeds_2SpFixed(std::vector void SeedFilter::filterSeeds_1SpFixed(std::vector& spacePointInfo, - CandidatesForMiddleSp>& + CandidatesForMiddleSp>& candidates_collector, std::size_t& numQualitySeeds, std::back_insert_iterator>> outIt) @@ -253,7 +253,7 @@ void SeedFilter::filterSeeds_1SpFixed(std::vector void SeedFilter::filterSeeds_1SpFixed(std::vector& spacePointInfo, std::vector>::value_type>& candidates, + const InternalSpacePoint>::value_type>& candidates, std::size_t& numQualitySeeds, std::back_insert_iterator>> outIt) const { diff --git a/Core/include/Acts/Seeding/SeedFinder.hpp b/Core/include/Acts/Seeding/SeedFinder.hpp index 3e0a9fc9cfb..22ede894b9f 100644 --- a/Core/include/Acts/Seeding/SeedFinder.hpp +++ b/Core/include/Acts/Seeding/SeedFinder.hpp @@ -61,7 +61,7 @@ class SeedFinder { std::vector ptVec; // managing seed candidates for SpM - CandidatesForMiddleSp> + CandidatesForMiddleSp> candidates_collector; // managing doublet candidates diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.hpp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.hpp index 478186311b8..f09f2d45776 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.hpp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.hpp @@ -216,7 +216,7 @@ class SeedFinderOrthogonal { const SeedFinderOptions &options, internal_sp_t &middle, std::vector &bottom, std::vector &top, SeedFilterState seedFilterState, - CandidatesForMiddleSp> + CandidatesForMiddleSp> &candidates_collector) const; /** diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index 29d4a0a4cff..823154beb95 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -244,7 +244,7 @@ void SeedFinderOrthogonal::filterCandidates( const SeedFinderOptions &options, internal_sp_t &middle, std::vector &bottom, std::vector &top, SeedFilterState seedFilterState, - CandidatesForMiddleSp> + CandidatesForMiddleSp> &candidates_collector) const { float rM = middle.radius(); float varianceRM = middle.varianceR(); @@ -473,7 +473,7 @@ void SeedFinderOrthogonal::processFromMiddleSP( std::size_t max_num_seeds_per_spm = m_config.seedFilter->getSeedFilterConfig().maxSeedsPerSpMConf; - CandidatesForMiddleSp> + CandidatesForMiddleSp> candidates_collector; candidates_collector.setMaxElements(max_num_seeds_per_spm, max_num_quality_seeds_per_spm); diff --git a/Core/include/Acts/Seeding/SeedFinderUtils.hpp b/Core/include/Acts/Seeding/SeedFinderUtils.hpp index ead9bc57bc1..6425616f3e1 100644 --- a/Core/include/Acts/Seeding/SeedFinderUtils.hpp +++ b/Core/include/Acts/Seeding/SeedFinderUtils.hpp @@ -59,13 +59,13 @@ LinCircle transformCoordinates(const external_spacepoint_t& sp, template std::vector transformCoordinates( std::vector& spacePointInfo, - std::vector*>& vec, + const std::vector*>& vec, const InternalSpacePoint& spM, bool bottom, std::vector& linCircleVec); template std::vector transformCoordinates(std::vector& spacePointInfo, - std::vector& vec, const external_spacepoint_t& spM, + const std::vector& vec, const external_spacepoint_t& spM, bool bottom, std::vector& linCircleVec, callable_t&& extractFunction); diff --git a/Core/include/Acts/Seeding/SeedFinderUtils.ipp b/Core/include/Acts/Seeding/SeedFinderUtils.ipp index 0b9c54db540..89d7dd79bb4 100644 --- a/Core/include/Acts/Seeding/SeedFinderUtils.ipp +++ b/Core/include/Acts/Seeding/SeedFinderUtils.ipp @@ -62,7 +62,7 @@ inline LinCircle transformCoordinates(const external_spacepoint_t& sp, template inline std::vector transformCoordinates(std::vector& spacePointInfo, - std::vector*>& vec, + const std::vector*>& vec, const InternalSpacePoint& spM, bool bottom, std::vector& linCircleVec) { auto extractFunction = @@ -79,7 +79,7 @@ inline std::vector transformCoordinates(std::vector inline std::vector transformCoordinates(std::vector& spacePointInfo, - std::vector& vec, const external_spacepoint_t& spM, + const std::vector& vec, const external_spacepoint_t& spM, bool bottom, std::vector& linCircleVec, callable_t&& extractFunction) { std::vector indexes(vec.size()); From 49079fd82f5294e461981b0293effa2b75109479 Mon Sep 17 00:00:00 2001 From: Carlo Varni Date: Tue, 14 Mar 2023 15:26:36 +0100 Subject: [PATCH 04/14] other changes to constness --- Core/include/Acts/Seeding/SeedFilter.hpp | 6 +++--- Core/include/Acts/Seeding/SeedFilter.ipp | 6 +++--- Core/include/Acts/Seeding/SeedFinder.hpp | 4 ++-- Core/include/Acts/Seeding/SeedFinder.ipp | 6 +++--- Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Core/include/Acts/Seeding/SeedFilter.hpp b/Core/include/Acts/Seeding/SeedFilter.hpp index 70ccf60ab62..ca4c99ebfc2 100644 --- a/Core/include/Acts/Seeding/SeedFilter.hpp +++ b/Core/include/Acts/Seeding/SeedFilter.hpp @@ -60,9 +60,9 @@ class SeedFilter { /// @param seedFilterState holds quantities used in seed filter /// @param candidates_collector container for the seed candidates virtual void filterSeeds_2SpFixed(std::vector& spacePointInfo, - InternalSpacePoint& bottomSP, - InternalSpacePoint& middleSP, - std::vector*>& topSpVec, + const InternalSpacePoint& bottomSP, + const InternalSpacePoint& middleSP, + const std::vector*>& topSpVec, const std::vector& invHelixDiameterVec, const std::vector& impactParametersVec, SeedFilterState& seedFilterState, diff --git a/Core/include/Acts/Seeding/SeedFilter.ipp b/Core/include/Acts/Seeding/SeedFilter.ipp index dae5c478091..48caef00e67 100644 --- a/Core/include/Acts/Seeding/SeedFilter.ipp +++ b/Core/include/Acts/Seeding/SeedFilter.ipp @@ -28,9 +28,9 @@ SeedFilter::SeedFilter( // return vector must contain weight of each seed template void SeedFilter::filterSeeds_2SpFixed(std::vector& spacePointInfo, - InternalSpacePoint& bottomSP, - InternalSpacePoint& middleSP, - std::vector*>& topSpVec, + const InternalSpacePoint& bottomSP, + const InternalSpacePoint& middleSP, + const std::vector*>& topSpVec, const std::vector& invHelixDiameterVec, const std::vector& impactParametersVec, SeedFilterState& seedFilterState, diff --git a/Core/include/Acts/Seeding/SeedFinder.hpp b/Core/include/Acts/Seeding/SeedFinder.hpp index 22ede894b9f..f88d1e7ca46 100644 --- a/Core/include/Acts/Seeding/SeedFinder.hpp +++ b/Core/include/Acts/Seeding/SeedFinder.hpp @@ -54,7 +54,7 @@ class SeedFinder { std::vector linCircleTop; // create vectors here to avoid reallocation in each loop - std::vector*> topSpVec; + std::vector*> topSpVec; std::vector curvatures; std::vector impactParameters; std::vector etaVec; @@ -137,7 +137,7 @@ class SeedFinder { template void getCompatibleDoublets( const Acts::SeedFinderOptions& options, - Acts::SpacePointGrid& grid, + const Acts::SpacePointGrid& grid, boost::container::small_vector, 9>& otherSPs, const InternalSpacePoint& mediumSP, diff --git a/Core/include/Acts/Seeding/SeedFinder.ipp b/Core/include/Acts/Seeding/SeedFinder.ipp index 81ea6e6b234..972716862bd 100644 --- a/Core/include/Acts/Seeding/SeedFinder.ipp +++ b/Core/include/Acts/Seeding/SeedFinder.ipp @@ -171,7 +171,7 @@ template template void SeedFinder::getCompatibleDoublets( const Acts::SeedFinderOptions& options, - Acts::SpacePointGrid& grid, + const Acts::SpacePointGrid& grid, boost::container::small_vector, 9>& otherSPsNeighbours, const InternalSpacePoint& mediumSP, @@ -189,7 +189,7 @@ void SeedFinder::getCompatibleDoublets( const float ratio_yM_rM = yM / rM; for (auto& otherSPCol : otherSPsNeighbours) { - auto& otherSPs = grid.at(otherSPCol.index); + const auto& otherSPs = grid.at(otherSPCol.index); if (otherSPs.size() == 0) { continue; } @@ -200,7 +200,7 @@ void SeedFinder::getCompatibleDoublets( bool found = false; for (; min_itr != otherSPs.end(); ++min_itr) { - auto& otherSP = *min_itr; + const auto& otherSP = *min_itr; const float rO = otherSP->radius(); float deltaR = sign * (rO - rM); diff --git a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp index 823154beb95..84f720e0bec 100644 --- a/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp +++ b/Core/include/Acts/Seeding/SeedFinderOrthogonal.ipp @@ -268,7 +268,7 @@ void SeedFinderOrthogonal::filterCandidates( } } - std::vector top_valid; + std::vector top_valid; std::vector curvatures; std::vector impactParameters; From 78b67f6cf9a8c706c59f1aa990798a6dfbf6f214 Mon Sep 17 00:00:00 2001 From: Carlo Varni Date: Tue, 14 Mar 2023 15:32:19 +0100 Subject: [PATCH 05/14] seeding runs on const inputs --- Core/include/Acts/Seeding/Neighbour.hpp | 8 ++++---- Core/include/Acts/Seeding/SeedFinder.hpp | 6 +++--- Core/include/Acts/Seeding/SeedFinder.ipp | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Core/include/Acts/Seeding/Neighbour.hpp b/Core/include/Acts/Seeding/Neighbour.hpp index 669a417a29f..47e4e63f7da 100644 --- a/Core/include/Acts/Seeding/Neighbour.hpp +++ b/Core/include/Acts/Seeding/Neighbour.hpp @@ -43,24 +43,24 @@ struct Neighbour { /// @param grid The grid containing the space points /// @param idx The global index of the bin in the grid /// @param lowerBound The lower bound of the allowed space point - Neighbour(Acts::SpacePointGrid& grid, std::size_t idx, + Neighbour(const Acts::SpacePointGrid& grid, std::size_t idx, const float lowerBound); /// The global bin index on the grid std::size_t index; /// The iterator containing the position of the first space point in the valid /// radius range - typename Acts::SpacePointGrid::value_type::iterator + typename Acts::SpacePointGrid::value_type::const_iterator itr; }; template Neighbour::Neighbour( - Acts::SpacePointGrid& grid, std::size_t idx, + const Acts::SpacePointGrid& grid, std::size_t idx, const float lowerBound) : index(idx) { /// Get the space points in this specific global bin - auto& collection = grid.at(idx); + const auto& collection = grid.at(idx); /// If there are no elements in the bin, we simply set the iterator to begin() /// and return. In this case begin() == end() so we run on nothing if (collection.size() == 0) { diff --git a/Core/include/Acts/Seeding/SeedFinder.hpp b/Core/include/Acts/Seeding/SeedFinder.hpp index f88d1e7ca46..64b53fec4d3 100644 --- a/Core/include/Acts/Seeding/SeedFinder.hpp +++ b/Core/include/Acts/Seeding/SeedFinder.hpp @@ -101,7 +101,7 @@ class SeedFinder { template