diff --git a/Core/include/Acts/Seeding/BinnedSPGroup.hpp b/Core/include/Acts/Seeding/BinnedSPGroup.hpp index 7fffa881b0e..f426da42b36 100644 --- a/Core/include/Acts/Seeding/BinnedSPGroup.hpp +++ b/Core/include/Acts/Seeding/BinnedSPGroup.hpp @@ -30,7 +30,7 @@ template class NeighborhoodIterator { public: using sp_it_t = typename std::vector>>::const_iterator; + InternalSpacePoint>>::const_iterator; NeighborhoodIterator() = delete; @@ -94,7 +94,7 @@ class NeighborhoodIterator { } } - const InternalSpacePoint* operator*() { + InternalSpacePoint* operator*() { return (*m_curIt).get(); } diff --git a/Core/include/Acts/Seeding/BinnedSPGroup.ipp b/Core/include/Acts/Seeding/BinnedSPGroup.ipp index 6246c99eca1..c7724c9af02 100644 --- a/Core/include/Acts/Seeding/BinnedSPGroup.ipp +++ b/Core/include/Acts/Seeding/BinnedSPGroup.ipp @@ -35,8 +35,8 @@ Acts::BinnedSPGroup::BinnedSPGroup( // create number of bins equal to number of millimeters rMax // (worst case minR: configured minR + 1mm) size_t numRBins = (config.rMax + config.beamPos.norm()); - std::vector>>> + std::vector< + std::vector>>> rBins(numRBins); for (spacepoint_iterator_t it = spBegin; it != spEnd; it++) { if (*it == nullptr) { @@ -58,9 +58,8 @@ Acts::BinnedSPGroup::BinnedSPGroup( continue; } - auto isp = - std::make_unique>( - sp, spPosition, config.beamPos, variance); + auto isp = std::make_unique>( + sp, spPosition, config.beamPos, variance); // calculate r-Bin index and protect against overflow (underflow not // possible) size_t rIndex = isp->radius(); @@ -75,8 +74,7 @@ Acts::BinnedSPGroup::BinnedSPGroup( for (auto& rbin : rBins) { for (auto& isp : rbin) { Acts::Vector2 spLocation(isp->phi(), isp->z()); - std::vector< - std::unique_ptr>>& + std::vector>>& bin = grid->atPosition(spLocation); bin.push_back(std::move(isp)); } diff --git a/Core/include/Acts/Seeding/InternalSeed.hpp b/Core/include/Acts/Seeding/InternalSeed.hpp index c22ee2e0ef3..28dd297400a 100644 --- a/Core/include/Acts/Seeding/InternalSeed.hpp +++ b/Core/include/Acts/Seeding/InternalSeed.hpp @@ -21,12 +21,12 @@ class InternalSeed { ///////////////////////////////////////////////////////////////////////////////// public: - InternalSeed(const InternalSpacePoint& s0, - const InternalSpacePoint& s1, - const InternalSpacePoint& s2, float z); + InternalSeed(InternalSpacePoint& s0, + InternalSpacePoint& s1, + InternalSpacePoint& s2, float z); InternalSeed& operator=(const InternalSeed& seed); - const std::array*, 3> sp; + const std::array*, 3> sp; float z() const { return m_z; } protected: @@ -49,9 +49,8 @@ inline InternalSeed& InternalSeed::operator=( template inline InternalSeed::InternalSeed( - const InternalSpacePoint& s0, - const InternalSpacePoint& s1, - const InternalSpacePoint& s2, float z) + InternalSpacePoint& s0, InternalSpacePoint& s1, + InternalSpacePoint& s2, float z) : sp({&s0, &s1, &s2}) { m_z = z; } diff --git a/Core/include/Acts/Seeding/InternalSpacePoint.hpp b/Core/include/Acts/Seeding/InternalSpacePoint.hpp index cb5ac8d0262..c7d980ee945 100644 --- a/Core/include/Acts/Seeding/InternalSpacePoint.hpp +++ b/Core/include/Acts/Seeding/InternalSpacePoint.hpp @@ -40,16 +40,32 @@ 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& quality() const { return m_quality; } + const float& cotTheta() const { return m_cotTheta; } + void setCotTheta(float cotTheta) { m_cotTheta = cotTheta; } + void setQuality(float quality) { + if (quality >= m_quality) { + m_quality = quality; + } + } const SpacePoint& sp() const { return m_sp; } protected: - 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 - float m_r; // radius in beam system coordinates - float m_varianceR; // - float m_varianceZ; // - const SpacePoint& m_sp; // external space point + 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 + float m_r; // radius in beam system coordinates + float m_varianceR; // + float m_varianceZ; // + float m_cotTheta = std::numeric_limits< + double>::quiet_NaN(); // 1/tanTheta estimated from central+this space + // point. Its evaluation requires that the space + // point is a candidate for triplet search. + 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 }; ///////////////////////////////////////////////////////////////////////////////// @@ -75,14 +91,6 @@ inline InternalSpacePoint::InternalSpacePoint( template inline InternalSpacePoint::InternalSpacePoint( - const InternalSpacePoint& sp) - : m_sp(sp.sp()) { - m_x = sp.m_x; - m_y = sp.m_y; - m_z = sp.m_z; - m_r = sp.m_r; - m_varianceR = sp.m_varianceR; - m_varianceZ = sp.m_varianceZ; -} + const InternalSpacePoint& sp) = default; } // end of namespace Acts diff --git a/Core/include/Acts/Seeding/SeedFilter.hpp b/Core/include/Acts/Seeding/SeedFilter.hpp index d9d1e927c8f..0b5761be138 100644 --- a/Core/include/Acts/Seeding/SeedFilter.hpp +++ b/Core/include/Acts/Seeding/SeedFilter.hpp @@ -42,9 +42,9 @@ class SeedFilter { /// @param zOrigin on the z axis as defined by bottom and middle space point /// @param outIt Output iterator for the seeds virtual void filterSeeds_2SpFixed( - const InternalSpacePoint& bottomSP, - const InternalSpacePoint& middleSP, - std::vector*>& topSpVec, + InternalSpacePoint& bottomSP, + InternalSpacePoint& middleSP, + std::vector*>& topSpVec, std::vector& invHelixDiameterVec, std::vector& impactParametersVec, float zOrigin, std::back_insert_iterator::SeedFilter( // return vector must contain weight of each seed template void SeedFilter::filterSeeds_2SpFixed( - const InternalSpacePoint& bottomSP, - const InternalSpacePoint& middleSP, - std::vector*>& topSpVec, + InternalSpacePoint& bottomSP, + InternalSpacePoint& middleSP, + std::vector*>& topSpVec, std::vector& invHelixDiameterVec, std::vector& impactParametersVec, float zOrigin, std::back_insert_iterator::filterSeeds_1SpFixed( // ordering by weight by filterSeeds_2SpFixed means these are the lowest // weight seeds for (; it < itBegin + maxSeeds; ++it) { + float bestSeedQuality = (*it).first; + + (*it).second->sp[0]->setQuality(bestSeedQuality); + (*it).second->sp[1]->setQuality(bestSeedQuality); + (*it).second->sp[2]->setQuality(bestSeedQuality); + outIt = Seed{ (*it).second->sp[0]->sp(), (*it).second->sp[1]->sp(), (*it).second->sp[2]->sp(), (*it).second->z()}; diff --git a/Core/include/Acts/Seeding/SeedFinderUtils.hpp b/Core/include/Acts/Seeding/SeedFinderUtils.hpp index 1e61cdaca09..a0fa62897e6 100644 --- a/Core/include/Acts/Seeding/SeedFinderUtils.hpp +++ b/Core/include/Acts/Seeding/SeedFinderUtils.hpp @@ -32,9 +32,9 @@ struct LinCircle { /// @param[in] spM The middle spacepoint to use. /// @param[in] bottom Should be true if sp is a bottom SP. template -LinCircle transformCoordinates( - const InternalSpacePoint& sp, - const InternalSpacePoint& spM, bool bottom); +LinCircle transformCoordinates(InternalSpacePoint& sp, + InternalSpacePoint& spM, + bool bottom); /// @brief Transform a vector of spacepoints to u-v space circles with respect /// to a given middle spacepoint. @@ -48,8 +48,8 @@ LinCircle transformCoordinates( /// @param[out] linCircleVec The output vector to write to. template void transformCoordinates( - const std::vector*>& vec, - const InternalSpacePoint& spM, bool bottom, + const std::vector*>& vec, + InternalSpacePoint& spM, bool bottom, bool enableCutsForSortedSP, std::vector& linCircleVec); } // namespace Acts diff --git a/Core/include/Acts/Seeding/SeedFinderUtils.ipp b/Core/include/Acts/Seeding/SeedFinderUtils.ipp index 18d1b09a125..63a27f02ca2 100644 --- a/Core/include/Acts/Seeding/SeedFinderUtils.ipp +++ b/Core/include/Acts/Seeding/SeedFinderUtils.ipp @@ -8,9 +8,9 @@ namespace Acts { template -LinCircle transformCoordinates( - const InternalSpacePoint& sp, - const InternalSpacePoint& spM, bool bottom) { +LinCircle transformCoordinates(InternalSpacePoint& sp, + InternalSpacePoint& spM, + bool bottom) { // The computation inside this function is exactly identical to that in the // vectorized version of this function, except that it operates on a single // spacepoint. Please see the other version of this function for more @@ -46,8 +46,8 @@ LinCircle transformCoordinates( template void transformCoordinates( - const std::vector*>& vec, - const InternalSpacePoint& spM, bool bottom, + const std::vector*>& vec, + InternalSpacePoint& spM, bool bottom, bool enableCutsForSortedSP, std::vector& linCircleVec) { float xM = spM.x(); float yM = spM.y(); @@ -93,6 +93,7 @@ void transformCoordinates( (cot_theta * cot_theta) * (varianceRM + sp->varianceR())) * iDeltaR2; linCircleVec.push_back(l); + sp->setCotTheta(cot_theta); } // sort the SP in order of cotTheta if (enableCutsForSortedSP) { diff --git a/Core/include/Acts/Seeding/Seedfinder.hpp b/Core/include/Acts/Seeding/Seedfinder.hpp index c300d2aa345..7c76e07399d 100644 --- a/Core/include/Acts/Seeding/Seedfinder.hpp +++ b/Core/include/Acts/Seeding/Seedfinder.hpp @@ -34,9 +34,8 @@ class Seedfinder { public: struct State { // bottom space point - std::vector*> - compatBottomSP; - std::vector*> compatTopSP; + std::vector*> compatBottomSP; + std::vector*> compatTopSP; // contains parameters required to calculate circle with linear equation // ...for bottom-middle std::vector linCircleBottom; @@ -44,7 +43,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; diff --git a/Core/include/Acts/Seeding/SpacePointGrid.hpp b/Core/include/Acts/Seeding/SpacePointGrid.hpp index e026a7fed49..dec2a665ca4 100644 --- a/Core/include/Acts/Seeding/SpacePointGrid.hpp +++ b/Core/include/Acts/Seeding/SpacePointGrid.hpp @@ -59,8 +59,7 @@ struct SpacePointGridConfig { template using SpacePointGrid = detail::Grid< - std::vector< - std::unique_ptr>>, + std::vector>>, detail::Axis, detail::Axis>; diff --git a/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding/Seedfinder.ipp b/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding/Seedfinder.ipp index 8c22b345a7d..3390fb17f84 100644 --- a/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding/Seedfinder.ipp +++ b/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding/Seedfinder.ipp @@ -66,11 +66,9 @@ Seedfinder::createSeedsForGroup( // Algorithm 0. Matrix Flattening //--------------------------------- - std::vector*> - middleSPvec; - std::vector*> - bottomSPvec; - std::vector*> topSPvec; + std::vector*> middleSPvec; + std::vector*> bottomSPvec; + std::vector*> topSPvec; // Get the size of spacepoints int nSpM(0); @@ -296,4 +294,4 @@ Seedfinder::createSeedsForGroup( ACTS_CUDA_ERROR_CHECK(cudaStreamDestroy(cuStream)); return outputVec; } -} // namespace Acts +} // namespace Acts \ No newline at end of file diff --git a/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding2/SeedFinder.ipp b/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding2/SeedFinder.ipp index 47167699a88..2e17aa11d14 100644 --- a/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding2/SeedFinder.ipp +++ b/Plugins/Cuda/include/Acts/Plugins/Cuda/Seeding2/SeedFinder.ipp @@ -81,18 +81,18 @@ SeedFinder::createSeedsForGroup( // Create more convenient vectors out of the space point containers. auto spVecMaker = [](sp_range_t spRange) { - std::vector*> result; + std::vector*> result; for (auto* sp : spRange) { result.push_back(sp); } return result; }; - std::vector*> - bottomSPVec(spVecMaker(bottomSPs)); - std::vector*> - middleSPVec(spVecMaker(middleSPs)); - std::vector*> topSPVec( + std::vector*> bottomSPVec( + spVecMaker(bottomSPs)); + std::vector*> middleSPVec( + spVecMaker(middleSPs)); + std::vector*> topSPVec( spVecMaker(topSPs)); // If either one of them is empty, we have nothing to find. @@ -193,12 +193,12 @@ SeedFinder::createSeedsForGroup( std::vector>>> seedsPerSPM; - const auto& middleSP = *(middleSPVec[middleIndex]); + auto& middleSP = *(middleSPVec[middleIndex]); for (const Details::Triplet& triplet : *triplet_itr) { assert(triplet.bottomIndex < bottomSPVec.size()); - const auto& bottomSP = *(bottomSPVec[triplet.bottomIndex]); + auto& bottomSP = *(bottomSPVec[triplet.bottomIndex]); assert(triplet.topIndex < topSPVec.size()); - const auto& topSP = *(topSPVec[triplet.topIndex]); + auto& topSP = *(topSPVec[triplet.topIndex]); seedsPerSPM.emplace_back(std::make_pair( triplet.weight, std::make_unique>( @@ -222,4 +222,4 @@ void SeedFinder::setLogger( } } // namespace Cuda -} // namespace Acts +} // namespace Acts \ No newline at end of file diff --git a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/Seedfinder.ipp b/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/Seedfinder.ipp index 96dece6be9e..31d345ff3d4 100644 --- a/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/Seedfinder.ipp +++ b/Plugins/Sycl/include/Acts/Plugins/Sycl/Seeding/Seedfinder.ipp @@ -84,37 +84,33 @@ Seedfinder::createSeedsForGroup( vecmem::vector deviceMiddleSPs(m_resource); vecmem::vector deviceTopSPs(m_resource); - std::vector*> - bottomSPvec; - std::vector*> - middleSPvec; - std::vector*> topSPvec; + std::vector*> bottomSPvec; + std::vector*> middleSPvec; + std::vector*> topSPvec; - for (const Acts::InternalSpacePoint* SP : bottomSPs) { + for (auto SP : bottomSPs) { bottomSPvec.push_back(SP); } deviceBottomSPs.reserve(bottomSPvec.size()); - for (const Acts::InternalSpacePoint* SP : - bottomSPvec) { + for (auto SP : bottomSPvec) { deviceBottomSPs.push_back({SP->x(), SP->y(), SP->z(), SP->radius(), SP->varianceR(), SP->varianceZ()}); } - for (const Acts::InternalSpacePoint* SP : middleSPs) { + for (auto SP : middleSPs) { middleSPvec.push_back(SP); } deviceMiddleSPs.reserve(middleSPvec.size()); - for (const Acts::InternalSpacePoint* SP : - middleSPvec) { + for (auto SP : middleSPvec) { deviceMiddleSPs.push_back({SP->x(), SP->y(), SP->z(), SP->radius(), SP->varianceR(), SP->varianceZ()}); } - for (const Acts::InternalSpacePoint* SP : topSPs) { + for (auto SP : topSPs) { topSPvec.push_back(SP); } deviceTopSPs.reserve(topSPvec.size()); - for (const Acts::InternalSpacePoint* SP : topSPvec) { + for (auto SP : topSPvec) { deviceTopSPs.push_back({SP->x(), SP->y(), SP->z(), SP->radius(), SP->varianceR(), SP->varianceZ()}); } @@ -149,4 +145,4 @@ Seedfinder::createSeedsForGroup( } return outputVec; } -} // namespace Acts::Sycl +} // namespace Acts::Sycl \ No newline at end of file