From eb6a5f11df765261ac9f1b75e0eeb8f3e855eb59 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 29 Nov 2024 18:10:50 +0100 Subject: [PATCH 1/8] feat: compatibility for EDM4hep < `0.99` & >= `0.99` (#3921) This updates our code so it compiles with both EDM4hep versions below `0.99` and above/equal to `0.99`. Breaking changes are: - `TrackerHit` becomes `TrackerHit3D`. - `SimTrackerHit::getMCParticle` becomes `SimTrackerHit::getParticle`, with the original name being deprecated. I'm aliasing the new name `TrackerHit3D` and `TrackerHit3DCollection` to the old types, so that when we drop support for < `0.99` versions, they're already correct. ## Summary by CodeRabbit - **New Features** - Enhanced compatibility with different versions of the EDM4hep library for particle handling. - Introduced utility functions for retrieving and setting particle information in `SimTrackerHit` objects. - Added type aliases to streamline the handling of tracker hit collections. - **Bug Fixes** - Improved error handling in the `EDM4hepReader` for missing particles. - **Refactor** - Updated function signatures and internal logic to utilize new utility functions for better maintainability. - Streamlined the `EDM4hepMeasurementWriter` and `EDM4hepMeasurementReader` to accommodate new data structures. - Adjusted header inclusions and conditional compilation for better flexibility. - **Documentation** - Added comments to indicate changes in parameter handling for clarity. --- .../Io/EDM4hep/EDM4hepMeasurementWriter.hpp | 3 - .../ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp | 21 +++--- .../EDM4hep/src/EDM4hepMeasurementReader.cpp | 5 +- .../EDM4hep/src/EDM4hepMeasurementWriter.cpp | 5 +- Examples/Io/EDM4hep/src/EDM4hepReader.cpp | 6 +- Examples/Io/EDM4hep/src/EDM4hepUtil.cpp | 73 ++++++------------- .../Acts/Plugins/EDM4hep/EDM4hepUtil.hpp | 12 ++- .../EDM4hep/TrackerHitCompatibility.hpp | 22 ++++++ Plugins/EDM4hep/src/EDM4hepUtil.cpp | 34 ++++++++- 9 files changed, 105 insertions(+), 76 deletions(-) create mode 100644 Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepMeasurementWriter.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepMeasurementWriter.hpp index d559ee9a5e4..04cf8805df4 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepMeasurementWriter.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepMeasurementWriter.hpp @@ -16,9 +16,6 @@ #include -#include -#include - namespace ActsExamples { /// Write out a measurement cluster collection to EDM4hep. diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp index bdce08bc876..4973763a087 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp @@ -8,6 +8,7 @@ #pragma once #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp" #include "ActsExamples/EventData/Cluster.hpp" #include "ActsExamples/EventData/Measurement.hpp" #include "ActsExamples/EventData/SimParticle.hpp" @@ -16,15 +17,13 @@ #include -#include "edm4hep/MCParticle.h" -#include "edm4hep/MutableMCParticle.h" -#include "edm4hep/MutableSimTrackerHit.h" -#include "edm4hep/MutableTrack.h" -#include "edm4hep/MutableTrackerHitPlane.h" -#include "edm4hep/SimTrackerHit.h" -#include "edm4hep/TrackerHit.h" -#include "edm4hep/TrackerHitCollection.h" -#include "edm4hep/TrackerHitPlane.h" +#include +#include +#include +#include +#include +#include +#include namespace ActsExamples::EDM4hepUtil { @@ -91,7 +90,7 @@ void writeSimHit(const ActsFatras::Hit& from, edm4hep::MutableSimTrackerHit to, /// - local 2D coordinates and time are read from position VariableBoundMeasurementProxy readMeasurement( MeasurementContainer& container, const edm4hep::TrackerHitPlane& from, - const edm4hep::TrackerHitCollection* fromClusters, Cluster* toCluster, + const edm4hep::TrackerHit3DCollection* fromClusters, Cluster* toCluster, const MapGeometryIdFrom& geometryMapper); /// Writes a measurement cluster to EDM4hep. @@ -107,7 +106,7 @@ VariableBoundMeasurementProxy readMeasurement( void writeMeasurement(const ConstVariableBoundMeasurementProxy& from, edm4hep::MutableTrackerHitPlane to, const Cluster* fromCluster, - edm4hep::TrackerHitCollection& toClusters, + edm4hep::TrackerHit3DCollection& toClusters, const MapGeometryIdTo& geometryMapper); /// Writes a trajectory to EDM4hep. diff --git a/Examples/Io/EDM4hep/src/EDM4hepMeasurementReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepMeasurementReader.cpp index 237ff19e3b6..5299da121ca 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepMeasurementReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepMeasurementReader.cpp @@ -9,6 +9,7 @@ #include "ActsExamples/Io/EDM4hep/EDM4hepMeasurementReader.hpp" #include "Acts/Definitions/Units.hpp" +#include "Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp" #include "Acts/Plugins/Podio/PodioUtil.hpp" #include "ActsExamples/EventData/Cluster.hpp" #include "ActsExamples/EventData/Measurement.hpp" @@ -18,8 +19,6 @@ #include #include -#include -#include #include #include @@ -60,7 +59,7 @@ ProcessCode EDM4hepMeasurementReader::read(const AlgorithmContext& ctx) { const auto& trackerHitPlaneCollection = frame.get("ActsTrackerHitsPlane"); const auto& trackerHitRawCollection = - frame.get("ActsTrackerHitsRaw"); + frame.get("ActsTrackerHitsRaw"); for (const auto& trackerHitPlane : trackerHitPlaneCollection) { Cluster cluster; diff --git a/Examples/Io/EDM4hep/src/EDM4hepMeasurementWriter.cpp b/Examples/Io/EDM4hep/src/EDM4hepMeasurementWriter.cpp index 0f9e9422d28..23e291cc2dd 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepMeasurementWriter.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepMeasurementWriter.cpp @@ -9,6 +9,7 @@ #include "ActsExamples/Io/EDM4hep/EDM4hepMeasurementWriter.hpp" #include "Acts/Definitions/Units.hpp" +#include "Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp" #include "ActsExamples/EventData/Cluster.hpp" #include "ActsExamples/EventData/Measurement.hpp" #include "ActsExamples/Framework/WhiteBoard.hpp" @@ -16,6 +17,8 @@ #include +#include +#include #include namespace ActsExamples { @@ -44,7 +47,7 @@ ActsExamples::ProcessCode EDM4hepMeasurementWriter::writeT( podio::Frame frame; edm4hep::TrackerHitPlaneCollection hitsPlane; - edm4hep::TrackerHitCollection hits; + edm4hep::TrackerHit3DCollection hits; if (!m_cfg.inputClusters.empty()) { ACTS_VERBOSE("Fetch clusters for writing: " << m_cfg.inputClusters); diff --git a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp index 4561bc61db0..0b82a20181b 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepReader.cpp @@ -10,6 +10,7 @@ #include "Acts/Definitions/Units.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" +#include "Acts/Plugins/EDM4hep/EDM4hepUtil.hpp" #include "ActsExamples/DD4hepDetector/DD4hepDetector.hpp" #include "ActsExamples/EventData/SimHit.hpp" #include "ActsExamples/EventData/SimParticle.hpp" @@ -305,8 +306,9 @@ ProcessCode EDM4hepReader::read(const AlgorithmContext& ctx) { auto simHit = EDM4hepUtil::readSimHit( hit, [&](const auto& inParticle) { - ACTS_VERBOSE("SimHit has source particle: " - << hit.getMCParticle().getObjectID().index); + ACTS_VERBOSE( + "SimHit has source particle: " + << Acts::EDM4hepUtil::getParticle(hit).getObjectID().index); auto it = edm4hepParticleMap.find(inParticle.getObjectID().index); if (it == edm4hepParticleMap.end()) { ACTS_ERROR( diff --git a/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp b/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp index 38e26038779..adb433891d9 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp @@ -70,9 +70,10 @@ void EDM4hepUtil::writeParticle(const SimParticle& from, ActsFatras::Hit EDM4hepUtil::readSimHit( const edm4hep::SimTrackerHit& from, const MapParticleIdFrom& particleMapper, const MapGeometryIdFrom& geometryMapper) { - ActsFatras::Barcode particleId = particleMapper(from.getMCParticle()); + auto particle = Acts::EDM4hepUtil::getParticle(from); + ActsFatras::Barcode particleId = particleMapper(particle); - const auto mass = from.getMCParticle().getMass() * 1_GeV; + const auto mass = particle.getMass() * 1_GeV; const Acts::Vector3 momentum{ from.getMomentum().x * 1_GeV, from.getMomentum().y * 1_GeV, @@ -116,7 +117,7 @@ void EDM4hepUtil::writeSimHit(const ActsFatras::Hit& from, const auto delta4 = from.momentum4After() - momentum4Before; if (particleMapper) { - to.setMCParticle(particleMapper(from.particleId())); + Acts::EDM4hepUtil::setParticle(to, particleMapper(from.particleId())); } if (geometryMapper) { @@ -146,8 +147,8 @@ void EDM4hepUtil::writeSimHit(const ActsFatras::Hit& from, VariableBoundMeasurementProxy EDM4hepUtil::readMeasurement( MeasurementContainer& container, const edm4hep::TrackerHitPlane& from, - const edm4hep::TrackerHitCollection* fromClusters, Cluster* toCluster, - const MapGeometryIdFrom& geometryMapper) { + const edm4hep::TrackerHit3DCollection* /*fromClusters*/, + Cluster* /*toCluster*/, const MapGeometryIdFrom& geometryMapper) { // no need for digitization as we only want to identify the sensor Acts::GeometryIdentifier geometryId = geometryMapper(from.getCellID()); @@ -171,32 +172,15 @@ VariableBoundMeasurementProxy EDM4hepUtil::readMeasurement( auto to = createMeasurement(container, geometryId, dParameters); - if (fromClusters != nullptr) { - for (const auto objectId : from.getRawHits()) { - const auto& c = fromClusters->at(objectId.index); - - // TODO get EDM4hep fixed - // misusing some fields to store ACTS specific information - // don't ask ... - ActsFatras::Segmentizer::Bin2D bin{ - static_cast(c.getType()), - static_cast(c.getQuality())}; - ActsFatras::Segmentizer::Segment2D path2D{ - {Acts::Vector2::Zero(), Acts::Vector2::Zero()}}; - double activation = c.getTime(); - ActsFatras::Segmentizer::ChannelSegment cell{bin, path2D, activation}; - - toCluster->channels.push_back(cell); - } - } + // @TODO: Figure out if cell information is accessible return to; } void EDM4hepUtil::writeMeasurement( const ConstVariableBoundMeasurementProxy& from, - edm4hep::MutableTrackerHitPlane to, const Cluster* fromCluster, - edm4hep::TrackerHitCollection& toClusters, + edm4hep::MutableTrackerHitPlane to, const Cluster* /*fromCluster*/, + edm4hep::TrackerHit3DCollection& /*toClusters*/, const MapGeometryIdTo& geometryMapper) { Acts::GeometryIdentifier geoId = from.geometryId(); @@ -224,21 +208,7 @@ void EDM4hepUtil::writeMeasurement( 0, }); - if (fromCluster != nullptr) { - for (const auto& c : fromCluster->channels) { - auto toChannel = toClusters.create(); - to.addToRawHits(toChannel.getObjectID()); - - // TODO digitization channel - - // TODO get EDM4hep fixed - // misusing some fields to store ACTS specific information - // don't ask ... - toChannel.setType(c.bin[0]); - toChannel.setQuality(c.bin[1]); - toChannel.setTime(c.activation); - } - } + // @TODO: Check if we can write cell info } void EDM4hepUtil::writeTrajectory( @@ -296,17 +266,18 @@ void EDM4hepUtil::writeTrajectory( trackState.referencePoint.z = center.z(); if (converted.covariance) { - const auto& c = converted.covariance.value(); - - trackState.covMatrix = { - static_cast(c(0, 0)), static_cast(c(1, 0)), - static_cast(c(1, 1)), static_cast(c(2, 0)), - static_cast(c(2, 1)), static_cast(c(2, 2)), - static_cast(c(3, 0)), static_cast(c(3, 1)), - static_cast(c(3, 2)), static_cast(c(3, 3)), - static_cast(c(4, 0)), static_cast(c(4, 1)), - static_cast(c(4, 2)), static_cast(c(4, 3)), - static_cast(c(4, 4))}; + auto c = [&](std::size_t row, std::size_t col) { + return static_cast(converted.covariance.value()(row, col)); + }; + + // clang-format off + trackState.covMatrix = {c(0, 0), + c(1, 0), c(1, 1), + c(2, 0), c(2, 1), c(2, 2), + c(3, 0), c(3, 1), c(3, 2), c(3, 3), + c(4, 0), c(4, 1), c(4, 2), c(4, 3), c(4, 4), + c(5, 0), c(5, 1), c(5, 2), c(5, 3), c(5, 4), c(5, 5)}; + // clang-format on } to.addToTrackStates(trackState); diff --git a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp index c5fda03bc82..e4836862769 100644 --- a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp +++ b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/EDM4hepUtil.hpp @@ -26,11 +26,13 @@ #include #include +#include +#include +#include +#include #include #include -#include "edm4hep/MutableTrack.h" - namespace Acts::EDM4hepUtil { static constexpr std::int32_t EDM4HEP_ACTS_POSITION_TYPE = 42; @@ -61,6 +63,12 @@ BoundTrackParameters convertTrackParametersFromEdm4hep( } // namespace detail +// Compatibility with EDM4hep < 0.99 and >= 0.99 +edm4hep::MCParticle getParticle(const edm4hep::SimTrackerHit& hit); + +void setParticle(edm4hep::MutableSimTrackerHit& hit, + const edm4hep::MCParticle& particle); + template void writeTrack(const Acts::GeometryContext& gctx, track_proxy_t track, edm4hep::MutableTrack to, double Bz, diff --git a/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp new file mode 100644 index 00000000000..11115e7cbe5 --- /dev/null +++ b/Plugins/EDM4hep/include/Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp @@ -0,0 +1,22 @@ +// This file is part of the ACTS project. +// +// Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/. + +#pragma once + +// Compatibility with EDM4hep < 0.99 and >= 0.99 +#if __has_include() +#include "edm4hep/TrackerHit3D.h" +#include "edm4hep/TrackerHit3DCollection.h" +#else +#include "edm4hep/TrackerHit.h" +#include "edm4hep/TrackerHitCollection.h" +namespace edm4hep { +using TrackerHit3DCollection = edm4hep::TrackerHitCollection; +using TrackerHit3D = edm4hep::TrackerHit; +} // namespace edm4hep +#endif diff --git a/Plugins/EDM4hep/src/EDM4hepUtil.cpp b/Plugins/EDM4hep/src/EDM4hepUtil.cpp index 515063da679..60d466d0427 100644 --- a/Plugins/EDM4hep/src/EDM4hepUtil.cpp +++ b/Plugins/EDM4hep/src/EDM4hepUtil.cpp @@ -18,9 +18,14 @@ #include -#include "edm4hep/TrackState.h" +#include +#include +#include +#include +#include -namespace Acts::EDM4hepUtil::detail { +namespace Acts::EDM4hepUtil { +namespace detail { ActsSquareMatrix<6> jacobianToEdm4hep(double theta, double qOverP, double Bz) { // Calculate jacobian from our internal parametrization (d0, z0, phi, theta, @@ -185,4 +190,27 @@ BoundTrackParameters convertTrackParametersFromEdm4hep( return {params.surface, targetPars, cov, params.particleHypothesis}; } -} // namespace Acts::EDM4hepUtil::detail +} // namespace detail + +#if EDM4HEP_VERSION_MAJOR >= 1 || \ + (EDM4HEP_VERSION_MAJOR == 0 && EDM4HEP_VERSION_MINOR == 99) +edm4hep::MCParticle getParticle(const edm4hep::SimTrackerHit& hit) { + return hit.getParticle(); +} + +void setParticle(edm4hep::MutableSimTrackerHit& hit, + const edm4hep::MCParticle& particle) { + hit.setParticle(particle); +} +#else +edm4hep::MCParticle getParticle(const edm4hep::SimTrackerHit& hit) { + return hit.getMCParticle(); +} + +void setParticle(edm4hep::MutableSimTrackerHit& hit, + const edm4hep::MCParticle& particle) { + hit.setMCParticle(particle); +} +#endif + +} // namespace Acts::EDM4hepUtil From 6a836db2a62deec29f0f1913f557a59088bb2978 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 29 Nov 2024 21:52:08 +0100 Subject: [PATCH 2/8] ci: Add LCG 106a job (#3918) This adds jobs for LCG 106a to the GitLab CI. I'm bumping ODD to the [`v4.0.3`](https://gitlab.cern.ch/acts/OpenDataDetector/-/tags/v4.0.3) where I cherry picked a tiny code fix that was breaking the build here. Blocked by: - #3921 ## Summary by CodeRabbit - **New Features** - Introduced a new CI/CD job `lcg_106a` for enhanced build configurations. - **Improvements** - Simplified the `lcg_105` job by directly setting `LCG_PLATFORM` for the `alma9` OS. - **Updates** - Updated the commit reference for the `OpenDataDetector` subproject to the latest version. --- .gitlab-ci.yml | 20 +++++++++++++++----- thirdparty/OpenDataDetector | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b0a213e607d..c897c947010 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -382,11 +382,7 @@ linux_ubuntu_2204_clang: # Figure out LCG platform name based on version number and OS - > if [ "$OS" = "alma9" ]; then - if [ "$LCG_VERSION" -ge "104" ]; then - export LCG_PLATFORM="el9" - else - export LCG_PLATFORM="centos9" - fi + export LCG_PLATFORM="el9" else export LCG_PLATFORM="$OS" fi @@ -431,3 +427,17 @@ lcg_105: COMPILER: - gcc13 - clang16 + +lcg_106a: + extends: .lcg_base_job + + variables: + LCG_VERSION: "106a" + + parallel: + matrix: + - OS: [alma9] + COMPILER: + - gcc13 + - gcc14 + - clang16 diff --git a/thirdparty/OpenDataDetector b/thirdparty/OpenDataDetector index 0bf11ff33bd..4c5e7413a50 160000 --- a/thirdparty/OpenDataDetector +++ b/thirdparty/OpenDataDetector @@ -1 +1 @@ -Subproject commit 0bf11ff33bd10d3070e6ecbc4bea0a7c42d86fa0 +Subproject commit 4c5e7413a505a7743cbec9544901e8c55172e513 From 8895da1c915b56c9ea2498e32bf86dadb4f8b018 Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Fri, 29 Nov 2024 23:19:49 +0100 Subject: [PATCH 3/8] fix: Remove `final` on template derived classes (#3923) This seems to cause issues when using `dynamic_cast` on AppleClang 16 and llvm 18 on macOS 15 (at least). Reproducer: https://gist.github.com/paulgessinger/2c1d2abdeb322072c507878ab5833728 ## Summary by CodeRabbit - **New Features** - Enhanced extensibility of the `GridPortalLinkT`, `Axis`, `Affine3Transformed`, `GlobalSubspace`, and `LocalSubspace` classes by allowing subclassing. - Updated constructors and methods in `GridPortalLinkT` to improve error handling and functionality. - **Bug Fixes** - Improved validation in the `resolveVolume` method to ensure positions are within valid bounds. - **Documentation** - Clarified class hierarchies and relationships due to changes in access specifiers. --- Core/include/Acts/Geometry/GridPortalLink.hpp | 2 +- Core/include/Acts/Utilities/Axis.hpp | 4 ++-- Core/include/Acts/Utilities/GridAccessHelpers.hpp | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Core/include/Acts/Geometry/GridPortalLink.hpp b/Core/include/Acts/Geometry/GridPortalLink.hpp index 411e6bb9962..8bf1d06ee08 100644 --- a/Core/include/Acts/Geometry/GridPortalLink.hpp +++ b/Core/include/Acts/Geometry/GridPortalLink.hpp @@ -396,7 +396,7 @@ class GridPortalLink : public PortalLinkBase { /// @tparam Axes The axis types of the grid template requires(sizeof...(Axes) <= 2) -class GridPortalLinkT final : public GridPortalLink { +class GridPortalLinkT : public GridPortalLink { public: /// The internal grid type using GridType = Grid; diff --git a/Core/include/Acts/Utilities/Axis.hpp b/Core/include/Acts/Utilities/Axis.hpp index 5b55d27cd77..758a8c2ec3c 100644 --- a/Core/include/Acts/Utilities/Axis.hpp +++ b/Core/include/Acts/Utilities/Axis.hpp @@ -97,7 +97,7 @@ class NeighborHoodIndices { /// This class provides some basic functionality for calculating bin indices /// for a given equidistant binning. template -class Axis final : public IAxis { +class Axis : public IAxis { public: static constexpr AxisType type = AxisType::Equidistant; @@ -417,7 +417,7 @@ class Axis final : public IAxis { /// This class provides some basic functionality for calculating bin indices /// for a given binning with variable bin sizes. template -class Axis final : public IAxis { +class Axis : public IAxis { public: static constexpr AxisType type = AxisType::Variable; diff --git a/Core/include/Acts/Utilities/GridAccessHelpers.hpp b/Core/include/Acts/Utilities/GridAccessHelpers.hpp index 085ea318f26..fbaf7f3acbd 100644 --- a/Core/include/Acts/Utilities/GridAccessHelpers.hpp +++ b/Core/include/Acts/Utilities/GridAccessHelpers.hpp @@ -110,7 +110,7 @@ class IBoundToGridLocal { }; template -class Affine3Transformed final : public IGlobalToGridLocal { +class Affine3Transformed : public IGlobalToGridLocal { public: using grid_local_t = typename global_to_grid_local_t::grid_local_t; @@ -142,7 +142,7 @@ class Affine3Transformed final : public IGlobalToGridLocal { /// position /// @tparam ...Args template -class GlobalSubspace final : public IGlobalToGridLocal { +class GlobalSubspace : public IGlobalToGridLocal { public: using grid_local_t = std::array; @@ -179,7 +179,7 @@ class GlobalSubspace final : public IGlobalToGridLocal { // The bound to grid local transformation, if only access of a subspace // is requested template -class LocalSubspace final : public IBoundToGridLocal { +class LocalSubspace : public IBoundToGridLocal { public: using grid_local_t = std::array; From bf997eb640537c9d91f0ee7f54e95216a680a98a Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:36:44 +0100 Subject: [PATCH 4/8] refactor: modernise map utils (#3615) ## Summary by CodeRabbit - **New Features** - Introduced a new function to compute minimum and maximum values along with unique bin counts for input vectors. - **Refactor** - Enhanced the handling of magnetic field data by improving type usage and logic in multiple functions. - Streamlined calculations for minimum and maximum values using the new utility function. - Simplified the material mapping functions to improve maintainability and reduce complexity. - **Bug Fixes** - Adjusted error handling and control flow for grid value settings based on magnetic field data. --- .../Acts/MagneticField/BFieldMapUtils.hpp | 15 +- Core/include/Acts/Utilities/Helpers.hpp | 45 +++ Core/src/MagneticField/BFieldMapUtils.cpp | 269 +++++++----------- Core/src/Material/MaterialMapUtils.cpp | 98 ++----- 4 files changed, 175 insertions(+), 252 deletions(-) diff --git a/Core/include/Acts/MagneticField/BFieldMapUtils.hpp b/Core/include/Acts/MagneticField/BFieldMapUtils.hpp index 09ac0035d9b..4aa1934699b 100644 --- a/Core/include/Acts/MagneticField/BFieldMapUtils.hpp +++ b/Core/include/Acts/MagneticField/BFieldMapUtils.hpp @@ -75,7 +75,7 @@ fieldMapRZ(const std::function binsRZ, std::array nBinsRZ)>& localToGlobalBin, std::vector rPos, std::vector zPos, - std::vector bField, + const std::vector& bField, double lengthUnit = UnitConstants::mm, double BFieldUnit = UnitConstants::T, bool firstQuadrant = false); @@ -137,7 +137,7 @@ fieldMapXYZ( std::array nBinsXYZ)>& localToGlobalBin, std::vector xPos, std::vector yPos, - std::vector zPos, std::vector bField, + std::vector zPos, const std::vector& bField, double lengthUnit = UnitConstants::mm, double BFieldUnit = UnitConstants::T, bool firstOctant = false); @@ -145,17 +145,18 @@ fieldMapXYZ( /// creates a field mapper by sampling grid points from the analytical /// solenoid field. /// -/// @param rlim pair of r bounds -/// @param zlim pair of z bounds -/// @param nbins pair of bin counts +/// @param rLim pair of r bounds +/// @param zLim pair of z bounds +/// @param nBins pair of bin counts /// @param field the solenoid field instance /// /// @return A field map instance for use in interpolation. Acts::InterpolatedBFieldMap< Acts::Grid, Acts::Axis>> -solenoidFieldMap(std::pair rlim, std::pair zlim, - std::pair nbins, +solenoidFieldMap(const std::pair& rLim, + const std::pair& zLim, + const std::pair& nBins, const SolenoidBField& field); } // namespace Acts diff --git a/Core/include/Acts/Utilities/Helpers.hpp b/Core/include/Acts/Utilities/Helpers.hpp index 44bf23d9157..56d9b36481f 100644 --- a/Core/include/Acts/Utilities/Helpers.hpp +++ b/Core/include/Acts/Utilities/Helpers.hpp @@ -221,4 +221,49 @@ struct overloaded : Ts... { template overloaded(Ts...) -> overloaded; +namespace detail { + +/// Computes the minimum, maximum, and bin count for a given vector of values. +/// +/// This function processes a vector of doubles to compute: +/// - The minimum value (@c xMin) +/// - The maximum value (@c xMax), adjusted to include an additional bin +/// - The bin count (@c xBinCount) based on the number of unique values +/// +/// The computation is performed as follows: +/// 1. Sorts the input vector using @c std::ranges::sort to prepare for uniqueness. +/// 2. Determines the number of unique values using @c std::unique and calculates the bin count. +/// 3. Calculates the minimum and maximum using @c std::ranges::minmax. +/// 4. Adjusts the maximum to include an additional bin by adding the bin step +/// size. +/// +/// @param xPos A reference to a vector of doubles. +/// @return A tuple containing: +/// - The minimum value (double) +/// - The adjusted maximum value (double) +/// - The bin count (std::size_t) +/// +/// @note The vector xPos will be modified during the call. +inline auto getMinMaxAndBinCount(std::vector& xPos) { + // sort the values for unique() + std::ranges::sort(xPos); + + // get the number of bins over unique values + auto it = std::unique(xPos.begin(), xPos.end()); + const std::size_t xBinCount = std::distance(xPos.begin(), it); + + // get the minimum and maximum + auto [xMin, xMax] = std::ranges::minmax(xPos); + + // calculate maxima (add one last bin, because bin value always corresponds to + // left boundary) + const double stepX = (xMax - xMin) / static_cast(xBinCount - 1); + xMax += stepX; + + // Return all values as a tuple + return std::make_tuple(xMin, xMax, xBinCount); +} + +} // namespace detail + } // namespace Acts diff --git a/Core/src/MagneticField/BFieldMapUtils.cpp b/Core/src/MagneticField/BFieldMapUtils.cpp index b5b92191589..f5b1b410ffe 100644 --- a/Core/src/MagneticField/BFieldMapUtils.cpp +++ b/Core/src/MagneticField/BFieldMapUtils.cpp @@ -12,12 +12,14 @@ #include "Acts/MagneticField/SolenoidBField.hpp" #include "Acts/Utilities/Axis.hpp" #include "Acts/Utilities/Grid.hpp" +#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Result.hpp" #include "Acts/Utilities/VectorHelpers.hpp" #include "Acts/Utilities/detail/grid_helper.hpp" #include #include +#include #include #include #include @@ -35,100 +37,73 @@ Acts::fieldMapRZ( std::array nBinsRZ)>& localToGlobalBin, std::vector rPos, std::vector zPos, - std::vector bField, double lengthUnit, double BFieldUnit, + const std::vector& bField, double lengthUnit, double BFieldUnit, bool firstQuadrant) { // [1] Create Grid - // sort the values - std::ranges::sort(rPos); - std::ranges::sort(zPos); - // Get unique values - rPos.erase(std::unique(rPos.begin(), rPos.end()), rPos.end()); - zPos.erase(std::unique(zPos.begin(), zPos.end()), zPos.end()); - rPos.shrink_to_fit(); - zPos.shrink_to_fit(); - // get the number of bins - std::size_t nBinsR = rPos.size(); - std::size_t nBinsZ = zPos.size(); - - // get the minimum and maximum. We just sorted the vectors, so these are just - // the first and last elements. - double rMin = rPos[0]; - double zMin = zPos[0]; - double rMax = rPos[nBinsR - 1]; - double zMax = zPos[nBinsZ - 1]; - // calculate maxima (add one last bin, because bin value always corresponds to - // left boundary) - double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); - double stepR = std::abs(rMax - rMin) / (nBinsR - 1); - rMax += stepR; - zMax += stepZ; + const auto [rMin, rMax, rBinCount] = detail::getMinMaxAndBinCount(rPos); + auto [zMin, zMax, zBinCount] = detail::getMinMaxAndBinCount(zPos); + + const std::size_t nBinsR = rBinCount; + std::size_t nBinsZ = zBinCount; + if (firstQuadrant) { zMin = -zPos[nBinsZ - 1]; - nBinsZ = static_cast(2. * nBinsZ - 1); + nBinsZ = 2 * nBinsZ - 1; } // Create the axis for the grid - Acts::Axis rAxis(rMin * lengthUnit, rMax * lengthUnit, nBinsR); - Acts::Axis zAxis(zMin * lengthUnit, zMax * lengthUnit, nBinsZ); + Axis rAxis(rMin * lengthUnit, rMax * lengthUnit, nBinsR); + Axis zAxis(zMin * lengthUnit, zMax * lengthUnit, nBinsZ); // Create the grid - Grid grid(Type, std::move(rAxis), std::move(zAxis)); + Grid grid(Type, std::move(rAxis), std::move(zAxis)); using Grid_t = decltype(grid); // [2] Set the bField values + const std::array nIndices = {{rBinCount, zBinCount}}; for (std::size_t i = 1; i <= nBinsR; ++i) { for (std::size_t j = 1; j <= nBinsZ; ++j) { - std::array nIndices = {{rPos.size(), zPos.size()}}; Grid_t::index_t indices = {{i, j}}; + // std::vectors begin with 0 and we do not want the user needing to take + // underflow or overflow bins in account this is why we need to subtract + // by one if (firstQuadrant) { - // std::vectors begin with 0 and we do not want the user needing to - // take underflow or overflow bins in account this is why we need to - // subtract by one - std::size_t n = - std::abs(static_cast(j) - static_cast(zPos.size())); - Grid_t::index_t indicesFirstQuadrant = {{i - 1, n}}; + std::size_t n = std::abs(static_cast(j) - + static_cast(zBinCount)); grid.atLocalBins(indices) = - bField.at(localToGlobalBin(indicesFirstQuadrant, nIndices)) * - BFieldUnit; + bField.at(localToGlobalBin({{i - 1, n}}, nIndices)) * BFieldUnit; } else { - // std::vectors begin with 0 and we do not want the user needing to - // take underflow or overflow bins in account this is why we need to - // subtract by one grid.atLocalBins(indices) = bField.at(localToGlobalBin({{i - 1, j - 1}}, nIndices)) * BFieldUnit; } } } - grid.setExteriorBins(Acts::Vector2::Zero()); + grid.setExteriorBins(Vector2::Zero()); - // [3] Create the transformation for the position - // map (x,y,z) -> (r,z) - auto transformPos = [](const Acts::Vector3& pos) { - return Acts::Vector2(perp(pos), pos.z()); + // [3] Create the transformation for the position map (x,y,z) -> (r,z) + auto transformPos = [](const Vector3& pos) { + return Vector2(perp(pos), pos.z()); }; - // [4] Create the transformation for the bfield - // map (Br,Bz) -> (Bx,By,Bz) - auto transformBField = [](const Acts::Vector2& field, - const Acts::Vector3& pos) { - double r_sin_theta_2 = pos.x() * pos.x() + pos.y() * pos.y(); - double cos_phi = 0, sin_phi = 0; - if (r_sin_theta_2 > std::numeric_limits::min()) { - double inv_r_sin_theta = 1. / sqrt(r_sin_theta_2); - cos_phi = pos.x() * inv_r_sin_theta; - sin_phi = pos.y() * inv_r_sin_theta; - } else { - cos_phi = 1.; - sin_phi = 0.; + // [4] Create the transformation for the bField map (Br,Bz) -> (Bx,By,Bz) + auto transformBField = [](const Vector2& field, const Vector3& pos) { + const double rSinTheta2 = pos.x() * pos.x() + pos.y() * pos.y(); + double cosPhi = 1.; + double sinPhi = 0.; + + if (rSinTheta2 > std::numeric_limits::min()) { + const double invRsinTheta = 1. / std::sqrt(rSinTheta2); + cosPhi = pos.x() * invRsinTheta; + sinPhi = pos.y() * invRsinTheta; } - return Acts::Vector3(field.x() * cos_phi, field.x() * sin_phi, field.y()); + + return Vector3(field.x() * cosPhi, field.x() * sinPhi, field.y()); }; - // [5] Create the mapper & BField Service - // create field mapping - return Acts::InterpolatedBFieldMap( + // [5] Create the mapper & BField Service create field mapping + return InterpolatedBFieldMap( {transformPos, transformBField, std::move(grid)}); } @@ -141,88 +116,58 @@ Acts::fieldMapXYZ( std::array nBinsXYZ)>& localToGlobalBin, std::vector xPos, std::vector yPos, - std::vector zPos, std::vector bField, + std::vector zPos, const std::vector& bField, double lengthUnit, double BFieldUnit, bool firstOctant) { // [1] Create Grid - // Sort the values - std::ranges::sort(xPos); - std::ranges::sort(yPos); - std::ranges::sort(zPos); - // Get unique values - xPos.erase(std::unique(xPos.begin(), xPos.end()), xPos.end()); - yPos.erase(std::unique(yPos.begin(), yPos.end()), yPos.end()); - zPos.erase(std::unique(zPos.begin(), zPos.end()), zPos.end()); - xPos.shrink_to_fit(); - yPos.shrink_to_fit(); - zPos.shrink_to_fit(); - // get the number of bins - std::size_t nBinsX = xPos.size(); - std::size_t nBinsY = yPos.size(); - std::size_t nBinsZ = zPos.size(); + auto [xMin, xMax, xBinCount] = detail::getMinMaxAndBinCount(xPos); + auto [yMin, yMax, yBinCount] = detail::getMinMaxAndBinCount(yPos); + auto [zMin, zMax, zBinCount] = detail::getMinMaxAndBinCount(zPos); - // Create the axis for the grid - // get minima and maximia. We just sorted the vectors, so these are just the - // first and last elements. - double xMin = xPos[0]; - double yMin = yPos[0]; - double zMin = zPos[0]; - // get maxima - double xMax = xPos[nBinsX - 1]; - double yMax = yPos[nBinsY - 1]; - double zMax = zPos[nBinsZ - 1]; - // calculate maxima (add one last bin, because bin value always corresponds to - // left boundary) - double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); - double stepY = std::abs(yMax - yMin) / (nBinsY - 1); - double stepX = std::abs(xMax - xMin) / (nBinsX - 1); - xMax += stepX; - yMax += stepY; - zMax += stepZ; + std::size_t nBinsX = xBinCount; + std::size_t nBinsY = yBinCount; + std::size_t nBinsZ = zBinCount; - // If only the first octant is given if (firstOctant) { xMin = -xPos[nBinsX - 1]; - yMin = -yPos[nBinsY - 1]; - zMin = -zPos[nBinsZ - 1]; nBinsX = 2 * nBinsX - 1; + yMin = -yPos[nBinsY - 1]; nBinsY = 2 * nBinsY - 1; + zMin = -zPos[nBinsZ - 1]; nBinsZ = 2 * nBinsZ - 1; } - Acts::Axis xAxis(xMin * lengthUnit, xMax * lengthUnit, nBinsX); - Acts::Axis yAxis(yMin * lengthUnit, yMax * lengthUnit, nBinsY); - Acts::Axis zAxis(zMin * lengthUnit, zMax * lengthUnit, nBinsZ); + + Axis xAxis(xMin * lengthUnit, xMax * lengthUnit, nBinsX); + Axis yAxis(yMin * lengthUnit, yMax * lengthUnit, nBinsY); + Axis zAxis(zMin * lengthUnit, zMax * lengthUnit, nBinsZ); // Create the grid Grid grid(Type, std::move(xAxis), std::move(yAxis), std::move(zAxis)); using Grid_t = decltype(grid); // [2] Set the bField values + const std::array nIndices = { + {xBinCount, yBinCount, zBinCount}}; + + auto calcAbsDiff = [](std::size_t val, std::size_t binCount) { + return std::abs(static_cast(val) - + static_cast(binCount)); + }; + for (std::size_t i = 1; i <= nBinsX; ++i) { for (std::size_t j = 1; j <= nBinsY; ++j) { for (std::size_t k = 1; k <= nBinsZ; ++k) { Grid_t::index_t indices = {{i, j, k}}; - std::array nIndices = { - {xPos.size(), yPos.size(), zPos.size()}}; + // std::vectors begin with 0 and we do not want the user needing to take + // underflow or overflow bins in account this is why we need to subtract + // by one if (firstOctant) { - // std::vectors begin with 0 and we do not want the user needing to - // take underflow or overflow bins in account this is why we need to - // subtract by one - std::size_t m = - std::abs(static_cast(i) - (static_cast(xPos.size()))); - std::size_t n = - std::abs(static_cast(j) - (static_cast(yPos.size()))); - std::size_t l = - std::abs(static_cast(k) - (static_cast(zPos.size()))); - Grid_t::index_t indicesFirstOctant = {{m, n, l}}; + const std::size_t l = calcAbsDiff(i, xBinCount); + const std::size_t m = calcAbsDiff(j, yBinCount); + const std::size_t n = calcAbsDiff(k, zBinCount); grid.atLocalBins(indices) = - bField.at(localToGlobalBin(indicesFirstOctant, nIndices)) * - BFieldUnit; - + bField.at(localToGlobalBin({{l, m, n}}, nIndices)) * BFieldUnit; } else { - // std::vectors begin with 0 and we do not want the user needing to - // take underflow or overflow bins in account this is why we need to - // subtract by one grid.atLocalBins(indices) = bField.at(localToGlobalBin({{i - 1, j - 1, k - 1}}, nIndices)) * BFieldUnit; @@ -230,74 +175,67 @@ Acts::fieldMapXYZ( } } } - grid.setExteriorBins(Acts::Vector3::Zero()); + grid.setExteriorBins(Vector3::Zero()); - // [3] Create the transformation for the position - // map (x,y,z) -> (r,z) - auto transformPos = [](const Acts::Vector3& pos) { return pos; }; + // [3] Create the transformation for the position map (x,y,z) -> (r,z) + auto transformPos = [](const Vector3& pos) { return pos; }; - // [4] Create the transformation for the bfield - // map (Bx,By,Bz) -> (Bx,By,Bz) - auto transformBField = [](const Acts::Vector3& field, - const Acts::Vector3& /*pos*/) { return field; }; + // [4] Create the transformation for the BField map (Bx,By,Bz) -> (Bx,By,Bz) + auto transformBField = [](const Vector3& field, const Vector3& /*pos*/) { + return field; + }; - // [5] Create the mapper & BField Service - // create field mapping - return Acts::InterpolatedBFieldMap( + // [5] Create the mapper & BField Service create field mapping + return InterpolatedBFieldMap( {transformPos, transformBField, std::move(grid)}); } Acts::InterpolatedBFieldMap< Acts::Grid, Acts::Axis>> -Acts::solenoidFieldMap(std::pair rlim, - std::pair zlim, - std::pair nbins, +Acts::solenoidFieldMap(const std::pair& rLim, + const std::pair& zLim, + const std::pair& nBins, const SolenoidBField& field) { - auto [rMin, rMax] = rlim; - auto [zMin, zMax] = zlim; - const auto [nBinsR, nBinsZ] = nbins; + auto [rMin, rMax] = rLim; + auto [zMin, zMax] = zLim; + const auto [nBinsR, nBinsZ] = nBins; double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); double stepR = std::abs(rMax - rMin) / (nBinsR - 1); - rMax += stepR; zMax += stepZ; // Create the axis for the grid - Acts::Axis rAxis(rMin, rMax, nBinsR); - Acts::Axis zAxis(zMin, zMax, nBinsZ); + Axis rAxis(rMin, rMax, nBinsR); + Axis zAxis(zMin, zMax, nBinsZ); // Create the grid - Grid grid(Type, std::move(rAxis), std::move(zAxis)); + Grid grid(Type, std::move(rAxis), std::move(zAxis)); using Grid_t = decltype(grid); - // Create the transformation for the position - // map (x,y,z) -> (r,z) - auto transformPos = [](const Acts::Vector3& pos) { - return Acts::Vector2(perp(pos), pos.z()); + // Create the transformation for the position map (x,y,z) -> (r,z) + auto transformPos = [](const Vector3& pos) { + return Vector2(perp(pos), pos.z()); }; - // Create the transformation for the bfield - // map (Br,Bz) -> (Bx,By,Bz) - auto transformBField = [](const Acts::Vector2& bfield, - const Acts::Vector3& pos) { - double r_sin_theta_2 = pos.x() * pos.x() + pos.y() * pos.y(); - double cos_phi = 0, sin_phi = 0; - if (r_sin_theta_2 > std::numeric_limits::min()) { - double inv_r_sin_theta = 1. / sqrt(r_sin_theta_2); - cos_phi = pos.x() * inv_r_sin_theta; - sin_phi = pos.y() * inv_r_sin_theta; - } else { - cos_phi = 1.; - sin_phi = 0.; + // Create the transformation for the bField map (Br,Bz) -> (Bx,By,Bz) + auto transformBField = [](const Vector2& bField, const Vector3& pos) { + const double rSinTheta2 = pos.x() * pos.x() + pos.y() * pos.y(); + double cosPhi = 1.; + double sinPhi = 0.; + + if (rSinTheta2 > std::numeric_limits::min()) { + const double invRsinTheta = 1. / std::sqrt(rSinTheta2); + cosPhi = pos.x() * invRsinTheta; + sinPhi = pos.y() * invRsinTheta; } - return Acts::Vector3(bfield.x() * cos_phi, bfield.x() * sin_phi, - bfield.y()); + + return Vector3(bField.x() * cosPhi, bField.x() * sinPhi, bField.y()); }; - // iterate over all bins, set their value to the solenoid value - // at their lower left position + // iterate over all bins, set their value to the solenoid value at their lower + // left position for (std::size_t i = 0; i <= nBinsR + 1; i++) { for (std::size_t j = 0; j <= nBinsZ + 1; j++) { Grid_t::index_t index({i, j}); @@ -314,9 +252,8 @@ Acts::solenoidFieldMap(std::pair rlim, } } - // Create the mapper & BField Service - // create field mapping - Acts::InterpolatedBFieldMap map( + // Create the mapper & BField Service create field mapping + InterpolatedBFieldMap map( {transformPos, transformBField, std::move(grid)}); return map; } diff --git a/Core/src/Material/MaterialMapUtils.cpp b/Core/src/Material/MaterialMapUtils.cpp index b51b1a3e223..8f4d23cd71e 100644 --- a/Core/src/Material/MaterialMapUtils.cpp +++ b/Core/src/Material/MaterialMapUtils.cpp @@ -12,6 +12,7 @@ #include "Acts/Material/Material.hpp" #include "Acts/Utilities/Axis.hpp" #include "Acts/Utilities/Grid.hpp" +#include "Acts/Utilities/Helpers.hpp" #include #include @@ -43,31 +44,8 @@ auto Acts::materialMapperRZ( } // [2] Create Grid - // sort the values - std::ranges::sort(rPos); - std::ranges::sort(zPos); - // Get unique values - rPos.erase(std::unique(rPos.begin(), rPos.end()), rPos.end()); - zPos.erase(std::unique(zPos.begin(), zPos.end()), zPos.end()); - rPos.shrink_to_fit(); - zPos.shrink_to_fit(); - // get the number of bins - std::size_t nBinsR = rPos.size(); - std::size_t nBinsZ = zPos.size(); - - // get the minimum and maximum - auto minMaxR = std::minmax_element(rPos.begin(), rPos.end()); - auto minMaxZ = std::minmax_element(zPos.begin(), zPos.end()); - double rMin = *minMaxR.first; - double zMin = *minMaxZ.first; - double rMax = *minMaxR.second; - double zMax = *minMaxZ.second; - // calculate maxima (add one last bin, because bin value always corresponds to - // left boundary) - double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); - double stepR = std::abs(rMax - rMin) / (nBinsR - 1); - rMax += stepR; - zMax += stepZ; + const auto [rMin, rMax, nBinsR] = detail::getMinMaxAndBinCount(rPos); + const auto [zMin, zMax, nBinsZ] = detail::getMinMaxAndBinCount(zPos); // Create the axis for the grid Axis rAxis(rMin * lengthUnit, rMax * lengthUnit, nBinsR); @@ -79,13 +57,13 @@ auto Acts::materialMapperRZ( using Grid_t = decltype(grid); // [3] Set the material values + const std::array nIndices = {{nBinsR, nBinsZ}}; for (std::size_t i = 1; i <= nBinsR; ++i) { for (std::size_t j = 1; j <= nBinsZ; ++j) { - std::array nIndices = {{rPos.size(), zPos.size()}}; Grid_t::index_t indices = {{i, j}}; - // std::vectors begin with 0 and we do not want the user needing to - // take underflow or overflow bins in account this is why we need to - // subtract by one + // std::vectors begin with 0 and we do not want the user needing to take + // underflow or overflow bins in account this is why we need to subtract + // by one grid.atLocalBins(indices) = materialVector.at( materialVectorToGridMapper({{i - 1, j - 1}}, nIndices)); } @@ -95,14 +73,12 @@ auto Acts::materialMapperRZ( 0., 0., 0.; grid.setExteriorBins(vec); - // [4] Create the transformation for the position - // map (x,y,z) -> (r,z) + // [4] Create the transformation for the position map (x,y,z) -> (r,z) auto transformPos = [](const Vector3& pos) { return Vector2(perp(pos), pos.z()); }; - // [5] Create the mapper & BField Service - // create material mapping + // [5] Create the mapper & BField Service create material mapping return MaterialMapper(transformPos, std::move(grid)); } @@ -125,44 +101,11 @@ auto Acts::materialMapperXYZ( } // [2] Create Grid - // Sort the values - std::ranges::sort(xPos); - std::ranges::sort(yPos); - std::ranges::sort(zPos); - // Get unique values - xPos.erase(std::unique(xPos.begin(), xPos.end()), xPos.end()); - yPos.erase(std::unique(yPos.begin(), yPos.end()), yPos.end()); - zPos.erase(std::unique(zPos.begin(), zPos.end()), zPos.end()); - xPos.shrink_to_fit(); - yPos.shrink_to_fit(); - zPos.shrink_to_fit(); - // get the number of bins - std::size_t nBinsX = xPos.size(); - std::size_t nBinsY = yPos.size(); - std::size_t nBinsZ = zPos.size(); - - // get the minimum and maximum - auto minMaxX = std::minmax_element(xPos.begin(), xPos.end()); - auto minMaxY = std::minmax_element(yPos.begin(), yPos.end()); - auto minMaxZ = std::minmax_element(zPos.begin(), zPos.end()); - // Create the axis for the grid - // get minima - double xMin = *minMaxX.first; - double yMin = *minMaxY.first; - double zMin = *minMaxZ.first; - // get maxima - double xMax = *minMaxX.second; - double yMax = *minMaxY.second; - double zMax = *minMaxZ.second; - // calculate maxima (add one last bin, because bin value always corresponds to - // left boundary) - double stepZ = std::abs(zMax - zMin) / (nBinsZ - 1); - double stepY = std::abs(yMax - yMin) / (nBinsY - 1); - double stepX = std::abs(xMax - xMin) / (nBinsX - 1); - xMax += stepX; - yMax += stepY; - zMax += stepZ; + const auto [xMin, xMax, nBinsX] = detail::getMinMaxAndBinCount(xPos); + const auto [yMin, yMax, nBinsY] = detail::getMinMaxAndBinCount(yPos); + const auto [zMin, zMax, nBinsZ] = detail::getMinMaxAndBinCount(zPos); + // Create the axis for the grid Axis xAxis(xMin * lengthUnit, xMax * lengthUnit, nBinsX); Axis yAxis(yMin * lengthUnit, yMax * lengthUnit, nBinsY); Axis zAxis(zMin * lengthUnit, zMax * lengthUnit, nBinsZ); @@ -172,15 +115,14 @@ auto Acts::materialMapperXYZ( using Grid_t = decltype(grid); // [3] Set the bField values + const std::array nIndices = {{nBinsX, nBinsY, nBinsZ}}; for (std::size_t i = 1; i <= nBinsX; ++i) { for (std::size_t j = 1; j <= nBinsY; ++j) { for (std::size_t k = 1; k <= nBinsZ; ++k) { Grid_t::index_t indices = {{i, j, k}}; - std::array nIndices = { - {xPos.size(), yPos.size(), zPos.size()}}; - // std::vectors begin with 0 and we do not want the user needing to - // take underflow or overflow bins in account this is why we need to - // subtract by one + // std::vectors begin with 0 and we do not want the user needing to take + // underflow or overflow bins in account this is why we need to subtract + // by one grid.atLocalBins(indices) = materialVector.at( materialVectorToGridMapper({{i - 1, j - 1, k - 1}}, nIndices)); } @@ -191,11 +133,9 @@ auto Acts::materialMapperXYZ( 0., 0., 0.; grid.setExteriorBins(vec); - // [4] Create the transformation for the position - // map (x,y,z) -> (r,z) + // [4] Create the transformation for the position map (x,y,z) -> (r,z) auto transformPos = [](const Vector3& pos) { return pos; }; - // [5] Create the mapper & BField Service - // create material mapping + // [5] Create the mapper & BField Service create material mapping return MaterialMapper(transformPos, std::move(grid)); } From 4a506f8298d13376c5c85335e3783c1e7aed43c8 Mon Sep 17 00:00:00 2001 From: "Alexander J. Pfleger" <70842573+AJPfleger@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:51:03 +0100 Subject: [PATCH 5/8] refactor: replace `long unsigned int` with `std::size_t` (#3930) ## Summary by CodeRabbit - **New Features** - Enhanced error handling for input space points in the GbtsSeedingAlgorithm. - Improved seed finding logic based on internal ROI descriptors. - **Bug Fixes** - Updated handling of mapping logic to ensure clarity and prevent missing keys. - **Refactor** - Changed variable types from `long unsigned int` to `std::size_t` across multiple components for improved type safety. - **Tests** - Updated loop index types in various test cases to enhance type safety and align with best practices. --- Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp | 2 +- .../include/ActsExamples/Io/Root/RootAthenaDumpReader.hpp | 2 +- Tests/UnitTests/Plugins/GeoModel/GeoBoxToVolumeTest.cpp | 2 +- Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp | 4 ++-- Tests/UnitTests/Plugins/GeoModel/GeoPolyConverterTests.cpp | 4 ++-- Tests/UnitTests/Plugins/GeoModel/GeoTubeToVolumeTest.cpp | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp index 677ba2b4c10..c126225aea1 100644 --- a/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/GbtsSeedingAlgorithm.cpp @@ -355,7 +355,7 @@ ActsExamples::GbtsSeedingAlgorithm::LayerNumbering() const { } }); - for (long unsigned int i = 0; i < input_vector.size(); i++) { + for (std::size_t i = 0; i < input_vector.size(); i++) { input_vector[i].m_refCoord = input_vector[i].m_refCoord / count_vector[i]; } diff --git a/Examples/Io/Root/include/ActsExamples/Io/Root/RootAthenaDumpReader.hpp b/Examples/Io/Root/include/ActsExamples/Io/Root/RootAthenaDumpReader.hpp index 2a09d8492b2..f7873bd0e2a 100644 --- a/Examples/Io/Root/include/ActsExamples/Io/Root/RootAthenaDumpReader.hpp +++ b/Examples/Io/Root/include/ActsExamples/Io/Root/RootAthenaDumpReader.hpp @@ -172,7 +172,7 @@ class RootAthenaDumpReader : public IReader { /// Vector of {eventNr, entryMin, entryMax} std::vector> m_eventMap; std::shared_ptr m_inputchain; - long unsigned int m_events; + std::size_t m_events; bool m_haveStripFeatures = true; static constexpr unsigned int maxCL = 1500000; diff --git a/Tests/UnitTests/Plugins/GeoModel/GeoBoxToVolumeTest.cpp b/Tests/UnitTests/Plugins/GeoModel/GeoBoxToVolumeTest.cpp index b905fda65ee..426b7cc07c3 100644 --- a/Tests/UnitTests/Plugins/GeoModel/GeoBoxToVolumeTest.cpp +++ b/Tests/UnitTests/Plugins/GeoModel/GeoBoxToVolumeTest.cpp @@ -58,7 +58,7 @@ BOOST_AUTO_TEST_CASE(GeoBoxToSensitiveConversion) { const auto* bounds = dynamic_cast(&volumeBox->volumeBounds()); std::vector convHls = bounds->values(); - for (long unsigned int i = 0; i < hls.size(); i++) { + for (std::size_t i = 0; i < hls.size(); i++) { BOOST_CHECK(hls[i] == convHls[i]); } } diff --git a/Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp b/Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp index 033f2c9cb4a..ae3c4ec0420 100644 --- a/Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp +++ b/Tests/UnitTests/Plugins/GeoModel/GeoDetectorObjectTest.cpp @@ -43,7 +43,7 @@ void test(const Acts::GeoModelDetectorObjectFactory::Cache& cache, GeoModelDetObj::GeoDims geoDims) { for (const auto& box : cache.boundingBoxes) { const Acts::VolumeBounds& bounds = box->volumeBounds(); - for (long unsigned int i = 0; i < geoDims.boxO.size(); i++) { + for (std::size_t i = 0; i < geoDims.boxO.size(); i++) { BOOST_CHECK(geoDims.boxO[i] == bounds.values()[i]); } std::vector surfaces = box->surfaces(); @@ -75,7 +75,7 @@ void test(const Acts::GeoModelDetectorObjectFactory::Cache& cache, dynamic_cast(&sbounds); std::vector trapVerts = trapBounds->vertices(); - for (long unsigned int i = 0; i < trapVerts.size(); i++) { + for (std::size_t i = 0; i < trapVerts.size(); i++) { BOOST_CHECK(trapVerts[i][0] == geoDims.trapVerts[i][0]); BOOST_CHECK(trapVerts[i][1] == geoDims.trapVerts[i][1]); } diff --git a/Tests/UnitTests/Plugins/GeoModel/GeoPolyConverterTests.cpp b/Tests/UnitTests/Plugins/GeoModel/GeoPolyConverterTests.cpp index b273b0a2364..a9ed6fa6f56 100644 --- a/Tests/UnitTests/Plugins/GeoModel/GeoPolyConverterTests.cpp +++ b/Tests/UnitTests/Plugins/GeoModel/GeoPolyConverterTests.cpp @@ -88,7 +88,7 @@ BOOST_AUTO_TEST_CASE(GeoModelDetectorObjectFactory) { const auto* polyBounds = dynamic_cast(&polySurface->bounds()); std::vector convPolyVerts = polyBounds->vertices(); - for (long unsigned int i = 0; i < polyVerts.size(); i++) { + for (std::size_t i = 0; i < polyVerts.size(); i++) { BOOST_CHECK(polyVerts[i][0] == convPolyVerts[i][0]); BOOST_CHECK(polyVerts[i][1] == convPolyVerts[i][1]); } @@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(GeoModelDetectorObjectFactory) { const auto* trapBounds = dynamic_cast(&trapSurface->bounds()); std::vector convTrapVerts = trapBounds->vertices(); - for (long unsigned int i = 0; i < trapVerts.size(); i++) { + for (std::size_t i = 0; i < trapVerts.size(); i++) { BOOST_CHECK(trapVerts[i][0] == convTrapVerts[i][0]); BOOST_CHECK(trapVerts[i][1] == convTrapVerts[i][1]); } diff --git a/Tests/UnitTests/Plugins/GeoModel/GeoTubeToVolumeTest.cpp b/Tests/UnitTests/Plugins/GeoModel/GeoTubeToVolumeTest.cpp index 64d368e7f2b..fd58df2f7ff 100644 --- a/Tests/UnitTests/Plugins/GeoModel/GeoTubeToVolumeTest.cpp +++ b/Tests/UnitTests/Plugins/GeoModel/GeoTubeToVolumeTest.cpp @@ -56,7 +56,7 @@ BOOST_AUTO_TEST_CASE(GeoBoxToSensitiveConversion) { const auto* bounds = dynamic_cast( &volumeTube->volumeBounds()); std::vector convDims = bounds->values(); - for (long unsigned int i = 0; i < dims.size(); i++) { + for (std::size_t i = 0; i < dims.size(); i++) { BOOST_CHECK(dims[i] == convDims[i]); } } From 6cbf203aa3703d8484e501a3c119e1c3dca32c8b Mon Sep 17 00:00:00 2001 From: Stephen Nicholas Swatman Date: Mon, 2 Dec 2024 18:45:58 +0100 Subject: [PATCH 6/8] fix: Explicitly disable paging in pre-commit hook (#3928) The pre-commit hook that checks for leftover conflict markers introduced in #3708 calls git diff. While this works well in general, I am running into an edge case where git is failing to determine that it is not being run in a TTY, causing it to fire up a pager which, in turn, causes pre-commit to hang as it waits for the pager to close. This commit fixes this issue by adding the `--no-pager` flag to the git command. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 68c78341c5d..4158678a3e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -92,7 +92,7 @@ repos: - id: leftover_conflict_markers name: Leftover conflict markers language: system - entry: git diff --staged --check + entry: git --no-pager diff --staged --check - repo: local hooks: From c4c5f95aaca94faa5aa70ed697f3b16d700a3a3a Mon Sep 17 00:00:00 2001 From: Benjamin Huth <37871400+benjaminhuth@users.noreply.github.com> Date: Mon, 2 Dec 2024 20:30:47 +0100 Subject: [PATCH 7/8] fix: Add hit count in root dump reader (#3929) Adds hit count information to particles read from the `RootAthenaDumpReader`. Even though simhits != measurements strictely speaking, in that scenario it is ok to assume this I think. ## Summary by CodeRabbit - **New Features** - Enhanced particle measurement tracking by updating the `newParticle` object to accurately reflect the number of hits during processing. - **Bug Fixes** - Improved accuracy in the processing of particles by ensuring the number of hits is correctly determined. --- Examples/Io/Root/src/RootAthenaDumpReader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/Io/Root/src/RootAthenaDumpReader.cpp b/Examples/Io/Root/src/RootAthenaDumpReader.cpp index 47e5150501a..421affa36ba 100644 --- a/Examples/Io/Root/src/RootAthenaDumpReader.cpp +++ b/Examples/Io/Root/src/RootAthenaDumpReader.cpp @@ -672,6 +672,7 @@ RootAthenaDumpReader::reprocessParticles( } auto newParticle = particle.withParticleId(fatrasBarcode); + newParticle.final().setNumberOfHits(std::distance(begin, end)); newParticles.push_back(newParticle); for (auto it = begin; it != end; ++it) { From 797c3c355368308eb5a96fa390e1be27d4fc3534 Mon Sep 17 00:00:00 2001 From: Juan Miguel Carceller <22276694+jmcarcell@users.noreply.github.com> Date: Mon, 2 Dec 2024 23:02:05 +0100 Subject: [PATCH 8/8] chore: clean up a few includes and imports (#3925) Remove a few headers and imports flagged by clangd and add some where they are used but not included. --- Core/include/Acts/EventData/TrackContainer.hpp | 7 +------ Core/include/Acts/EventData/TrackProxy.hpp | 1 - Core/include/Acts/Geometry/Extent.hpp | 1 + Core/include/Acts/Geometry/GeometryIdentifier.hpp | 1 - .../Acts/TrackFinding/CombinatorialKalmanFilter.hpp | 2 +- Core/include/Acts/TrackFinding/MeasurementSelector.hpp | 2 -- Core/include/Acts/Utilities/Helpers.hpp | 2 -- .../Algorithms/Digitization/src/DigitizationAlgorithm.cpp | 4 ++++ .../Algorithms/Digitization/src/MeasurementCreation.cpp | 3 --- .../ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp | 4 +--- .../TrackFinding/TrackParamsEstimationAlgorithm.hpp | 7 ------- Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp | 5 ----- Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp | 3 --- .../TrackFinding/src/TrackParamsEstimationAlgorithm.cpp | 2 +- .../ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp | 1 - .../include/ActsExamples/EventData/GeometryContainers.hpp | 4 ---- .../include/ActsExamples/EventData/Measurement.hpp | 1 + .../include/ActsExamples/EventData/SimSpacePoint.hpp | 1 - .../Framework/src/EventData/MeasurementCalibration.cpp | 2 -- Examples/Scripts/GsfDebugger/src/processors.py | 2 -- Plugins/DD4hep/src/ConvertDD4hepDetector.cpp | 3 --- Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp | 1 - Plugins/DD4hep/src/DD4hepLayerBuilder.cpp | 3 --- 23 files changed, 10 insertions(+), 52 deletions(-) diff --git a/Core/include/Acts/EventData/TrackContainer.hpp b/Core/include/Acts/EventData/TrackContainer.hpp index 03f7f1f8bb1..842c6a136dd 100644 --- a/Core/include/Acts/EventData/TrackContainer.hpp +++ b/Core/include/Acts/EventData/TrackContainer.hpp @@ -8,9 +8,6 @@ #pragma once -#include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" -#include "Acts/Definitions/Units.hpp" #include "Acts/EventData/MultiTrajectory.hpp" #include "Acts/EventData/MultiTrajectoryBackendConcept.hpp" #include "Acts/EventData/TrackContainerBackendConcept.hpp" @@ -21,11 +18,9 @@ #include "Acts/Utilities/Holders.hpp" #include "Acts/Utilities/Iterator.hpp" #include "Acts/Utilities/TypeTraits.hpp" -#include "Acts/Utilities/UnitVectors.hpp" #include -#include -#include +#include #include namespace Acts { diff --git a/Core/include/Acts/EventData/TrackProxy.hpp b/Core/include/Acts/EventData/TrackProxy.hpp index 7e62eea943d..722c69afba1 100644 --- a/Core/include/Acts/EventData/TrackProxy.hpp +++ b/Core/include/Acts/EventData/TrackProxy.hpp @@ -21,7 +21,6 @@ #include "Acts/Utilities/UnitVectors.hpp" #include -#include namespace Acts { diff --git a/Core/include/Acts/Geometry/Extent.hpp b/Core/include/Acts/Geometry/Extent.hpp index ca4d439e9ba..840a4ef582c 100644 --- a/Core/include/Acts/Geometry/Extent.hpp +++ b/Core/include/Acts/Geometry/Extent.hpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include diff --git a/Core/include/Acts/Geometry/GeometryIdentifier.hpp b/Core/include/Acts/Geometry/GeometryIdentifier.hpp index f1bf7a26736..6b43e510f78 100644 --- a/Core/include/Acts/Geometry/GeometryIdentifier.hpp +++ b/Core/include/Acts/Geometry/GeometryIdentifier.hpp @@ -11,7 +11,6 @@ #include #include #include -#include namespace Acts { diff --git a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp index 90a7ab5f134..1ab019b59ce 100644 --- a/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp +++ b/Core/include/Acts/TrackFinding/CombinatorialKalmanFilter.hpp @@ -365,7 +365,7 @@ class CombinatorialKalmanFilter { ACTS_VERBOSE("Create temp track state with mask: " << mask); // CAREFUL! This trackstate has a previous index that is not in this - // MultiTrajectory Visiting brackwards from this track state will + // MultiTrajectory Visiting backwards from this track state will // fail! auto ts = bufferTrajectory.makeTrackState(mask, prevTip); diff --git a/Core/include/Acts/TrackFinding/MeasurementSelector.hpp b/Core/include/Acts/TrackFinding/MeasurementSelector.hpp index fd348d44075..4c205820b76 100644 --- a/Core/include/Acts/TrackFinding/MeasurementSelector.hpp +++ b/Core/include/Acts/TrackFinding/MeasurementSelector.hpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" #include "Acts/EventData/MultiTrajectory.hpp" -#include "Acts/EventData/TrackParameters.hpp" #include "Acts/EventData/Types.hpp" #include "Acts/Geometry/GeometryHierarchyMap.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" @@ -21,7 +20,6 @@ #include #include -#include #include #include #include diff --git a/Core/include/Acts/Utilities/Helpers.hpp b/Core/include/Acts/Utilities/Helpers.hpp index 56d9b36481f..6e60443da36 100644 --- a/Core/include/Acts/Utilities/Helpers.hpp +++ b/Core/include/Acts/Utilities/Helpers.hpp @@ -15,8 +15,6 @@ #include #include #include -#include -#include #include #include diff --git a/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp b/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp index 08b19b34ba1..d7b4754cb3a 100644 --- a/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp +++ b/Examples/Algorithms/Digitization/src/DigitizationAlgorithm.cpp @@ -13,11 +13,15 @@ #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Utilities/BinUtility.hpp" #include "ActsExamples/Digitization/ModuleClusters.hpp" +#include "ActsExamples/EventData/GeometryContainers.hpp" +#include "ActsExamples/EventData/Index.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" +#include "ActsExamples/Utilities/Range.hpp" #include "ActsFatras/EventData/Barcode.hpp" #include #include +#include #include #include #include diff --git a/Examples/Algorithms/Digitization/src/MeasurementCreation.cpp b/Examples/Algorithms/Digitization/src/MeasurementCreation.cpp index 066901cc0cf..0e2f0668615 100644 --- a/Examples/Algorithms/Digitization/src/MeasurementCreation.cpp +++ b/Examples/Algorithms/Digitization/src/MeasurementCreation.cpp @@ -9,14 +9,11 @@ #include "ActsExamples/Digitization/MeasurementCreation.hpp" #include "Acts/EventData/MeasurementHelpers.hpp" -#include "Acts/EventData/SourceLink.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" -#include "ActsExamples/EventData/IndexSourceLink.hpp" #include "ActsExamples/EventData/Measurement.hpp" #include #include -#include ActsExamples::VariableBoundMeasurementProxy ActsExamples::createMeasurement( MeasurementContainer& container, Acts::GeometryIdentifier geometryId, diff --git a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp index 0f532be2d28..804d554515d 100644 --- a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp +++ b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackFindingAlgorithm.hpp @@ -8,11 +8,10 @@ #pragma once -#include "Acts/EventData/SourceLink.hpp" #include "Acts/EventData/TrackContainer.hpp" -#include "Acts/EventData/TrackProxy.hpp" #include "Acts/EventData/VectorMultiTrajectory.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" +#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/TrackFinding/CombinatorialKalmanFilter.hpp" #include "Acts/TrackFinding/MeasurementSelector.hpp" #include "Acts/TrackFinding/TrackSelector.hpp" @@ -32,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp index 1df8dc87700..3e39b4c24e7 100644 --- a/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp +++ b/Examples/Algorithms/TrackFinding/include/ActsExamples/TrackFinding/TrackParamsEstimationAlgorithm.hpp @@ -8,12 +8,9 @@ #pragma once -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Definitions/Units.hpp" #include "Acts/EventData/ParticleHypothesis.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" -#include "Acts/MagneticField/ConstantBField.hpp" -#include "Acts/MagneticField/InterpolatedBFieldMap.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/EventData/ProtoTrack.hpp" #include "ActsExamples/EventData/SimSeed.hpp" @@ -21,14 +18,10 @@ #include "ActsExamples/Framework/DataHandle.hpp" #include "ActsExamples/Framework/IAlgorithm.hpp" #include "ActsExamples/Framework/ProcessCode.hpp" -#include "ActsExamples/MagneticField/MagneticField.hpp" -#include #include -#include #include #include -#include namespace Acts { class TrackingGeometry; diff --git a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp index 2cea4b7b505..fe69a290935 100644 --- a/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/SeedingAlgorithm.cpp @@ -10,20 +10,15 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/EventData/Seed.hpp" -#include "Acts/EventData/SpacePointData.hpp" #include "Acts/Seeding/BinnedGroup.hpp" #include "Acts/Seeding/SeedFilter.hpp" -#include "Acts/Utilities/BinningType.hpp" #include "Acts/Utilities/Delegate.hpp" -#include "Acts/Utilities/Grid.hpp" #include "Acts/Utilities/GridBinFinder.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "ActsExamples/EventData/SimSeed.hpp" #include #include #include -#include #include #include #include diff --git a/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp b/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp index 673ffa8b103..36bf40a3544 100644 --- a/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp +++ b/Examples/Algorithms/TrackFinding/src/SpacePointMaker.cpp @@ -9,7 +9,6 @@ #include "ActsExamples/TrackFinding/SpacePointMaker.hpp" #include "Acts/Definitions/Algebra.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/SourceLink.hpp" #include "Acts/SpacePointFormation/SpacePointBuilderConfig.hpp" #include "Acts/SpacePointFormation/SpacePointBuilderOptions.hpp" @@ -19,7 +18,6 @@ #include "ActsExamples/EventData/SimSpacePoint.hpp" #include "ActsExamples/Framework/AlgorithmContext.hpp" #include "ActsExamples/Utilities/GroupBy.hpp" -#include "ActsExamples/Utilities/Range.hpp" #include #include @@ -27,7 +25,6 @@ #include #include #include -#include ActsExamples::SpacePointMaker::SpacePointMaker(Config cfg, Acts::Logging::Level lvl) diff --git a/Examples/Algorithms/TrackFinding/src/TrackParamsEstimationAlgorithm.cpp b/Examples/Algorithms/TrackFinding/src/TrackParamsEstimationAlgorithm.cpp index f2711ce1d1a..8f349dd6193 100644 --- a/Examples/Algorithms/TrackFinding/src/TrackParamsEstimationAlgorithm.cpp +++ b/Examples/Algorithms/TrackFinding/src/TrackParamsEstimationAlgorithm.cpp @@ -13,9 +13,9 @@ #include "Acts/EventData/Seed.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" #include "Acts/Geometry/TrackingGeometry.hpp" +#include "Acts/MagneticField/MagneticFieldProvider.hpp" #include "Acts/Seeding/EstimateTrackParamsFromSeed.hpp" #include "Acts/Surfaces/Surface.hpp" -#include "Acts/Utilities/Result.hpp" #include "ActsExamples/EventData/IndexSourceLink.hpp" #include "ActsExamples/EventData/SimSpacePoint.hpp" #include "ActsExamples/EventData/Track.hpp" diff --git a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp index b1e19293a6e..6ea0225e200 100644 --- a/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp +++ b/Examples/Algorithms/TruthTracking/ActsExamples/TruthTracking/TruthSeedingAlgorithm.cpp @@ -9,7 +9,6 @@ #include "ActsExamples/TruthTracking/TruthSeedingAlgorithm.hpp" #include "Acts/EventData/SourceLink.hpp" -#include "Acts/Utilities/MultiIndex.hpp" #include "ActsExamples/EventData/IndexSourceLink.hpp" #include "ActsExamples/EventData/SimParticle.hpp" #include "ActsExamples/Utilities/Range.hpp" diff --git a/Examples/Framework/include/ActsExamples/EventData/GeometryContainers.hpp b/Examples/Framework/include/ActsExamples/EventData/GeometryContainers.hpp index 0724ed8c4ae..e88e8e9db38 100644 --- a/Examples/Framework/include/ActsExamples/EventData/GeometryContainers.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/GeometryContainers.hpp @@ -8,16 +8,12 @@ #pragma once -#include "Acts/EventData/SourceLink.hpp" #include "Acts/Geometry/GeometryIdentifier.hpp" -#include "Acts/Surfaces/Surface.hpp" #include "ActsExamples/Utilities/GroupBy.hpp" #include "ActsExamples/Utilities/Range.hpp" #include #include -#include -#include #include #include diff --git a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp index 174dc05ef40..251d7bc293a 100644 --- a/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/Measurement.hpp @@ -19,6 +19,7 @@ #include "ActsExamples/EventData/MeasurementConcept.hpp" #include +#include #include #include diff --git a/Examples/Framework/include/ActsExamples/EventData/SimSpacePoint.hpp b/Examples/Framework/include/ActsExamples/EventData/SimSpacePoint.hpp index bf5780c5a76..4593b3f9e3d 100644 --- a/Examples/Framework/include/ActsExamples/EventData/SimSpacePoint.hpp +++ b/Examples/Framework/include/ActsExamples/EventData/SimSpacePoint.hpp @@ -11,7 +11,6 @@ #include "Acts/Definitions/Algebra.hpp" #include "Acts/Definitions/Common.hpp" #include "Acts/EventData/SourceLink.hpp" -#include "ActsExamples/EventData/Index.hpp" #include "ActsExamples/EventData/IndexSourceLink.hpp" #include diff --git a/Examples/Framework/src/EventData/MeasurementCalibration.cpp b/Examples/Framework/src/EventData/MeasurementCalibration.cpp index d7b8c96da70..5bf28eb3ab4 100644 --- a/Examples/Framework/src/EventData/MeasurementCalibration.cpp +++ b/Examples/Framework/src/EventData/MeasurementCalibration.cpp @@ -8,13 +8,11 @@ #include "ActsExamples/EventData/MeasurementCalibration.hpp" -#include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/EventData/SourceLink.hpp" #include "ActsExamples/EventData/IndexSourceLink.hpp" #include "ActsExamples/EventData/Measurement.hpp" #include -#include namespace Acts { class VectorMultiTrajectory; diff --git a/Examples/Scripts/GsfDebugger/src/processors.py b/Examples/Scripts/GsfDebugger/src/processors.py index 3d42d06c123..71c39f5a3a4 100644 --- a/Examples/Scripts/GsfDebugger/src/processors.py +++ b/Examples/Scripts/GsfDebugger/src/processors.py @@ -1,7 +1,5 @@ -import traceback import re import copy -import sys from itertools import cycle import numpy as np diff --git a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp index 848de200db0..be76e7c8278 100644 --- a/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp +++ b/Plugins/DD4hep/src/ConvertDD4hepDetector.cpp @@ -21,7 +21,6 @@ #include "Acts/Geometry/TrackingVolumeArrayCreator.hpp" #include "Acts/Geometry/Volume.hpp" #include "Acts/Material/ISurfaceMaterial.hpp" -#include "Acts/Material/ProtoSurfaceMaterial.hpp" #include "Acts/Plugins/DD4hep/DD4hepConversionHelpers.hpp" #include "Acts/Plugins/DD4hep/DD4hepLayerBuilder.hpp" #include "Acts/Plugins/DD4hep/DD4hepMaterialHelpers.hpp" @@ -31,9 +30,7 @@ #include #include #include -#include #include -#include #include #include #include diff --git a/Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp b/Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp index c043a58d347..7f0275ed1a8 100644 --- a/Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp +++ b/Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp @@ -15,7 +15,6 @@ #include "Acts/Plugins/DD4hep/DD4hepConversionHelpers.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "Acts/Plugins/TGeo/TGeoMaterialConverter.hpp" -#include "Acts/Plugins/TGeo/TGeoPrimitivesHelper.hpp" #include "Acts/Plugins/TGeo/TGeoSurfaceConverter.hpp" #include "DD4hep/DetElement.h" diff --git a/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp b/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp index c7cffaaf5aa..3ae1ecd9145 100644 --- a/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp +++ b/Plugins/DD4hep/src/DD4hepLayerBuilder.cpp @@ -25,15 +25,12 @@ #include "Acts/Surfaces/RadialBounds.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Surfaces/SurfaceArray.hpp" -#include "Acts/Utilities/Helpers.hpp" #include "Acts/Utilities/Logger.hpp" #include -#include #include #include #include -#include #include #include #include