From f83dc94daf5be921482ddf71fc9fda242d019bc4 Mon Sep 17 00:00:00 2001 From: cvarni Date: Mon, 7 Oct 2024 12:36:43 +0200 Subject: [PATCH] Do not insert space points if not inside grid boundaries --- .../detail/CylindricalSpacePointGrid.hpp | 19 +++++++++++++++++++ .../detail/CylindricalSpacePointGrid.ipp | 15 +++++++++++---- .../TrackFinding/src/SeedingAlgorithm.cpp | 4 ++-- Examples/Python/python/acts/examples/itk.py | 4 ++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp index 42d60158dd0..1621c1a948b 100644 --- a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp +++ b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.hpp @@ -78,6 +78,7 @@ struct CylindricalSpacePointGridConfig { "Repeated conversion to internal units for " "CylindricalSpacePointGridConfig"); } + using namespace Acts::UnitLiterals; CylindricalSpacePointGridConfig config = *this; config.isInInternalUnits = true; @@ -88,6 +89,24 @@ struct CylindricalSpacePointGridConfig { config.zMin /= 1_mm; config.deltaRMax /= 1_mm; + if (phiMin < -M_PI || phiMax > M_PI) { + throw std::runtime_error( + "CylindricalSpacePointGridConfig: phiMin and/or phiMax are outside " + "the allowed phi range, defined as [-M_PI, M_PI]"); + } + if (phiMin > phiMax) { + throw std::runtime_error( + "CylindricalSpacePointGridConfig: phiMin is bigger then phiMax"); + } + if (rMin > rMax) { + throw std::runtime_error( + "CylindricalSpacePointGridConfig: rMin is bigger then rMax"); + } + if (zMin > zMax) { + throw std::runtime_error( + "CylindricalSpacePointGridConfig: zMin is bigger than zMax"); + } + return config; } }; diff --git a/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp b/Core/include/Acts/Seeding/detail/CylindricalSpacePointGrid.ipp index 5d8c886f980..82a8c2b3ab0 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 @@ -167,9 +168,11 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid( // Space points are assumed to be ALREADY CORRECTED for beamspot position // phi, z and r space point selection comes naturally from the - // grid axis definition. No need to explicitly cut on those values. + // grid axis definition. Calling `isInside` will let us know if we are + // inside the grid range. // If a space point is outside the validity range of these quantities - // it goes in an over- or under-flow bin. + // it goes in an over- or under-flow bin. We want to avoid to consider those + // and skip some computations. // Additional cuts can be applied by customizing the space point selector // in the config object. @@ -189,8 +192,12 @@ void Acts::CylindricalSpacePointGridCreator::fillGrid( } // fill rbins into grid - std::size_t globIndex = grid.globalBinFromPosition( - Acts::Vector3{sp.phi(), sp.z(), sp.radius()}); + Acts::Vector3 position(sp.phi(), sp.z(), sp.radius()); + if (!grid.isInside(position)) { + continue; + } + + std::size_t globIndex = grid.globalBinFromPosition(position); auto& rbin = grid.at(globIndex); rbin.push_back(&sp); diff --git a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp index 14b89d848ca..16ad38dc02c 100644 --- a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp @@ -274,8 +274,8 @@ ActsExamples::ProcessCode ActsExamples::SeedingAlgorithm::execute( /// variable middle SP radial region of interest const Acts::Range1D rMiddleSPRange( - minRange + m_cfg.seedFinderConfig.deltaRMiddleMinSPRange, - maxRange - m_cfg.seedFinderConfig.deltaRMiddleMaxSPRange); + std::floor(minRange/2)*2 + m_cfg.seedFinderConfig.deltaRMiddleMinSPRange, + std::floor(maxRange/2)*2 - m_cfg.seedFinderConfig.deltaRMiddleMaxSPRange); // run the seeding static thread_local std::vector seeds; diff --git a/Examples/Python/python/acts/examples/itk.py b/Examples/Python/python/acts/examples/itk.py index b9d92b04001..b8e2eba8796 100644 --- a/Examples/Python/python/acts/examples/itk.py +++ b/Examples/Python/python/acts/examples/itk.py @@ -372,8 +372,8 @@ def itkSeedingAlgConfig( ) zOriginWeightFactor = 1 compatSeedWeight = 100 - phiMin = 0 - phiMax = 2 * math.pi + phiMin = -math.pi + phiMax = math.pi phiBinDeflectionCoverage = 3 numPhiNeighbors = 1 maxPhiBins = 200