9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/old/interface.hpp>
11 #include <boost/test/unit_test.hpp>
12 #include <boost/test/unit_test_suite.hpp>
23 #include "ActsPodioEdm/BoundParametersCollection.h"
24 #include "ActsPodioEdm/JacobianCollection.h"
25 #include "ActsPodioEdm/TrackStateCollection.h"
29 #include <podio/ROOTFrameReader.h>
30 #include <podio/ROOTFrameWriter.h>
31 #include <podio/UserDataCollection.h>
36 using namespace Acts::UnitLiterals;
37 using namespace Acts::Test;
40 std::default_random_engine
rng(31415);
44 std::optional<PodioUtil::Identifier> surfaceToIdentifier(
45 const Surface& )
const override {
48 const Surface* identifierToSurface(
64 struct MapHelper :
public NullHelper {
65 std::optional<PodioUtil::Identifier> surfaceToIdentifier(
67 for (
auto&& [
id, srf] : surfaces) {
68 if (srf == &surface) {
75 auto it = surfaces.find(
id);
76 if (
it == surfaces.end()) {
84 sourceLinks.push_back(sl);
85 return sourceLinks.size() - 1;
89 return sourceLinks.at(
id);
92 std::unordered_map<PodioUtil::Identifier, const Surface*> surfaces;
93 std::vector<SourceLink> sourceLinks;
101 std::list<ActsPodioEdm::TrackStateCollection> m_collections;
102 std::list<ActsPodioEdm::BoundParametersCollection>
m_params;
103 std::list<ActsPodioEdm::JacobianCollection> m_jacs;
113 BOOST_AUTO_TEST_SUITE(PodioTrackStateContainerTest)
131 ct.testApplyWithAbort();
136 ct.testAddTrackStateWithBitMask();
142 ct.testTrackStateProxyCrossTalk(
rng);
147 ct.testTrackStateReassignment(
rng);
153 ct.testTrackStateProxyStorage(
rng, nMeasurements);
158 ct.testTrackStateProxyAllocations(
rng);
163 ct.testTrackStateProxyGetMask();
168 ct.testTrackStateProxyCopy(
rng);
173 ct.testTrackStateProxyCopyDiffMTJ();
178 ct.testProxyAssignment();
183 ct.testCopyFromConst();
188 ct.testTrackStateProxyShare(
rng);
193 ct.testMultiTrajectoryExtraColumns();
198 ct.testMultiTrajectoryExtraColumnsRuntime();
202 using namespace HashedStringLiteral;
207 auto tmp_path = std::filesystem::current_path();
211 tv1 << 1, 1, 1, 1, 1, 1;
224 auto rBounds = std::make_shared<RectangleBounds>(15, 20);
225 auto trf = Transform3::Identity();
226 trf.translation().setRandom();
227 auto free = Acts::Surface::makeShared<PlaneSurface>(trf,
rBounds);
228 auto reg = Acts::Surface::makeShared<PlaneSurface>(trf,
rBounds);
230 helper.surfaces[666] = reg.get();
235 BOOST_CHECK(!
c.hasColumn(
"int_column"_hash));
236 BOOST_CHECK(!
c.hasColumn(
"float_column"_hash));
237 c.addColumn<int32_t>(
"int_column");
238 c.addColumn<
float>(
"float_column");
239 BOOST_CHECK(
c.hasColumn(
"int_column"_hash));
240 BOOST_CHECK(
c.hasColumn(
"float_column"_hash));
243 auto t1 =
c.getTrackState(
c.addTrackState(TrackStatePropMask::Predicted));
244 t1.predicted() = tv1;
245 t1.predictedCovariance() = cov1;
247 t1.setReferenceSurface(free);
250 c.getTrackState(
c.addTrackState(TrackStatePropMask::All,
t1.index()));
251 t2.predicted() = tv2;
252 t2.predictedCovariance() = cov2;
255 t2.filteredCovariance() = cov3;
258 t2.smoothedCovariance() = cov4;
260 t2.jacobian() = cov2;
262 auto t3 =
c.getTrackState(
c.addTrackState());
263 t3.setReferenceSurface(reg);
265 t1.component<int32_t,
"int_column"_hash>() = -11;
266 t2.component<int32_t,
"int_column"_hash>() = 42;
267 t3.component<int32_t,
"int_column"_hash>() = -98;
269 t1.component<float,
"float_column"_hash>() = -11.2
f;
270 t2.component<float,
"float_column"_hash>() = 42.4
f;
271 t3.component<float,
"float_column"_hash>() = -98.9
f;
274 c.releaseInto(frame,
"test");
276 BOOST_CHECK_EQUAL(frame.get(
"trackStates_test")->size(), 3);
277 BOOST_CHECK_EQUAL(frame.get(
"trackStateParameters_test")->size(), 7);
278 BOOST_CHECK_EQUAL(frame.get(
"trackStateJacobians_test")->size(), 2);
279 BOOST_CHECK_NE(frame.get(
"trackStates_test_extra__int_column"),
nullptr);
280 BOOST_CHECK_NE(frame.get(
"trackStates_test_extra__float_column"),
nullptr);
284 BOOST_CHECK_EQUAL(cc.size(), 3);
285 BOOST_CHECK(cc.hasColumn(
"int_column"_hash));
286 BOOST_CHECK(cc.hasColumn(
"float_column"_hash));
288 auto t1 = cc.getTrackState(0);
289 auto t2 = cc.getTrackState(1);
290 auto t3 = cc.getTrackState(2);
292 BOOST_CHECK_EQUAL(
t2.previous(), 0);
294 BOOST_CHECK(
t1.hasReferenceSurface());
295 BOOST_CHECK(!
t2.hasReferenceSurface());
296 BOOST_CHECK(
t3.hasReferenceSurface());
300 const auto& ext =
t1.referenceSurface();
301 BOOST_CHECK_NE(&ext, free.get());
302 BOOST_CHECK_EQUAL(trf.matrix(), ext.transform(
gctx).matrix());
303 BOOST_CHECK_EQUAL(free->bounds().type(), ext.bounds().type());
304 BOOST_CHECK_EQUAL(free->type(), ext.type());
305 const auto* rBounds2 =
dynamic_cast<const RectangleBounds*
>(&ext.bounds());
306 BOOST_REQUIRE_NE(rBounds2,
nullptr);
307 BOOST_CHECK_EQUAL(
rBounds->halfLengthX(), rBounds2->halfLengthX());
308 BOOST_CHECK_EQUAL(
rBounds->halfLengthY(), rBounds2->halfLengthY());
310 BOOST_CHECK_EQUAL(
t1.predicted(), tv1);
311 BOOST_CHECK_EQUAL(
t1.predictedCovariance(), cov1);
313 BOOST_CHECK_EQUAL(
t2.predicted(), tv2);
314 BOOST_CHECK_EQUAL(
t2.predictedCovariance(), cov2);
315 BOOST_CHECK_EQUAL(
t2.filtered(), tv3);
316 BOOST_CHECK_EQUAL(
t2.filteredCovariance(), cov3);
317 BOOST_CHECK_EQUAL(
t2.smoothed(), tv4);
318 BOOST_CHECK_EQUAL(
t2.smoothedCovariance(), cov4);
320 BOOST_CHECK_EQUAL(
t2.jacobian(), cov2);
322 BOOST_CHECK_EQUAL(&
t3.referenceSurface(), reg.get());
324 BOOST_CHECK_EQUAL((
t1.component<int32_t,
"int_column"_hash>()), -11);
325 BOOST_CHECK_EQUAL((
t2.component<int32_t,
"int_column"_hash>()), 42);
326 BOOST_CHECK_EQUAL((
t3.component<int32_t,
"int_column"_hash>()), -98);
328 BOOST_CHECK_EQUAL((
t1.component<
float,
"float_column"_hash>()), -11.2f);
329 BOOST_CHECK_EQUAL((
t2.component<
float,
"float_column"_hash>()), 42.4f);
330 BOOST_CHECK_EQUAL((
t3.component<
float,
"float_column"_hash>()), -98.9f);
333 BOOST_AUTO_TEST_SUITE_END()