Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix compilation for Acts versions from v36 up to v38 #1715

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ find_package(DD4hep REQUIRED)

# ACTS cmake-lint: disable=C0103
find_package(Acts REQUIRED COMPONENTS Core PluginDD4hep PluginJson)
set(Acts_VERSION_MIN "19.0.0")
set(Acts_VERSION_MIN "30.0.0")
set(Acts_VERSION
"${Acts_VERSION_MAJOR}.${Acts_VERSION_MINOR}.${Acts_VERSION_PATCH}")
if(${Acts_VERSION} VERSION_LESS ${Acts_VERSION_MIN} AND NOT "${Acts_VERSION}"
Expand Down
2 changes: 1 addition & 1 deletion cmake/jana_plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ macro(plugin_add_acts _name)

if(NOT Acts_FOUND)
find_package(Acts REQUIRED COMPONENTS Core PluginDD4hep PluginJson)
set(Acts_VERSION_MIN "20.2.0")
set(Acts_VERSION_MIN "30.0.0")
set(Acts_VERSION
"${Acts_VERSION_MAJOR}.${Acts_VERSION_MINOR}.${Acts_VERSION_PATCH}")
if(${Acts_VERSION} VERSION_LESS ${Acts_VERSION_MIN}
Expand Down
23 changes: 18 additions & 5 deletions src/algorithms/tracking/ActsGeometryProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,19 @@ class ActsGeometryProvider {
std::shared_ptr<spdlog::logger> m_init_log;

/// Configuration for obj export
#if Acts_VERSION_MAJOR >= 37
Acts::ViewConfig m_containerView{.color = {220, 220, 220}};
Acts::ViewConfig m_volumeView{.color = {220, 220, 0}};
Acts::ViewConfig m_sensitiveView{.color = {0, 180, 240}};
Acts::ViewConfig m_passiveView{.color = {240, 280, 0}};
Acts::ViewConfig m_gridView{.color = {220, 0, 0}};
#else
Acts::ViewConfig m_containerView{{220, 220, 220}};
Acts::ViewConfig m_volumeView{{220, 220, 0}};
Acts::ViewConfig m_sensitiveView{{0, 180, 240}};
Acts::ViewConfig m_passiveView{{240, 280, 0}};
Acts::ViewConfig m_gridView{{220, 0, 0}};
#endif
bool m_objWriteIt{false};
bool m_plyWriteIt{false};
std::string m_outputTag{""};
Expand All @@ -129,15 +137,20 @@ class ActsGeometryProvider {
void setOutputDir(std::string dir) { m_outputDir = dir; }
std::string getOutputDir() const { return m_outputDir; }

void setContainerView(std::array<int,3> view) { m_containerView = Acts::ViewConfig{view}; }
#if Acts_VERSION_MAJOR >= 37
using Color = Acts::Color;
#else
using Color = Acts::ColorRGB;
#endif
void setContainerView(std::array<int,3> c) { m_containerView.color = Color(c); }
const Acts::ViewConfig& getContainerView() const { return m_containerView; }
void setVolumeView(std::array<int,3> view) { m_volumeView = Acts::ViewConfig{view}; }
void setVolumeView(std::array<int,3> c) { m_volumeView.color = Color(c); }
const Acts::ViewConfig& getVolumeView() const { return m_volumeView; }
void setSensitiveView(std::array<int,3> view) { m_sensitiveView = Acts::ViewConfig{view}; }
void setSensitiveView(std::array<int,3> c) { m_sensitiveView.color = Color(c); }
const Acts::ViewConfig& getSensitiveView() const { return m_sensitiveView; }
void setPassiveView(std::array<int,3> view) { m_passiveView = Acts::ViewConfig{view}; }
void setPassiveView(std::array<int,3> c) { m_passiveView.color = Color(c); }
const Acts::ViewConfig& getPassiveView() const { return m_passiveView; }
void setGridView(std::array<int,3> view) { m_gridView = Acts::ViewConfig{view}; }
void setGridView(std::array<int,3> c) { m_gridView.color = Color(c); }
const Acts::ViewConfig& getGridView() const { return m_gridView; }

};
5 changes: 5 additions & 0 deletions src/algorithms/tracking/AmbiguitySolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ AmbiguitySolver::process(std::vector<const ActsExamples::ConstTrackContainer*> i
tips.clear();
parameters.clear();

if (!track.hasReferenceSurface()) {
ACTS_WARNING("Track has no reference surface.");
continue;
}

tips.push_back(track.tipIndex());
parameters.emplace(
std::pair{track.tipIndex(),
Expand Down
100 changes: 92 additions & 8 deletions src/algorithms/tracking/CKFTracking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,19 @@
#include <Acts/EventData/VectorTrackContainer.hpp>
#include <Acts/Geometry/GeometryIdentifier.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"
#endif
#include <Acts/Propagator/Propagator.hpp>
#if Acts_VERSION_MAJOR >= 36
#include "Acts/Propagator/PropagatorOptions.hpp"
#endif
#if Acts_VERSION_MAJOR >= 34
#include "Acts/Propagator/StandardAborters.hpp"
#endif
Expand Down Expand Up @@ -123,42 +130,78 @@ namespace eicrecon {

// need list here for stable addresses
std::list<ActsExamples::IndexSourceLink> sourceLinkStorage;
#if Acts_VERSION_MAJOR < 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR < 1)
ActsExamples::IndexSourceLinkContainer src_links;
src_links.reserve(meas2Ds.size());
#endif
std::size_t hit_index = 0;


for (const auto& meas2D : meas2Ds) {

Acts::GeometryIdentifier geoId = meas2D.getSurface();

// --follow example from ACTS to create source links
sourceLinkStorage.emplace_back(meas2D.getSurface(), hit_index);
sourceLinkStorage.emplace_back(geoId, hit_index);
ActsExamples::IndexSourceLink& sourceLink = sourceLinkStorage.back();
// Add to output containers:
// index map and source link container are geometry-ordered.
// since the input is also geometry-ordered, new items can
// be added at the end.
#if Acts_VERSION_MAJOR < 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR < 1)
src_links.insert(src_links.end(), sourceLink);
#endif
// ---
// Create ACTS measurements
Acts::Vector2 loc = Acts::Vector2::Zero();
std::array<Acts::BoundIndices, 2> indices{Acts::eBoundLoc0, Acts::eBoundLoc1};

Acts::ActsVector<2> loc = Acts::Vector2::Zero();
loc[Acts::eBoundLoc0] = meas2D.getLoc().a;
loc[Acts::eBoundLoc1] = meas2D.getLoc().b;


Acts::SquareMatrix2 cov = Acts::SquareMatrix2::Zero();
Acts::ActsSquareMatrix<2> cov = Acts::ActsSquareMatrix<2>::Zero();
cov(0, 0) = meas2D.getCovariance().xx;
cov(1, 1) = meas2D.getCovariance().yy;
cov(0, 1) = meas2D.getCovariance().xy;
cov(1, 0) = meas2D.getCovariance().xy;

#if Acts_VERSION_MAJOR >= 36
#if Acts_VERSION_MAJOR > 37 || (Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR >= 1)
Acts::visit_measurement(
indices.size(), [&](auto dim) -> ActsExamples::VariableBoundMeasurementProxy {
if constexpr (dim == indices.size()) {
return ActsExamples::VariableBoundMeasurementProxy{
measurements->emplaceMeasurement<dim>(geoId, indices, loc, cov)
};
} else {
throw std::runtime_error("Dimension not supported in measurement creation");
}
}
);
#elif Acts_VERSION_MAJOR == 37 && Acts_VERSION_MINOR == 0
Acts::visit_measurement(
indices.size(), [&](auto dim) -> ActsExamples::VariableBoundMeasurementProxy {
if constexpr (dim == indices.size()) {
return ActsExamples::VariableBoundMeasurementProxy{
measurements->emplaceMeasurement<dim>(Acts::SourceLink{sourceLink}, indices, loc, cov)
};
} else {
throw std::runtime_error("Dimension not supported in measurement creation");
}
}
);
#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);
#endif
measurements->emplace_back(std::move(measurement));
#endif

hit_index++;
}
Expand Down Expand Up @@ -197,7 +240,11 @@ namespace eicrecon {

ACTS_LOCAL_LOGGER(eicrecon::getSpdlogLogger("CKF", m_log, {"^No tracks found$"}));

#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 @@ -208,13 +255,25 @@ namespace eicrecon {
#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 @@ -225,7 +284,11 @@ namespace eicrecon {
&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 @@ -241,13 +304,29 @@ namespace eicrecon {
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_geoSvc->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_geoSvc->trackingGeometry()},
logger().cloneWithSuffix("Navigator")),
logger().cloneWithSuffix("Propagator"));

Acts::PropagatorOptions<Acts::ActionList<Acts::MaterialInteractor>,
Acts::AbortList<Acts::EndOfWorldReached>>
extrapolationOptions(m_geoctx, m_fieldctx);
Expand Down Expand Up @@ -371,6 +450,11 @@ namespace eicrecon {

lastSeed = constSeedNumber(track);

if (!track.hasReferenceSurface()) {
ACTS_WARNING("Track has no reference surface.");
continue;
}

tips.push_back(track.tipIndex());
parameters.emplace(
std::pair{track.tipIndex(),
Expand Down
6 changes: 6 additions & 0 deletions src/algorithms/tracking/CKFTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ namespace eicrecon {
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 Down
11 changes: 11 additions & 0 deletions src/algorithms/tracking/CKFTrackingFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#include <Acts/EventData/ParticleHypothesis.hpp>
#include <Acts/EventData/TrackContainer.hpp>
#include <Acts/EventData/TrackStatePropMask.hpp>
#if Acts_VERSION_MAJOR < 36
#include <Acts/EventData/VectorMultiTrajectory.hpp>
#include <Acts/EventData/VectorTrackContainer.hpp>
#endif
#include <Acts/Geometry/Layer.hpp>
#include <Acts/Geometry/TrackingGeometry.hpp>
#include <Acts/Geometry/TrackingVolume.hpp>
Expand Down Expand Up @@ -38,12 +40,17 @@ namespace eicrecon{
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,
wdconinc marked this conversation as resolved.
Show resolved Hide resolved
Acts::VectorMultiTrajectory, std::shared_ptr>;
#endif

/** Finder implementation .
*
Expand All @@ -58,7 +65,11 @@ namespace eicrecon{
eicrecon::CKFTracking::TrackFinderResult operator()(
const ActsExamples::TrackParameters& initialParameters,
const eicrecon::CKFTracking::TrackFinderOptions& options,
#if Acts_VERSION_MAJOR >= 36
ActsExamples::TrackContainer& tracks) const override {
#else
TrackContainer& tracks) const override {
#endif
return trackFinder.findTracks(initialParameters, options, tracks);
};
};
Expand Down
6 changes: 5 additions & 1 deletion src/algorithms/tracking/SpacePoint.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#pragma once

#include <Acts/Geometry/GeometryIdentifier.hpp>
#if Acts_VERSION_MAJOR >= 37
#include <Acts/EventData/Seed.hpp>
#else
#include <Acts/Seeding/Seed.hpp>
#endif
#include <Acts/Geometry/GeometryIdentifier.hpp>
#include <Acts/Surfaces/Surface.hpp>
#include "ActsGeometryProvider.h"
namespace eicrecon {
Expand Down
4 changes: 4 additions & 0 deletions src/algorithms/tracking/TrackPropagation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ void TrackPropagation::propagateToSurfaceList(

ACTS_LOCAL_LOGGER(eicrecon::getSpdlogLogger("PROP", m_log));

#if Acts_VERSION_MAJOR >= 36
Propagator::template Options<> options(m_geoContext, m_fieldContext);
#else
Acts::PropagatorOptions<> options(m_geoContext, m_fieldContext);
#endif

auto result = propagator.propagate(initial_bound_parameters, *targetSurf, options);

Expand Down
Loading
Loading