From 86713c025367a377466120e765d7f48c5993f648 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 17 Jun 2024 10:31:43 +0300 Subject: [PATCH 01/28] Adding telescope style seeding --- .../Acts/EventData/detail/TestSourceLink.hpp | 23 +- Core/include/Acts/Seeding/ISourceLinkGrid.hpp | 49 ++ Core/include/Acts/Seeding/PathSeeder.hpp | 212 ++++++++ Tests/UnitTests/Core/Seeding/CMakeLists.txt | 1 + .../UnitTests/Core/Seeding/PathSeederTest.cpp | 461 ++++++++++++++++++ .../SpacePointBuilderTests.cpp | 2 +- .../Core/TrackFitting/FitterTestsCommon.hpp | 2 +- .../UnitTests/Core/TrackFitting/Gx2fTests.cpp | 18 +- 8 files changed, 751 insertions(+), 17 deletions(-) create mode 100644 Core/include/Acts/Seeding/ISourceLinkGrid.hpp create mode 100644 Core/include/Acts/Seeding/PathSeeder.hpp create mode 100644 Tests/UnitTests/Core/Seeding/PathSeederTest.cpp diff --git a/Core/include/Acts/EventData/detail/TestSourceLink.hpp b/Core/include/Acts/EventData/detail/TestSourceLink.hpp index 41464682bde..906c64f3f40 100644 --- a/Core/include/Acts/EventData/detail/TestSourceLink.hpp +++ b/Core/include/Acts/EventData/detail/TestSourceLink.hpp @@ -8,6 +8,7 @@ #pragma once +#include "Acts/Detector/Detector.hpp" #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/Measurement.hpp" @@ -89,13 +90,23 @@ struct TestSourceLink final { constexpr std::size_t index() const { return sourceId; } struct SurfaceAccessor { - const Acts::TrackingGeometry& trackingGeometry; + const Acts::TrackingGeometry* trackingGeometry = nullptr; + const Acts::Experimental::Detector* detector = nullptr; - const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const { - const auto& testSourceLink = sourceLink.get(); - return trackingGeometry.findSurface(testSourceLink.m_geometryId); - } - }; + const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const { + const auto& testSourceLink = sourceLink.get(); + if (trackingGeometry) { + return trackingGeometry->findSurface(testSourceLink.m_geometryId); + } + else if (detector) { + return *detector->sensitiveHierarchyMap().find( + testSourceLink.m_geometryId); + } + else { + throw std::runtime_error("No tracking geometry or detector set"); + } + } + }; }; inline std::ostream& operator<<(std::ostream& os, diff --git a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp new file mode 100644 index 00000000000..2d2aad05a4c --- /dev/null +++ b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp @@ -0,0 +1,49 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/EventData/SourceLink.hpp" +#include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Definitions/Algebra.hpp" +#include "Acts/Utilities/detail/Axis.hpp" +#include "Acts/Utilities/Grid.hpp" + +namespace Acts { + +/// @brief Interface class for binning source links +/// into a lookup table -- a grid of source links +/// +/// @tparam axis_t Type of the axis +/// +template +class ISourceLinkGrid { + using slGrid = + Grid< + std::vector, + axis_t, + axis_t>; + + public: + /// @brief Virtual destructor + virtual ~ISourceLinkGrid() = default; + + /// @brief Interface function to sort + /// the source links into the grid + virtual void initialize( + const GeometryContext& gctx, + std::vector sourceLinks) = 0; + + /// @brief Interface function to get the + /// grid of source links for a + /// given geometry identifier + virtual slGrid getSourceLinkTable( + const GeometryIdentifier& geoId) const = 0; +}; + +} // namespace Acts diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp new file mode 100644 index 00000000000..52715b04ecc --- /dev/null +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -0,0 +1,212 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Seeding/ISourceLinkGrid.hpp" +#include "Acts/Surfaces/Surface.hpp" +#include "Acts/Utilities/Delegate.hpp" + +namespace Acts { + +/// @brief Seeding algorigthm that extracts +/// the IP parameters and sorts the source links +/// into possible track candidates +/// +/// @tparam axis_t Type of the axis to bin +/// the source links +/// +template +class PathSeeder { + public: + struct Seed { + ActsScalar ipP; + Vector3 ipDir; + Vector3 ipVertex; + std::vector sourceLinks; + }; + + using SourceLinkCalibrator = + Delegate; + + using PathWidthLookup = + Delegate( + const GeometryContext&, + const GeometryIdentifier&)>; + + using IntersectionLookup = + Delegate>( + const GeometryContext&, + const Vector3&, + const Vector3&, + const ActsScalar&)>; + + using TrackEstimator = + Delegate( + const GeometryContext&, + const Vector3&)>; + + /// @brief The nested configuration struct + struct Config { + /// Binned SourceLink provider + std::shared_ptr> sourceLinkGrid; + /// Parameters estimator + TrackEstimator trackEstimator; + /// Surface accessor + SourceLinkCalibrator sourceLinkCalibrator; + /// Intersection finder + IntersectionLookup intersectionFinder; + /// Path width provider + PathWidthLookup pathWidthProvider; + /// First layer extent + Extent firstLayerExtent; + /// Direction of the telescope extent + BinningValue orientation = binX; + }; + + /// @brief Constructor + PathSeeder(const Config& config) + : m_cfg(std::move(config)) {}; + + /// @brief Destructor + ~PathSeeder() = default; + + + /// @brief Extract the IP parameters and + /// sort the source links into the seeds + /// + /// @param gctx The geometry context + /// @param sourceLinks The source links to seed + /// + /// @return The vector of seeds + std::vector + getSeeds( + const GeometryContext& gctx, + const std::vector& sourceLinks) const { + // Sort the source links into the grid + m_cfg.sourceLinkGrid->initialize(gctx, sourceLinks); + + // Get plane of the telescope + // sensitive surfaces + BinningValue bin0, bin1; + if (m_cfg.orientation == binX) { + bin0 = binY; + bin1 = binZ; + } else if (m_cfg.orientation == binY) { + bin0 = binX; + bin1 = binZ; + } else { + bin0 = binX; + bin1 = binY; + } + + // Create the seeds + std::vector seeds; + for (const auto& sl : sourceLinks) { + Vector3 globalPos = m_cfg.sourceLinkCalibrator( + gctx, sl); + + // Check if the hit is in the + // first tracking layer + if (!m_cfg.firstLayerExtent.contains(globalPos)) { + continue; + } + + // Get the IP parameters + auto [ipP, ipVertex, ipDir, flDir] = + m_cfg.trackEstimator( + gctx, globalPos); + + // Intersect with the surfaces + std::vector> + intersections = + m_cfg.intersectionFinder( + gctx, globalPos, flDir, ipP); + + // Continue if no intersections + if (intersections.empty()) { + continue; + } + // Vector to store the source links + std::vector seedSourceLinks; + + // Store the IP parameters + Seed seed; + seed.ipP = ipP; + seed.ipDir = ipDir; + seed.ipVertex = ipVertex; + + // Store the pivot source link + seedSourceLinks.push_back(sl); + + // Iterate over the intersections + // and get the source links + // in the subsequent layers + for (auto& [geoId,refPoint] : intersections) { + // Get the path width + auto [pathWidth0, pathWidth1] = + m_cfg.pathWidthProvider( + gctx, + geoId); + + // Get the bounds of the path + ActsScalar top0 = + refPoint[bin0] + pathWidth0; + ActsScalar bot0 = + refPoint[bin0] - pathWidth0; + ActsScalar top1 = + refPoint[bin1] + pathWidth1; + ActsScalar bot1 = + refPoint[bin1] - pathWidth1; + + // Get the lookup table for the source links + auto grid = m_cfg.sourceLinkGrid->getSourceLinkTable( + geoId); + + // Get the range of bins to search for source links + auto botLeftBin = grid.localBinsFromPosition( + Vector2(bot0, bot1)); + auto topRightBin = grid.localBinsFromPosition( + Vector2(top0, top1)); + + // Get the source links from the lookup table + // by iterating over the bin ranges + auto currentBin = botLeftBin; + while (currentBin.at(1) <= topRightBin.at(1)) { + while (currentBin.at(0) <= topRightBin.at(0)) { + auto sourceLinksToAdd = + grid.atLocalBins(currentBin); + + seedSourceLinks.insert( + seedSourceLinks.end(), + sourceLinksToAdd.begin(), + sourceLinksToAdd.end()); + currentBin.at(0)++; + } + currentBin.at(1)++; + currentBin.at(0) = botLeftBin.at(0); + } + } + + // Add the source links to the seed + seed.sourceLinks = seedSourceLinks; + + // Add the seed to the list + seeds.push_back(seed); + } + return seeds; + }; + + + private: + Config m_cfg; +}; + +} // namespace Acts diff --git a/Tests/UnitTests/Core/Seeding/CMakeLists.txt b/Tests/UnitTests/Core/Seeding/CMakeLists.txt index 74279751405..24e224f685d 100644 --- a/Tests/UnitTests/Core/Seeding/CMakeLists.txt +++ b/Tests/UnitTests/Core/Seeding/CMakeLists.txt @@ -3,3 +3,4 @@ target_link_libraries(ActsUnitTestSeedFinder PRIVATE ActsCore Boost::boost) add_unittest(EstimateTrackParamsFromSeed EstimateTrackParamsFromSeedTest.cpp) add_unittest(BinnedGroupTest BinnedGroupTest.cpp) +add_unittest(PathSeeder PathSeederTest.cpp) diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp new file mode 100644 index 00000000000..81470a3cbd3 --- /dev/null +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -0,0 +1,461 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include "Acts/Seeding/PathSeeder.hpp" + +#include "Acts/Detector/Detector.hpp" +#include "Acts/Detector/DetectorVolume.hpp" +#include "Acts/Detector/PortalGenerators.hpp" +#include "Acts/Detector/GeometryIdGenerator.hpp" +#include "Acts/Detector/detail/CuboidalDetectorHelper.hpp" +#include "Acts/Surfaces/PlaneSurface.hpp" +#include "Acts/Surfaces/RectangleBounds.hpp" +#include "Acts/Navigation/DetectorNavigator.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" +#include "Acts/Navigation/DetectorVolumeFinders.hpp" +#include "Acts/Geometry/CuboidVolumeBounds.hpp" +#include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Propagator/Propagator.hpp" +#include "Acts/Propagator/StraightLineStepper.hpp" +#include "Acts/Propagator/EigenStepper.hpp" +#include "Acts/MagneticField/ConstantBField.hpp" +#include "Acts/Tests/CommonHelpers/MeasurementsCreator.hpp" +#include "Acts/EventData/detail/TestSourceLink.hpp" +#include "Acts/Utilities/Logger.hpp" + + +BOOST_AUTO_TEST_SUITE(PathSeeder) + +using namespace Acts; +using namespace Acts::UnitLiterals; + +using Axis = Acts::detail::EquidistantAxis; + +GeometryContext gctx; + +// Parameters for the geometry +const ActsScalar halfY = 10.; +const ActsScalar halfZ = 10.; +const ActsScalar deltaX = 10.; +const ActsScalar deltaYZ = 1.; + +// Intersection finding to get the +// region of interest for seeding +class NoFieldIntersectionFinder { + public: + ActsScalar tol = 1e-4; + + std::vector m_surfaces; + + // Find the intersections along the path + // and return them in the order of the path + // length + std::vector> + operator()( + const GeometryContext& geoCtx, + const Vector3& position, + const Vector3& direction, + [[maybe_unused]] const ActsScalar& Pmag = 0) const { + std::vector> sIntersections; + // Intersect the surfaces + for (auto& surface : m_surfaces) { + + // Get the intersection + auto sMultiIntersection = + surface->intersect( + geoCtx, + position, + direction, + BoundaryCheck(true), + tol); + + // Take the closest + auto closestForward = sMultiIntersection.closestForward(); + + // Store if the intersection is reachable + if (closestForward.status() == + IntersectionStatus::reachable && + closestForward.pathLength() > 0.0) { + sIntersections.push_back({closestForward.object()->geometryId(),closestForward.position()}); + continue; + } + } + return sIntersections; + } +}; + +// Grid to store the source links for +// the seeding fast lookup +class SourceLinkGrid : public ISourceLinkGrid { + public: + using eGrid = Grid, Axis, Axis>; + + /// Lookup table collection + std::unordered_map m_lookupTables; + + /// Surface accessor + SourceLinkSurfaceAccessor m_surfaceAccessor; + + void initialize( + const GeometryContext& geoCtx, + std::vector sourceLinks) override { + // Lookup table for each layer + std::unordered_map lookupTable; + + // Construct a binned grid for each layer + for (int i : {14, 15, 16, 17}) { + Axis xAxis(-halfY, halfY, 50); + Axis yAxis(-halfZ, halfZ, 50); + + eGrid grid(std::make_tuple(xAxis, yAxis)); + lookupTable.insert({i, grid}); + } + // Fill the grid with source links + for (auto& sl : sourceLinks) { + auto ssl = sl.get(); + auto id = ssl.m_geometryId; + + // Grid works with global positions + Acts::Vector3 globalPos = m_surfaceAccessor( + sl)->localToGlobal( + geoCtx, + ssl.parameters, + Acts::Vector3{0, 1, 0}); + + auto bin = lookupTable.at(id.sensitive()).localBinsFromPosition( + Acts::Vector2(globalPos.y(), globalPos.z())); + lookupTable.at(id.sensitive()).atLocalBins(bin).push_back(sl); + } + + m_lookupTables = lookupTable; + }; + + // Get the source link grid for a given geometry id + eGrid getSourceLinkTable(const Acts::GeometryIdentifier& geoId) const override { + return m_lookupTables.at(geoId.sensitive()); + } +}; + +// A simple path width provider to set +// the grid lookup boundaries around the +// intersection point +class PathWidthProvider { + public: + ActsScalar m_pathWidth = 0.1; + + std::pair operator()( + const GeometryContext& /*geoCtx*/, + const GeometryIdentifier& /*geoId*/) const { + return {m_pathWidth, m_pathWidth}; + } +}; + +// Calibrator to transform the source links +// to global coordinates +class SourceLinkCalibrator { + public: + SourceLinkSurfaceAccessor m_surfaceAccessor; + + Acts::Vector3 operator()( + const GeometryContext& geoCtx, + const Acts::SourceLink& sourceLink) const { + auto ssl = sourceLink.get(); + auto res = m_surfaceAccessor(sourceLink)->localToGlobal( + geoCtx, ssl.parameters, Acts::Vector3{0, 1, 0}); + return res; + } +}; + +// Estimator of the particle's energy, +// vertex, momentum direction at the IP +// and the direction at the first hit +class TrackEstimator { + public: + Vector3 ip; + + std::tuple + operator()( + const GeometryContext& /*geoCtx*/, + const Vector3& pivot) const { + Vector3 direction = (pivot - ip).normalized(); + return {1._GeV, ip, direction, direction}; + }; +}; + +// Construct a simple telescope detector +std::shared_ptr +constructTelescopeDetector() { + RotationMatrix3 rotation; + double angle = 90_degree; + Vector3 xPos(cos(angle), 0., sin(angle)); + Vector3 yPos(0., 1., 0.); + Vector3 zPos(-sin(angle), 0., cos(angle)); + rotation.col(0) = xPos; + rotation.col(1) = yPos; + rotation.col(2) = zPos; + + // Create a bunch of surface bounds + auto surf0bounds = + std::make_unique(halfY, halfZ); + + auto surf1bounds = + std::make_unique(halfY, halfZ); + + auto surf2bounds = + std::make_unique(halfY, halfZ); + + auto surf3bounds = + std::make_unique(halfY, halfZ); + + // Create a bunch of surfaces + auto transform0 = Transform3::Identity(); + auto surf0 = Surface::makeShared( + transform0 * Transform3(rotation), std::move(surf0bounds)); + auto geoId0 = GeometryIdentifier(); + geoId0.setSensitive(1); + + auto transform1 = + Transform3::Identity() * + Translation3(Vector3(2*deltaX, 0, 0)); + auto surf1 = Surface::makeShared( + transform1 * Transform3(rotation), std::move(surf1bounds)); + auto geoId1 = GeometryIdentifier(); + geoId1.setSensitive(2); + + auto transform2 = + Transform3::Identity() * + Translation3(Vector3(4*deltaX, 0, 0)); + auto surf2 = Surface::makeShared( + transform2 * Transform3(rotation), std::move(surf2bounds)); + auto geoId2 = GeometryIdentifier(); + geoId2.setSensitive(3); + + auto transform3 = + Transform3::Identity() * + Translation3(Vector3(6*deltaX, 0, 0)); + auto surf3 = Surface::makeShared( + transform3 * Transform3(rotation), std::move(surf3bounds)); + auto geoId3 = GeometryIdentifier(); + geoId3.setSensitive(4); + + // Create a bunch of volume bounds + auto vol0bounds = + std::make_unique( + deltaX, + halfY + deltaYZ, + halfZ + deltaYZ); + + auto vol1bounds = + std::make_unique( + deltaX, + halfY + deltaYZ, + halfZ + deltaYZ); + + auto vol2bounds = + std::make_unique( + deltaX, + halfY + deltaYZ, + halfZ + deltaYZ); + + auto vol3bounds = + std::make_unique( + deltaX, + halfY + deltaYZ, + halfZ + deltaYZ); + + // Create a bunch of volumes + auto vol0 = Experimental::DetectorVolumeFactory::construct( + Experimental::defaultPortalAndSubPortalGenerator(), gctx, + "vol0", transform0, std::move(vol0bounds), {surf0}, {}, + Experimental::tryNoVolumes(), + Experimental::tryAllPortalsAndSurfaces()); + + auto vol1 = Experimental::DetectorVolumeFactory::construct( + Experimental::defaultPortalAndSubPortalGenerator(), gctx, + "vol1", transform1, std::move(vol1bounds), {surf1}, {}, + Experimental::tryNoVolumes(), + Experimental::tryAllPortalsAndSurfaces()); + + auto vol2 = Experimental::DetectorVolumeFactory::construct( + Experimental::defaultPortalAndSubPortalGenerator(), gctx, + "vol2", transform2, std::move(vol2bounds), {surf2}, {}, + Experimental::tryNoVolumes(), + Experimental::tryAllPortalsAndSurfaces()); + + auto vol3 = Experimental::DetectorVolumeFactory::construct( + Experimental::defaultPortalAndSubPortalGenerator(), gctx, + "vol3", transform3, std::move(vol3bounds), {surf3}, {}, + Experimental::tryNoVolumes(), + Experimental::tryAllPortalsAndSurfaces()); + + std::vector> volumes = + {vol0, vol1, vol2, vol3}; + + // Connect the volumes + auto portalContainer = + Experimental::detail::CuboidalDetectorHelper::connect( + gctx, volumes, BinningValue::binX, {}, + Logging::VERBOSE); + + // Make sure that the geometry ids are + // independent of the potential Id generation + // changes + int id = 1; + + // Volume ids + for (auto& volume : volumes) { + volume->assignGeometryId(id); + id++; + } + // Intervolume portal ids + for (auto& volume : volumes) { + for (auto& port : volume->portalPtrs()) { + if (port->surface().geometryId() == 0) { + port->surface().assignGeometryId(id); + id++; + } + } + } + // Surface ids + for (auto& surf : {surf0, surf1, surf2, surf3}) { + auto geoId = GeometryIdentifier(); + geoId.setSensitive(id); + surf->assignGeometryId(geoId); + id++; + } + + auto detector = Experimental::Detector::makeShared( + "TelescopeDetector", volumes, + Experimental::tryRootVolumes()); + + return detector; +}; + +std::vector createSourceLinks( + const GeometryContext& geoCtx, + const Experimental::Detector& detector) { + NoFieldIntersectionFinder intersectionFinder; + + for (auto volume : detector.volumes()) { + for (auto surface : volume->surfaces()) { + intersectionFinder.m_surfaces.push_back(surface); + } + } + + Vector3 vertex(-5., 0., 0.); + std::vector phis = {-0.15, -0.1, -0.05, 0, 0.05, 0.1, 0.15}; + + std::vector sourceLinks; + for (ActsScalar phi : phis) { + Vector3 direction(cos(phi), sin(phi), 0.); + + auto intersections = intersectionFinder( + geoCtx, vertex, direction); + + SquareMatrix2 cov = Acts::SquareMatrix2::Identity(); + + for (auto& [id,refPoint] : intersections) { + auto surf = *detector.sensitiveHierarchyMap().find(id); + Acts::Vector2 val = + surf->globalToLocal( + geoCtx, refPoint, + direction).value(); + + Acts::detail::Test::TestSourceLink sourceLink( + eBoundLoc0, eBoundLoc1, + val, cov, + id, + id.value()); + + Acts::SourceLink sl{sourceLink}; + sourceLinks.push_back(sl); + } + } + + return sourceLinks; +} + +BOOST_AUTO_TEST_CASE(PathSeederZeroField) { + // Create detector + auto detector = constructTelescopeDetector(); + + // Create source links + auto sourceLinks = createSourceLinks(gctx, *detector); + + // Prepare the PathSeeder + auto pathSeederCfg = Acts::PathSeeder::Config(); + + // Grid to bin the source links + Acts::detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor; + surfaceAccessor.detector = detector.get(); + auto sourceLinkGrid = std::make_shared(); + sourceLinkGrid->m_surfaceAccessor.connect< + &Acts::detail::Test::TestSourceLink::SurfaceAccessor::operator()>( + &surfaceAccessor); + pathSeederCfg.sourceLinkGrid = sourceLinkGrid; + + // Estimator of the IP and first hit + // parameters of the track + TrackEstimator trackEstimator; + trackEstimator.ip = Vector3(-5., 0., 0.); + pathSeederCfg.trackEstimator.connect<&TrackEstimator::operator()>( + &trackEstimator); + + // Transforms the source links to global coordinates + SourceLinkCalibrator sourceLinkCalibrator; + sourceLinkCalibrator.m_surfaceAccessor.connect< + &Acts::detail::Test::TestSourceLink::SurfaceAccessor::operator()>( + &surfaceAccessor); + pathSeederCfg.sourceLinkCalibrator.connect<&SourceLinkCalibrator::operator()>( + &sourceLinkCalibrator); + + // Intersection finder + auto intersectionFinder = NoFieldIntersectionFinder(); + for (auto volume : detector->volumes()) { + for (auto surface : volume->surfaces()) { + intersectionFinder.m_surfaces.push_back(surface); + } + } + pathSeederCfg.intersectionFinder.connect<&NoFieldIntersectionFinder::operator()>( + &intersectionFinder); + + // Path width provider + auto pathWidthProvider = PathWidthProvider(); + pathSeederCfg.pathWidthProvider.connect<&PathWidthProvider::operator()>( + &pathWidthProvider); + + // First tracking layer + Extent firstLayerExtent; + firstLayerExtent.set( + Acts::binX, -0.1, 0.1); + firstLayerExtent.set( + Acts::binY, -halfY - deltaYZ, halfY + deltaYZ); + firstLayerExtent.set( + Acts::binZ, -halfZ - deltaYZ, halfZ + deltaYZ); + + pathSeederCfg.firstLayerExtent = firstLayerExtent; + + // Create the PathSeeder + Acts::PathSeeder pathSeeder(pathSeederCfg); + + // Get the seeds + auto seeds = pathSeeder.getSeeds(gctx, sourceLinks); + + // Check the seeds + BOOST_CHECK_EQUAL(seeds.size(), 7); + for (auto& seed : seeds) { + BOOST_CHECK_EQUAL(seed.sourceLinks.size(), 4); + BOOST_CHECK_EQUAL(seed.ipVertex, Vector3(-5., 0., 0.)); + BOOST_CHECK_EQUAL(seed.ipP, 1._GeV); + } +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp b/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp index 04335237ade..9d25f3f6d47 100644 --- a/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp +++ b/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp @@ -187,7 +187,7 @@ BOOST_DATA_TEST_CASE(SpacePointBuilder_basic, bdata::xrange(1), index) { auto spBuilderConfig = SpacePointBuilderConfig(); spBuilderConfig.trackingGeometry = geometry; - TestSourceLink::SurfaceAccessor surfaceAccessor{*geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{geometry.get()}; spBuilderConfig.slSurfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); diff --git a/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp b/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp index 048f29c99b2..4950936f356 100644 --- a/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp +++ b/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp @@ -127,7 +127,7 @@ struct FitterTester { std::shared_ptr geometry = geometryStore(); Acts::detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor{ - *geometry}; + geometry.get()}; // expected number of measurements for the given detector constexpr static std::size_t nMeasurements = 6u; diff --git a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index ad6f43d7d52..5a8ffa8fd0d 100644 --- a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp @@ -234,7 +234,7 @@ BOOST_AUTO_TEST_CASE(NoFit) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -321,7 +321,7 @@ BOOST_AUTO_TEST_CASE(Fit5Iterations) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -426,7 +426,7 @@ BOOST_AUTO_TEST_CASE(MixedDetector) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -521,7 +521,7 @@ BOOST_AUTO_TEST_CASE(FitWithBfield) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -618,7 +618,7 @@ BOOST_AUTO_TEST_CASE(relChi2changeCutOff) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -714,7 +714,7 @@ BOOST_AUTO_TEST_CASE(DidNotConverge) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -786,7 +786,7 @@ BOOST_AUTO_TEST_CASE(NotEnoughMeasurements) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -874,7 +874,7 @@ BOOST_AUTO_TEST_CASE(FindHoles) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -979,7 +979,7 @@ BOOST_AUTO_TEST_CASE(Material) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); From 7bc1aad9148591667c20ab8380c964547959b3a8 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 17 Jun 2024 12:53:10 +0300 Subject: [PATCH 02/28] format --- .../Acts/EventData/detail/TestSourceLink.hpp | 32 +- Core/include/Acts/Seeding/ISourceLinkGrid.hpp | 40 +- Core/include/Acts/Seeding/PathSeeder.hpp | 346 ++++----- .../UnitTests/Core/Seeding/PathSeederTest.cpp | 726 ++++++++---------- .../Visualization/EventDataView3DBase.hpp | 2 +- 5 files changed, 529 insertions(+), 617 deletions(-) diff --git a/Core/include/Acts/EventData/detail/TestSourceLink.hpp b/Core/include/Acts/EventData/detail/TestSourceLink.hpp index 906c64f3f40..fe32029019b 100644 --- a/Core/include/Acts/EventData/detail/TestSourceLink.hpp +++ b/Core/include/Acts/EventData/detail/TestSourceLink.hpp @@ -8,9 +8,9 @@ #pragma once -#include "Acts/Detector/Detector.hpp" #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" +#include "Acts/Detector/Detector.hpp" #include "Acts/EventData/Measurement.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/SourceLink.hpp" @@ -90,23 +90,21 @@ struct TestSourceLink final { constexpr std::size_t index() const { return sourceId; } struct SurfaceAccessor { - const Acts::TrackingGeometry* trackingGeometry = nullptr; - const Acts::Experimental::Detector* detector = nullptr; + const Acts::TrackingGeometry* trackingGeometry = nullptr; + const Acts::Experimental::Detector* detector = nullptr; - const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const { - const auto& testSourceLink = sourceLink.get(); - if (trackingGeometry) { - return trackingGeometry->findSurface(testSourceLink.m_geometryId); - } - else if (detector) { - return *detector->sensitiveHierarchyMap().find( - testSourceLink.m_geometryId); - } - else { - throw std::runtime_error("No tracking geometry or detector set"); - } - } - }; + const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const { + const auto& testSourceLink = sourceLink.get(); + if (trackingGeometry) { + return trackingGeometry->findSurface(testSourceLink.m_geometryId); + } else if (detector) { + return *detector->sensitiveHierarchyMap().find( + testSourceLink.m_geometryId); + } else { + throw std::runtime_error("No tracking geometry or detector set"); + } + } + }; }; inline std::ostream& operator<<(std::ostream& os, diff --git a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp index 2d2aad05a4c..1e11755ef1a 100644 --- a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp +++ b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp @@ -8,11 +8,11 @@ #pragma once +#include "Acts/Definitions/Algebra.hpp" #include "Acts/EventData/SourceLink.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Utilities/detail/Axis.hpp" #include "Acts/Utilities/Grid.hpp" +#include "Acts/Utilities/detail/Axis.hpp" namespace Acts { @@ -23,27 +23,21 @@ namespace Acts { /// template class ISourceLinkGrid { - using slGrid = - Grid< - std::vector, - axis_t, - axis_t>; - - public: - /// @brief Virtual destructor - virtual ~ISourceLinkGrid() = default; - - /// @brief Interface function to sort - /// the source links into the grid - virtual void initialize( - const GeometryContext& gctx, - std::vector sourceLinks) = 0; - - /// @brief Interface function to get the - /// grid of source links for a - /// given geometry identifier - virtual slGrid getSourceLinkTable( - const GeometryIdentifier& geoId) const = 0; + using slGrid = Grid, axis_t, axis_t>; + + public: + /// @brief Virtual destructor + virtual ~ISourceLinkGrid() = default; + + /// @brief Interface function to sort + /// the source links into the grid + virtual void initialize(const GeometryContext& gctx, + std::vector sourceLinks) = 0; + + /// @brief Interface function to get the + /// grid of source links for a + /// given geometry identifier + virtual slGrid getSourceLinkTable(const GeometryIdentifier& geoId) const = 0; }; } // namespace Acts diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 52715b04ecc..90280b97226 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -14,199 +14,171 @@ namespace Acts { -/// @brief Seeding algorigthm that extracts +/// @brief Seeding algorigthm that extracts /// the IP parameters and sorts the source links /// into possible track candidates /// -/// @tparam axis_t Type of the axis to bin +/// @tparam axis_t Type of the axis to bin /// the source links /// template class PathSeeder { - public: - struct Seed { - ActsScalar ipP; - Vector3 ipDir; - Vector3 ipVertex; - std::vector sourceLinks; - }; - - using SourceLinkCalibrator = - Delegate; - - using PathWidthLookup = - Delegate( - const GeometryContext&, - const GeometryIdentifier&)>; - - using IntersectionLookup = - Delegate>( - const GeometryContext&, - const Vector3&, - const Vector3&, - const ActsScalar&)>; - - using TrackEstimator = - Delegate( - const GeometryContext&, - const Vector3&)>; - - /// @brief The nested configuration struct - struct Config { - /// Binned SourceLink provider - std::shared_ptr> sourceLinkGrid; - /// Parameters estimator - TrackEstimator trackEstimator; - /// Surface accessor - SourceLinkCalibrator sourceLinkCalibrator; - /// Intersection finder - IntersectionLookup intersectionFinder; - /// Path width provider - PathWidthLookup pathWidthProvider; - /// First layer extent - Extent firstLayerExtent; - /// Direction of the telescope extent - BinningValue orientation = binX; - }; - - /// @brief Constructor - PathSeeder(const Config& config) - : m_cfg(std::move(config)) {}; - - /// @brief Destructor - ~PathSeeder() = default; - - - /// @brief Extract the IP parameters and - /// sort the source links into the seeds - /// - /// @param gctx The geometry context - /// @param sourceLinks The source links to seed - /// - /// @return The vector of seeds - std::vector - getSeeds( - const GeometryContext& gctx, - const std::vector& sourceLinks) const { - // Sort the source links into the grid - m_cfg.sourceLinkGrid->initialize(gctx, sourceLinks); - - // Get plane of the telescope - // sensitive surfaces - BinningValue bin0, bin1; - if (m_cfg.orientation == binX) { - bin0 = binY; - bin1 = binZ; - } else if (m_cfg.orientation == binY) { - bin0 = binX; - bin1 = binZ; - } else { - bin0 = binX; - bin1 = binY; - } - - // Create the seeds - std::vector seeds; - for (const auto& sl : sourceLinks) { - Vector3 globalPos = m_cfg.sourceLinkCalibrator( - gctx, sl); - - // Check if the hit is in the - // first tracking layer - if (!m_cfg.firstLayerExtent.contains(globalPos)) { - continue; - } - - // Get the IP parameters - auto [ipP, ipVertex, ipDir, flDir] = - m_cfg.trackEstimator( - gctx, globalPos); - - // Intersect with the surfaces - std::vector> - intersections = - m_cfg.intersectionFinder( - gctx, globalPos, flDir, ipP); - - // Continue if no intersections - if (intersections.empty()) { - continue; - } - // Vector to store the source links - std::vector seedSourceLinks; - - // Store the IP parameters - Seed seed; - seed.ipP = ipP; - seed.ipDir = ipDir; - seed.ipVertex = ipVertex; - - // Store the pivot source link - seedSourceLinks.push_back(sl); - - // Iterate over the intersections - // and get the source links - // in the subsequent layers - for (auto& [geoId,refPoint] : intersections) { - // Get the path width - auto [pathWidth0, pathWidth1] = - m_cfg.pathWidthProvider( - gctx, - geoId); - - // Get the bounds of the path - ActsScalar top0 = - refPoint[bin0] + pathWidth0; - ActsScalar bot0 = - refPoint[bin0] - pathWidth0; - ActsScalar top1 = - refPoint[bin1] + pathWidth1; - ActsScalar bot1 = - refPoint[bin1] - pathWidth1; - - // Get the lookup table for the source links - auto grid = m_cfg.sourceLinkGrid->getSourceLinkTable( - geoId); - - // Get the range of bins to search for source links - auto botLeftBin = grid.localBinsFromPosition( - Vector2(bot0, bot1)); - auto topRightBin = grid.localBinsFromPosition( - Vector2(top0, top1)); - - // Get the source links from the lookup table - // by iterating over the bin ranges - auto currentBin = botLeftBin; - while (currentBin.at(1) <= topRightBin.at(1)) { - while (currentBin.at(0) <= topRightBin.at(0)) { - auto sourceLinksToAdd = - grid.atLocalBins(currentBin); - - seedSourceLinks.insert( - seedSourceLinks.end(), - sourceLinksToAdd.begin(), - sourceLinksToAdd.end()); - currentBin.at(0)++; - } - currentBin.at(1)++; - currentBin.at(0) = botLeftBin.at(0); - } - } - - // Add the source links to the seed - seed.sourceLinks = seedSourceLinks; - - // Add the seed to the list - seeds.push_back(seed); - } - return seeds; - }; - - - private: - Config m_cfg; + public: + struct Seed { + ActsScalar ipP; + Vector3 ipDir; + Vector3 ipVertex; + std::vector sourceLinks; + }; + + using SourceLinkCalibrator = + Delegate; + + using PathWidthLookup = Delegate( + const GeometryContext&, const GeometryIdentifier&)>; + + using IntersectionLookup = + Delegate>( + const GeometryContext&, const Vector3&, const Vector3&, + const ActsScalar&)>; + + using TrackEstimator = + Delegate( + const GeometryContext&, const Vector3&)>; + + /// @brief The nested configuration struct + struct Config { + /// Binned SourceLink provider + std::shared_ptr> sourceLinkGrid; + /// Parameters estimator + TrackEstimator trackEstimator; + /// Surface accessor + SourceLinkCalibrator sourceLinkCalibrator; + /// Intersection finder + IntersectionLookup intersectionFinder; + /// Path width provider + PathWidthLookup pathWidthProvider; + /// First layer extent + Extent firstLayerExtent; + /// Direction of the telescope extent + BinningValue orientation = binX; + }; + + /// @brief Constructor + PathSeeder(const Config& config) : m_cfg(std::move(config)){}; + + /// @brief Destructor + ~PathSeeder() = default; + + /// @brief Extract the IP parameters and + /// sort the source links into the seeds + /// + /// @param gctx The geometry context + /// @param sourceLinks The source links to seed + /// + /// @return The vector of seeds + std::vector getSeeds(const GeometryContext& gctx, + const std::vector& sourceLinks) const { + // Sort the source links into the grid + m_cfg.sourceLinkGrid->initialize(gctx, sourceLinks); + + // Get plane of the telescope + // sensitive surfaces + BinningValue bin0, bin1; + if (m_cfg.orientation == binX) { + bin0 = binY; + bin1 = binZ; + } else if (m_cfg.orientation == binY) { + bin0 = binX; + bin1 = binZ; + } else { + bin0 = binX; + bin1 = binY; + } + + // Create the seeds + std::vector seeds; + for (const auto& sl : sourceLinks) { + Vector3 globalPos = m_cfg.sourceLinkCalibrator(gctx, sl); + + // Check if the hit is in the + // first tracking layer + if (!m_cfg.firstLayerExtent.contains(globalPos)) { + continue; + } + + // Get the IP parameters + auto [ipP, ipVertex, ipDir, flDir] = + m_cfg.trackEstimator(gctx, globalPos); + + // Intersect with the surfaces + std::vector> intersections = + m_cfg.intersectionFinder(gctx, globalPos, flDir, ipP); + + // Continue if no intersections + if (intersections.empty()) { + continue; + } + // Vector to store the source links + std::vector seedSourceLinks; + + // Store the IP parameters + Seed seed; + seed.ipP = ipP; + seed.ipDir = ipDir; + seed.ipVertex = ipVertex; + + // Store the pivot source link + seedSourceLinks.push_back(sl); + + // Iterate over the intersections + // and get the source links + // in the subsequent layers + for (auto& [geoId, refPoint] : intersections) { + // Get the path width + auto [pathWidth0, pathWidth1] = m_cfg.pathWidthProvider(gctx, geoId); + + // Get the bounds of the path + ActsScalar top0 = refPoint[bin0] + pathWidth0; + ActsScalar bot0 = refPoint[bin0] - pathWidth0; + ActsScalar top1 = refPoint[bin1] + pathWidth1; + ActsScalar bot1 = refPoint[bin1] - pathWidth1; + + // Get the lookup table for the source links + auto grid = m_cfg.sourceLinkGrid->getSourceLinkTable(geoId); + + // Get the range of bins to search for source links + auto botLeftBin = grid.localBinsFromPosition(Vector2(bot0, bot1)); + auto topRightBin = grid.localBinsFromPosition(Vector2(top0, top1)); + + // Get the source links from the lookup table + // by iterating over the bin ranges + auto currentBin = botLeftBin; + while (currentBin.at(1) <= topRightBin.at(1)) { + while (currentBin.at(0) <= topRightBin.at(0)) { + auto sourceLinksToAdd = grid.atLocalBins(currentBin); + + seedSourceLinks.insert(seedSourceLinks.end(), + sourceLinksToAdd.begin(), + sourceLinksToAdd.end()); + currentBin.at(0)++; + } + currentBin.at(1)++; + currentBin.at(0) = botLeftBin.at(0); + } + } + + // Add the source links to the seed + seed.sourceLinks = seedSourceLinks; + + // Add the seed to the list + seeds.push_back(seed); + } + return seeds; + }; + + private: + Config m_cfg; }; -} // namespace Acts +} // namespace Acts diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 81470a3cbd3..82afa1acaa1 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -8,29 +8,27 @@ #include -#include "Acts/Seeding/PathSeeder.hpp" - #include "Acts/Detector/Detector.hpp" #include "Acts/Detector/DetectorVolume.hpp" -#include "Acts/Detector/PortalGenerators.hpp" #include "Acts/Detector/GeometryIdGenerator.hpp" +#include "Acts/Detector/PortalGenerators.hpp" #include "Acts/Detector/detail/CuboidalDetectorHelper.hpp" -#include "Acts/Surfaces/PlaneSurface.hpp" -#include "Acts/Surfaces/RectangleBounds.hpp" -#include "Acts/Navigation/DetectorNavigator.hpp" -#include "Acts/Navigation/InternalNavigation.hpp" -#include "Acts/Navigation/DetectorVolumeFinders.hpp" +#include "Acts/EventData/detail/TestSourceLink.hpp" #include "Acts/Geometry/CuboidVolumeBounds.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/MagneticField/ConstantBField.hpp" +#include "Acts/Navigation/DetectorNavigator.hpp" +#include "Acts/Navigation/DetectorVolumeFinders.hpp" +#include "Acts/Navigation/InternalNavigation.hpp" +#include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" -#include "Acts/Propagator/EigenStepper.hpp" -#include "Acts/MagneticField/ConstantBField.hpp" +#include "Acts/Seeding/PathSeeder.hpp" +#include "Acts/Surfaces/PlaneSurface.hpp" +#include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Tests/CommonHelpers/MeasurementsCreator.hpp" -#include "Acts/EventData/detail/TestSourceLink.hpp" #include "Acts/Utilities/Logger.hpp" - BOOST_AUTO_TEST_SUITE(PathSeeder) using namespace Acts; @@ -46,416 +44,366 @@ const ActsScalar halfZ = 10.; const ActsScalar deltaX = 10.; const ActsScalar deltaYZ = 1.; -// Intersection finding to get the +// Intersection finding to get the // region of interest for seeding class NoFieldIntersectionFinder { - public: - ActsScalar tol = 1e-4; - - std::vector m_surfaces; - - // Find the intersections along the path - // and return them in the order of the path - // length - std::vector> - operator()( - const GeometryContext& geoCtx, - const Vector3& position, - const Vector3& direction, - [[maybe_unused]] const ActsScalar& Pmag = 0) const { - std::vector> sIntersections; - // Intersect the surfaces - for (auto& surface : m_surfaces) { - - // Get the intersection - auto sMultiIntersection = - surface->intersect( - geoCtx, - position, - direction, - BoundaryCheck(true), - tol); - - // Take the closest - auto closestForward = sMultiIntersection.closestForward(); - - // Store if the intersection is reachable - if (closestForward.status() == - IntersectionStatus::reachable && - closestForward.pathLength() > 0.0) { - sIntersections.push_back({closestForward.object()->geometryId(),closestForward.position()}); - continue; - } - } - return sIntersections; - } + public: + ActsScalar tol = 1e-4; + + std::vector m_surfaces; + + // Find the intersections along the path + // and return them in the order of the path + // length + std::vector> operator()( + const GeometryContext& geoCtx, const Vector3& position, + const Vector3& direction, + [[maybe_unused]] const ActsScalar& Pmag = 0) const { + std::vector> sIntersections; + // Intersect the surfaces + for (auto& surface : m_surfaces) { + // Get the intersection + auto sMultiIntersection = surface->intersect(geoCtx, position, direction, + BoundaryCheck(true), tol); + + // Take the closest + auto closestForward = sMultiIntersection.closestForward(); + + // Store if the intersection is reachable + if (closestForward.status() == IntersectionStatus::reachable && + closestForward.pathLength() > 0.0) { + sIntersections.push_back( + {closestForward.object()->geometryId(), closestForward.position()}); + continue; + } + } + return sIntersections; + } }; -// Grid to store the source links for +// Grid to store the source links for // the seeding fast lookup class SourceLinkGrid : public ISourceLinkGrid { - public: - using eGrid = Grid, Axis, Axis>; - - /// Lookup table collection - std::unordered_map m_lookupTables; - - /// Surface accessor - SourceLinkSurfaceAccessor m_surfaceAccessor; - - void initialize( - const GeometryContext& geoCtx, - std::vector sourceLinks) override { - // Lookup table for each layer - std::unordered_map lookupTable; - - // Construct a binned grid for each layer - for (int i : {14, 15, 16, 17}) { - Axis xAxis(-halfY, halfY, 50); - Axis yAxis(-halfZ, halfZ, 50); - - eGrid grid(std::make_tuple(xAxis, yAxis)); - lookupTable.insert({i, grid}); - } - // Fill the grid with source links - for (auto& sl : sourceLinks) { - auto ssl = sl.get(); - auto id = ssl.m_geometryId; - - // Grid works with global positions - Acts::Vector3 globalPos = m_surfaceAccessor( - sl)->localToGlobal( - geoCtx, - ssl.parameters, - Acts::Vector3{0, 1, 0}); - - auto bin = lookupTable.at(id.sensitive()).localBinsFromPosition( - Acts::Vector2(globalPos.y(), globalPos.z())); - lookupTable.at(id.sensitive()).atLocalBins(bin).push_back(sl); - } - - m_lookupTables = lookupTable; - }; - - // Get the source link grid for a given geometry id - eGrid getSourceLinkTable(const Acts::GeometryIdentifier& geoId) const override { - return m_lookupTables.at(geoId.sensitive()); - } + public: + using eGrid = Grid, Axis, Axis>; + + /// Lookup table collection + std::unordered_map m_lookupTables; + + /// Surface accessor + SourceLinkSurfaceAccessor m_surfaceAccessor; + + void initialize(const GeometryContext& geoCtx, + std::vector sourceLinks) override { + // Lookup table for each layer + std::unordered_map lookupTable; + + // Construct a binned grid for each layer + for (int i : {14, 15, 16, 17}) { + Axis xAxis(-halfY, halfY, 50); + Axis yAxis(-halfZ, halfZ, 50); + + eGrid grid(std::make_tuple(xAxis, yAxis)); + lookupTable.insert({i, grid}); + } + // Fill the grid with source links + for (auto& sl : sourceLinks) { + auto ssl = sl.get(); + auto id = ssl.m_geometryId; + + // Grid works with global positions + Acts::Vector3 globalPos = m_surfaceAccessor(sl)->localToGlobal( + geoCtx, ssl.parameters, Acts::Vector3{0, 1, 0}); + + auto bin = lookupTable.at(id.sensitive()) + .localBinsFromPosition( + Acts::Vector2(globalPos.y(), globalPos.z())); + lookupTable.at(id.sensitive()).atLocalBins(bin).push_back(sl); + } + + m_lookupTables = lookupTable; + }; + + // Get the source link grid for a given geometry id + eGrid getSourceLinkTable( + const Acts::GeometryIdentifier& geoId) const override { + return m_lookupTables.at(geoId.sensitive()); + } }; -// A simple path width provider to set +// A simple path width provider to set // the grid lookup boundaries around the // intersection point class PathWidthProvider { - public: - ActsScalar m_pathWidth = 0.1; - - std::pair operator()( - const GeometryContext& /*geoCtx*/, - const GeometryIdentifier& /*geoId*/) const { - return {m_pathWidth, m_pathWidth}; - } + public: + ActsScalar m_pathWidth = 0.1; + + std::pair operator()( + const GeometryContext& /*geoCtx*/, + const GeometryIdentifier& /*geoId*/) const { + return {m_pathWidth, m_pathWidth}; + } }; // Calibrator to transform the source links // to global coordinates class SourceLinkCalibrator { - public: - SourceLinkSurfaceAccessor m_surfaceAccessor; - - Acts::Vector3 operator()( - const GeometryContext& geoCtx, - const Acts::SourceLink& sourceLink) const { - auto ssl = sourceLink.get(); - auto res = m_surfaceAccessor(sourceLink)->localToGlobal( - geoCtx, ssl.parameters, Acts::Vector3{0, 1, 0}); - return res; - } + public: + SourceLinkSurfaceAccessor m_surfaceAccessor; + + Acts::Vector3 operator()(const GeometryContext& geoCtx, + const Acts::SourceLink& sourceLink) const { + auto ssl = sourceLink.get(); + auto res = + m_surfaceAccessor(sourceLink) + ->localToGlobal(geoCtx, ssl.parameters, Acts::Vector3{0, 1, 0}); + return res; + } }; -// Estimator of the particle's energy, +// Estimator of the particle's energy, // vertex, momentum direction at the IP // and the direction at the first hit class TrackEstimator { - public: - Vector3 ip; - - std::tuple - operator()( - const GeometryContext& /*geoCtx*/, - const Vector3& pivot) const { - Vector3 direction = (pivot - ip).normalized(); - return {1._GeV, ip, direction, direction}; - }; + public: + Vector3 ip; + + std::tuple operator()( + const GeometryContext& /*geoCtx*/, const Vector3& pivot) const { + Vector3 direction = (pivot - ip).normalized(); + return {1._GeV, ip, direction, direction}; + }; }; // Construct a simple telescope detector -std::shared_ptr -constructTelescopeDetector() { - RotationMatrix3 rotation; - double angle = 90_degree; - Vector3 xPos(cos(angle), 0., sin(angle)); - Vector3 yPos(0., 1., 0.); - Vector3 zPos(-sin(angle), 0., cos(angle)); - rotation.col(0) = xPos; - rotation.col(1) = yPos; - rotation.col(2) = zPos; - - // Create a bunch of surface bounds - auto surf0bounds = - std::make_unique(halfY, halfZ); - - auto surf1bounds = - std::make_unique(halfY, halfZ); - - auto surf2bounds = - std::make_unique(halfY, halfZ); - - auto surf3bounds = - std::make_unique(halfY, halfZ); - - // Create a bunch of surfaces - auto transform0 = Transform3::Identity(); - auto surf0 = Surface::makeShared( - transform0 * Transform3(rotation), std::move(surf0bounds)); - auto geoId0 = GeometryIdentifier(); - geoId0.setSensitive(1); - - auto transform1 = - Transform3::Identity() * - Translation3(Vector3(2*deltaX, 0, 0)); - auto surf1 = Surface::makeShared( - transform1 * Transform3(rotation), std::move(surf1bounds)); - auto geoId1 = GeometryIdentifier(); - geoId1.setSensitive(2); - - auto transform2 = - Transform3::Identity() * - Translation3(Vector3(4*deltaX, 0, 0)); - auto surf2 = Surface::makeShared( - transform2 * Transform3(rotation), std::move(surf2bounds)); - auto geoId2 = GeometryIdentifier(); - geoId2.setSensitive(3); - - auto transform3 = - Transform3::Identity() * - Translation3(Vector3(6*deltaX, 0, 0)); - auto surf3 = Surface::makeShared( - transform3 * Transform3(rotation), std::move(surf3bounds)); - auto geoId3 = GeometryIdentifier(); - geoId3.setSensitive(4); - - // Create a bunch of volume bounds - auto vol0bounds = - std::make_unique( - deltaX, - halfY + deltaYZ, - halfZ + deltaYZ); - - auto vol1bounds = - std::make_unique( - deltaX, - halfY + deltaYZ, - halfZ + deltaYZ); - - auto vol2bounds = - std::make_unique( - deltaX, - halfY + deltaYZ, - halfZ + deltaYZ); - - auto vol3bounds = - std::make_unique( - deltaX, - halfY + deltaYZ, - halfZ + deltaYZ); - - // Create a bunch of volumes - auto vol0 = Experimental::DetectorVolumeFactory::construct( - Experimental::defaultPortalAndSubPortalGenerator(), gctx, - "vol0", transform0, std::move(vol0bounds), {surf0}, {}, - Experimental::tryNoVolumes(), - Experimental::tryAllPortalsAndSurfaces()); - - auto vol1 = Experimental::DetectorVolumeFactory::construct( - Experimental::defaultPortalAndSubPortalGenerator(), gctx, - "vol1", transform1, std::move(vol1bounds), {surf1}, {}, - Experimental::tryNoVolumes(), - Experimental::tryAllPortalsAndSurfaces()); - - auto vol2 = Experimental::DetectorVolumeFactory::construct( - Experimental::defaultPortalAndSubPortalGenerator(), gctx, - "vol2", transform2, std::move(vol2bounds), {surf2}, {}, - Experimental::tryNoVolumes(), - Experimental::tryAllPortalsAndSurfaces()); - - auto vol3 = Experimental::DetectorVolumeFactory::construct( - Experimental::defaultPortalAndSubPortalGenerator(), gctx, - "vol3", transform3, std::move(vol3bounds), {surf3}, {}, - Experimental::tryNoVolumes(), - Experimental::tryAllPortalsAndSurfaces()); - - std::vector> volumes = - {vol0, vol1, vol2, vol3}; - - // Connect the volumes - auto portalContainer = - Experimental::detail::CuboidalDetectorHelper::connect( - gctx, volumes, BinningValue::binX, {}, - Logging::VERBOSE); - - // Make sure that the geometry ids are - // independent of the potential Id generation - // changes - int id = 1; - - // Volume ids - for (auto& volume : volumes) { - volume->assignGeometryId(id); - id++; - } - // Intervolume portal ids - for (auto& volume : volumes) { - for (auto& port : volume->portalPtrs()) { - if (port->surface().geometryId() == 0) { - port->surface().assignGeometryId(id); - id++; - } - } - } - // Surface ids - for (auto& surf : {surf0, surf1, surf2, surf3}) { - auto geoId = GeometryIdentifier(); - geoId.setSensitive(id); - surf->assignGeometryId(geoId); +std::shared_ptr constructTelescopeDetector() { + RotationMatrix3 rotation; + double angle = 90_degree; + Vector3 xPos(cos(angle), 0., sin(angle)); + Vector3 yPos(0., 1., 0.); + Vector3 zPos(-sin(angle), 0., cos(angle)); + rotation.col(0) = xPos; + rotation.col(1) = yPos; + rotation.col(2) = zPos; + + // Create a bunch of surface bounds + auto surf0bounds = std::make_unique(halfY, halfZ); + + auto surf1bounds = std::make_unique(halfY, halfZ); + + auto surf2bounds = std::make_unique(halfY, halfZ); + + auto surf3bounds = std::make_unique(halfY, halfZ); + + // Create a bunch of surfaces + auto transform0 = Transform3::Identity(); + auto surf0 = Surface::makeShared( + transform0 * Transform3(rotation), std::move(surf0bounds)); + auto geoId0 = GeometryIdentifier(); + geoId0.setSensitive(1); + + auto transform1 = + Transform3::Identity() * Translation3(Vector3(2 * deltaX, 0, 0)); + auto surf1 = Surface::makeShared( + transform1 * Transform3(rotation), std::move(surf1bounds)); + auto geoId1 = GeometryIdentifier(); + geoId1.setSensitive(2); + + auto transform2 = + Transform3::Identity() * Translation3(Vector3(4 * deltaX, 0, 0)); + auto surf2 = Surface::makeShared( + transform2 * Transform3(rotation), std::move(surf2bounds)); + auto geoId2 = GeometryIdentifier(); + geoId2.setSensitive(3); + + auto transform3 = + Transform3::Identity() * Translation3(Vector3(6 * deltaX, 0, 0)); + auto surf3 = Surface::makeShared( + transform3 * Transform3(rotation), std::move(surf3bounds)); + auto geoId3 = GeometryIdentifier(); + geoId3.setSensitive(4); + + // Create a bunch of volume bounds + auto vol0bounds = std::make_unique( + deltaX, halfY + deltaYZ, halfZ + deltaYZ); + + auto vol1bounds = std::make_unique( + deltaX, halfY + deltaYZ, halfZ + deltaYZ); + + auto vol2bounds = std::make_unique( + deltaX, halfY + deltaYZ, halfZ + deltaYZ); + + auto vol3bounds = std::make_unique( + deltaX, halfY + deltaYZ, halfZ + deltaYZ); + + // Create a bunch of volumes + auto vol0 = Experimental::DetectorVolumeFactory::construct( + Experimental::defaultPortalAndSubPortalGenerator(), gctx, "vol0", + transform0, std::move(vol0bounds), {surf0}, {}, + Experimental::tryNoVolumes(), Experimental::tryAllPortalsAndSurfaces()); + + auto vol1 = Experimental::DetectorVolumeFactory::construct( + Experimental::defaultPortalAndSubPortalGenerator(), gctx, "vol1", + transform1, std::move(vol1bounds), {surf1}, {}, + Experimental::tryNoVolumes(), Experimental::tryAllPortalsAndSurfaces()); + + auto vol2 = Experimental::DetectorVolumeFactory::construct( + Experimental::defaultPortalAndSubPortalGenerator(), gctx, "vol2", + transform2, std::move(vol2bounds), {surf2}, {}, + Experimental::tryNoVolumes(), Experimental::tryAllPortalsAndSurfaces()); + + auto vol3 = Experimental::DetectorVolumeFactory::construct( + Experimental::defaultPortalAndSubPortalGenerator(), gctx, "vol3", + transform3, std::move(vol3bounds), {surf3}, {}, + Experimental::tryNoVolumes(), Experimental::tryAllPortalsAndSurfaces()); + + std::vector> volumes = { + vol0, vol1, vol2, vol3}; + + // Connect the volumes + auto portalContainer = Experimental::detail::CuboidalDetectorHelper::connect( + gctx, volumes, BinningValue::binX, {}, Logging::VERBOSE); + + // Make sure that the geometry ids are + // independent of the potential Id generation + // changes + int id = 1; + + // Volume ids + for (auto& volume : volumes) { + volume->assignGeometryId(id); + id++; + } + // Intervolume portal ids + for (auto& volume : volumes) { + for (auto& port : volume->portalPtrs()) { + if (port->surface().geometryId() == 0) { + port->surface().assignGeometryId(id); id++; + } } - - auto detector = Experimental::Detector::makeShared( - "TelescopeDetector", volumes, - Experimental::tryRootVolumes()); - - return detector; + } + // Surface ids + for (auto& surf : {surf0, surf1, surf2, surf3}) { + auto geoId = GeometryIdentifier(); + geoId.setSensitive(id); + surf->assignGeometryId(geoId); + id++; + } + + auto detector = Experimental::Detector::makeShared( + "TelescopeDetector", volumes, Experimental::tryRootVolumes()); + + return detector; }; std::vector createSourceLinks( - const GeometryContext& geoCtx, - const Experimental::Detector& detector) { - NoFieldIntersectionFinder intersectionFinder; - - for (auto volume : detector.volumes()) { - for (auto surface : volume->surfaces()) { - intersectionFinder.m_surfaces.push_back(surface); - } - } - - Vector3 vertex(-5., 0., 0.); - std::vector phis = {-0.15, -0.1, -0.05, 0, 0.05, 0.1, 0.15}; - - std::vector sourceLinks; - for (ActsScalar phi : phis) { - Vector3 direction(cos(phi), sin(phi), 0.); - - auto intersections = intersectionFinder( - geoCtx, vertex, direction); - - SquareMatrix2 cov = Acts::SquareMatrix2::Identity(); - - for (auto& [id,refPoint] : intersections) { - auto surf = *detector.sensitiveHierarchyMap().find(id); - Acts::Vector2 val = - surf->globalToLocal( - geoCtx, refPoint, - direction).value(); - - Acts::detail::Test::TestSourceLink sourceLink( - eBoundLoc0, eBoundLoc1, - val, cov, - id, - id.value()); - - Acts::SourceLink sl{sourceLink}; - sourceLinks.push_back(sl); - } - } - - return sourceLinks; + const GeometryContext& geoCtx, const Experimental::Detector& detector) { + NoFieldIntersectionFinder intersectionFinder; + + for (auto volume : detector.volumes()) { + for (auto surface : volume->surfaces()) { + intersectionFinder.m_surfaces.push_back(surface); + } + } + + Vector3 vertex(-5., 0., 0.); + std::vector phis = {-0.15, -0.1, -0.05, 0, 0.05, 0.1, 0.15}; + + std::vector sourceLinks; + for (ActsScalar phi : phis) { + Vector3 direction(cos(phi), sin(phi), 0.); + + auto intersections = intersectionFinder(geoCtx, vertex, direction); + + SquareMatrix2 cov = Acts::SquareMatrix2::Identity(); + + for (auto& [id, refPoint] : intersections) { + auto surf = *detector.sensitiveHierarchyMap().find(id); + Acts::Vector2 val = + surf->globalToLocal(geoCtx, refPoint, direction).value(); + + Acts::detail::Test::TestSourceLink sourceLink(eBoundLoc0, eBoundLoc1, val, + cov, id, id.value()); + + Acts::SourceLink sl{sourceLink}; + sourceLinks.push_back(sl); + } + } + + return sourceLinks; } BOOST_AUTO_TEST_CASE(PathSeederZeroField) { - // Create detector - auto detector = constructTelescopeDetector(); - - // Create source links - auto sourceLinks = createSourceLinks(gctx, *detector); - - // Prepare the PathSeeder - auto pathSeederCfg = Acts::PathSeeder::Config(); - - // Grid to bin the source links - Acts::detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor; - surfaceAccessor.detector = detector.get(); - auto sourceLinkGrid = std::make_shared(); - sourceLinkGrid->m_surfaceAccessor.connect< - &Acts::detail::Test::TestSourceLink::SurfaceAccessor::operator()>( - &surfaceAccessor); - pathSeederCfg.sourceLinkGrid = sourceLinkGrid; - - // Estimator of the IP and first hit - // parameters of the track - TrackEstimator trackEstimator; - trackEstimator.ip = Vector3(-5., 0., 0.); - pathSeederCfg.trackEstimator.connect<&TrackEstimator::operator()>( - &trackEstimator); - - // Transforms the source links to global coordinates - SourceLinkCalibrator sourceLinkCalibrator; - sourceLinkCalibrator.m_surfaceAccessor.connect< - &Acts::detail::Test::TestSourceLink::SurfaceAccessor::operator()>( - &surfaceAccessor); - pathSeederCfg.sourceLinkCalibrator.connect<&SourceLinkCalibrator::operator()>( - &sourceLinkCalibrator); - - // Intersection finder - auto intersectionFinder = NoFieldIntersectionFinder(); - for (auto volume : detector->volumes()) { - for (auto surface : volume->surfaces()) { - intersectionFinder.m_surfaces.push_back(surface); - } - } - pathSeederCfg.intersectionFinder.connect<&NoFieldIntersectionFinder::operator()>( - &intersectionFinder); - - // Path width provider - auto pathWidthProvider = PathWidthProvider(); - pathSeederCfg.pathWidthProvider.connect<&PathWidthProvider::operator()>( - &pathWidthProvider); - - // First tracking layer - Extent firstLayerExtent; - firstLayerExtent.set( - Acts::binX, -0.1, 0.1); - firstLayerExtent.set( - Acts::binY, -halfY - deltaYZ, halfY + deltaYZ); - firstLayerExtent.set( - Acts::binZ, -halfZ - deltaYZ, halfZ + deltaYZ); - - pathSeederCfg.firstLayerExtent = firstLayerExtent; - - // Create the PathSeeder - Acts::PathSeeder pathSeeder(pathSeederCfg); - - // Get the seeds - auto seeds = pathSeeder.getSeeds(gctx, sourceLinks); - - // Check the seeds - BOOST_CHECK_EQUAL(seeds.size(), 7); - for (auto& seed : seeds) { - BOOST_CHECK_EQUAL(seed.sourceLinks.size(), 4); - BOOST_CHECK_EQUAL(seed.ipVertex, Vector3(-5., 0., 0.)); - BOOST_CHECK_EQUAL(seed.ipP, 1._GeV); + // Create detector + auto detector = constructTelescopeDetector(); + + // Create source links + auto sourceLinks = createSourceLinks(gctx, *detector); + + // Prepare the PathSeeder + auto pathSeederCfg = Acts::PathSeeder::Config(); + + // Grid to bin the source links + Acts::detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor; + surfaceAccessor.detector = detector.get(); + auto sourceLinkGrid = std::make_shared(); + sourceLinkGrid->m_surfaceAccessor.connect< + &Acts::detail::Test::TestSourceLink::SurfaceAccessor::operator()>( + &surfaceAccessor); + pathSeederCfg.sourceLinkGrid = sourceLinkGrid; + + // Estimator of the IP and first hit + // parameters of the track + TrackEstimator trackEstimator; + trackEstimator.ip = Vector3(-5., 0., 0.); + pathSeederCfg.trackEstimator.connect<&TrackEstimator::operator()>( + &trackEstimator); + + // Transforms the source links to global coordinates + SourceLinkCalibrator sourceLinkCalibrator; + sourceLinkCalibrator.m_surfaceAccessor.connect< + &Acts::detail::Test::TestSourceLink::SurfaceAccessor::operator()>( + &surfaceAccessor); + pathSeederCfg.sourceLinkCalibrator.connect<&SourceLinkCalibrator::operator()>( + &sourceLinkCalibrator); + + // Intersection finder + auto intersectionFinder = NoFieldIntersectionFinder(); + for (auto volume : detector->volumes()) { + for (auto surface : volume->surfaces()) { + intersectionFinder.m_surfaces.push_back(surface); } + } + pathSeederCfg.intersectionFinder + .connect<&NoFieldIntersectionFinder::operator()>(&intersectionFinder); + + // Path width provider + auto pathWidthProvider = PathWidthProvider(); + pathSeederCfg.pathWidthProvider.connect<&PathWidthProvider::operator()>( + &pathWidthProvider); + + // First tracking layer + Extent firstLayerExtent; + firstLayerExtent.set(Acts::binX, -0.1, 0.1); + firstLayerExtent.set(Acts::binY, -halfY - deltaYZ, halfY + deltaYZ); + firstLayerExtent.set(Acts::binZ, -halfZ - deltaYZ, halfZ + deltaYZ); + + pathSeederCfg.firstLayerExtent = firstLayerExtent; + + // Create the PathSeeder + Acts::PathSeeder pathSeeder(pathSeederCfg); + + // Get the seeds + auto seeds = pathSeeder.getSeeds(gctx, sourceLinks); + + // Check the seeds + BOOST_CHECK_EQUAL(seeds.size(), 7); + for (auto& seed : seeds) { + BOOST_CHECK_EQUAL(seed.sourceLinks.size(), 4); + BOOST_CHECK_EQUAL(seed.ipVertex, Vector3(-5., 0., 0.)); + BOOST_CHECK_EQUAL(seed.ipP, 1._GeV); + } } BOOST_AUTO_TEST_SUITE_END() diff --git a/Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp b/Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp index 06174e88dd8..bc09775e54a 100644 --- a/Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp +++ b/Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp @@ -352,7 +352,7 @@ static inline std::string testMultiTrajectory(IVisualization3D& helper) { .connect<&Acts::GainMatrixSmoother::operator()>( &kfSmoother); - detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor{*detector}; + detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor{detector.get()}; extensions.surfaceAccessor .connect<&detail::Test::TestSourceLink::SurfaceAccessor::operator()>( &surfaceAccessor); From e51586a90bd74542637f3b32feed06c7cf687309 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 17 Jun 2024 13:03:36 +0300 Subject: [PATCH 03/28] minor test fix --- Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp index 77549e821cf..15803e0bd95 100644 --- a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp +++ b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp @@ -296,7 +296,7 @@ BOOST_AUTO_TEST_CASE(ZeroFieldKalmanAlignment) { // Construct the KalmanFitter options auto extensions = getExtensions(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); KalmanFitterOptions kfOptions(geoCtx, magCtx, calCtx, extensions, From 51c71dee96bd7cd171582b360c363f3e98d82e5d Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 17 Jun 2024 13:15:47 +0300 Subject: [PATCH 04/28] pedantic fix --- Tests/UnitTests/Core/Seeding/PathSeederTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 82afa1acaa1..250788e0e31 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -295,7 +295,7 @@ std::shared_ptr constructTelescopeDetector() { "TelescopeDetector", volumes, Experimental::tryRootVolumes()); return detector; -}; +} std::vector createSourceLinks( const GeometryContext& geoCtx, const Experimental::Detector& detector) { From 1bec75f5c7e0484fa76c7631d4d91817c6be2db5 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 17 Jun 2024 14:39:02 +0300 Subject: [PATCH 05/28] tidy fixes --- .../Acts/EventData/detail/TestSourceLink.hpp | 4 ++-- Core/include/Acts/Seeding/PathSeeder.hpp | 22 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Core/include/Acts/EventData/detail/TestSourceLink.hpp b/Core/include/Acts/EventData/detail/TestSourceLink.hpp index fe32029019b..faa9ec31bf0 100644 --- a/Core/include/Acts/EventData/detail/TestSourceLink.hpp +++ b/Core/include/Acts/EventData/detail/TestSourceLink.hpp @@ -95,9 +95,9 @@ struct TestSourceLink final { const Acts::Surface* operator()(const Acts::SourceLink& sourceLink) const { const auto& testSourceLink = sourceLink.get(); - if (trackingGeometry) { + if (trackingGeometry != nullptr) { return trackingGeometry->findSurface(testSourceLink.m_geometryId); - } else if (detector) { + } else if (detector != nullptr) { return *detector->sensitiveHierarchyMap().find( testSourceLink.m_geometryId); } else { diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 90280b97226..2ef45977d5f 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -29,6 +29,11 @@ class PathSeeder { Vector3 ipDir; Vector3 ipVertex; std::vector sourceLinks; + + Seed() = delete; + Seed(ActsScalar ipPmag, Vector3 ipPdir, Vector3 ipPos, + std::vector sls) + : ipP(ipPmag), ipDir(ipPdir), ipVertex(ipPos), sourceLinks(sls){}; }; using SourceLinkCalibrator = @@ -84,16 +89,14 @@ class PathSeeder { // Get plane of the telescope // sensitive surfaces - BinningValue bin0, bin1; + BinningValue bin0 = binX; + BinningValue bin1 = binY; if (m_cfg.orientation == binX) { bin0 = binY; bin1 = binZ; } else if (m_cfg.orientation == binY) { bin0 = binX; bin1 = binZ; - } else { - bin0 = binX; - bin1 = binY; } // Create the seeds @@ -122,12 +125,6 @@ class PathSeeder { // Vector to store the source links std::vector seedSourceLinks; - // Store the IP parameters - Seed seed; - seed.ipP = ipP; - seed.ipDir = ipDir; - seed.ipVertex = ipVertex; - // Store the pivot source link seedSourceLinks.push_back(sl); @@ -168,8 +165,9 @@ class PathSeeder { } } - // Add the source links to the seed - seed.sourceLinks = seedSourceLinks; + // Store the IP parameters and + // add the source links to the seed + Seed seed{ipP, ipDir, ipVertex, seedSourceLinks}; // Add the seed to the list seeds.push_back(seed); From 048f6d4754509874cf34e11052f476329a3d6551 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 17 Jun 2024 15:28:31 +0300 Subject: [PATCH 06/28] another tidy fix --- Core/include/Acts/Seeding/PathSeeder.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 2ef45977d5f..5b0d9483840 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -33,7 +33,10 @@ class PathSeeder { Seed() = delete; Seed(ActsScalar ipPmag, Vector3 ipPdir, Vector3 ipPos, std::vector sls) - : ipP(ipPmag), ipDir(ipPdir), ipVertex(ipPos), sourceLinks(sls){}; + : ipP(ipPmag), + ipDir(std::move(ipPdir)), + ipVertex(std::move(ipPos)), + sourceLinks(std::move(sls)){}; }; using SourceLinkCalibrator = From d5f8637c0d1ea5c235c8bab3716c876028213d0b Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 11 Jul 2024 11:16:53 +0300 Subject: [PATCH 07/28] remove Measurement --- Core/include/Acts/EventData/detail/TestSourceLink.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/include/Acts/EventData/detail/TestSourceLink.hpp b/Core/include/Acts/EventData/detail/TestSourceLink.hpp index f8609119a82..2a2e509e34d 100644 --- a/Core/include/Acts/EventData/detail/TestSourceLink.hpp +++ b/Core/include/Acts/EventData/detail/TestSourceLink.hpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Detector/Detector.hpp" -#include "Acts/EventData/Measurement.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/SourceLink.hpp" #include "Acts/Geometry/GeometryContext.hpp" From bd304060c7b495efef005a6f6b227beb65bfda65 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 11 Jul 2024 11:23:58 +0300 Subject: [PATCH 08/28] fixing includes --- Core/include/Acts/Seeding/ISourceLinkGrid.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp index 1e11755ef1a..5904e59e5f1 100644 --- a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp +++ b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp @@ -12,7 +12,7 @@ #include "Acts/EventData/SourceLink.hpp" #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/Utilities/Grid.hpp" -#include "Acts/Utilities/detail/Axis.hpp" +#include "Acts/Utilities/Axis.hpp" namespace Acts { From 972d0e71a88d90744c4a35997f0e3f256ec25ebc Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 11 Jul 2024 12:28:39 +0300 Subject: [PATCH 09/28] compatibility fixes --- Core/include/Acts/Seeding/ISourceLinkGrid.hpp | 2 +- Core/include/Acts/Seeding/PathSeeder.hpp | 18 +++++++++--------- .../UnitTests/Core/Seeding/PathSeederTest.cpp | 14 ++++++++------ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp index 5904e59e5f1..d1dbdd46bb2 100644 --- a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp +++ b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp @@ -11,8 +11,8 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/EventData/SourceLink.hpp" #include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Utilities/Grid.hpp" #include "Acts/Utilities/Axis.hpp" +#include "Acts/Utilities/Grid.hpp" namespace Acts { diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 5b0d9483840..151178f401e 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -69,7 +69,7 @@ class PathSeeder { /// First layer extent Extent firstLayerExtent; /// Direction of the telescope extent - BinningValue orientation = binX; + BinningValue orientation = BinningValue::binX; }; /// @brief Constructor @@ -92,14 +92,14 @@ class PathSeeder { // Get plane of the telescope // sensitive surfaces - BinningValue bin0 = binX; - BinningValue bin1 = binY; - if (m_cfg.orientation == binX) { - bin0 = binY; - bin1 = binZ; - } else if (m_cfg.orientation == binY) { - bin0 = binX; - bin1 = binZ; + int bin0 = static_cast(BinningValue::binX); + int bin1 = static_cast(BinningValue::binY); + if (m_cfg.orientation == BinningValue::binX) { + bin0 = static_cast(BinningValue::binY); + bin1 = static_cast(BinningValue::binZ); + } else if (m_cfg.orientation == BinningValue::binY) { + bin0 = static_cast(BinningValue::binX); + bin1 = static_cast(BinningValue::binZ); } // Create the seeds diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 250788e0e31..289fc5e5c4f 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -24,6 +24,7 @@ #include "Acts/Propagator/Propagator.hpp" #include "Acts/Propagator/StraightLineStepper.hpp" #include "Acts/Seeding/PathSeeder.hpp" +#include "Acts/Surfaces/BoundaryTolerance.hpp" #include "Acts/Surfaces/PlaneSurface.hpp" #include "Acts/Surfaces/RectangleBounds.hpp" #include "Acts/Tests/CommonHelpers/MeasurementsCreator.hpp" @@ -34,7 +35,7 @@ BOOST_AUTO_TEST_SUITE(PathSeeder) using namespace Acts; using namespace Acts::UnitLiterals; -using Axis = Acts::detail::EquidistantAxis; +using Axis = Acts::Axis; GeometryContext gctx; @@ -63,8 +64,9 @@ class NoFieldIntersectionFinder { // Intersect the surfaces for (auto& surface : m_surfaces) { // Get the intersection - auto sMultiIntersection = surface->intersect(geoCtx, position, direction, - BoundaryCheck(true), tol); + auto sMultiIntersection = + surface->intersect(geoCtx, position, direction, + BoundaryTolerance::AbsoluteCartesian(tol, tol)); // Take the closest auto closestForward = sMultiIntersection.closestForward(); @@ -385,9 +387,9 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { // First tracking layer Extent firstLayerExtent; - firstLayerExtent.set(Acts::binX, -0.1, 0.1); - firstLayerExtent.set(Acts::binY, -halfY - deltaYZ, halfY + deltaYZ); - firstLayerExtent.set(Acts::binZ, -halfZ - deltaYZ, halfZ + deltaYZ); + firstLayerExtent.set(BinningValue::binX, -0.1, 0.1); + firstLayerExtent.set(BinningValue::binY, -halfY - deltaYZ, halfY + deltaYZ); + firstLayerExtent.set(BinningValue::binZ, -halfZ - deltaYZ, halfZ + deltaYZ); pathSeederCfg.firstLayerExtent = firstLayerExtent; From a68e6d78600b1057ee541653dfbcd388d965c85f Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 11 Jul 2024 12:35:14 +0300 Subject: [PATCH 10/28] cleanup --- .../UnitTests/Core/Seeding/PathSeederTest.cpp | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 289fc5e5c4f..aba79c47c87 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -110,16 +110,16 @@ class SourceLinkGrid : public ISourceLinkGrid { } // Fill the grid with source links for (auto& sl : sourceLinks) { - auto ssl = sl.get(); + auto ssl = sl.get(); auto id = ssl.m_geometryId; // Grid works with global positions - Acts::Vector3 globalPos = m_surfaceAccessor(sl)->localToGlobal( - geoCtx, ssl.parameters, Acts::Vector3{0, 1, 0}); + Vector3 globalPos = m_surfaceAccessor(sl)->localToGlobal( + geoCtx, ssl.parameters, Vector3{0, 1, 0}); - auto bin = lookupTable.at(id.sensitive()) - .localBinsFromPosition( - Acts::Vector2(globalPos.y(), globalPos.z())); + auto bin = + lookupTable.at(id.sensitive()) + .localBinsFromPosition(Vector2(globalPos.y(), globalPos.z())); lookupTable.at(id.sensitive()).atLocalBins(bin).push_back(sl); } @@ -127,8 +127,7 @@ class SourceLinkGrid : public ISourceLinkGrid { }; // Get the source link grid for a given geometry id - eGrid getSourceLinkTable( - const Acts::GeometryIdentifier& geoId) const override { + eGrid getSourceLinkTable(const GeometryIdentifier& geoId) const override { return m_lookupTables.at(geoId.sensitive()); } }; @@ -153,12 +152,11 @@ class SourceLinkCalibrator { public: SourceLinkSurfaceAccessor m_surfaceAccessor; - Acts::Vector3 operator()(const GeometryContext& geoCtx, - const Acts::SourceLink& sourceLink) const { - auto ssl = sourceLink.get(); - auto res = - m_surfaceAccessor(sourceLink) - ->localToGlobal(geoCtx, ssl.parameters, Acts::Vector3{0, 1, 0}); + Vector3 operator()(const GeometryContext& geoCtx, + const SourceLink& sourceLink) const { + auto ssl = sourceLink.get(); + auto res = m_surfaceAccessor(sourceLink) + ->localToGlobal(geoCtx, ssl.parameters, Vector3{0, 1, 0}); return res; } }; @@ -318,17 +316,16 @@ std::vector createSourceLinks( auto intersections = intersectionFinder(geoCtx, vertex, direction); - SquareMatrix2 cov = Acts::SquareMatrix2::Identity(); + SquareMatrix2 cov = SquareMatrix2::Identity(); for (auto& [id, refPoint] : intersections) { auto surf = *detector.sensitiveHierarchyMap().find(id); - Acts::Vector2 val = - surf->globalToLocal(geoCtx, refPoint, direction).value(); + Vector2 val = surf->globalToLocal(geoCtx, refPoint, direction).value(); - Acts::detail::Test::TestSourceLink sourceLink(eBoundLoc0, eBoundLoc1, val, - cov, id, id.value()); + detail::Test::TestSourceLink sourceLink(eBoundLoc0, eBoundLoc1, val, cov, + id, id.value()); - Acts::SourceLink sl{sourceLink}; + SourceLink sl{sourceLink}; sourceLinks.push_back(sl); } } @@ -347,12 +344,12 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { auto pathSeederCfg = Acts::PathSeeder::Config(); // Grid to bin the source links - Acts::detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor; + detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor; surfaceAccessor.detector = detector.get(); auto sourceLinkGrid = std::make_shared(); - sourceLinkGrid->m_surfaceAccessor.connect< - &Acts::detail::Test::TestSourceLink::SurfaceAccessor::operator()>( - &surfaceAccessor); + sourceLinkGrid->m_surfaceAccessor + .connect<&detail::Test::TestSourceLink::SurfaceAccessor::operator()>( + &surfaceAccessor); pathSeederCfg.sourceLinkGrid = sourceLinkGrid; // Estimator of the IP and first hit From 149c28100a312fe098d6baef2ff0f638faba6c3c Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 11 Jul 2024 15:44:02 +0300 Subject: [PATCH 11/28] test commit From a9954775e02d4a1f9c79b1d2f49ff3a9e8b01e6a Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 11 Jul 2024 16:17:00 +0300 Subject: [PATCH 12/28] bumping the CI test --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 25ba774defd..a567761c29a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -352,7 +352,7 @@ linux_ubuntu_2204_cpp20: <<: *linux_ubuntu_extra variables: CXXSTD: 20 - image: ghcr.io/acts-project/ubuntu2204_cpp20:v41 + image: ghcr.io/acts-project/ubuntu2204_cpp20:51 linux_ubuntu_2204_clang: <<: *linux_ubuntu_extra From eb9378548e841bd610ace0a89e7b2753cd930720 Mon Sep 17 00:00:00 2001 From: ssdetlab <113530373+ssdetlab@users.noreply.github.com> Date: Sun, 14 Jul 2024 01:08:50 +0300 Subject: [PATCH 13/28] Update .gitlab-ci.yml --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1173dac8ca9..64e12d877a2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -348,7 +348,6 @@ linux_ubuntu_2404: CXXSTD: 20 image: ghcr.io/acts-project/ubuntu2404:52 - linux_ubuntu_2204_clang: <<: *linux_ubuntu_extra variables: From acac6e43b481b88079e86d308da316ba9e087426 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 25 Jul 2024 15:24:13 +0300 Subject: [PATCH 14/28] Experimental namespace and charge --- Core/include/Acts/Seeding/PathSeeder.hpp | 12 ++++++++---- Tests/UnitTests/Core/Seeding/PathSeederTest.cpp | 11 ++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 151178f401e..a399ea4eaa0 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -14,6 +14,8 @@ namespace Acts { +namespace Experimental { + /// @brief Seeding algorigthm that extracts /// the IP parameters and sorts the source links /// into possible track candidates @@ -48,10 +50,10 @@ class PathSeeder { using IntersectionLookup = Delegate>( const GeometryContext&, const Vector3&, const Vector3&, - const ActsScalar&)>; + const ActsScalar&, const ActsScalar&)>; using TrackEstimator = - Delegate( + Delegate( const GeometryContext&, const Vector3&)>; /// @brief The nested configuration struct @@ -114,12 +116,12 @@ class PathSeeder { } // Get the IP parameters - auto [ipP, ipVertex, ipDir, flDir] = + auto [q, ipP, ipVertex, ipDir, flDir] = m_cfg.trackEstimator(gctx, globalPos); // Intersect with the surfaces std::vector> intersections = - m_cfg.intersectionFinder(gctx, globalPos, flDir, ipP); + m_cfg.intersectionFinder(gctx, globalPos, flDir, ipP, q); // Continue if no intersections if (intersections.empty()) { @@ -182,4 +184,6 @@ class PathSeeder { Config m_cfg; }; +} // namespace Experimental + } // namespace Acts diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index aba79c47c87..029e5b36b48 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -59,7 +59,8 @@ class NoFieldIntersectionFinder { std::vector> operator()( const GeometryContext& geoCtx, const Vector3& position, const Vector3& direction, - [[maybe_unused]] const ActsScalar& Pmag = 0) const { + [[maybe_unused]] const ActsScalar& Pmag = 0, + [[maybe_unused]] const ActsScalar& Charge = 0) const { std::vector> sIntersections; // Intersect the surfaces for (auto& surface : m_surfaces) { @@ -168,10 +169,10 @@ class TrackEstimator { public: Vector3 ip; - std::tuple operator()( + std::tuple operator()( const GeometryContext& /*geoCtx*/, const Vector3& pivot) const { Vector3 direction = (pivot - ip).normalized(); - return {1._GeV, ip, direction, direction}; + return {1_e, 1._GeV, ip, direction, direction}; }; }; @@ -341,7 +342,7 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { auto sourceLinks = createSourceLinks(gctx, *detector); // Prepare the PathSeeder - auto pathSeederCfg = Acts::PathSeeder::Config(); + auto pathSeederCfg = Acts::Experimental::PathSeeder::Config(); // Grid to bin the source links detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor; @@ -391,7 +392,7 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { pathSeederCfg.firstLayerExtent = firstLayerExtent; // Create the PathSeeder - Acts::PathSeeder pathSeeder(pathSeederCfg); + Acts::Experimental::PathSeeder pathSeeder(pathSeederCfg); // Get the seeds auto seeds = pathSeeder.getSeeds(gctx, sourceLinks); From 42d5e23c4b1d705651a4314c69d3b24f2c16ccb2 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 25 Jul 2024 16:02:35 +0300 Subject: [PATCH 15/28] format --- Tests/UnitTests/Core/Seeding/PathSeederTest.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 029e5b36b48..74e500b64d5 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -58,8 +58,7 @@ class NoFieldIntersectionFinder { // length std::vector> operator()( const GeometryContext& geoCtx, const Vector3& position, - const Vector3& direction, - [[maybe_unused]] const ActsScalar& Pmag = 0, + const Vector3& direction, [[maybe_unused]] const ActsScalar& Pmag = 0, [[maybe_unused]] const ActsScalar& Charge = 0) const { std::vector> sIntersections; // Intersect the surfaces From 54053ba1ad19976b47b29055a7c66f66ba37ea4a Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Sun, 4 Aug 2024 16:46:55 +0300 Subject: [PATCH 16/28] temporarily fix the tests --- Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index 34c17120903..f7303c81694 100644 --- a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp @@ -566,7 +566,7 @@ BOOST_AUTO_TEST_CASE(UpdatePushedToNewVolume) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; + TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); From 468124fb6c4bdb77345ee8c7b68f1a587b5b497e Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Sun, 4 Aug 2024 17:11:09 +0300 Subject: [PATCH 17/28] expanding documentation --- Core/include/Acts/Seeding/PathSeeder.hpp | 67 +++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index a399ea4eaa0..db871ade4c5 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -20,16 +20,46 @@ namespace Experimental { /// the IP parameters and sorts the source links /// into possible track candidates /// +/// The algorithm to convert the given source links +/// into seeds -- pairs of IP parameters and the corresponding +/// source links -- as follows: First the source links +/// are sorted into a user-defined grid. Then, iteration over the source links +/// is performed. If a source link is attached to a surface that is +/// in the first tracking layer, as defined by the user, the IP parameters +/// are estimated and the tracking layers are intersected to construct the +/// core of the "Path". The source links in the subsequent layers are then +/// added to the seed if they lie within the path width of the core. +/// Both the list of source links and the IP parameters are stored in the seed +/// struct. +/// /// @tparam axis_t Type of the axis to bin /// the source links /// +/// @note The algorithm is designed to be used in the +/// context of a telescope-style geometry. The surfaces +/// are assumed to be planar. +/// +/// @note Handling of the rotated surfaces has to happen +/// in the user-defined delegate functions. template class PathSeeder { public: + /// @brief The seed struct + /// + /// The seed struct contains the IP parameters + /// and the source links that are associated with + /// the seed. struct Seed { + /// The IP momentum magnitude ActsScalar ipP; + + /// The IP momentum direction Vector3 ipDir; + + /// The IP vertex position Vector3 ipVertex; + + /// The source links associated with the seed std::vector sourceLinks; Seed() = delete; @@ -41,17 +71,52 @@ class PathSeeder { sourceLinks(std::move(sls)){}; }; + /// @brief Delegate to transform the source link to the + /// appropriate global frame. + /// + /// @arg The geometry context to use + /// @arg The source link to calibrate + /// + /// @return The global position of the source link measurement using SourceLinkCalibrator = Delegate; + /// @brief Delegate to provide the path width around + /// the intersection point to pull the source links + /// from the grid + /// + /// @arg The geometry context to use + /// @arg The geometry identifier to use if the + /// path width is varied across different tracking layers + /// + /// @return The path width in the bin0 and bin1 direction + /// defined with respect to the surface normal using PathWidthLookup = Delegate( const GeometryContext&, const GeometryIdentifier&)>; + /// @brief Delegate to find the intersections for the given pivot + /// source link + /// + /// @arg The geometry context to use + /// @arg The global position of the pivot source link + /// @arg The momentum direction of the pivot source link + /// at the first tracking layer + /// @arg The IP momentum magnitude + /// @arg The particle charge using IntersectionLookup = Delegate>( const GeometryContext&, const Vector3&, const Vector3&, const ActsScalar&, const ActsScalar&)>; + /// @brief Delegate to estimate the IP parameters + /// and the momentum direction at the first tracking layer + /// + /// @arg The geometry context to use + /// @arg The global position of the pivot source link + /// + /// @return Particle charge, the IP momentum magnitude, the IP vertex position, + /// the IP momentum direction, the momentum direction at the + /// first tracking layer using TrackEstimator = Delegate( const GeometryContext&, const Vector3&)>; @@ -62,7 +127,7 @@ class PathSeeder { std::shared_ptr> sourceLinkGrid; /// Parameters estimator TrackEstimator trackEstimator; - /// Surface accessor + /// SourceLink calibrator SourceLinkCalibrator sourceLinkCalibrator; /// Intersection finder IntersectionLookup intersectionFinder; From fa32185a6a2efb2a38947fcaaf1fdad21515601e Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Tue, 6 Aug 2024 18:50:07 +0300 Subject: [PATCH 18/28] reconcile test source link --- .../UnitTests/Core/Seeding/PathSeederTest.cpp | 9 +++++---- .../SpacePointBuilderTests.cpp | 2 +- .../Core/TrackFitting/FitterTestsCommon.hpp | 2 +- .../UnitTests/Core/TrackFitting/Gx2fTests.cpp | 20 +++++++++---------- .../Visualization/EventDataView3DBase.hpp | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 74e500b64d5..23e4c71b6ab 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -334,6 +334,8 @@ std::vector createSourceLinks( } BOOST_AUTO_TEST_CASE(PathSeederZeroField) { + using SurfaceAccessor = detail::Test::Experimental::TestSourceLinkSurfaceAccessor; + // Create detector auto detector = constructTelescopeDetector(); @@ -344,11 +346,10 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { auto pathSeederCfg = Acts::Experimental::PathSeeder::Config(); // Grid to bin the source links - detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor; - surfaceAccessor.detector = detector.get(); + SurfaceAccessor surfaceAccessor{*detector}; auto sourceLinkGrid = std::make_shared(); sourceLinkGrid->m_surfaceAccessor - .connect<&detail::Test::TestSourceLink::SurfaceAccessor::operator()>( + .connect<&SurfaceAccessor::operator()>( &surfaceAccessor); pathSeederCfg.sourceLinkGrid = sourceLinkGrid; @@ -362,7 +363,7 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { // Transforms the source links to global coordinates SourceLinkCalibrator sourceLinkCalibrator; sourceLinkCalibrator.m_surfaceAccessor.connect< - &Acts::detail::Test::TestSourceLink::SurfaceAccessor::operator()>( + &SurfaceAccessor::operator()>( &surfaceAccessor); pathSeederCfg.sourceLinkCalibrator.connect<&SourceLinkCalibrator::operator()>( &sourceLinkCalibrator); diff --git a/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp b/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp index d510cb7f401..37fced5bf35 100644 --- a/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp +++ b/Tests/UnitTests/Core/SpacePointFormation/SpacePointBuilderTests.cpp @@ -186,7 +186,7 @@ BOOST_DATA_TEST_CASE(SpacePointBuilder_basic, bdata::xrange(1), index) { auto spBuilderConfig = SpacePointBuilderConfig(); spBuilderConfig.trackingGeometry = geometry; - TestSourceLink::SurfaceAccessor surfaceAccessor{geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*geometry}; spBuilderConfig.slSurfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); diff --git a/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp b/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp index 4950936f356..048f29c99b2 100644 --- a/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp +++ b/Tests/UnitTests/Core/TrackFitting/FitterTestsCommon.hpp @@ -127,7 +127,7 @@ struct FitterTester { std::shared_ptr geometry = geometryStore(); Acts::detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor{ - geometry.get()}; + *geometry}; // expected number of measurements for the given detector constexpr static std::size_t nMeasurements = 6u; diff --git a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp index f7303c81694..44ebc963829 100644 --- a/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp +++ b/Tests/UnitTests/Core/TrackFitting/Gx2fTests.cpp @@ -380,7 +380,7 @@ BOOST_AUTO_TEST_CASE(NoFit) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -468,7 +468,7 @@ BOOST_AUTO_TEST_CASE(Fit5Iterations) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -566,7 +566,7 @@ BOOST_AUTO_TEST_CASE(UpdatePushedToNewVolume) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -688,7 +688,7 @@ BOOST_AUTO_TEST_CASE(MixedDetector) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -784,7 +784,7 @@ BOOST_AUTO_TEST_CASE(FitWithBfield) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -882,7 +882,7 @@ BOOST_AUTO_TEST_CASE(relChi2changeCutOff) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -979,7 +979,7 @@ BOOST_AUTO_TEST_CASE(DidNotConverge) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -1052,7 +1052,7 @@ BOOST_AUTO_TEST_CASE(NotEnoughMeasurements) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -1141,7 +1141,7 @@ BOOST_AUTO_TEST_CASE(FindHoles) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); @@ -1247,7 +1247,7 @@ BOOST_AUTO_TEST_CASE(Material) { Experimental::Gx2FitterExtensions extensions; extensions.calibrator .connect<&testSourceLinkCalibrator>(); - TestSourceLink::SurfaceAccessor surfaceAccessor{detector.geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*detector.geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); diff --git a/Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp b/Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp index f657da60ab6..b642b3a5ddc 100644 --- a/Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp +++ b/Tests/UnitTests/Core/Visualization/EventDataView3DBase.hpp @@ -351,7 +351,7 @@ static inline std::string testMultiTrajectory(IVisualization3D& helper) { .connect<&Acts::GainMatrixSmoother::operator()>( &kfSmoother); - detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor{detector.get()}; + detail::Test::TestSourceLink::SurfaceAccessor surfaceAccessor{*detector}; extensions.surfaceAccessor .connect<&detail::Test::TestSourceLink::SurfaceAccessor::operator()>( &surfaceAccessor); From b3456338b6340ad952acbc1d53de27f1e71cc996 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Tue, 6 Aug 2024 18:50:53 +0300 Subject: [PATCH 19/28] format --- Tests/UnitTests/Core/Seeding/PathSeederTest.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 23e4c71b6ab..648b7148602 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -334,7 +334,8 @@ std::vector createSourceLinks( } BOOST_AUTO_TEST_CASE(PathSeederZeroField) { - using SurfaceAccessor = detail::Test::Experimental::TestSourceLinkSurfaceAccessor; + using SurfaceAccessor = + detail::Test::Experimental::TestSourceLinkSurfaceAccessor; // Create detector auto detector = constructTelescopeDetector(); @@ -348,9 +349,8 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { // Grid to bin the source links SurfaceAccessor surfaceAccessor{*detector}; auto sourceLinkGrid = std::make_shared(); - sourceLinkGrid->m_surfaceAccessor - .connect<&SurfaceAccessor::operator()>( - &surfaceAccessor); + sourceLinkGrid->m_surfaceAccessor.connect<&SurfaceAccessor::operator()>( + &surfaceAccessor); pathSeederCfg.sourceLinkGrid = sourceLinkGrid; // Estimator of the IP and first hit @@ -362,8 +362,7 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { // Transforms the source links to global coordinates SourceLinkCalibrator sourceLinkCalibrator; - sourceLinkCalibrator.m_surfaceAccessor.connect< - &SurfaceAccessor::operator()>( + sourceLinkCalibrator.m_surfaceAccessor.connect<&SurfaceAccessor::operator()>( &surfaceAccessor); pathSeederCfg.sourceLinkCalibrator.connect<&SourceLinkCalibrator::operator()>( &sourceLinkCalibrator); From e39d99b078721f7231cc4058c79ed27e08701b1c Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Tue, 6 Aug 2024 18:52:24 +0300 Subject: [PATCH 20/28] alignment fix --- Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp index 122617f8c56..5a388d3a307 100644 --- a/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp +++ b/Tests/UnitTests/Alignment/Kernel/AlignmentTests.cpp @@ -296,7 +296,7 @@ BOOST_AUTO_TEST_CASE(ZeroFieldKalmanAlignment) { // Construct the KalmanFitter options auto extensions = getExtensions(); - TestSourceLink::SurfaceAccessor surfaceAccessor{geometry.get()}; + TestSourceLink::SurfaceAccessor surfaceAccessor{*geometry}; extensions.surfaceAccessor .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor); KalmanFitterOptions kfOptions(geoCtx, magCtx, calCtx, extensions, From 439716c0f350a4f3019902ab23bd7afcc0229593 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Wed, 7 Aug 2024 01:01:58 +0300 Subject: [PATCH 21/28] tidy fix --- Core/include/Acts/Seeding/PathSeeder.hpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index db871ade4c5..e12f7594664 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -12,9 +12,7 @@ #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Delegate.hpp" -namespace Acts { - -namespace Experimental { +namespace Acts::Experimental { /// @brief Seeding algorigthm that extracts /// the IP parameters and sorts the source links @@ -249,6 +247,5 @@ class PathSeeder { Config m_cfg; }; -} // namespace Experimental +} // namespace Acts::Experimental -} // namespace Acts From 4d478e1e07fa758413022f2b41510de97a0ca9d4 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Wed, 7 Aug 2024 10:07:06 +0300 Subject: [PATCH 22/28] format --- Core/include/Acts/Seeding/PathSeeder.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index e12f7594664..730e075aa01 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -248,4 +248,3 @@ class PathSeeder { }; } // namespace Acts::Experimental - From d1e885dbcd441a8bd3884513c3a9f43310530862 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Thu, 15 Aug 2024 22:02:13 +0300 Subject: [PATCH 23/28] lint fixes --- Core/include/Acts/Seeding/PathSeeder.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 730e075aa01..29392862df1 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -66,7 +66,7 @@ class PathSeeder { : ipP(ipPmag), ipDir(std::move(ipPdir)), ipVertex(std::move(ipPos)), - sourceLinks(std::move(sls)){}; + sourceLinks(std::move(sls)) {}; }; /// @brief Delegate to transform the source link to the @@ -138,7 +138,7 @@ class PathSeeder { }; /// @brief Constructor - PathSeeder(const Config& config) : m_cfg(std::move(config)){}; + PathSeeder(const Config& config) : m_cfg(std::move(config)) {}; /// @brief Destructor ~PathSeeder() = default; From 0b93c9187be272a3aaca97ca8333656ff361a732 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 19 Aug 2024 14:40:23 +0300 Subject: [PATCH 24/28] nitpicks and the sourcelink grid consistency --- Core/include/Acts/Seeding/ISourceLinkGrid.hpp | 43 ----------- Core/include/Acts/Seeding/PathSeeder.hpp | 75 +++++++++++-------- .../UnitTests/Core/Seeding/PathSeederTest.cpp | 65 ++++++++-------- 3 files changed, 72 insertions(+), 111 deletions(-) delete mode 100644 Core/include/Acts/Seeding/ISourceLinkGrid.hpp diff --git a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp b/Core/include/Acts/Seeding/ISourceLinkGrid.hpp deleted file mode 100644 index d1dbdd46bb2..00000000000 --- a/Core/include/Acts/Seeding/ISourceLinkGrid.hpp +++ /dev/null @@ -1,43 +0,0 @@ -// This file is part of the Acts project. -// -// Copyright (C) 2024 CERN for the benefit of the Acts project -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#pragma once - -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/EventData/SourceLink.hpp" -#include "Acts/Geometry/GeometryContext.hpp" -#include "Acts/Utilities/Axis.hpp" -#include "Acts/Utilities/Grid.hpp" - -namespace Acts { - -/// @brief Interface class for binning source links -/// into a lookup table -- a grid of source links -/// -/// @tparam axis_t Type of the axis -/// -template -class ISourceLinkGrid { - using slGrid = Grid, axis_t, axis_t>; - - public: - /// @brief Virtual destructor - virtual ~ISourceLinkGrid() = default; - - /// @brief Interface function to sort - /// the source links into the grid - virtual void initialize(const GeometryContext& gctx, - std::vector sourceLinks) = 0; - - /// @brief Interface function to get the - /// grid of source links for a - /// given geometry identifier - virtual slGrid getSourceLinkTable(const GeometryIdentifier& geoId) const = 0; -}; - -} // namespace Acts diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 29392862df1..780a00c805a 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -8,7 +8,6 @@ #pragma once -#include "Acts/Seeding/ISourceLinkGrid.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Delegate.hpp" @@ -39,9 +38,12 @@ namespace Acts::Experimental { /// /// @note Handling of the rotated surfaces has to happen /// in the user-defined delegate functions. -template + +template class PathSeeder { public: + using GridType = grid_t; + /// @brief The seed struct /// /// The seed struct contains the IP parameters @@ -66,9 +68,32 @@ class PathSeeder { : ipP(ipPmag), ipDir(std::move(ipPdir)), ipVertex(std::move(ipPos)), - sourceLinks(std::move(sls)) {}; + sourceLinks(std::move(sls)){}; }; + /// @brief Delegate to provide the relevant grid + /// filled with source links for the given geometry + /// member + /// + /// @arg The geometry identifier to use + /// + /// @return The grid filled with source links + using SourceLinkGridLookup = + Delegate; + + /// @brief Delegate to estimate the IP parameters + /// and the momentum direction at the first tracking layer + /// + /// @arg The geometry context to use + /// @arg The global position of the pivot source link + /// + /// @return Particle charge, the IP momentum magnitude, the IP vertex position, + /// the IP momentum direction, the momentum direction at the + /// first tracking layer + using TrackEstimator = Delegate< + const std::tuple( + const GeometryContext&, const Vector3&)>; + /// @brief Delegate to transform the source link to the /// appropriate global frame. /// @@ -77,20 +102,7 @@ class PathSeeder { /// /// @return The global position of the source link measurement using SourceLinkCalibrator = - Delegate; - - /// @brief Delegate to provide the path width around - /// the intersection point to pull the source links - /// from the grid - /// - /// @arg The geometry context to use - /// @arg The geometry identifier to use if the - /// path width is varied across different tracking layers - /// - /// @return The path width in the bin0 and bin1 direction - /// defined with respect to the surface normal - using PathWidthLookup = Delegate( - const GeometryContext&, const GeometryIdentifier&)>; + Delegate; /// @brief Delegate to find the intersections for the given pivot /// source link @@ -102,27 +114,27 @@ class PathSeeder { /// @arg The IP momentum magnitude /// @arg The particle charge using IntersectionLookup = - Delegate>( + Delegate>( const GeometryContext&, const Vector3&, const Vector3&, const ActsScalar&, const ActsScalar&)>; - /// @brief Delegate to estimate the IP parameters - /// and the momentum direction at the first tracking layer + /// @brief Delegate to provide the path width around + /// the intersection point to pull the source links + /// from the grid /// /// @arg The geometry context to use - /// @arg The global position of the pivot source link + /// @arg The geometry identifier to use if the + /// path width is varied across different tracking layers /// - /// @return Particle charge, the IP momentum magnitude, the IP vertex position, - /// the IP momentum direction, the momentum direction at the - /// first tracking layer - using TrackEstimator = - Delegate( - const GeometryContext&, const Vector3&)>; + /// @return The path width in the bin0 and bin1 direction + /// defined with respect to the surface normal + using PathWidthLookup = Delegate( + const GeometryContext&, const GeometryIdentifier&)>; /// @brief The nested configuration struct struct Config { /// Binned SourceLink provider - std::shared_ptr> sourceLinkGrid; + SourceLinkGridLookup sourceLinkGridLookup; /// Parameters estimator TrackEstimator trackEstimator; /// SourceLink calibrator @@ -138,7 +150,7 @@ class PathSeeder { }; /// @brief Constructor - PathSeeder(const Config& config) : m_cfg(std::move(config)) {}; + PathSeeder(const Config& config) : m_cfg(std::move(config)){}; /// @brief Destructor ~PathSeeder() = default; @@ -152,9 +164,6 @@ class PathSeeder { /// @return The vector of seeds std::vector getSeeds(const GeometryContext& gctx, const std::vector& sourceLinks) const { - // Sort the source links into the grid - m_cfg.sourceLinkGrid->initialize(gctx, sourceLinks); - // Get plane of the telescope // sensitive surfaces int bin0 = static_cast(BinningValue::binX); @@ -210,7 +219,7 @@ class PathSeeder { ActsScalar bot1 = refPoint[bin1] - pathWidth1; // Get the lookup table for the source links - auto grid = m_cfg.sourceLinkGrid->getSourceLinkTable(geoId); + auto grid = m_cfg.sourceLinkGridLookup(geoId); // Get the range of bins to search for source links auto botLeftBin = grid.localBinsFromPosition(Vector2(bot0, bot1)); diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 648b7148602..871d93b802f 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -36,6 +36,7 @@ using namespace Acts; using namespace Acts::UnitLiterals; using Axis = Acts::Axis; +using Grid = Acts::Grid, Axis, Axis>; GeometryContext gctx; @@ -49,14 +50,14 @@ const ActsScalar deltaYZ = 1.; // region of interest for seeding class NoFieldIntersectionFinder { public: - ActsScalar tol = 1e-4; + ActsScalar m_tol = 1e-4; std::vector m_surfaces; // Find the intersections along the path // and return them in the order of the path // length - std::vector> operator()( + const std::vector> operator()( const GeometryContext& geoCtx, const Vector3& position, const Vector3& direction, [[maybe_unused]] const ActsScalar& Pmag = 0, [[maybe_unused]] const ActsScalar& Charge = 0) const { @@ -64,9 +65,9 @@ class NoFieldIntersectionFinder { // Intersect the surfaces for (auto& surface : m_surfaces) { // Get the intersection - auto sMultiIntersection = - surface->intersect(geoCtx, position, direction, - BoundaryTolerance::AbsoluteCartesian(tol, tol)); + auto sMultiIntersection = surface->intersect( + geoCtx, position, direction, + BoundaryTolerance::AbsoluteCartesian(m_tol, m_tol)); // Take the closest auto closestForward = sMultiIntersection.closestForward(); @@ -85,27 +86,27 @@ class NoFieldIntersectionFinder { // Grid to store the source links for // the seeding fast lookup -class SourceLinkGrid : public ISourceLinkGrid { +class SourceLinkGrid { public: - using eGrid = Grid, Axis, Axis>; + using GridType = Grid; /// Lookup table collection - std::unordered_map m_lookupTables; + std::unordered_map m_lookupTables; /// Surface accessor SourceLinkSurfaceAccessor m_surfaceAccessor; void initialize(const GeometryContext& geoCtx, - std::vector sourceLinks) override { + std::vector sourceLinks) { // Lookup table for each layer - std::unordered_map lookupTable; + std::unordered_map lookupTable; // Construct a binned grid for each layer for (int i : {14, 15, 16, 17}) { Axis xAxis(-halfY, halfY, 50); Axis yAxis(-halfZ, halfZ, 50); - eGrid grid(std::make_tuple(xAxis, yAxis)); + GridType grid(std::make_tuple(xAxis, yAxis)); lookupTable.insert({i, grid}); } // Fill the grid with source links @@ -127,7 +128,7 @@ class SourceLinkGrid : public ISourceLinkGrid { }; // Get the source link grid for a given geometry id - eGrid getSourceLinkTable(const GeometryIdentifier& geoId) const override { + const GridType operator()(const GeometryIdentifier& geoId) const { return m_lookupTables.at(geoId.sensitive()); } }; @@ -135,16 +136,10 @@ class SourceLinkGrid : public ISourceLinkGrid { // A simple path width provider to set // the grid lookup boundaries around the // intersection point -class PathWidthProvider { - public: - ActsScalar m_pathWidth = 0.1; - - std::pair operator()( - const GeometryContext& /*geoCtx*/, - const GeometryIdentifier& /*geoId*/) const { - return {m_pathWidth, m_pathWidth}; - } -}; +const std::pair getPathWidth( + const GeometryContext& /*gctx*/, const GeometryIdentifier& /*geoId*/) { + return {0.1, 0.1}; +} // Calibrator to transform the source links // to global coordinates @@ -152,8 +147,8 @@ class SourceLinkCalibrator { public: SourceLinkSurfaceAccessor m_surfaceAccessor; - Vector3 operator()(const GeometryContext& geoCtx, - const SourceLink& sourceLink) const { + const Vector3 operator()(const GeometryContext& geoCtx, + const SourceLink& sourceLink) const { auto ssl = sourceLink.get(); auto res = m_surfaceAccessor(sourceLink) ->localToGlobal(geoCtx, ssl.parameters, Vector3{0, 1, 0}); @@ -168,8 +163,8 @@ class TrackEstimator { public: Vector3 ip; - std::tuple operator()( - const GeometryContext& /*geoCtx*/, const Vector3& pivot) const { + const std::tuple + operator()(const GeometryContext& /*geoCtx*/, const Vector3& pivot) const { Vector3 direction = (pivot - ip).normalized(); return {1_e, 1._GeV, ip, direction, direction}; }; @@ -344,14 +339,15 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { auto sourceLinks = createSourceLinks(gctx, *detector); // Prepare the PathSeeder - auto pathSeederCfg = Acts::Experimental::PathSeeder::Config(); + auto pathSeederCfg = Acts::Experimental::PathSeeder::Config(); // Grid to bin the source links SurfaceAccessor surfaceAccessor{*detector}; - auto sourceLinkGrid = std::make_shared(); - sourceLinkGrid->m_surfaceAccessor.connect<&SurfaceAccessor::operator()>( + SourceLinkGrid sourceLinkGrid; + sourceLinkGrid.m_surfaceAccessor.connect<&SurfaceAccessor::operator()>( &surfaceAccessor); - pathSeederCfg.sourceLinkGrid = sourceLinkGrid; + pathSeederCfg.sourceLinkGridLookup.connect<&SourceLinkGrid::operator()>( + &sourceLinkGrid); // Estimator of the IP and first hit // parameters of the track @@ -368,7 +364,7 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { &sourceLinkCalibrator); // Intersection finder - auto intersectionFinder = NoFieldIntersectionFinder(); + NoFieldIntersectionFinder intersectionFinder; for (auto volume : detector->volumes()) { for (auto surface : volume->surfaces()) { intersectionFinder.m_surfaces.push_back(surface); @@ -378,9 +374,7 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { .connect<&NoFieldIntersectionFinder::operator()>(&intersectionFinder); // Path width provider - auto pathWidthProvider = PathWidthProvider(); - pathSeederCfg.pathWidthProvider.connect<&PathWidthProvider::operator()>( - &pathWidthProvider); + pathSeederCfg.pathWidthProvider.connect<&getPathWidth>(); // First tracking layer Extent firstLayerExtent; @@ -391,9 +385,10 @@ BOOST_AUTO_TEST_CASE(PathSeederZeroField) { pathSeederCfg.firstLayerExtent = firstLayerExtent; // Create the PathSeeder - Acts::Experimental::PathSeeder pathSeeder(pathSeederCfg); + Acts::Experimental::PathSeeder pathSeeder(pathSeederCfg); // Get the seeds + sourceLinkGrid.initialize(gctx, sourceLinks); auto seeds = pathSeeder.getSeeds(gctx, sourceLinks); // Check the seeds From abf2e6463d3855829be4342d40e12de83ef4fb2d Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 19 Aug 2024 14:44:09 +0300 Subject: [PATCH 25/28] lint fixes --- Core/include/Acts/Seeding/PathSeeder.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 780a00c805a..aee7350ce2b 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -68,7 +68,7 @@ class PathSeeder { : ipP(ipPmag), ipDir(std::move(ipPdir)), ipVertex(std::move(ipPos)), - sourceLinks(std::move(sls)){}; + sourceLinks(std::move(sls)) {}; }; /// @brief Delegate to provide the relevant grid @@ -150,7 +150,7 @@ class PathSeeder { }; /// @brief Constructor - PathSeeder(const Config& config) : m_cfg(std::move(config)){}; + PathSeeder(const Config& config) : m_cfg(std::move(config)) {}; /// @brief Destructor ~PathSeeder() = default; From 69cdca022adb2ecb0da189042fdf0bfe91442ea3 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 19 Aug 2024 15:44:53 +0300 Subject: [PATCH 26/28] missing includes --- Core/include/Acts/Seeding/PathSeeder.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index aee7350ce2b..3aebf1a6c45 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -8,6 +8,7 @@ #pragma once +#include "Acts/EventData/SourceLink.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Delegate.hpp" @@ -68,7 +69,7 @@ class PathSeeder { : ipP(ipPmag), ipDir(std::move(ipPdir)), ipVertex(std::move(ipPos)), - sourceLinks(std::move(sls)) {}; + sourceLinks(std::move(sls)){}; }; /// @brief Delegate to provide the relevant grid @@ -150,7 +151,7 @@ class PathSeeder { }; /// @brief Constructor - PathSeeder(const Config& config) : m_cfg(std::move(config)) {}; + PathSeeder(const Config& config) : m_cfg(std::move(config)){}; /// @brief Destructor ~PathSeeder() = default; From a98a692306c7deb4a5430bf571b0d7356360d140 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Mon, 19 Aug 2024 15:45:34 +0300 Subject: [PATCH 27/28] lint --- Core/include/Acts/Seeding/PathSeeder.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index 3aebf1a6c45..d873de3ad0b 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -69,7 +69,7 @@ class PathSeeder { : ipP(ipPmag), ipDir(std::move(ipPdir)), ipVertex(std::move(ipPos)), - sourceLinks(std::move(sls)){}; + sourceLinks(std::move(sls)) {}; }; /// @brief Delegate to provide the relevant grid @@ -151,7 +151,7 @@ class PathSeeder { }; /// @brief Constructor - PathSeeder(const Config& config) : m_cfg(std::move(config)){}; + PathSeeder(const Config& config) : m_cfg(std::move(config)) {}; /// @brief Destructor ~PathSeeder() = default; From e258805faeeb4298314b67bbe955ac57668c7cf9 Mon Sep 17 00:00:00 2001 From: ssdetlab Date: Wed, 21 Aug 2024 08:10:46 +0300 Subject: [PATCH 28/28] cleanup --- Core/include/Acts/Seeding/PathSeeder.hpp | 13 ++++++------- Tests/UnitTests/Core/Seeding/PathSeederTest.cpp | 14 +++++++------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Core/include/Acts/Seeding/PathSeeder.hpp b/Core/include/Acts/Seeding/PathSeeder.hpp index d873de3ad0b..fdf4680022f 100644 --- a/Core/include/Acts/Seeding/PathSeeder.hpp +++ b/Core/include/Acts/Seeding/PathSeeder.hpp @@ -79,8 +79,7 @@ class PathSeeder { /// @arg The geometry identifier to use /// /// @return The grid filled with source links - using SourceLinkGridLookup = - Delegate; + using SourceLinkGridLookup = Delegate; /// @brief Delegate to estimate the IP parameters /// and the momentum direction at the first tracking layer @@ -91,8 +90,8 @@ class PathSeeder { /// @return Particle charge, the IP momentum magnitude, the IP vertex position, /// the IP momentum direction, the momentum direction at the /// first tracking layer - using TrackEstimator = Delegate< - const std::tuple( + using TrackEstimator = + Delegate( const GeometryContext&, const Vector3&)>; /// @brief Delegate to transform the source link to the @@ -103,7 +102,7 @@ class PathSeeder { /// /// @return The global position of the source link measurement using SourceLinkCalibrator = - Delegate; + Delegate; /// @brief Delegate to find the intersections for the given pivot /// source link @@ -115,7 +114,7 @@ class PathSeeder { /// @arg The IP momentum magnitude /// @arg The particle charge using IntersectionLookup = - Delegate>( + Delegate>( const GeometryContext&, const Vector3&, const Vector3&, const ActsScalar&, const ActsScalar&)>; @@ -129,7 +128,7 @@ class PathSeeder { /// /// @return The path width in the bin0 and bin1 direction /// defined with respect to the surface normal - using PathWidthLookup = Delegate( + using PathWidthLookup = Delegate( const GeometryContext&, const GeometryIdentifier&)>; /// @brief The nested configuration struct diff --git a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp index 871d93b802f..6e293a96b73 100644 --- a/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp +++ b/Tests/UnitTests/Core/Seeding/PathSeederTest.cpp @@ -57,7 +57,7 @@ class NoFieldIntersectionFinder { // Find the intersections along the path // and return them in the order of the path // length - const std::vector> operator()( + std::vector> operator()( const GeometryContext& geoCtx, const Vector3& position, const Vector3& direction, [[maybe_unused]] const ActsScalar& Pmag = 0, [[maybe_unused]] const ActsScalar& Charge = 0) const { @@ -128,7 +128,7 @@ class SourceLinkGrid { }; // Get the source link grid for a given geometry id - const GridType operator()(const GeometryIdentifier& geoId) const { + GridType operator()(const GeometryIdentifier& geoId) const { return m_lookupTables.at(geoId.sensitive()); } }; @@ -136,7 +136,7 @@ class SourceLinkGrid { // A simple path width provider to set // the grid lookup boundaries around the // intersection point -const std::pair getPathWidth( +std::pair getPathWidth( const GeometryContext& /*gctx*/, const GeometryIdentifier& /*geoId*/) { return {0.1, 0.1}; } @@ -147,8 +147,8 @@ class SourceLinkCalibrator { public: SourceLinkSurfaceAccessor m_surfaceAccessor; - const Vector3 operator()(const GeometryContext& geoCtx, - const SourceLink& sourceLink) const { + Vector3 operator()(const GeometryContext& geoCtx, + const SourceLink& sourceLink) const { auto ssl = sourceLink.get(); auto res = m_surfaceAccessor(sourceLink) ->localToGlobal(geoCtx, ssl.parameters, Vector3{0, 1, 0}); @@ -163,8 +163,8 @@ class TrackEstimator { public: Vector3 ip; - const std::tuple - operator()(const GeometryContext& /*geoCtx*/, const Vector3& pivot) const { + std::tuple operator()( + const GeometryContext& /*geoCtx*/, const Vector3& pivot) const { Vector3 direction = (pivot - ip).normalized(); return {1_e, 1._GeV, ip, direction, direction}; };