Skip to content

Commit

Permalink
Merge branch 'main' into ex-fix-seedperfwriter-multithreading
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Nov 12, 2024
2 parents 70b042c + a8f07b9 commit 0fdad51
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 31 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ if(ACTS_SETUP_BOOST)
endif()

if(Boost_VERSION VERSION_EQUAL "1.85.0")
set(_boost_version_severity WARNING)
if(ACTS_BUILD_EXAMPLES)
set(_boost_version_severity FATAL_ERROR)
endif()
message(
WARNING
${_boost_version_severity}
"Boost 1.85.0 is known to be broken (https://github.com/boostorg/container/issues/273). Please use a different version."
)
endif()
Expand Down
5 changes: 2 additions & 3 deletions Core/include/Acts/EventData/detail/TestSourceLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,13 @@ void testSourceLinkCalibratorReturn(
trackState.allocateCalibrated(2);
trackState.template calibrated<2>() = sl.parameters;
trackState.template calibratedCovariance<2>() = sl.covariance;
trackState.template setSubspaceIndices(
std::array{sl.indices[0], sl.indices[1]});
trackState.setSubspaceIndices(std::array{sl.indices[0], sl.indices[1]});
} else if (sl.indices[0] != Acts::eBoundSize) {
trackState.allocateCalibrated(1);
trackState.template calibrated<1>() = sl.parameters.head<1>();
trackState.template calibratedCovariance<1>() =
sl.covariance.topLeftCorner<1, 1>();
trackState.template setSubspaceIndices(std::array{sl.indices[0]});
trackState.setSubspaceIndices(std::array{sl.indices[0]});
} else {
throw std::runtime_error(
"Tried to extract measurement from invalid TestSourceLink");
Expand Down
38 changes: 23 additions & 15 deletions Core/include/Acts/TrackFinding/TrackSelector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,24 +304,32 @@ inline TrackSelector::Config& TrackSelector::Config::pt(double min,

inline std::ostream& operator<<(std::ostream& os,
const TrackSelector::Config& cuts) {
auto print = [&](const char* name, const auto& min, const auto& max) {
// for printing cuts set up with `within`
auto printMinMax = [&](const char* name, const auto& min, const auto& max) {
os << " - " << min << " <= " << name << " < " << max << "\n";
};
// for printing cuts set up with `checkMin`
auto printMin = [&](const char* name, const auto& min) {
os << " - " << min << " <= " << name << "\n";
};
// for printing cuts set up with `checkMax`
auto printMax = [&](const char* name, const auto& max) {
os << " - " << name << " <= " << max << "\n";
};

print("loc0", cuts.loc0Min, cuts.loc0Max);
print("loc1", cuts.loc1Min, cuts.loc1Max);
print("time", cuts.timeMin, cuts.timeMax);
print("phi", cuts.phiMin, cuts.phiMax);
print("eta", cuts.etaMin, cuts.etaMax);
print("absEta", cuts.absEtaMin, cuts.absEtaMax);
print("pt", cuts.ptMin, cuts.ptMax);
print("nHoles", 0, cuts.maxHoles);
print("nOutliers", 0, cuts.maxOutliers);
print("nHoles + nOutliers", 0, cuts.maxHolesAndOutliers);
print("nSharedHits", 0, cuts.maxSharedHits);
print("chi2", 0.0, cuts.maxChi2);
os << " - " << cuts.minMeasurements << " <= nMeasurements\n";

printMinMax("loc0", cuts.loc0Min, cuts.loc0Max);
printMinMax("loc1", cuts.loc1Min, cuts.loc1Max);
printMinMax("time", cuts.timeMin, cuts.timeMax);
printMinMax("phi", cuts.phiMin, cuts.phiMax);
printMinMax("eta", cuts.etaMin, cuts.etaMax);
printMinMax("absEta", cuts.absEtaMin, cuts.absEtaMax);
printMinMax("pt", cuts.ptMin, cuts.ptMax);
printMax("nHoles", cuts.maxHoles);
printMax("nOutliers", cuts.maxOutliers);
printMax("nHoles + nOutliers", cuts.maxHolesAndOutliers);
printMax("nSharedHits", cuts.maxSharedHits);
printMax("chi2", cuts.maxChi2);
printMin("nMeasurements", cuts.minMeasurements);
return os;
}

Expand Down
16 changes: 8 additions & 8 deletions Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,12 +1306,12 @@ class Gx2Fitter {
// existing states, but this needs some more thinking.
trackContainerTemp.clear();

auto propagationResult = m_propagator.template propagate(propagatorState);
auto propagationResult = m_propagator.propagate(propagatorState);

// Run the fitter
auto result = m_propagator.template makeResult(std::move(propagatorState),
propagationResult,
propagatorOptions, false);
auto result =
m_propagator.makeResult(std::move(propagatorState), propagationResult,
propagatorOptions, false);

if (!result.ok()) {
ACTS_ERROR("Propagation failed: " << result.error());
Expand Down Expand Up @@ -1502,12 +1502,12 @@ class Gx2Fitter {
auto& r = propagatorState.template get<Gx2FitterResult<traj_t>>();
r.fittedStates = &trackContainer.trackStateContainer();

auto propagationResult = m_propagator.template propagate(propagatorState);
auto propagationResult = m_propagator.propagate(propagatorState);

// Run the fitter
auto result = m_propagator.template makeResult(std::move(propagatorState),
propagationResult,
propagatorOptions, false);
auto result =
m_propagator.makeResult(std::move(propagatorState), propagationResult,
propagatorOptions, false);

if (!result.ok()) {
ACTS_ERROR("Propagation failed: " << result.error());
Expand Down
2 changes: 1 addition & 1 deletion Core/include/Acts/TrackFitting/KalmanFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ class KalmanFitter {
track_container_t& trackContainer) const
-> Result<typename track_container_t::TrackProxy> {
auto propagatorState =
m_propagator.template makeState(sParameters, propagatorOptions);
m_propagator.makeState(sParameters, propagatorOptions);

auto& kalmanResult =
propagatorState.template get<KalmanFitterResult<traj_t>>();
Expand Down
4 changes: 3 additions & 1 deletion Examples/Python/src/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ void addMaterial(Context& ctx) {
{
py::class_<Acts::IMaterialDecorator,
std::shared_ptr<Acts::IMaterialDecorator>>(m,
"IMaterialDecorator");
"IMaterialDecorator")
.def("decorate", py::overload_cast<Surface&>(
&Acts::IMaterialDecorator::decorate, py::const_));
}

{
Expand Down
1 change: 1 addition & 0 deletions Tests/Benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ add_benchmark(StraightLineStepper StraightLineStepperBenchmark.cpp)
add_benchmark(SympyStepper SympyStepperBenchmark.cpp)
add_benchmark(Stepper StepperBenchmark.cpp)
add_benchmark(SourceLink SourceLinkBenchmark.cpp)
add_benchmark(TrackEdm TrackEdmBenchmark.cpp)
184 changes: 184 additions & 0 deletions Tests/Benchmarks/TrackEdmBenchmark.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
// 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/.

#include "Acts/EventData/SubspaceHelpers.hpp"
#include "Acts/EventData/TrackContainer.hpp"
#include "Acts/EventData/TrackStatePropMask.hpp"
#include "Acts/EventData/TrackStateType.hpp"
#include "Acts/EventData/VectorMultiTrajectory.hpp"
#include "Acts/EventData/VectorTrackContainer.hpp"
#include "Acts/EventData/detail/GenerateParameters.hpp"
#include "Acts/Geometry/GeometryIdentifier.hpp"
#include "Acts/Surfaces/PerigeeSurface.hpp"
#include "Acts/Surfaces/PlaneSurface.hpp"
#include "Acts/Surfaces/RectangleBounds.hpp"
#include "Acts/Utilities/TrackHelpers.hpp"

#include <iostream>
#include <numeric>
#include <random>
#include <type_traits>

using namespace Acts;

class BenchmarkSourceLink final {
public:
using Index = std::uint32_t;

/// Construct from geometry identifier and index.
constexpr BenchmarkSourceLink(Acts::GeometryIdentifier gid, Index idx)
: m_geometryId(gid), m_index(idx) {}

BenchmarkSourceLink() = default;
BenchmarkSourceLink(const BenchmarkSourceLink&) = default;
BenchmarkSourceLink(BenchmarkSourceLink&&) = default;
BenchmarkSourceLink& operator=(const BenchmarkSourceLink&) = default;
BenchmarkSourceLink& operator=(BenchmarkSourceLink&&) = default;

/// Access the index.
constexpr Index index() const { return m_index; }

Acts::GeometryIdentifier geometryId() const { return m_geometryId; }

private:
Acts::GeometryIdentifier m_geometryId;
Index m_index = 0;

friend bool operator==(const BenchmarkSourceLink& lhs,
const BenchmarkSourceLink& rhs) {
return (lhs.geometryId() == rhs.geometryId()) &&
(lhs.m_index == rhs.m_index);
}
};

int main(int /*argc*/, char** /*argv[]*/) {
std::size_t runs = 1000000;
std::size_t nTracks = 10000;

VectorMultiTrajectory mtj;
VectorTrackContainer vtc;
TrackContainer tc{vtc, mtj};

VectorMultiTrajectory mtjOut;
VectorTrackContainer vtcOut;
TrackContainer output{vtcOut, mtjOut};

GeometryIdentifier gid;
gid.setVolume(5);
gid.setLayer(3);
gid.setSensitive(1);

static_assert(sizeof(BenchmarkSourceLink) <= ACTS_SOURCELINK_SBO_SIZE);

static_assert(std::is_trivially_move_constructible_v<BenchmarkSourceLink>);

std::uniform_int_distribution<> nStatesDist(1, 20);
std::uniform_int_distribution<> measDimDist(1, 3);
std::uniform_real_distribution<> typeDist(0, 1);
std::uniform_real_distribution<> copyDist(0, 1);
std::mt19937 rng{42};

std::vector<std::shared_ptr<Surface>> surfaces;
std::vector<std::pair<BoundVector, BoundMatrix>> parametersVector;
for (std::size_t s = 0; s < 50; ++s) {
surfaces.push_back(Surface::makeShared<PlaneSurface>(
Transform3::Identity(), std::make_shared<RectangleBounds>(50, 50)));

parametersVector.push_back(
detail::Test::generateBoundParametersCovariance(rng, {}));
}

std::size_t nSurface = 0;
auto surface = [&]() {
nSurface++;
return surfaces.at(nSurface % surfaces.size());
};

std::size_t nParams = 0;
auto parameters = [&]() -> const std::pair<BoundVector, BoundMatrix>& {
nParams++;
return parametersVector.at(nParams % parametersVector.size());
};

auto perigee = Surface::makeShared<PerigeeSurface>(Vector3::Zero());

std::cout << "Creating " << nTracks << " tracks x " << runs << " runs"
<< std::endl;
for (std::size_t r = 0; r < runs; ++r) {
tc.clear();
for (std::size_t i = 0; i < nTracks; ++i) {
auto track = tc.makeTrack();

std::size_t nStates = nStatesDist(rng);

for (std::size_t j = 0; j < nStates; ++j) {
auto trackState = track.appendTrackState(TrackStatePropMask::All);
trackState.setReferenceSurface(surface());

trackState.jacobian().setZero();
trackState.jacobian().row(j % eBoundSize).setOnes();

double crit = typeDist(rng);

if (crit < 0.1) {
// hole
trackState.typeFlags().set(TrackStateFlag::HoleFlag);
} else if (crit < 0.2) {
// material
trackState.typeFlags().set(TrackStateFlag::MaterialFlag);
} else {
BenchmarkSourceLink bsl{gid, 123};
trackState.allocateCalibrated(measDimDist(rng));

const auto& [predicted, covariance] = parameters();
trackState.predicted() = predicted;
trackState.predictedCovariance() = covariance;

visit_measurement(
trackState.calibratedSize(),
[&]<std::size_t N>(std::integral_constant<std::size_t, N> /*d*/) {
trackState.calibrated<N>().setOnes();
trackState.calibratedCovariance<N>().setIdentity();

std::array<std::uint8_t, eBoundSize> indices{0};
std::iota(indices.begin(), indices.end(), 0);
trackState.setBoundSubspaceIndices(indices);
});

trackState.typeFlags().set(TrackStateFlag::MeasurementFlag);
if (crit < 0.4) {
// outlier
trackState.typeFlags().set(TrackStateFlag::OutlierFlag);
}
}
}

track.setReferenceSurface(perigee);

const auto& [ref, cov] = parameters();
track.parameters() = ref;
track.covariance() = cov;

track.linkForward();

calculateTrackQuantities(track);
}

for (const auto& track : tc) {
if (copyDist(rng) > 0.1) {
// copy only 10% of tracks
continue;
}

auto target = output.makeTrack();
target.copyFrom(track);
}
}

return 0;
}
6 changes: 4 additions & 2 deletions Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ class SurfaceBoundsStub : public SurfaceBounds {
std::iota(m_values.begin(), m_values.end(), 0);
}

#if defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)
#if defined(__GNUC__) && (__GNUC__ == 13 || __GNUC__ == 14) && \
!defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
SurfaceBoundsStub(const SurfaceBoundsStub& other) = default;
#if defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)
#if defined(__GNUC__) && (__GNUC__ == 13 || __GNUC__ == 14) && \
!defined(__clang__)
#pragma GCC diagnostic pop
#endif

Expand Down
3 changes: 3 additions & 0 deletions cmake/setup_withdeps.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ if [[ -d "@Geant4_DIR@" ]]; then
fi
if [[ -d "@DD4hep_DIR@" ]]; then
. @DD4hep_INCLUDE_DIRS@/../bin/thisdd4hep.sh
# Without this, DD4hep's Xerces-C XML parsing fails with:
# > Could not load a transcoding service
export LC_ALL=C
fi
if [[ -d "@podio_DIR@" ]]; then
export LD_LIBRARY_PATH="@podio_LIBRARY_DIR@:${LD_LIBRARY_PATH}"
Expand Down

0 comments on commit 0fdad51

Please sign in to comment.