diff --git a/Core/include/Acts/Seeding/SeedFinder.hpp b/Core/include/Acts/Seeding/SeedFinder.hpp index 254b500ad01..06a804f8b48 100644 --- a/Core/include/Acts/Seeding/SeedFinder.hpp +++ b/Core/include/Acts/Seeding/SeedFinder.hpp @@ -31,13 +31,17 @@ namespace Acts { -template -concept GridBinCollection = std::ranges::random_access_range && +template +concept GridBinCollection = + std::ranges::random_access_range && std::same_as; -template -concept CollectionStoresSeedsTo = std::ranges::output_range>; - +template +concept CollectionStoresSeedsTo = requires(Coll coll, external_t sp) { + Acts::detail::pushBackOrInsertAtEnd(coll, + Acts::Seed(sp, sp, sp)); +}; + enum class SpacePointCandidateType : short { eBottom, eTop }; enum class DetectorMeasurementInfo : short { eDefault, eDetailed }; diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp index d4fa9e294a5..9c350dbf816 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp @@ -1,3 +1,4 @@ +// -*- C++ -*- // This file is part of the ACTS project. // // Copyright (C) 2016 CERN for the benefit of the ACTS project diff --git a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/SeedingAlgorithmHashing.hpp b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/SeedingAlgorithmHashing.hpp index 78a0ef2ae89..abe98737428 100644 --- a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/SeedingAlgorithmHashing.hpp +++ b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/SeedingAlgorithmHashing.hpp @@ -110,6 +110,12 @@ class SeedingAlgorithmHashing final : public IAlgorithm { // Connect custom selections on the space points or to the doublet // compatibility bool useExtraCuts = false; + + float deltaRMiddleMinSPRange = 10. * Acts::UnitConstants::mm; + float deltaRMiddleMaxSPRange = 10. * Acts::UnitConstants::mm; + + /// Order of z bins to loop over when searching for SPs + std::vector zBinsCustomLooping = {}; }; /// Construct the seeding algorithm. diff --git a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithmHashing.cpp b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithmHashing.cpp index c722a9e5a2b..6fffd0531fb 100644 --- a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithmHashing.cpp +++ b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithmHashing.cpp @@ -77,22 +77,10 @@ ActsExamples::SeedingAlgorithmHashing::SeedingAlgorithmHashing( m_outputSeeds.initialize(m_cfg.outputSeeds); m_outputBuckets.initialize(m_cfg.outputBuckets); - if (m_cfg.gridConfig.rMax != m_cfg.seedFinderConfig.rMax && - m_cfg.allowSeparateRMax == false) { - throw std::invalid_argument( - "Inconsistent config rMax: using different values in gridConfig and " - "seedFinderConfig. If values are intentional set allowSeparateRMax to " - "true"); - } - if (m_cfg.seedFilterConfig.deltaRMin != m_cfg.seedFinderConfig.deltaRMin) { throw std::invalid_argument("Inconsistent config deltaRMin"); } - if (m_cfg.gridConfig.deltaRMax != m_cfg.seedFinderConfig.deltaRMax) { - throw std::invalid_argument("Inconsistent config deltaRMax"); - } - static_assert( std::numeric_limits< decltype(m_cfg.seedFinderConfig.deltaRMaxTopSP)>::has_quiet_NaN, @@ -114,7 +102,7 @@ ActsExamples::SeedingAlgorithmHashing::SeedingAlgorithmHashing( "Value of deltaRMinBottomSP must support NaN values"); if (std::isnan(m_cfg.seedFinderConfig.deltaRMaxTopSP)) { - m_cfg.seedFinderConfig.deltaRMaxTopSP = m_cfg.seedFinderConfig.deltaRMax; + m_cfg.seedFinderConfig.deltaRMaxTopSP = m_cfg.gridConfig.deltaRMax; } if (std::isnan(m_cfg.seedFinderConfig.deltaRMinTopSP)) { @@ -122,21 +110,13 @@ ActsExamples::SeedingAlgorithmHashing::SeedingAlgorithmHashing( } if (std::isnan(m_cfg.seedFinderConfig.deltaRMaxBottomSP)) { - m_cfg.seedFinderConfig.deltaRMaxBottomSP = m_cfg.seedFinderConfig.deltaRMax; + m_cfg.seedFinderConfig.deltaRMaxBottomSP = m_cfg.gridConfig.deltaRMax; } if (std::isnan(m_cfg.seedFinderConfig.deltaRMinBottomSP)) { m_cfg.seedFinderConfig.deltaRMinBottomSP = m_cfg.seedFinderConfig.deltaRMin; } - if (m_cfg.gridConfig.zMin != m_cfg.seedFinderConfig.zMin) { - throw std::invalid_argument("Inconsistent config zMin"); - } - - if (m_cfg.gridConfig.zMax != m_cfg.seedFinderConfig.zMax) { - throw std::invalid_argument("Inconsistent config zMax"); - } - if (m_cfg.seedFilterConfig.maxSeedsPerSpM != m_cfg.seedFinderConfig.maxSeedsPerSpM) { throw std::invalid_argument("Inconsistent config maxSeedsPerSpM"); @@ -273,10 +253,12 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithmHashing::execute( Acts::CylindricalSpacePointGridCreator::createGrid( m_cfg.gridConfig, m_cfg.gridOptions); Acts::CylindricalSpacePointGridCreator::fillGrid( - m_cfg.seedFinderConfig, m_cfg.seedFinderOptions, grid, + m_cfg.seedFinderConfig, grid, spContainer.begin(), spContainer.end()); // Compute radius Range + auto localSeedFinderOptions = m_cfg.seedFinderOptions; + // we rely on the fact the grid is storing the proxies // with a sorting in the radius float minRange = std::numeric_limits::max(); @@ -292,7 +274,7 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithmHashing::execute( } std::array, 3ul> navigation; - navigation[1ul] = m_cfg.seedFinderConfig.zBinsCustomLooping; + navigation[1ul] = m_cfg.zBinsCustomLooping; // groups spacepoints auto spacePointsGrouping = Acts::CylindricalBinnedGroup( @@ -300,16 +282,17 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithmHashing::execute( std::move(navigation)); /// variable middle SP radial region of interest - const Acts::Range1D rMiddleSPRange( - minRange + m_cfg.seedFinderConfig.deltaRMiddleMinSPRange, - maxRange - m_cfg.seedFinderConfig.deltaRMiddleMaxSPRange); - + localSeedFinderOptions.rMinMiddle = std::floor(minRange / 2) * 2 + + m_cfg.deltaRMiddleMinSPRange; + localSeedFinderOptions.rMaxMiddle = std::floor(maxRange / 2) * 2 - + m_cfg.deltaRMiddleMaxSPRange; + // this creates seeds of proxy, we need to convert it to seed of space // points for (const auto [bottom, middle, top] : spacePointsGrouping) { m_seedFinder.createSeedsForGroup( - m_cfg.seedFinderOptions, state, spacePointsGrouping.grid(), - seedsSetForBucket, bottom, middle, top, rMiddleSPRange); + localSeedFinderOptions, state, spacePointsGrouping.grid(), + seedsSetForBucket, bottom, middle, top); } // proxies die when the Acts::SpacePointContainer dies, so we need to diff --git a/Examples/Python/python/acts/examples/reconstruction.py b/Examples/Python/python/acts/examples/reconstruction.py index 11b71676a9e..01b796ac9d4 100644 --- a/Examples/Python/python/acts/examples/reconstruction.py +++ b/Examples/Python/python/acts/examples/reconstruction.py @@ -223,8 +223,13 @@ HashingAlgorithmConfigArg = namedtuple( "HashingAlgorithmConfig", - ["bucketSize", "zBins", "phiBins"], - defaults=[None] * 3, + ["bucketSize", + "zBins", + "phiBins", + "deltaRMiddleMinSPRange", + "deltaRMiddleMaxSPRange", + "zBinsCustomLooping"], + defaults=[None] * 6, ) @@ -690,6 +695,7 @@ def addStandardSeeding( if seedFinderConfigArg.deltaRBottomSP[1] is None else seedFinderConfigArg.deltaRBottomSP[1] ), + middleRangeStrategy=seedFinderConfigArg.middleRangeStrategy, collisionRegionMin=seedFinderConfigArg.collisionRegion[0], collisionRegionMax=seedFinderConfigArg.collisionRegion[1], maxSeedsPerSpM=seedFinderConfigArg.maxSeedsPerSpM, @@ -918,10 +924,7 @@ def addHashingSeeding( # Same configuration than the standard seeding seedFinderConfig = acts.SeedFinderConfig( **acts.examples.defaultKWArgs( - rMin=seedFinderConfigArg.r[0], - rMax=seedFinderConfigArg.r[1], deltaRMin=seedFinderConfigArg.deltaR[0], - deltaRMax=seedFinderConfigArg.deltaR[1], deltaRMinTopSP=( seedFinderConfigArg.deltaR[0] if seedFinderConfigArg.deltaRTopSP[0] is None @@ -942,12 +945,9 @@ def addHashingSeeding( if seedFinderConfigArg.deltaRBottomSP[1] is None else seedFinderConfigArg.deltaRBottomSP[1] ), - deltaRMiddleMinSPRange=seedFinderConfigArg.deltaRMiddleSPRange[0], - deltaRMiddleMaxSPRange=seedFinderConfigArg.deltaRMiddleSPRange[1], + middleRangeStrategy=seedFinderConfigArg.middleRangeStrategy, collisionRegionMin=seedFinderConfigArg.collisionRegion[0], collisionRegionMax=seedFinderConfigArg.collisionRegion[1], - zMin=seedFinderConfigArg.z[0], - zMax=seedFinderConfigArg.z[1], maxSeedsPerSpM=seedFinderConfigArg.maxSeedsPerSpM, cotThetaMax=seedFinderConfigArg.cotThetaMax, sigmaScattering=seedFinderConfigArg.sigmaScattering, @@ -958,10 +958,6 @@ def addHashingSeeding( deltaZMax=seedFinderConfigArg.deltaZMax, maxPtScattering=seedFinderConfigArg.maxPtScattering, zBinEdges=seedFinderConfigArg.zBinEdges, - zBinsCustomLooping=seedFinderConfigArg.zBinsCustomLooping, - rRangeMiddleSP=seedFinderConfigArg.rRangeMiddleSP, - useVariableMiddleSPRange=seedFinderConfigArg.useVariableMiddleSPRange, - binSizeR=seedFinderConfigArg.binSizeR, seedConfirmation=seedFinderConfigArg.seedConfirmation, centralSeedConfirmationRange=seedFinderConfigArg.centralSeedConfirmationRange, forwardSeedConfirmationRange=seedFinderConfigArg.forwardSeedConfirmationRange, @@ -1005,13 +1001,10 @@ def addHashingSeeding( gridConfig = acts.SpacePointGridConfig( **acts.examples.defaultKWArgs( minPt=seedFinderConfig.minPt, - rMax=( - seedFinderConfig.rMax - if spacePointGridConfigArg.rMax is None - else spacePointGridConfigArg.rMax - ), - zMax=seedFinderConfig.zMax, - zMin=seedFinderConfig.zMin, + rMin=spacePointGridConfigArg.r[0], + rMax=spacePointGridConfigArg.r[1], + zMin=spacePointGridConfigArg.z[0], + zMax=spacePointGridConfigArg.z[1], deltaRMax=( seedFinderConfig.deltaRMax if spacePointGridConfigArg.deltaRMax is None @@ -1046,6 +1039,9 @@ def addHashingSeeding( bucketSize=hashingAlgorithmConfigArg.bucketSize, zBins=hashingAlgorithmConfigArg.zBins, phiBins=hashingAlgorithmConfigArg.phiBins, + deltaRMiddleMinSPRange=hashingAlgorithmConfigArg.deltaRMiddleMinSPRange, + deltaRMiddleMaxSPRange=hashingAlgorithmConfigArg.deltaRMiddleMaxSPRange, + zBinsCustomLooping=hashingAlgorithmConfigArg.zBinsCustomLooping, ), ) diff --git a/Examples/Python/src/Hashing.cpp b/Examples/Python/src/Hashing.cpp index 57883557846..fb449720995 100644 --- a/Examples/Python/src/Hashing.cpp +++ b/Examples/Python/src/Hashing.cpp @@ -57,7 +57,8 @@ void addHashing(Context& ctx) { "SeedingAlgorithmHashing", inputSpacePoints, outputSeeds, outputBuckets, seedFilterConfig, seedFinderConfig, seedFinderOptions, gridConfig, gridOptions, allowSeparateRMax, zBinNeighborsTop, zBinNeighborsBottom, - numPhiNeighbors, hashingConfig, hashingTrainingConfig, useExtraCuts); + numPhiNeighbors, hashingConfig, hashingTrainingConfig, useExtraCuts, deltaRMiddleMinSPRange, + deltaRMiddleMaxSPRange, zBinsCustomLooping); } } // namespace Acts::Python