File indexing completed on 2025-01-18 09:12:35
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/unit_test.hpp>
0010
0011 #include "Acts/EventData/TrackStatePropMask.hpp"
0012 #include "Acts/Utilities/Helpers.hpp"
0013
0014 #include <array>
0015 #include <bitset>
0016 #include <cstddef>
0017 #include <type_traits>
0018
0019 using namespace Acts;
0020
0021 BOOST_AUTO_TEST_SUITE(TrackStatePropMaskTest)
0022
0023 BOOST_AUTO_TEST_CASE(BitmaskOperators) {
0024 using PM = TrackStatePropMask;
0025
0026 auto bs1 = PM::Predicted;
0027
0028 BOOST_CHECK(ACTS_CHECK_BIT(bs1, PM::Predicted));
0029 BOOST_CHECK(!ACTS_CHECK_BIT(bs1, PM::Calibrated));
0030
0031 auto bs2 = PM::Calibrated;
0032
0033 BOOST_CHECK(!ACTS_CHECK_BIT(bs2, PM::Predicted));
0034 BOOST_CHECK(ACTS_CHECK_BIT(bs2, PM::Calibrated));
0035
0036 auto bs3 = PM::Calibrated | PM::Predicted;
0037
0038 BOOST_CHECK(ACTS_CHECK_BIT(bs3, PM::Predicted));
0039 BOOST_CHECK(ACTS_CHECK_BIT(bs3, PM::Calibrated));
0040
0041 BOOST_CHECK(ACTS_CHECK_BIT(PM::All, PM::Predicted));
0042 BOOST_CHECK(ACTS_CHECK_BIT(PM::All, PM::Calibrated));
0043
0044 auto bs4 = PM::Predicted | PM::Jacobian | PM::Smoothed;
0045 BOOST_CHECK(ACTS_CHECK_BIT(bs4, PM::Predicted));
0046 BOOST_CHECK(ACTS_CHECK_BIT(bs4, PM::Jacobian));
0047 BOOST_CHECK(ACTS_CHECK_BIT(bs4, PM::Smoothed));
0048 BOOST_CHECK(!ACTS_CHECK_BIT(bs4, PM::Calibrated));
0049 BOOST_CHECK(!ACTS_CHECK_BIT(bs4, PM::Filtered));
0050
0051 auto cnv = [](auto a) -> std::bitset<8> {
0052 return static_cast<std::underlying_type_t<PM>>(a);
0053 };
0054
0055 BOOST_CHECK(cnv(PM::All).all());
0056 BOOST_CHECK(cnv(PM::None).none());
0057
0058
0059 std::array<PM, 5> values{PM::Predicted, PM::Filtered, PM::Smoothed,
0060 PM::Jacobian, PM::Calibrated};
0061 for (std::size_t i = 0; i < values.size(); i++) {
0062 for (std::size_t j = 0; j < values.size(); j++) {
0063 PM a = values[i];
0064 PM b = values[j];
0065
0066 if (i == j) {
0067 BOOST_CHECK_EQUAL(cnv(a & b).count(), 1);
0068 } else {
0069 BOOST_CHECK(cnv(a & b).none());
0070 }
0071 }
0072 }
0073
0074 BOOST_CHECK_EQUAL(cnv(PM::Predicted ^ PM::Filtered).count(), 2);
0075 BOOST_CHECK(cnv(PM::Predicted ^ PM::Predicted).none());
0076 BOOST_CHECK_EQUAL(~(PM::Predicted | PM::Calibrated),
0077 (PM::All ^ PM::Predicted ^ PM::Calibrated));
0078
0079 PM base = PM::None;
0080 BOOST_CHECK_EQUAL(cnv(base), 0);
0081
0082 base &= PM::Filtered;
0083 BOOST_CHECK_EQUAL(cnv(base), 0);
0084
0085 base |= PM::Filtered;
0086 BOOST_CHECK_EQUAL(base, PM::Filtered);
0087
0088 base |= PM::Calibrated;
0089 BOOST_CHECK_EQUAL(base, (PM::Filtered | PM::Calibrated));
0090
0091 base ^= PM::All;
0092 BOOST_CHECK_EQUAL(base, ~(PM::Filtered | PM::Calibrated));
0093 }
0094 BOOST_AUTO_TEST_SUITE_END()