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 9 commits into
base: main
Choose a base branch
from
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; }

};
79 changes: 73 additions & 6 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,66 @@ 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();
loc[Acts::eBoundLoc0] = meas2D.getLoc().a;
loc[Acts::eBoundLoc1] = meas2D.getLoc().b;


Acts::SquareMatrix2 cov = Acts::SquareMatrix2::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)
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 == 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);
#endif
measurements->emplace_back(std::move(measurement));
#endif

hit_index++;
}
Expand Down Expand Up @@ -197,7 +228,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 +243,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 +272,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 +292,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
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
5 changes: 5 additions & 0 deletions src/algorithms/tracking/CKFTrackingFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ 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>;
#endif

using TrackContainer =
Acts::TrackContainer<Acts::VectorTrackContainer,
Comment on lines 49 to 50
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think TrackContainer is now unused for Acts_VERSION_MAJOR >= 36.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, #include <Acts/EventData/VectorMultiTrajectory.hpp> is probably unnecessary for Acts_VERSION_MAJOR >= 36.

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
52 changes: 49 additions & 3 deletions src/algorithms/tracking/TrackSeeding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@

#include <Acts/Definitions/Algebra.hpp>
#include <Acts/Definitions/Units.hpp>
#if Acts_VERSION_MAJOR >= 37
#include <Acts/EventData/Seed.hpp>
#else
#include <Acts/Seeding/Seed.hpp>
#endif
#include <Acts/Seeding/SeedConfirmationRangeConfig.hpp>
#include <Acts/Seeding/SeedFilter.hpp>
#include <Acts/Seeding/SeedFilterConfig.hpp>
Expand Down Expand Up @@ -85,7 +89,11 @@ void eicrecon::TrackSeeding::configure() {
m_seedFilterConfig = m_seedFilterConfig.toInternalUnits();

// Finder parameters
#if Acts_VERSION_MAJOR >= 37
m_seedFinderConfig.seedFilter = std::make_unique<Acts::SeedFilter<proxy_type>>(m_seedFilterConfig);
#else
m_seedFinderConfig.seedFilter = std::make_unique<Acts::SeedFilter<eicrecon::SpacePoint>>(Acts::SeedFilter<eicrecon::SpacePoint>(m_seedFilterConfig));
#endif
m_seedFinderConfig.rMax = m_cfg.rMax;
m_seedFinderConfig.rMin = m_cfg.rMin;
m_seedFinderConfig.deltaRMinTopSP = m_cfg.deltaRMinTopSP;
Expand Down Expand Up @@ -120,30 +128,68 @@ std::unique_ptr<edm4eic::TrackParametersCollection> eicrecon::TrackSeeding::prod

std::vector<const eicrecon::SpacePoint*> spacePoints = getSpacePoints(trk_hits);

#if Acts_VERSION_MAJOR >=37
Acts::SeedFinderOrthogonal<proxy_type> finder(m_seedFinderConfig); // FIXME move into class scope
#else
Acts::SeedFinderOrthogonal<eicrecon::SpacePoint> finder(m_seedFinderConfig); // FIXME move into class scope
#endif


#if Acts_VERSION_MAJOR >= 37
// Config
Acts::SpacePointContainerConfig spConfig;

// Options
Acts::SpacePointContainerOptions spOptions;
spOptions.beamPos = {0., 0.};

ActsExamples::SpacePointContainer container(spacePoints);
Acts::SpacePointContainer<decltype(container), Acts::detail::RefHolder>
spContainer(spConfig, spOptions, container);

#if Acts_VERSION_MAJOR >= 32
std::vector<Acts::Seed<proxy_type>> seeds =
finder.createSeeds(m_seedFinderOptions, spContainer);

// need to convert here from seed of proxies to seed of sps
eicrecon::SeedContainer seedsToAdd;
seedsToAdd.reserve(seeds.size());
for (const auto &seed : seeds) {
const auto &sps = seed.sp();
seedsToAdd.emplace_back(*sps[0]->externalSpacePoint(),
*sps[1]->externalSpacePoint(),
*sps[2]->externalSpacePoint());
seedsToAdd.back().setVertexZ(seed.z());
seedsToAdd.back().setQuality(seed.seedQuality());
}

std::unique_ptr<edm4eic::TrackParametersCollection> trackparams = makeTrackParams(seedsToAdd);

#else

# if Acts_VERSION_MAJOR >= 32
std::function<std::tuple<Acts::Vector3, Acts::Vector2, std::optional<Acts::ActsScalar>>(
const eicrecon::SpacePoint *sp)>
create_coordinates = [](const eicrecon::SpacePoint *sp) {
Acts::Vector3 position(sp->x(), sp->y(), sp->z());
Acts::Vector2 variance(sp->varianceR(), sp->varianceZ());
return std::make_tuple(position, variance, sp->t());
};
#else
# else
std::function<std::pair<Acts::Vector3, Acts::Vector2>(
const eicrecon::SpacePoint *sp)>
create_coordinates = [](const eicrecon::SpacePoint *sp) {
Acts::Vector3 position(sp->x(), sp->y(), sp->z());
Acts::Vector2 variance(sp->varianceR(), sp->varianceZ());
return std::make_pair(position, variance);
};
#endif
# endif

eicrecon::SeedContainer seeds = finder.createSeeds(m_seedFinderOptions, spacePoints, create_coordinates);

std::unique_ptr<edm4eic::TrackParametersCollection> trackparams = makeTrackParams(seeds);

#endif

for (auto& sp: spacePoints) {
delete sp;
}
Expand Down
Loading
Loading