From 7dfe0266d4430f07704fe7f4801dfd886de1f1eb Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 17 Jan 2025 18:21:43 -0600 Subject: [PATCH] feat: fix compilation for Acts versions from v36 up to v38 --- JugTrack/src/components/CKFTracking.cpp | 47 ++++++++++++++++++- JugTrack/src/components/CKFTracking.h | 8 ++++ .../src/components/CKFTrackingFunction.cpp | 5 ++ .../components/SingleTrackSourceLinker.cpp | 37 ++++++++++++--- .../src/components/TrackerSourceLinker.cpp | 36 ++++++++++++-- 5 files changed, 121 insertions(+), 12 deletions(-) diff --git a/JugTrack/src/components/CKFTracking.cpp b/JugTrack/src/components/CKFTracking.cpp index bba17a9..5c965f0 100644 --- a/JugTrack/src/components/CKFTracking.cpp +++ b/JugTrack/src/components/CKFTracking.cpp @@ -29,7 +29,11 @@ #include "Acts/TrackFitting/GainMatrixUpdater.hpp" #include "Acts/Propagator/EigenStepper.hpp" #if Acts_VERSION_MAJOR >= 34 +#if Acts_VERSION_MAJOR >= 37 +#include "Acts/Propagator/ActorList.hpp" +#else #include "Acts/Propagator/AbortList.hpp" +#endif #include "Acts/Propagator/EigenStepper.hpp" #include "Acts/Propagator/MaterialInteractor.hpp" #include "Acts/Propagator/Navigator.hpp" @@ -89,7 +93,9 @@ namespace Jug::Reco { CKFTracking::CKFTracking(const std::string& name, ISvcLocator* svcLoc) : GaudiAlgorithm(name, svcLoc) { +#if Acts_VERSION_MAJOR < 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR < 1) declareProperty("inputSourceLinks", m_inputSourceLinks, ""); +#endif declareProperty("inputMeasurements", m_inputMeasurements, ""); declareProperty("inputInitialTrackParameters", m_inputInitialTrackParameters, ""); declareProperty("outputTracks", m_outputTracks, ""); @@ -136,7 +142,9 @@ namespace Jug::Reco { StatusCode CKFTracking::execute() { // Read input data +#if Acts_VERSION_MAJOR < 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR < 1) const auto* const src_links = m_inputSourceLinks.get(); +#endif const auto* const init_trk_params = m_inputInitialTrackParameters.get(); const auto* const measurements = m_inputMeasurements.get(); @@ -149,7 +157,11 @@ namespace Jug::Reco { ACTS_LOCAL_LOGGER(Acts::getDefaultLogger("CKFTracking Logger", m_actsLoggingLevel)); +#if Acts_VERSION_MAJOR >= 36 + Acts::PropagatorPlainOptions pOptions(m_geoctx, m_fieldctx); +#else Acts::PropagatorPlainOptions pOptions; +#endif pOptions.maxSteps = 10000; ActsExamples::PassThroughCalibrator pcalibrator; @@ -160,14 +172,26 @@ namespace Jug::Reco { #endif Acts::MeasurementSelector measSel{m_sourcelinkSelectorCfg}; +#if Acts_VERSION_MAJOR >= 36 + Acts::CombinatorialKalmanFilterExtensions + extensions; +#else Acts::CombinatorialKalmanFilterExtensions extensions; +#endif extensions.calibrator.connect< &ActsExamples::MeasurementCalibratorAdapter::calibrate>( &calibrator); +#if Acts_VERSION_MAJOR >= 36 + extensions.updater.connect< + &Acts::GainMatrixUpdater::operator()< + typename ActsExamples::TrackContainer::TrackStateContainerBackend>>( + &kfUpdater); +#else extensions.updater.connect< &Acts::GainMatrixUpdater::operator()>( &kfUpdater); +#endif #if Acts_VERSION_MAJOR < 34 extensions.smoother.connect< &Acts::GainMatrixSmoother::operator()>( @@ -178,7 +202,11 @@ namespace Jug::Reco { &measSel); ActsExamples::IndexSourceLinkAccessor slAccessor; +#if Acts_VERSION_MAJOR >= 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR >= 1) + slAccessor.container = measurements->orderedIndices(); +#else slAccessor.container = src_links; +#endif Acts::SourceLinkAccessorDelegate slAccessorDelegate; slAccessorDelegate.connect<&ActsExamples::IndexSourceLinkAccessor::range>(&slAccessor); @@ -194,7 +222,24 @@ namespace Jug::Reco { extensions, pOptions); #endif -#if Acts_VERSION_MAJOR >= 34 +#if Acts_VERSION_MAJOR >= 36 + using Extrapolator = Acts::Propagator, Acts::Navigator>; +# if Acts_VERSION_MAJOR >= 37 + using ExtrapolatorOptions = + Extrapolator::template Options>; +# else + using ExtrapolatorOptions = + Extrapolator::template Options, + Acts::AbortList>; +# endif + Extrapolator extrapolator( + Acts::EigenStepper<>(m_BField), + Acts::Navigator({m_actsGeoSvc->trackingGeometry()}, + logger().cloneWithSuffix("Navigator")), + logger().cloneWithSuffix("Propagator")); + ExtrapolatorOptions extrapolationOptions(m_geoctx, m_fieldctx); +#elif Acts_VERSION_MAJOR >= 34 Acts::Propagator, Acts::Navigator> extrapolator( Acts::EigenStepper<>(m_BField), Acts::Navigator({m_actsGeoSvc->trackingGeometry()}, diff --git a/JugTrack/src/components/CKFTracking.h b/JugTrack/src/components/CKFTracking.h index ccca7c6..b91c869 100644 --- a/JugTrack/src/components/CKFTracking.h +++ b/JugTrack/src/components/CKFTracking.h @@ -41,9 +41,15 @@ class CKFTracking : public GaudiAlgorithm { public: /// Track finder function that takes input measurements, initial trackstate /// and track finder options and returns some track-finder-specific result. +#if Acts_VERSION_MAJOR >= 36 + using TrackFinderOptions = + Acts::CombinatorialKalmanFilterOptions; +#else using TrackFinderOptions = Acts::CombinatorialKalmanFilterOptions; +#endif using TrackFinderResult = Acts::Result>; @@ -66,7 +72,9 @@ class CKFTracking : public GaudiAlgorithm { std::shared_ptr magneticField); public: +#if Acts_VERSION_MAJOR < 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR < 1) DataHandle m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this}; +#endif DataHandle m_inputMeasurements{"inputMeasurements", Gaudi::DataHandle::Reader, this}; DataHandle m_inputInitialTrackParameters{"inputInitialTrackParameters", Gaudi::DataHandle::Reader, this}; diff --git a/JugTrack/src/components/CKFTrackingFunction.cpp b/JugTrack/src/components/CKFTrackingFunction.cpp index a6a3022..895c5dc 100644 --- a/JugTrack/src/components/CKFTrackingFunction.cpp +++ b/JugTrack/src/components/CKFTrackingFunction.cpp @@ -34,12 +34,17 @@ namespace { using Stepper = Acts::EigenStepper<>; using Navigator = Acts::Navigator; using Propagator = Acts::Propagator; +#if Acts_VERSION_MAJOR >= 36 + using CKF = + Acts::CombinatorialKalmanFilter; +#else using CKF = Acts::CombinatorialKalmanFilter; using TrackContainer = Acts::TrackContainer; +#endif /** Finder implmentation . * diff --git a/JugTrack/src/components/SingleTrackSourceLinker.cpp b/JugTrack/src/components/SingleTrackSourceLinker.cpp index 75b2753..e29f7e5 100644 --- a/JugTrack/src/components/SingleTrackSourceLinker.cpp +++ b/JugTrack/src/components/SingleTrackSourceLinker.cpp @@ -21,6 +21,9 @@ #include "Acts/Definitions/Common.hpp" #include "Acts/Definitions/Units.hpp" +#if Acts_VERSION_MAJOR < 36 +#include "Acts/EventData/Measurement.hpp" +#endif #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -160,13 +163,35 @@ class SingleTrackSourceLinker : public GaudiAlgorithm { linkStorage->emplace_back(surface->geometryId(), ihit); ActsExamples::IndexSourceLink& sourceLink = linkStorage->back(); - auto meas = - Acts::makeMeasurement(Acts::SourceLink{sourceLink}, pos, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); - - // add to output containers. since the input is already geometry-order, - // new elements in geometry containers can just be appended at the end. sourceLinks->emplace_hint(sourceLinks->end(), sourceLink); - measurements->emplace_back(std::move(meas)); + +#if Acts_VERSION_MAJOR > 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR >= 1) + std::array indices = {Acts::eBoundLoc0, Acts::eBoundLoc1}; + Acts::visit_measurement( + indices.size(), [&](auto dim) -> ActsExamples::FixedBoundMeasurementProxy<6> { + return measurements->emplaceMeasurement(geoId, indices, pos, cov); + } + ); +#elif Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR == 0 + std::array indices = {Acts::eBoundLoc0, Acts::eBoundLoc1}; + Acts::visit_measurement( + indices.size(), [&](auto dim) -> ActsExamples::FixedBoundMeasurementProxy<6> { + return measurements->emplaceMeasurement(sourceLink, indices, pos, cov); + } + ); +#elif Acts_VERSION_MAJOR == 36 && Acts_VERSION_MINOR >= 1 + auto measurement = ActsExamples::makeVariableSizeMeasurement( + Acts::SourceLink{sourceLink}, pos, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); + measurements->emplace_back(std::move(measurement)); +#elif Acts_VERSION_MAJOR == 36 && Acts_VERSION_MINOR == 0 + auto measurement = ActsExamples::makeFixedSizeMeasurement( + Acts::SourceLink{sourceLink}, pos, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); + measurements->emplace_back(std::move(measurement)); +#else + auto measurement = + Acts::makeMeasurement(Acts::SourceLink{sourceLink}, pos, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); + measurements->emplace_back(std::move(measurement)); +#endif ihit++; } diff --git a/JugTrack/src/components/TrackerSourceLinker.cpp b/JugTrack/src/components/TrackerSourceLinker.cpp index 22ada49..9fb8643 100644 --- a/JugTrack/src/components/TrackerSourceLinker.cpp +++ b/JugTrack/src/components/TrackerSourceLinker.cpp @@ -23,6 +23,9 @@ #include "Acts/Definitions/Common.hpp" #include "Acts/Definitions/Units.hpp" +#if Acts_VERSION_MAJOR < 36 +#include "Acts/EventData/Measurement.hpp" +#endif #include "Acts/Geometry/TrackingGeometry.hpp" #include "Acts/Plugins/DD4hep/DD4hepDetectorElement.hpp" #include "Acts/Surfaces/Surface.hpp" @@ -155,12 +158,35 @@ class TrackerSourceLinker : public GaudiAlgorithm { // Index hitIdx = measurements->size(); linkStorage->emplace_back(surface->geometryId(), ihit); ActsExamples::IndexSourceLink& sourceLink = linkStorage->back(); - auto meas = Acts::makeMeasurement(Acts::SourceLink{sourceLink}, loc, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); - - // add to output containers. since the input is already geometry-order, - // new elements in geometry containers can just be appended at the end. sourceLinks->emplace_hint(sourceLinks->end(), sourceLink); - measurements->emplace_back(std::move(meas)); + +#if Acts_VERSION_MAJOR > 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR >= 1) + std::array indices = {Acts::eBoundLoc0, Acts::eBoundLoc1}; + Acts::visit_measurement( + indices.size(), [&](auto dim) -> ActsExamples::FixedBoundMeasurementProxy<6> { + return measurements->emplaceMeasurement(geoId, indices, loc, cov); + } + ); +#elif Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR == 0 + std::array indices = {Acts::eBoundLoc0, Acts::eBoundLoc1}; + Acts::visit_measurement( + indices.size(), [&](auto dim) -> ActsExamples::FixedBoundMeasurementProxy<6> { + return measurements->emplaceMeasurement(sourceLink, indices, loc, cov); + } + ); +#elif Acts_VERSION_MAJOR == 36 && Acts_VERSION_MINOR >= 1 + auto measurement = ActsExamples::makeVariableSizeMeasurement( + Acts::SourceLink{sourceLink}, loc, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); + measurements->emplace_back(std::move(measurement)); +#elif Acts_VERSION_MAJOR == 36 && Acts_VERSION_MINOR == 0 + auto measurement = ActsExamples::makeFixedSizeMeasurement( + Acts::SourceLink{sourceLink}, loc, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); + measurements->emplace_back(std::move(measurement)); +#else + auto measurement = Acts::makeMeasurement( + Acts::SourceLink{sourceLink}, loc, cov, Acts::eBoundLoc0, Acts::eBoundLoc1); + measurements->emplace_back(std::move(measurement)); +#endif ihit++; }