Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a9c80f

Browse files
authoredDec 3, 2024··
Merge branch 'main' into oneAPI2025Compat-main-20241203
2 parents 0f4d888 + cb5bfbe commit 4a9c80f

File tree

3 files changed

+96
-19
lines changed

3 files changed

+96
-19
lines changed
 

‎Core/include/Acts/Utilities/TrackHelpers.hpp

+24-15
Original file line numberDiff line numberDiff line change
@@ -517,10 +517,11 @@ calculatePredictedResidual(track_state_proxy_t trackState) {
517517
}
518518

519519
auto subspaceHelper =
520-
trackState.template fixedBoundSubspaceHelper<nMeasurementDim>();
520+
trackState.template projectorSubspaceHelper<nMeasurementDim>();
521521

522-
auto measurement = trackState.calibrated();
523-
auto measurementCovariance = trackState.calibratedCovariance();
522+
auto measurement = trackState.template calibrated<nMeasurementDim>();
523+
auto measurementCovariance =
524+
trackState.template calibratedCovariance<nMeasurementDim>();
524525
MeasurementVector predicted =
525526
subspaceHelper.projectVector(trackState.predicted());
526527
MeasurementMatrix predictedCovariance =
@@ -553,10 +554,11 @@ calculateFilteredResidual(track_state_proxy_t trackState) {
553554
}
554555

555556
auto subspaceHelper =
556-
trackState.template fixedBoundSubspaceHelper<nMeasurementDim>();
557+
trackState.template projectorSubspaceHelper<nMeasurementDim>();
557558

558-
auto measurement = trackState.calibrated();
559-
auto measurementCovariance = trackState.calibratedCovariance();
559+
auto measurement = trackState.template calibrated<nMeasurementDim>();
560+
auto measurementCovariance =
561+
trackState.template calibratedCovariance<nMeasurementDim>();
560562
MeasurementVector filtered =
561563
subspaceHelper.projectVector(trackState.filtered());
562564
MeasurementMatrix filteredCovariance =
@@ -589,10 +591,11 @@ calculateSmoothedResidual(track_state_proxy_t trackState) {
589591
}
590592

591593
auto subspaceHelper =
592-
trackState.template fixedBoundSubspaceHelper<nMeasurementDim>();
594+
trackState.template projectorSubspaceHelper<nMeasurementDim>();
593595

594-
auto measurement = trackState.calibrated();
595-
auto measurementCovariance = trackState.calibratedCovariance();
596+
auto measurement = trackState.template calibrated<nMeasurementDim>();
597+
auto measurementCovariance =
598+
trackState.template calibratedCovariance<nMeasurementDim>();
596599
MeasurementVector smoothed =
597600
subspaceHelper.projectVector(trackState.smoothed());
598601
MeasurementMatrix smoothedCovariance =
@@ -620,11 +623,13 @@ double calculatePredictedChi2(track_state_proxy_t trackState) {
620623

621624
return visit_measurement(
622625
trackState.calibratedSize(),
623-
[&]<std::size_t measdim>(std::integral_constant<std::size_t, measdim>) {
626+
[&]<std::size_t measdim>(
627+
std::integral_constant<std::size_t, measdim>) -> double {
624628
auto [residual, residualCovariance] =
625629
calculatePredictedResidual<measdim>(trackState);
626630

627-
return residual.transpose() * residualCovariance.inverse() * residual;
631+
return (residual.transpose() * residualCovariance.inverse() * residual)
632+
.eval()(0, 0);
628633
});
629634
}
630635

@@ -643,11 +648,13 @@ double calculateFilteredChi2(track_state_proxy_t trackState) {
643648

644649
return visit_measurement(
645650
trackState.calibratedSize(),
646-
[&]<std::size_t measdim>(std::integral_constant<std::size_t, measdim>) {
651+
[&]<std::size_t measdim>(
652+
std::integral_constant<std::size_t, measdim>) -> double {
647653
auto [residual, residualCovariance] =
648654
calculateFilteredResidual<measdim>(trackState);
649655

650-
return residual.transpose() * residualCovariance.inverse() * residual;
656+
return (residual.transpose() * residualCovariance.inverse() * residual)
657+
.eval()(0, 0);
651658
});
652659
}
653660

@@ -666,11 +673,13 @@ double calculateSmoothedChi2(track_state_proxy_t trackState) {
666673

667674
return visit_measurement(
668675
trackState.calibratedSize(),
669-
[&]<std::size_t measdim>(std::integral_constant<std::size_t, measdim>) {
676+
[&]<std::size_t measdim>(
677+
std::integral_constant<std::size_t, measdim>) -> double {
670678
auto [residual, residualCovariance] =
671679
calculateSmoothedResidual<measdim>(trackState);
672680

673-
return residual.transpose() * residualCovariance.inverse() * residual;
681+
return (residual.transpose() * residualCovariance.inverse() * residual)
682+
.eval()(0, 0);
674683
});
675684
}
676685

‎Core/src/Vertexing/AdaptiveGridTrackDensity.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ double AdaptiveGridTrackDensity::getBinCenter(std::int32_t bin,
4343
}
4444

4545
std::int32_t AdaptiveGridTrackDensity::getBin(double value, double binExtent) {
46-
return static_cast<int>(std::floor(value / binExtent - 0.5) + 1);
46+
return static_cast<std::int32_t>(std::floor(value / binExtent - 0.5) + 1);
4747
}
4848

4949
std::uint32_t AdaptiveGridTrackDensity::getTrkGridSize(

‎Tests/UnitTests/Core/Utilities/TrackHelpersTests.cpp

+71-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88

99
#include <boost/test/unit_test.hpp>
1010

11+
#include "Acts/Definitions/TrackParametrization.hpp"
1112
#include "Acts/EventData/TrackContainer.hpp"
1213
#include "Acts/EventData/TrackStateType.hpp"
1314
#include "Acts/EventData/VectorMultiTrajectory.hpp"
1415
#include "Acts/EventData/VectorTrackContainer.hpp"
16+
#include "Acts/Tests/CommonHelpers/FloatComparisons.hpp"
1517
#include "Acts/Utilities/TrackHelpers.hpp"
1618

17-
#include <memory>
18-
#include <span>
19-
2019
namespace Acts::Test {
2120

2221
namespace {
@@ -35,6 +34,33 @@ auto createTestTrack(TrackContainer& tc, const FlagsPerState& flagsPerState) {
3534
return t;
3635
}
3736

37+
template <typename TrackContainer>
38+
auto createTestTrackState(TrackContainer& tc) {
39+
auto t = tc.makeTrack();
40+
41+
auto ts = t.appendTrackState();
42+
43+
ts.allocateCalibrated(Vector2::Zero(), SquareMatrix2::Identity());
44+
ts.setProjectorSubspaceIndices(std::array{eBoundLoc0, eBoundLoc1});
45+
46+
ts.predicted() = BoundVector::Zero();
47+
ts.predicted()[eBoundLoc0] = 1.;
48+
ts.predicted()[eBoundLoc1] = 1.;
49+
ts.predictedCovariance() = BoundMatrix::Identity() * 1.;
50+
51+
ts.filtered() = BoundVector::Zero();
52+
ts.filtered()[eBoundLoc0] = 0.5;
53+
ts.filtered()[eBoundLoc1] = 0.5;
54+
ts.filteredCovariance() = BoundMatrix::Identity() * 0.5;
55+
56+
ts.smoothed() = BoundVector::Zero();
57+
ts.smoothed()[eBoundLoc0] = 0.1;
58+
ts.smoothed()[eBoundLoc1] = 0.1;
59+
ts.smoothedCovariance() = BoundMatrix::Identity() * 0.1;
60+
61+
return ts;
62+
}
63+
3864
} // namespace
3965

4066
BOOST_AUTO_TEST_SUITE(Utilities)
@@ -106,6 +132,48 @@ BOOST_AUTO_TEST_CASE(TrimTrack) {
106132
BOOST_CHECK_EQUAL(t.nSharedHits(), 1);
107133
}
108134

135+
BOOST_AUTO_TEST_CASE(CalculatePredictedChi2) {
136+
TrackContainer tc{VectorTrackContainer{}, VectorMultiTrajectory{}};
137+
auto ts = createTestTrackState(tc);
138+
139+
// reference found by running the code
140+
BOOST_CHECK_CLOSE(calculatePredictedChi2(ts), 1., 1e-6);
141+
}
142+
143+
BOOST_AUTO_TEST_CASE(CalculateFilteredChi2) {
144+
TrackContainer tc{VectorTrackContainer{}, VectorMultiTrajectory{}};
145+
auto ts = createTestTrackState(tc);
146+
147+
// reference found by running the code
148+
BOOST_CHECK_CLOSE(calculateFilteredChi2(ts), 1. / 3., 1e-6);
149+
}
150+
151+
BOOST_AUTO_TEST_CASE(CalculateSmoothedChi2) {
152+
TrackContainer tc{VectorTrackContainer{}, VectorMultiTrajectory{}};
153+
auto ts = createTestTrackState(tc);
154+
155+
// reference found by running the code
156+
BOOST_CHECK_CLOSE(calculateSmoothedChi2(ts), 1. / 55., 1e-6);
157+
}
158+
159+
BOOST_AUTO_TEST_CASE(CalculateUnbiasedParametersCovariance) {
160+
TrackContainer tc{VectorTrackContainer{}, VectorMultiTrajectory{}};
161+
auto ts = createTestTrackState(tc);
162+
163+
auto [params, cov] = calculateUnbiasedParametersCovariance(ts);
164+
165+
// reference found by running the code
166+
BoundVector refParams = BoundVector::Zero();
167+
refParams[eBoundLoc0] = 1. / 9.;
168+
refParams[eBoundLoc1] = 1. / 9.;
169+
BoundMatrix refCov = BoundMatrix::Identity() * 0.1;
170+
refCov(eBoundLoc0, eBoundLoc0) = 1. / 9.;
171+
refCov(eBoundLoc1, eBoundLoc1) = 1. / 9.;
172+
173+
CHECK_CLOSE_ABS(params, refParams, 1e-6);
174+
CHECK_CLOSE_ABS(cov, refCov, 1e-6);
175+
}
176+
109177
BOOST_AUTO_TEST_SUITE_END()
110178

111179
} // namespace Acts::Test

0 commit comments

Comments
 (0)
Please sign in to comment.