Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:02:34

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011 
0012 #include "Acts/Definitions/Algebra.hpp"
0013 #include "Acts/Definitions/TrackParametrization.hpp"
0014 #include "Acts/EventData/detail/GenerateParameters.hpp"
0015 #include "Acts/Geometry/GeometryIdentifier.hpp"
0016 #include "ActsExamples/EventData/Measurement.hpp"
0017 #include "ActsTests/CommonHelpers/FloatComparisons.hpp"
0018 
0019 #include <algorithm>
0020 #include <array>
0021 #include <cmath>
0022 #include <limits>
0023 #include <random>
0024 #include <tuple>
0025 #include <utility>
0026 #include <variant>
0027 #include <vector>
0028 
0029 using namespace Acts;
0030 using namespace Acts::detail::Test;
0031 using namespace ActsExamples;
0032 namespace bd = boost::unit_test::data;
0033 
0034 namespace {
0035 constexpr BoundIndices boundIndices[] = {
0036     eBoundLoc0, eBoundLoc1, eBoundTime, eBoundPhi, eBoundTheta, eBoundQOverP,
0037 };
0038 constexpr GeometryIdentifier geoId{1};
0039 // fix seed for reproducible tests
0040 std::default_random_engine rng(123);
0041 }  // namespace
0042 
0043 // the underlying subspace implementation is already tested exhaustively in a
0044 // separate unit test. here we only test concrete extreme cases and
0045 // measurement-specific functionality.
0046 
0047 namespace ActsTests {
0048 
0049 BOOST_AUTO_TEST_SUITE(EventDataSuite)
0050 
0051 BOOST_DATA_TEST_CASE(VariableBoundOne, bd::make(boundIndices), index) {
0052   MeasurementContainer container;
0053 
0054   auto [params, cov] = generateParametersCovariance<double, 1u>(rng);
0055 
0056   FixedBoundMeasurementProxy<1> meas = container.makeMeasurement<1>(geoId);
0057   meas.setSubspaceIndices(std::array{index});
0058   meas.parameters() = params;
0059   meas.covariance() = cov;
0060 
0061   BOOST_CHECK_EQUAL(meas.size(), 1);
0062   for (auto i : boundIndices) {
0063     BOOST_CHECK_EQUAL(meas.contains(i), i == index);
0064   }
0065   BOOST_CHECK_EQUAL(meas.parameters(), params);
0066   BOOST_CHECK_EQUAL(meas.covariance(), cov);
0067   BOOST_CHECK_EQUAL(meas.geometryId(), geoId);
0068 }
0069 
0070 BOOST_DATA_TEST_CASE(VariableBoundOneEmplace, bd::make(boundIndices), index) {
0071   MeasurementContainer container;
0072 
0073   auto [params, cov] = generateParametersCovariance<double, 1u>(rng);
0074 
0075   FixedBoundMeasurementProxy<1> meas =
0076       container.emplaceMeasurement<1>(geoId, std::array{index}, params, cov);
0077 
0078   BOOST_CHECK_EQUAL(meas.size(), 1);
0079   for (auto i : boundIndices) {
0080     BOOST_CHECK_EQUAL(meas.contains(i), i == index);
0081   }
0082   BOOST_CHECK_EQUAL(meas.parameters(), params);
0083   BOOST_CHECK_EQUAL(meas.covariance(), cov);
0084   BOOST_CHECK_EQUAL(meas.geometryId(), geoId);
0085 }
0086 
0087 BOOST_AUTO_TEST_CASE(VariableBoundAll) {
0088   MeasurementContainer container;
0089 
0090   auto [params, cov] = generateParametersCovariance<double, eBoundSize>(rng);
0091 
0092   FixedBoundMeasurementProxy<eBoundSize> meas =
0093       container.makeMeasurement<eBoundSize>(geoId);
0094   meas.setSubspaceIndices(std::array{eBoundLoc0, eBoundLoc1, eBoundTime,
0095                                      eBoundPhi, eBoundTheta, eBoundQOverP});
0096   meas.parameters() = params;
0097   meas.covariance() = cov;
0098 
0099   BOOST_CHECK_EQUAL(meas.size(), eBoundSize);
0100   for (auto i : boundIndices) {
0101     BOOST_CHECK(meas.contains(i));
0102   }
0103   BOOST_CHECK_EQUAL(meas.parameters(), params);
0104   BOOST_CHECK_EQUAL(meas.covariance(), cov);
0105   BOOST_CHECK_EQUAL(meas.geometryId(), geoId);
0106 }
0107 
0108 BOOST_AUTO_TEST_CASE(VariableBoundAllEmplace) {
0109   MeasurementContainer container;
0110 
0111   auto [params, cov] = generateParametersCovariance<double, eBoundSize>(rng);
0112 
0113   FixedBoundMeasurementProxy<eBoundSize> meas =
0114       container.emplaceMeasurement<eBoundSize>(
0115           geoId,
0116           std::array{eBoundLoc0, eBoundLoc1, eBoundTime, eBoundPhi, eBoundTheta,
0117                      eBoundQOverP},
0118           params, cov);
0119 
0120   BOOST_CHECK_EQUAL(meas.size(), eBoundSize);
0121   for (auto i : boundIndices) {
0122     BOOST_CHECK(meas.contains(i));
0123   }
0124   BOOST_CHECK_EQUAL(meas.parameters(), params);
0125   BOOST_CHECK_EQUAL(meas.covariance(), cov);
0126   BOOST_CHECK_EQUAL(meas.geometryId(), geoId);
0127 }
0128 
0129 BOOST_AUTO_TEST_CASE(VariableBoundReassign) {
0130   MeasurementContainer container;
0131 
0132   // generate w/ two parameter
0133   auto [params1, cov1] = generateParametersCovariance<double, 2u>(rng);
0134 
0135   VariableBoundMeasurementProxy meas = container.makeMeasurement(2, geoId);
0136   meas.setSubspaceIndices(std::array{eBoundPhi, eBoundTheta});
0137   meas.parameters() = params1;
0138   meas.covariance() = cov1;
0139 
0140   BOOST_CHECK_EQUAL(meas.size(), 2);
0141   BOOST_CHECK(!meas.contains(eBoundLoc0));
0142   BOOST_CHECK(!meas.contains(eBoundLoc1));
0143   BOOST_CHECK(!meas.contains(eBoundTime));
0144   BOOST_CHECK(meas.contains(eBoundPhi));
0145   BOOST_CHECK(meas.contains(eBoundTheta));
0146   BOOST_CHECK(!meas.contains(eBoundQOverP));
0147 
0148   // reassign w/ all parameters
0149   auto [paramsN, covN] = generateParametersCovariance<double, eBoundSize>(rng);
0150 
0151   meas = container.makeMeasurement(eBoundSize, geoId);
0152   meas.setSubspaceIndices(std::array{eBoundLoc0, eBoundLoc1, eBoundTime,
0153                                      eBoundPhi, eBoundTheta, eBoundQOverP});
0154   meas.parameters() = paramsN;
0155   meas.covariance() = covN;
0156 
0157   BOOST_CHECK_EQUAL(meas.size(), eBoundSize);
0158   BOOST_CHECK(meas.contains(eBoundLoc0));
0159   BOOST_CHECK(meas.contains(eBoundLoc1));
0160   BOOST_CHECK(meas.contains(eBoundTime));
0161   BOOST_CHECK(meas.contains(eBoundPhi));
0162   BOOST_CHECK(meas.contains(eBoundTheta));
0163   BOOST_CHECK(meas.contains(eBoundQOverP));
0164 }
0165 
0166 BOOST_AUTO_TEST_SUITE_END()
0167 
0168 }  // namespace ActsTests