Skip to content

Commit

Permalink
Merge branch 'main' into align-initial-track-param-cov
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Sep 29, 2023
2 parents 8d3f0db + 29bd620 commit 27fc978
Show file tree
Hide file tree
Showing 9 changed files with 132 additions and 83 deletions.
35 changes: 21 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,19 @@ linux_ubuntu_2204_clang:
before_script:
- 'echo "LCG_VERSION: ${LCG_VERSION}"'
- 'echo "COMPILER: ${COMPILER}"'
- 'if [ "$OS" = "alma9" ]; then export LCG_PLATFORM="centos9"; else export LCG_PLATFORM="$OS"; fi'

# Figure out LCG platform name based on version number and OS
- >
if [ "$OS" = "alma9" ]; then
if [ "$LCG_VERSION" = "104" ]; then
export LCG_PLATFORM="el9"
else
export LCG_PLATFORM="centos9"
fi
else
export LCG_PLATFORM="$OS"
fi
- 'echo "LCG_PLATFORM: ${LCG_PLATFORM}"'
- source /cvmfs/sft.cern.ch/lcg/views/LCG_${LCG_VERSION}/x86_64-${LCG_PLATFORM}-${COMPILER}-opt/setup.sh

Expand All @@ -383,7 +395,7 @@ linux_ubuntu_2204_clang:
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
-DACTS_LOG_FAILURE_THRESHOLD=WARNING
-DACTS_BUILD_EXAMPLES_PYTHON_BINDINGS=ON
-DACTS_FORCE_ASSERTIONS=ON
-DACTS_FORCE_ASSERTIONS=OFF
-DACTS_BUILD_UNITTESTS=ON
-DACTS_BUILD_INTEGRATIONTESTS=ON
-DACTS_BUILD_BENCHMARKS=ON
Expand Down Expand Up @@ -424,31 +436,26 @@ lcg_102b:
- OS: [centos7]
COMPILER: [gcc11]

- OS: [centos8, alma9]
COMPILER: [gcc11]

lcg_103:
lcg_104:
<<: *lcg_base_job

variables:
LCG_VERSION: "103"
LCG_VERSION: "104"

parallel:
matrix:
- OS: [centos7]
COMPILER:
- gcc11
- gcc12
# currently failing:
# - clang12
# - clang15

- OS: [alma9]
COMPILER:
- gcc11
- gcc12
- gcc13
- clang16

- OS: [centos8]
COMPILER: [gcc11]

rules:
- if: '$COMPILER == "clang12" || $COMPILER == "clang15"'
allow_failure: true
- when: on_success
3 changes: 3 additions & 0 deletions Core/include/Acts/Definitions/Algebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmisleading-indentation"
#if __GNUC__ == 13
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
#include <Eigen/Core>
#include <Eigen/Geometry>
#pragma GCC diagnostic pop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class CombinatorialKalmanFilter {
// The last active tip
const auto& lastActiveTip = result.activeTips.back().first;
// Get the index of previous state
const auto& iprevious =
auto iprevious =
result.fittedStates->getTrackState(lastActiveTip).previous();
// Find the track states which have the same previous state and remove
// them from active tips
Expand Down
139 changes: 75 additions & 64 deletions Core/include/Acts/TrackFinding/MeasurementSelector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "Acts/Utilities/Result.hpp"
#include "Acts/Utilities/TypeTraits.hpp"

#include <cassert>
#include <cstddef>
#include <iterator>
#include <limits>
Expand Down Expand Up @@ -106,60 +107,82 @@ class MeasurementSelector {
return CombinatorialKalmanFilterError::MeasurementSelectionFailed;
}

assert(!cuts->chi2CutOff.empty());
const auto& chi2CutOff = cuts->chi2CutOff;
auto maxChi2Cut = *std::max_element(chi2CutOff.begin(), chi2CutOff.end());
double minChi2 = std::numeric_limits<double>::max();
size_t minIndex = 0;
size_t index = 0;
// Loop over all measurements to select the compatible measurements
for (auto& trackState : candidates) {
// Take the parameter covariance
// const auto predicted = tackState.predicted();
// const auto predictedCovariance = trackState.predictedCovariance();

double chi2 = calculateChi2(
// This abuses an incorrectly sized vector / matrix to access the
// data pointer! This works (don't use the matrix as is!), but be
// careful!
trackState
.template calibrated<MultiTrajectoryTraits::MeasurementSizeMax>()
.data(),
trackState
.template calibratedCovariance<
MultiTrajectoryTraits::MeasurementSizeMax>()
.data(),
trackState.predicted(), trackState.predictedCovariance(),
trackState.projector(), trackState.calibratedSize());

trackState.chi2() = chi2;

// Search for the measurement with the min chi2
if (chi2 < minChi2) {
minChi2 = chi2;
minIndex = index;
auto trackStateIterEnd = candidates.end();
{
auto trackStateIter = candidates.begin();
// Loop over all measurements to select the compatible measurements
// Sort track states which do not satisfy the chi2 cut to the end.
// When done trackStateIterEnd will point to the first element that
// does not satisfy the chi2 cut.
assert(trackStateIter != trackStateIterEnd);
for (;;) {
double chi2 = calculateChi2(
// This abuses an incorrectly sized vector / matrix to access the
// data pointer! This works (don't use the matrix as is!), but be
// careful!
trackStateIter
->template calibrated<
MultiTrajectoryTraits::MeasurementSizeMax>()
.data(),
trackStateIter
->template calibratedCovariance<
MultiTrajectoryTraits::MeasurementSizeMax>()
.data(),
trackStateIter->predicted(), trackStateIter->predictedCovariance(),
trackStateIter->projector(), trackStateIter->calibratedSize());

trackStateIter->chi2() = chi2;

// only consider track states which pass the chi2 cut
if (chi2 >= maxChi2Cut ||
chi2 >= VariableCut<traj_t>(*trackStateIter, cuts, chi2CutOff,
logger)) {
--trackStateIterEnd;
// still check whether the element has the smallest chi2 in case an
// outlier is returned.
if (chi2 < minChi2) {
minChi2 = chi2;
// the current element will be swapped with the last unchecked
// element if they are different
minIndex = std::distance(candidates.begin(), trackStateIterEnd);
}

if (trackStateIter == trackStateIterEnd) {
break;
} else {
// swap rejected element with last element in list
std::swap(*trackStateIter, *trackStateIterEnd);
}
} else {
// Search for the measurement with the min chi2
// @if there is a track state which passes the cut-off there is
// no need to remember the track state with the smallest chi2.
++trackStateIter;
if (trackStateIter == trackStateIterEnd) {
break;
}
}
}

index++;
}

const auto& chi2CutOff = cuts->chi2CutOff;

{
// If there is no selected measurement, return the measurement with the
// best chi2 and tag it as an outlier
// If there are no measurements below the chi2 cut off, return the
// measurement with the best chi2 and tag it as an outlier
if (candidates.begin() == trackStateIterEnd) {
const auto bestIt = std::next(candidates.begin(), minIndex);
const auto chi2 = bestIt->chi2();
const auto chi2Cut =
VariableCut<traj_t>(*bestIt, cuts, chi2CutOff, logger);
ACTS_VERBOSE("Chi2: " << chi2 << ", max: " << chi2Cut);
if (chi2 >= chi2Cut) {
ACTS_VERBOSE(
"No measurement candidate. Return an outlier measurement.");
isOutlier = true;
// return single item range, no sorting necessary
return Result::success(std::pair{bestIt, std::next(bestIt, 1)});
}
ACTS_VERBOSE(
"No measurement candidate. Return an outlier measurement chi2="
<< bestIt->chi2());
isOutlier = true;
// return single item range, no sorting necessary
return Result::success(std::pair{bestIt, std::next(bestIt, 1)});
}

std::sort(candidates.begin(), candidates.end(),
std::sort(candidates.begin(), trackStateIterEnd,
[](const auto& tsa, const auto& tsb) {
return tsa.chi2() < tsb.chi2();
});
Expand All @@ -168,30 +191,18 @@ class MeasurementSelector {
const auto numMeasurementsCut = VariableCut<traj_t>(
*candidates.begin(), cuts, cuts->numMeasurementsCutOff, logger);

auto endIterator = candidates.begin();
auto maxIterator = candidates.end();
if (candidates.size() > numMeasurementsCut && numMeasurementsCut > 0) {
maxIterator = std::next(candidates.begin(), numMeasurementsCut);
if (static_cast<std::size_t>(std::distance(
candidates.begin(), trackStateIterEnd)) > numMeasurementsCut &&
numMeasurementsCut > 0) {
trackStateIterEnd = std::next(candidates.begin(), numMeasurementsCut);
}

++endIterator; // best measurement already confirmed good
for (; endIterator != maxIterator; ++endIterator) {
const auto chi2 = endIterator->chi2();
const auto chi2Cut =
VariableCut<traj_t>(*endIterator, cuts, chi2CutOff, logger);
ACTS_VERBOSE("Chi2: " << chi2 << ", max: " << chi2Cut);
if (chi2 >= chi2Cut) {
break; // endIterator now points at the first track state with chi2
// larger than our cutoff => defines the end of our returned
// range
}
}
ACTS_VERBOSE("Number of selected measurements: "
<< std::distance(candidates.begin(), endIterator)
<< std::distance(candidates.begin(), trackStateIterEnd)
<< ", max: " << numMeasurementsCut);

isOutlier = false;
return std::pair{candidates.begin(), endIterator};
return std::pair{candidates.begin(), trackStateIterEnd};
}

private:
Expand Down
4 changes: 4 additions & 0 deletions Core/src/Geometry/GenericCuboidVolumeBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ Acts::OrientedSurfaces Acts::GenericCuboidVolumeBounds::orientedSurfaces(
// z is normal in local coordinates
// Volume local to surface local
Transform3 vol2srf;

// GCC13+ Complains about maybe uninitialized memory inside Eigen's SVD code
// This warning is ignored in this compilation unit by using the pragma at
// the top of this file.
vol2srf = (Eigen::Quaternion<Transform3::Scalar>().setFromTwoVectors(
normal, Vector3::UnitZ()));

Expand Down
5 changes: 4 additions & 1 deletion Examples/Io/Root/src/RootTrajectoryStatesWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,10 @@ ActsExamples::ProcessCode ActsExamples::RootTrajectoryStatesWriter::writeT(
auto H = state.effectiveProjector();
auto V = state.effectiveCalibratedCovariance();
auto resCov = V + H * covariance * H.transpose();
auto res = state.effectiveCalibrated() - H * parameters;
Acts::ActsDynamicVector res(state.calibratedSize());
res.setZero();

res = state.effectiveCalibrated() - H * parameters;

m_res_x_hit.push_back(res[Acts::eBoundLoc0]);
m_err_x_hit.push_back(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,15 @@ struct AutodiffExtensionWrapper {
bool finalize(propagator_state_t& state, const stepper_t& stepper,
const navigator_t& navigator, const double h,
FreeMatrix& D) const {
#if defined(__GNUC__) && __GNUC__ == 12 && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuse-after-free"
#endif
m_doubleExtension.finalize(state, stepper, navigator, h);
return transportMatrix(state, stepper, navigator, h, D);
#if defined(__GNUC__) && __GNUC__ == 12 && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
}

private:
Expand Down
18 changes: 16 additions & 2 deletions Tests/UnitTests/Core/Surfaces/SurfaceBoundsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@ class SurfaceBoundsStub : public SurfaceBounds {
std::iota(m_values.begin(), m_values.end(), 0);
}

#if defined(__GNUC__) && __GNUC__ == 13 && !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__)
#pragma GCC diagnostic pop
#endif

~SurfaceBoundsStub() override = default;
BoundsType type() const final { return SurfaceBounds::eOther; }
std::vector<double> values() const override { return m_values; }
BoundsType type() const final {
return SurfaceBounds::eOther;
}
std::vector<double> values() const override {
return m_values;
}
bool inside(const Vector2& /*lpos*/,
const BoundaryCheck& /*bcheck*/) const final {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ BOOST_DATA_TEST_CASE(RandomPlanarSurfaceMask,

if (index == 0) {
std::ofstream shape;
const auto centerXY = surface->center(geoCtx).segment<2>(0);
const Acts::Vector2 centerXY = surface->center(geoCtx).segment<2>(0);

// 0 - write the shape
shape.open("PlanarSurfaceMask" + name + "Borders.csv");
Expand Down

0 comments on commit 27fc978

Please sign in to comment.