Skip to content

Commit

Permalink
feat: fix compilation for Acts versions from v36 up to v38
Browse files Browse the repository at this point in the history
  • Loading branch information
wdconinc committed Jan 18, 2025
1 parent 539ddf8 commit 7dfe026
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 12 deletions.
47 changes: 46 additions & 1 deletion JugTrack/src/components/CKFTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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, "");
Expand Down Expand Up @@ -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();

Expand All @@ -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;
Expand All @@ -160,14 +172,26 @@ namespace Jug::Reco {
#endif
Acts::MeasurementSelector measSel{m_sourcelinkSelectorCfg};

#if Acts_VERSION_MAJOR >= 36
Acts::CombinatorialKalmanFilterExtensions<ActsExamples::TrackContainer>
extensions;
#else
Acts::CombinatorialKalmanFilterExtensions<Acts::VectorMultiTrajectory>
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()<Acts::VectorMultiTrajectory>>(
&kfUpdater);
#endif
#if Acts_VERSION_MAJOR < 34
extensions.smoother.connect<
&Acts::GainMatrixSmoother::operator()<Acts::VectorMultiTrajectory>>(
Expand All @@ -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<ActsExamples::IndexSourceLinkAccessor::Iterator>
slAccessorDelegate;
slAccessorDelegate.connect<&ActsExamples::IndexSourceLinkAccessor::range>(&slAccessor);
Expand All @@ -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::EigenStepper<>, Acts::Navigator>;
# if Acts_VERSION_MAJOR >= 37
using ExtrapolatorOptions =
Extrapolator::template Options<Acts::ActorList<Acts::MaterialInteractor,
Acts::EndOfWorldReached>>;
# else
using ExtrapolatorOptions =
Extrapolator::template Options<Acts::ActionList<Acts::MaterialInteractor>,
Acts::AbortList<Acts::EndOfWorldReached>>;
# 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::EigenStepper<>, Acts::Navigator> extrapolator(
Acts::EigenStepper<>(m_BField),
Acts::Navigator({m_actsGeoSvc->trackingGeometry()},
Expand Down
8 changes: 8 additions & 0 deletions JugTrack/src/components/CKFTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActsExamples::IndexSourceLinkAccessor::Iterator,
ActsExamples::TrackContainer>;
#else
using TrackFinderOptions =
Acts::CombinatorialKalmanFilterOptions<ActsExamples::IndexSourceLinkAccessor::Iterator,
Acts::VectorMultiTrajectory>;
#endif
using TrackFinderResult =
Acts::Result<std::vector<ActsExamples::TrackContainer::TrackProxy>>;

Expand All @@ -66,7 +72,9 @@ class CKFTracking : public GaudiAlgorithm {
std::shared_ptr<const Acts::MagneticFieldProvider> magneticField);

public:
#if Acts_VERSION_MAJOR < 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR < 1)
DataHandle<ActsExamples::IndexSourceLinkContainer> m_inputSourceLinks{"inputSourceLinks", Gaudi::DataHandle::Reader, this};
#endif
DataHandle<ActsExamples::MeasurementContainer> m_inputMeasurements{"inputMeasurements", Gaudi::DataHandle::Reader, this};
DataHandle<ActsExamples::TrackParametersContainer> m_inputInitialTrackParameters{"inputInitialTrackParameters",
Gaudi::DataHandle::Reader, this};
Expand Down
5 changes: 5 additions & 0 deletions JugTrack/src/components/CKFTrackingFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ namespace {
using Stepper = Acts::EigenStepper<>;
using Navigator = Acts::Navigator;
using Propagator = Acts::Propagator<Stepper, Navigator>;
#if Acts_VERSION_MAJOR >= 36
using CKF =
Acts::CombinatorialKalmanFilter<Propagator, ActsExamples::TrackContainer>;
#else
using CKF =
Acts::CombinatorialKalmanFilter<Propagator, Acts::VectorMultiTrajectory>;

using TrackContainer =
Acts::TrackContainer<Acts::VectorTrackContainer,
Acts::VectorMultiTrajectory, std::shared_ptr>;
#endif

/** Finder implmentation .
*
Expand Down
37 changes: 31 additions & 6 deletions JugTrack/src/components/SingleTrackSourceLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<Acts::BoundIndices, 2> indices = {Acts::eBoundLoc0, Acts::eBoundLoc1};
Acts::visit_measurement(
indices.size(), [&](auto dim) -> ActsExamples::FixedBoundMeasurementProxy<6> {
return measurements->emplaceMeasurement<dim>(geoId, indices, pos, cov);
}
);
#elif Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR == 0
std::array<Acts::BoundIndices, 2> indices = {Acts::eBoundLoc0, Acts::eBoundLoc1};
Acts::visit_measurement(
indices.size(), [&](auto dim) -> ActsExamples::FixedBoundMeasurementProxy<6> {
return measurements->emplaceMeasurement<dim>(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++;
}
Expand Down
36 changes: 31 additions & 5 deletions JugTrack/src/components/TrackerSourceLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<Acts::BoundIndices, 2> indices = {Acts::eBoundLoc0, Acts::eBoundLoc1};
Acts::visit_measurement(
indices.size(), [&](auto dim) -> ActsExamples::FixedBoundMeasurementProxy<6> {
return measurements->emplaceMeasurement<dim>(geoId, indices, loc, cov);
}
);
#elif Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR == 0
std::array<Acts::BoundIndices, 2> indices = {Acts::eBoundLoc0, Acts::eBoundLoc1};
Acts::visit_measurement(
indices.size(), [&](auto dim) -> ActsExamples::FixedBoundMeasurementProxy<6> {
return measurements->emplaceMeasurement<dim>(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++;
}
Expand Down

0 comments on commit 7dfe026

Please sign in to comment.