8 #include <boost/test/unit_test.hpp>
17 using namespace Acts::HashedStringLiteral;
20 BOOST_AUTO_TEST_SUITE(EventDataTrack)
27 tc.addColumn<
size_t>(
"counter");
28 tc.addColumn<
bool>(
"odd");
35 tc3.addColumn<
bool>(
"odd");
37 for (
size_t i = 0;
i < 10;
i++) {
38 auto t =
tc.getTrack(
tc.addTrack());
39 auto ts =
t.appendTrackState();
40 ts.predicted() = BoundVector::Ones();
41 ts =
t.appendTrackState();
42 ts.predicted().setOnes();
45 ts =
t.appendTrackState();
46 ts.predicted().setOnes();
49 t.template component<size_t>(
"counter") =
i;
50 t.template component<bool>(
"odd") =
i % 2 == 0;
52 auto t2 = tc2.getTrack(tc2.addTrack());
53 BOOST_CHECK_THROW(t2.copyFrom(
t),
54 std::invalid_argument);
56 auto t3 = tc3.getTrack(tc3.addTrack());
60 BOOST_CHECK(t3.nTrackStates() > 0);
61 BOOST_REQUIRE_EQUAL(
t.nTrackStates(), t3.nTrackStates());
63 for (
auto [tsa, tsb] :
64 zip(
t.trackStatesReversed(), t3.trackStatesReversed())) {
65 BOOST_CHECK_EQUAL(tsa.predicted(), tsb.predicted());
68 BOOST_CHECK_EQUAL(
t.template component<size_t>(
"counter"),
69 t3.template component<size_t>(
"counter"));
70 BOOST_CHECK_EQUAL(
t.template component<bool>(
"odd"),
71 t3.template component<bool>(
"odd"));
78 BOOST_REQUIRE_EQUAL(tc4.trackStateContainer().size(), before);
82 tc5.addColumn<
bool>(
"odd");
84 for (
size_t i = 0;
i < 10;
i++) {
85 auto t4 = tc4.getTrack(
i);
86 BOOST_CHECK_NE(
t4.nTrackStates(), 0);
88 auto t5 = tc5.getTrack(tc5.addTrack());
92 BOOST_CHECK(t5.nTrackStates() > 0);
93 BOOST_REQUIRE_EQUAL(
t4.nTrackStates(), t5.nTrackStates());
95 for (
auto [tsa, tsb] :
96 zip(
t4.trackStatesReversed(), t5.trackStatesReversed())) {
97 BOOST_CHECK_EQUAL(tsa.predicted(), tsb.predicted());
100 BOOST_CHECK_EQUAL(
t4.template component<size_t>(
"counter"),
101 t5.template component<size_t>(
"counter"));
102 BOOST_CHECK_EQUAL(
t4.template component<bool>(
"odd"),
103 t5.template component<bool>(
"odd"));
112 auto t =
tc.getTrack(
tc.addTrack());
114 for (
size_t i = 0;
i < 4;
i++) {
115 auto ts =
t.appendTrackState();
116 ts.jacobian() = Acts::BoundMatrix::Identity() *
i;
119 std::vector<IndexType> exp;
120 exp.resize(
t.nTrackStates());
121 std::iota(exp.rbegin(), exp.rend(), 0);
122 std::vector<IndexType> act;
123 std::transform(
t.trackStatesReversed().begin(),
t.trackStatesReversed().end(),
124 std::back_inserter(act),
125 [](
const auto& ts) {
return ts.index(); });
128 for (
const auto [
e, ts] :
zip(exp,
t.trackStatesReversed())) {
129 BOOST_CHECK_EQUAL(ts.jacobian(), Acts::BoundMatrix::Identity() *
e);
132 BOOST_CHECK_EQUAL_COLLECTIONS(exp.begin(), exp.end(), act.begin(), act.end());
135 t.reverseTrackStates();
137 std::iota(exp.begin(), exp.end(), 0);
139 std::transform(
t.trackStatesReversed().begin(),
t.trackStatesReversed().end(),
140 std::back_inserter(act),
141 [](
const auto& ts) {
return ts.index(); });
142 BOOST_CHECK_EQUAL_COLLECTIONS(exp.begin(), exp.end(), act.begin(), act.end());
145 for (
const auto [
e, ts] :
zip(exp,
t.trackStatesReversed())) {
146 BOOST_CHECK_EQUAL(ts.jacobian(), Acts::BoundMatrix::Identity() *
e);
150 t.reverseTrackStates();
153 for (
const auto [
e, ts] :
zip(exp,
t.trackStates())) {
154 BOOST_CHECK_EQUAL(ts.jacobian(), Acts::BoundMatrix::Identity() *
e);
158 t.reverseTrackStates(
true);
160 std::reverse(exp.begin(), exp.end());
161 std::rotate(exp.rbegin(),
std::next(exp.rbegin()), exp.rend());
163 for (
const auto [
e, ts] :
zip(exp,
t.trackStates())) {
166 expJac = Acts::BoundMatrix::Zero();
168 expJac = (Acts::BoundMatrix::Identity() *
e).inverse();
171 BOOST_CHECK_EQUAL(ts.jacobian(), expJac);
175 t.reverseTrackStates(
true);
178 std::iota(exp.begin(), exp.end(), 0);
180 for (
const auto [
e, ts] :
zip(exp,
t.trackStates())) {
181 BOOST_CHECK_EQUAL(ts.jacobian(), Acts::BoundMatrix::Identity() *
e);
185 BOOST_AUTO_TEST_SUITE_END()