File indexing completed on 2026-10-20 08:42:21
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Definitions/Alignment.hpp"
0013 #include "Acts/Definitions/TrackParametrization.hpp"
0014 #include "Acts/Surfaces/PlaneSurface.hpp"
0015 #include "Acts/Surfaces/RectangleBounds.hpp"
0016 #include "Acts/Surfaces/Surface.hpp"
0017 #include "Acts/Utilities/Logger.hpp"
0018 #include "ActsAlignment/Kernel/detail/AlignmentEngine.hpp"
0019 #include "ActsPlugins/Mille/ActsToMille.hpp"
0020
0021 #include <memory>
0022 #include <sstream>
0023 #include <string>
0024 #include <vector>
0025
0026 #include "Mille/MilleDecoder.h"
0027 #include "Mille/MilleFactory.h"
0028
0029
0030
0031
0032
0033
0034
0035 BOOST_AUTO_TEST_SUITE(ActsToMilleDiscardGuardTests)
0036
0037 BOOST_AUTO_TEST_CASE(MeasuredParametersAreKept) {
0038
0039 constexpr std::size_t nStates = 2;
0040 constexpr std::size_t nPar = nStates * Acts::eBoundSize;
0041 constexpr std::size_t nMeas = 2 * nStates;
0042
0043 auto surface = Acts::Surface::makeShared<Acts::PlaneSurface>(
0044 Acts::Transform3::Identity(),
0045 std::make_shared<Acts::RectangleBounds>(10., 10.));
0046
0047 ActsAlignment::detail::TrackAlignmentState state;
0048 state.measurementDim = nMeas;
0049 state.trackParametersDim = nPar;
0050 state.alignmentDof = Acts::eAlignmentSize;
0051 state.alignedSurfaces.emplace(surface.get(), std::make_pair(0u, 0u));
0052
0053
0054
0055
0056
0057 state.measurementCovariance =
0058 Acts::DynamicMatrix::Identity(nMeas, nMeas) * 0.05 * 0.05;
0059 state.trackParametersCovariance = Acts::DynamicMatrix::Zero(nPar, nPar);
0060 state.projectionMatrix = Acts::DynamicMatrix::Zero(nMeas, nPar);
0061 for (std::size_t s = 0; s < nStates; ++s) {
0062 const std::size_t o = s * Acts::eBoundSize;
0063 state.trackParametersCovariance(o + Acts::eBoundLoc0,
0064 o + Acts::eBoundLoc0) = 1e-3;
0065 state.trackParametersCovariance(o + Acts::eBoundLoc1,
0066 o + Acts::eBoundLoc1) = 1e-3;
0067 state.trackParametersCovariance(o + Acts::eBoundPhi, o + Acts::eBoundPhi) =
0068 1e-12;
0069 state.trackParametersCovariance(o + Acts::eBoundTheta,
0070 o + Acts::eBoundTheta) = 1e-12;
0071 state.trackParametersCovariance(o + Acts::eBoundQOverP,
0072 o + Acts::eBoundQOverP) = 1e-10;
0073 state.trackParametersCovariance(o + Acts::eBoundTime,
0074 o + Acts::eBoundTime) = 1e2;
0075 state.projectionMatrix(2 * s, o + Acts::eBoundLoc0) = 1.;
0076 state.projectionMatrix(2 * s + 1, o + Acts::eBoundLoc1) = 1.;
0077 }
0078 state.residual = Acts::DynamicVector::Zero(nMeas);
0079 state.alignmentToResidualDerivative =
0080 Acts::DynamicMatrix::Zero(nMeas, state.alignmentDof);
0081 for (std::size_t i = 0; i < nMeas; ++i) {
0082 state.residual(i) = 0.01 * (i + 1);
0083 for (std::size_t a = 0; a < Acts::eAlignmentSize; ++a) {
0084 state.alignmentToResidualDerivative(i, a) = 0.1 * (a + 1) + 0.01 * i;
0085 }
0086 }
0087
0088 std::ostringstream logStream;
0089 auto logger = Acts::getDefaultLogger("ActsToMilleDiscardGuard",
0090 Acts::Logging::WARNING, &logStream);
0091
0092 #ifdef ACTS_ENABLE_LOG_FAILURE_THRESHOLD
0093
0094 Acts::Logging::ScopedFailureThreshold threshold{Acts::Logging::FATAL};
0095 #endif
0096 const std::string fname = "ActsToMilleDiscardGuard.dat";
0097 {
0098 std::unique_ptr<Mille::MilleRecord> out = Mille::spawnMilleRecord(fname);
0099 BOOST_REQUIRE(out != nullptr);
0100 ActsPlugins::ActsToMille::dumpToMille(state, *out, true, *logger);
0101 }
0102 BOOST_CHECK(logStream.str().find("measured track parameter") !=
0103 std::string::npos);
0104
0105 auto reader = Mille::spawnMilleReader(fname);
0106 BOOST_REQUIRE(reader != nullptr);
0107 BOOST_REQUIRE(reader->open(fname));
0108 Mille::MilleDecoder decoder;
0109 std::vector<Mille::MilleMeasurement> measurements;
0110 BOOST_REQUIRE(decoder.decode(*reader, measurements) ==
0111 Mille::MilleDecoder::ReadResult::OK);
0112
0113
0114 std::size_t nWithGlobals = 0;
0115 for (const auto& measurement : measurements) {
0116 if (measurement.globalLabels.empty()) {
0117 continue;
0118 }
0119 ++nWithGlobals;
0120 BOOST_CHECK(!measurement.localLabels.empty());
0121 }
0122 BOOST_CHECK_EQUAL(nWithGlobals, nMeas);
0123 }
0124
0125 BOOST_AUTO_TEST_SUITE_END()