11 #include <boost/test/data/test_case.hpp>
12 #include <boost/test/unit_test.hpp>
24 namespace Acts::Test {
26 template <
typename factory_t>
45 auto i0 = t.addTrackState(kMask);
47 auto i1a = t.addTrackState(kMask, i0);
48 auto i1b = t.addTrackState(kMask, i0);
49 auto i2a = t.addTrackState(kMask, i1a);
50 auto i2b = t.addTrackState(kMask, i1b);
53 std::vector<size_t> act;
54 auto collect = [&](
auto p) {
55 act.push_back(
p.index());
56 BOOST_CHECK(!
p.hasCalibrated());
57 BOOST_CHECK(!
p.hasFiltered());
58 BOOST_CHECK(!
p.hasSmoothed());
59 BOOST_CHECK(!
p.hasJacobian());
60 BOOST_CHECK(!
p.hasProjector());
63 std::vector<size_t> exp = {i2a, i1a, i0};
64 t.visitBackwards(i2a, collect);
65 BOOST_CHECK_EQUAL_COLLECTIONS(act.begin(), act.end(), exp.begin(),
69 for (
const auto&
p : t.reverseTrackStateRange(i2a)) {
70 act.push_back(
p.index());
72 BOOST_CHECK_EQUAL_COLLECTIONS(act.begin(), act.end(), exp.begin(),
77 t.visitBackwards(i2b, collect);
78 BOOST_CHECK_EQUAL_COLLECTIONS(act.begin(), act.end(), exp.begin(),
82 for (
const auto&
p : t.reverseTrackStateRange(i2b)) {
83 act.push_back(
p.index());
85 BOOST_CHECK_EQUAL_COLLECTIONS(act.begin(), act.end(), exp.begin(),
89 t.applyBackwards(i2b, collect);
90 BOOST_CHECK_EQUAL_COLLECTIONS(act.begin(), act.end(), exp.begin(),
93 auto r = t.reverseTrackStateRange(i2b);
98 std::vector<BoundVector> predicteds;
100 for (
auto p : t.reverseTrackStateRange(i2b)) {
101 predicteds.push_back(BoundVector::Random());
102 p.predicted() = predicteds.back();
104 std::vector<BoundVector> predictedsAct;
105 for (
const auto&
p : ct.reverseTrackStateRange(i2b)) {
106 predictedsAct.push_back(
p.predicted());
110 BOOST_CHECK_EQUAL_COLLECTIONS(predictedsAct.begin(), predictedsAct.end(),
111 predicteds.begin(), predicteds.end());
117 BOOST_CHECK_EQUAL(t.size(), 0);
119 auto i0 = t.addTrackState(kMask);
121 auto i1a = t.addTrackState(kMask, i0);
122 auto i1b = t.addTrackState(kMask, i0);
123 t.addTrackState(kMask, i1a);
124 t.addTrackState(kMask, i1b);
126 BOOST_CHECK_EQUAL(t.size(), 5);
128 BOOST_CHECK_EQUAL(t.size(), 0);
136 auto i0 = t.addTrackState(kMask);
137 auto i1 = t.addTrackState(kMask, i0);
138 auto i2 = t.addTrackState(kMask, i1);
141 t.applyBackwards(i2, [&](
const auto&) {
145 BOOST_CHECK_EQUAL(n, 1
u);
148 t.applyBackwards(i2, [&](
const auto& ts) {
150 if (ts.index() == i1) {
155 BOOST_CHECK_EQUAL(n, 2
u);
158 t.applyBackwards(i2, [&](
const auto&) {
162 BOOST_CHECK_EQUAL(n, 3
u);
167 using namespace Acts::HashedStringLiteral;
171 auto alwaysPresent = [](
auto& ts) {
172 BOOST_CHECK(ts.template has<"referenceSurface"_hash>());
173 BOOST_CHECK(ts.template has<"measdim"_hash>());
174 BOOST_CHECK(ts.template has<"chi2"_hash>());
175 BOOST_CHECK(ts.template has<"pathLength"_hash>());
176 BOOST_CHECK(ts.template has<"typeFlags"_hash>());
179 auto ts =
t.getTrackState(
t.addTrackState(PM::All));
180 BOOST_CHECK(ts.hasPredicted());
181 BOOST_CHECK(ts.hasFiltered());
182 BOOST_CHECK(ts.hasSmoothed());
183 BOOST_CHECK(!ts.hasCalibrated());
184 BOOST_CHECK(ts.hasProjector());
185 BOOST_CHECK(ts.hasJacobian());
187 ts.allocateCalibrated(5);
188 BOOST_CHECK(ts.hasCalibrated());
190 ts =
t.getTrackState(
t.addTrackState(PM::None));
191 BOOST_CHECK(!ts.hasPredicted());
192 BOOST_CHECK(!ts.hasFiltered());
193 BOOST_CHECK(!ts.hasSmoothed());
194 BOOST_CHECK(!ts.hasCalibrated());
195 BOOST_CHECK(!ts.hasProjector());
196 BOOST_CHECK(!ts.hasJacobian());
199 ts =
t.getTrackState(
t.addTrackState(PM::Predicted));
200 BOOST_CHECK(ts.hasPredicted());
201 BOOST_CHECK(!ts.hasFiltered());
202 BOOST_CHECK(!ts.hasSmoothed());
203 BOOST_CHECK(!ts.hasCalibrated());
204 BOOST_CHECK(!ts.hasProjector());
205 BOOST_CHECK(!ts.hasJacobian());
208 ts =
t.getTrackState(
t.addTrackState(PM::Filtered));
209 BOOST_CHECK(!ts.hasPredicted());
210 BOOST_CHECK(ts.hasFiltered());
211 BOOST_CHECK(!ts.hasSmoothed());
212 BOOST_CHECK(!ts.hasCalibrated());
213 BOOST_CHECK(!ts.hasProjector());
214 BOOST_CHECK(!ts.hasJacobian());
217 ts =
t.getTrackState(
t.addTrackState(PM::Smoothed));
218 BOOST_CHECK(!ts.hasPredicted());
219 BOOST_CHECK(!ts.hasFiltered());
220 BOOST_CHECK(ts.hasSmoothed());
221 BOOST_CHECK(!ts.hasCalibrated());
222 BOOST_CHECK(!ts.hasProjector());
223 BOOST_CHECK(!ts.hasJacobian());
226 ts =
t.getTrackState(
t.addTrackState(PM::Calibrated));
227 BOOST_CHECK(!ts.hasPredicted());
228 BOOST_CHECK(!ts.hasFiltered());
229 BOOST_CHECK(!ts.hasSmoothed());
230 BOOST_CHECK(!ts.hasCalibrated());
231 BOOST_CHECK(ts.hasProjector());
232 BOOST_CHECK(!ts.hasJacobian());
233 ts.allocateCalibrated(5);
234 BOOST_CHECK(ts.hasCalibrated());
237 BOOST_CHECK(!ts.hasPredicted());
238 BOOST_CHECK(!ts.hasFiltered());
239 BOOST_CHECK(!ts.hasSmoothed());
240 BOOST_CHECK(!ts.hasCalibrated());
241 BOOST_CHECK(!ts.hasProjector());
242 BOOST_CHECK(ts.hasJacobian());
251 size_t index = traj.addTrackState();
253 auto ts = traj.getTrackState(index);
254 fillTrackState<trajectory_t>(pc, TrackStatePropMask::All, ts);
257 auto tsa = traj.getTrackState(index);
258 auto tsb = traj.getTrackState(index);
262 tsb.predicted() = par;
263 tsb.predictedCovariance() =
cov;
264 BOOST_CHECK_EQUAL(tsa.predicted(), par);
265 BOOST_CHECK_EQUAL(tsa.predictedCovariance(),
cov);
266 BOOST_CHECK_EQUAL(tsb.predicted(), par);
267 BOOST_CHECK_EQUAL(tsb.predictedCovariance(),
cov);
271 tsb.filtered() = par;
272 tsb.filteredCovariance() =
cov;
273 BOOST_CHECK_EQUAL(tsa.filtered(), par);
274 BOOST_CHECK_EQUAL(tsa.filteredCovariance(),
cov);
275 BOOST_CHECK_EQUAL(tsb.filtered(), par);
276 BOOST_CHECK_EQUAL(tsb.filteredCovariance(),
cov);
280 tsb.smoothed() = par;
281 tsb.smoothedCovariance() =
cov;
282 BOOST_CHECK_EQUAL(tsa.smoothed(), par);
283 BOOST_CHECK_EQUAL(tsa.smoothedCovariance(),
cov);
284 BOOST_CHECK_EQUAL(tsb.smoothed(), par);
285 BOOST_CHECK_EQUAL(tsb.smoothedCovariance(),
cov);
292 tsa.getUncalibratedSourceLink().template get<TestSourceLink>(),
295 tsb.getUncalibratedSourceLink().template get<TestSourceLink>(),
297 tsb.setUncalibratedSourceLink(
SourceLink{invalid});
299 tsa.getUncalibratedSourceLink().template get<TestSourceLink>(),
302 tsb.getUncalibratedSourceLink().template get<TestSourceLink>(),
309 tsb.template calibrated<eBoundSize>() = measPar;
310 tsb.template calibratedCovariance<eBoundSize>() = measCov;
311 BOOST_CHECK_EQUAL(tsa.template calibrated<eBoundSize>(), measPar);
312 BOOST_CHECK_EQUAL(tsa.template calibratedCovariance<eBoundSize>(),
314 BOOST_CHECK_EQUAL(tsb.template calibrated<eBoundSize>(), measPar);
315 BOOST_CHECK_EQUAL(tsb.template calibratedCovariance<eBoundSize>(),
321 size_t nMeasurements = tsb.effectiveCalibrated().rows();
322 auto effPar = measPar.head(nMeasurements);
323 auto effCov = measCov.topLeftCorner(nMeasurements, nMeasurements);
325 tsb.effectiveCalibrated() = effPar;
326 tsb.effectiveCalibratedCovariance() = effCov;
327 BOOST_CHECK_EQUAL(tsa.effectiveCalibrated(), effPar);
328 BOOST_CHECK_EQUAL(tsa.effectiveCalibratedCovariance(), effCov);
329 BOOST_CHECK_EQUAL(tsb.effectiveCalibrated(), effPar);
330 BOOST_CHECK_EQUAL(tsb.effectiveCalibratedCovariance(), effCov);
333 Jacobian jac = Jacobian::Identity();
334 BOOST_CHECK_NE(tsa.jacobian(), jac);
335 BOOST_CHECK_NE(tsb.jacobian(), jac);
336 tsb.jacobian() = jac;
337 BOOST_CHECK_EQUAL(tsa.jacobian(), jac);
338 BOOST_CHECK_EQUAL(tsb.jacobian(), jac);
342 BOOST_CHECK_EQUAL(tsa.chi2(), 98.0);
343 BOOST_CHECK_EQUAL(tsb.chi2(), 98.0);
346 tsb.pathLength() = 66.0;
347 BOOST_CHECK_EQUAL(tsa.pathLength(), 66.0);
348 BOOST_CHECK_EQUAL(tsb.pathLength(), 66.0);
356 size_t index = t.addTrackState();
357 auto ts = t.getTrackState(index);
358 fillTrackState<trajectory_t>(pc, TrackStatePropMask::All, ts);
361 BOOST_CHECK_EQUAL(ts.calibratedSize(), 1
u);
362 BOOST_CHECK_EQUAL(ts.effectiveCalibrated(),
363 (pc.sourceLink.parameters.head<1>()));
364 BOOST_CHECK_EQUAL(ts.effectiveCalibratedCovariance(),
365 (pc.sourceLink.covariance.topLeftCorner<1, 1>()));
372 ts.getUncalibratedSourceLink().template get<TestSourceLink>().sourceId,
373 pc.sourceLink.sourceId);
374 auto meas = testSourceLinkCalibratorReturn<trajectory_t>(
377 ts.getUncalibratedSourceLink().template get<TestSourceLink>().sourceId,
378 ttsb.sourceLink.sourceId);
379 auto m2 = std::get<Measurement<BoundIndices, 2u>>(meas);
381 BOOST_CHECK_EQUAL(ts.calibratedSize(), 2);
382 BOOST_CHECK_EQUAL(ts.effectiveCalibrated(),
m2.parameters());
383 BOOST_CHECK_EQUAL(ts.effectiveCalibratedCovariance(),
m2.covariance());
384 BOOST_CHECK_EQUAL(ts.effectiveProjector(),
m2.projector());
388 size_t nMeasurements) {
393 size_t index = t.addTrackState();
394 auto ts = t.getTrackState(index);
395 fillTrackState<trajectory_t>(pc, TrackStatePropMask::All, ts);
398 BOOST_CHECK_EQUAL(&ts.referenceSurface(), pc.surface.get());
399 BOOST_CHECK_EQUAL(ts.referenceSurface().geometryId(),
400 pc.sourceLink.m_geometryId);
403 BOOST_CHECK(ts.hasPredicted());
404 BOOST_CHECK_EQUAL(ts.predicted(), pc.predicted.parameters());
405 BOOST_CHECK(pc.predicted.covariance().has_value());
406 BOOST_CHECK_EQUAL(ts.predictedCovariance(), *pc.predicted.covariance());
407 BOOST_CHECK(ts.hasFiltered());
408 BOOST_CHECK_EQUAL(ts.filtered(), pc.filtered.parameters());
409 BOOST_CHECK(pc.filtered.covariance().has_value());
410 BOOST_CHECK_EQUAL(ts.filteredCovariance(), *pc.filtered.covariance());
411 BOOST_CHECK(ts.hasSmoothed());
412 BOOST_CHECK_EQUAL(ts.smoothed(), pc.smoothed.parameters());
413 BOOST_CHECK(pc.smoothed.covariance().has_value());
414 BOOST_CHECK_EQUAL(ts.smoothedCovariance(), *pc.smoothed.covariance());
417 BOOST_CHECK(ts.hasJacobian());
418 BOOST_CHECK_EQUAL(ts.jacobian(), pc.jacobian);
419 BOOST_CHECK_EQUAL(ts.pathLength(), pc.pathLength);
421 BOOST_CHECK_EQUAL(ts.chi2(), pc.chi2);
425 ts.getUncalibratedSourceLink().template get<TestSourceLink>(),
429 BOOST_CHECK(ts.hasCalibrated());
430 BOOST_CHECK_EQUAL(ts.effectiveCalibrated(),
431 pc.sourceLink.parameters.head(nMeasurements));
433 ts.effectiveCalibratedCovariance(),
434 pc.sourceLink.covariance.topLeftCorner(nMeasurements, nMeasurements));
438 mParFull.head(nMeasurements) =
439 pc.sourceLink.parameters.head(nMeasurements);
440 mCovFull.topLeftCorner(nMeasurements, nMeasurements) =
441 pc.sourceLink.covariance.topLeftCorner(nMeasurements, nMeasurements);
443 auto expMeas = pc.sourceLink.parameters.head(nMeasurements);
445 pc.sourceLink.covariance.topLeftCorner(nMeasurements, nMeasurements);
448 constexpr
size_t measdim = decltype(
N)::
value;
449 BOOST_CHECK_EQUAL(ts.template calibrated<measdim>(), expMeas);
450 BOOST_CHECK_EQUAL(ts.template calibratedCovariance<measdim>(), expCov);
454 BOOST_CHECK(ts.hasProjector());
461 auto meas = testSourceLinkCalibratorReturn<trajectory_t>(
465 fullProj.topLeftCorner(nMeasurements,
eBoundSize) =
m.projector();
469 BOOST_CHECK_EQUAL(ts.effectiveProjector(),
470 fullProj.topLeftCorner(nMeasurements,
eBoundSize));
471 BOOST_CHECK_EQUAL(ts.projector(), fullProj);
475 using namespace Acts::HashedStringLiteral;
481 size_t i =
t.addTrackState(TrackStatePropMask::Predicted |
482 TrackStatePropMask::Filtered |
484 auto tso =
t.getTrackState(
i);
485 fillTrackState<trajectory_t>(pc, TrackStatePropMask::Predicted, tso);
486 fillTrackState<trajectory_t>(pc, TrackStatePropMask::Filtered, tso);
489 BOOST_CHECK(tso.hasPredicted());
490 BOOST_CHECK(tso.hasFiltered());
491 BOOST_CHECK(!tso.hasSmoothed());
492 BOOST_CHECK(!tso.hasCalibrated());
493 BOOST_CHECK(tso.hasJacobian());
495 auto tsnone =
t.getTrackState(
t.addTrackState(TrackStatePropMask::None));
496 BOOST_CHECK(!tsnone.template has<"predicted"_hash>());
497 BOOST_CHECK(!tsnone.template has<"filtered"_hash>());
498 BOOST_CHECK(!tsnone.template has<"smoothed"_hash>());
499 BOOST_CHECK(!tsnone.template has<"jacobian"_hash>());
500 BOOST_CHECK(!tsnone.template has<"calibrated"_hash>());
501 BOOST_CHECK(!tsnone.template has<"projector"_hash>());
503 !tsnone.template has<"uncalibratedSourceLink"_hash>());
506 BOOST_CHECK(tsnone.template has<"referenceSurface"_hash>());
507 BOOST_CHECK(tsnone.template has<"measdim"_hash>());
508 BOOST_CHECK(tsnone.template has<"chi2"_hash>());
509 BOOST_CHECK(tsnone.template has<"pathLength"_hash>());
510 BOOST_CHECK(tsnone.template has<"typeFlags"_hash>());
512 auto tsall =
t.getTrackState(
t.addTrackState(TrackStatePropMask::All));
513 BOOST_CHECK(tsall.template has<"predicted"_hash>());
514 BOOST_CHECK(tsall.template has<"filtered"_hash>());
515 BOOST_CHECK(tsall.template has<"smoothed"_hash>());
516 BOOST_CHECK(tsall.template has<"jacobian"_hash>());
517 BOOST_CHECK(!tsall.template has<"calibrated"_hash>());
518 tsall.allocateCalibrated(5);
519 BOOST_CHECK(tsall.template has<"calibrated"_hash>());
520 BOOST_CHECK(tsall.template has<"projector"_hash>());
521 BOOST_CHECK(!tsall.template has<
522 "uncalibratedSourceLink"_hash>());
524 BOOST_CHECK(tsall.template has<"referenceSurface"_hash>());
525 BOOST_CHECK(tsall.template has<"measdim"_hash>());
526 BOOST_CHECK(tsall.template has<"chi2"_hash>());
527 BOOST_CHECK(tsall.template has<"pathLength"_hash>());
528 BOOST_CHECK(tsall.template has<"typeFlags"_hash>());
530 tsall.unset(TrackStatePropMask::Predicted);
531 BOOST_CHECK(!tsall.template has<"predicted"_hash>());
532 tsall.unset(TrackStatePropMask::Filtered);
533 BOOST_CHECK(!tsall.template has<"filtered"_hash>());
534 tsall.unset(TrackStatePropMask::Smoothed);
535 BOOST_CHECK(!tsall.template has<"smoothed"_hash>());
537 BOOST_CHECK(!tsall.template has<"jacobian"_hash>());
538 tsall.unset(TrackStatePropMask::Calibrated);
539 BOOST_CHECK(!tsall.template has<"calibrated"_hash>());
545 std::array<PM, 5>
values{PM::Predicted, PM::Filtered, PM::Smoothed,
547 PM all = std::accumulate(
values.begin(),
values.end(), PM::None,
548 [](
auto a,
auto b) {
return a |
b; });
552 auto ts = mj.getTrackState(mj.addTrackState(PM::All));
554 BOOST_CHECK_EQUAL(ts.getMask(), (all & ~PM::Calibrated));
555 ts.allocateCalibrated(4);
556 BOOST_CHECK_EQUAL(ts.getMask(), all);
560 mj.getTrackState(mj.addTrackState(PM::Filtered | PM::Calibrated));
562 BOOST_CHECK_EQUAL(ts.getMask(), PM::Filtered);
563 ts.allocateCalibrated(4);
564 BOOST_CHECK_EQUAL(ts.getMask(), (PM::Filtered | PM::Calibrated));
567 auto ts = mj.getTrackState(
568 mj.addTrackState(PM::Filtered | PM::Smoothed | PM::Predicted));
569 BOOST_CHECK(ts.getMask() ==
570 (PM::Filtered | PM::Smoothed | PM::Predicted));
574 auto ts = mj.getTrackState(mj.addTrackState(
mask));
576 BOOST_CHECK_EQUAL(ts.getMask(), (
mask & ~PM::Calibrated));
584 std::array<PM, 4>
values{PM::Predicted, PM::Filtered, PM::Smoothed,
588 auto mkts = [&](PM
mask) {
589 auto r = mj.getTrackState(mj.addTrackState(
mask));
595 for (PM
b : values) {
600 BOOST_CHECK_THROW(tsa.copyFrom(tsb), std::runtime_error);
601 BOOST_CHECK_THROW(tsb.copyFrom(tsa), std::runtime_error);
610 BOOST_TEST_CHECKPOINT(
"Calib auto alloc");
611 auto tsa = mkts(PM::All);
612 auto tsb = mkts(PM::All);
613 tsb.allocateCalibrated(5);
614 tsb.template calibrated<5>().setRandom();
615 tsb.template calibratedCovariance<5>().setRandom();
616 tsa.copyFrom(tsb, PM::All);
617 BOOST_CHECK_EQUAL(tsa.template calibrated<5>(),
618 tsb.template calibrated<5>());
619 BOOST_CHECK_EQUAL(tsa.template calibratedCovariance<5>(),
620 tsb.template calibratedCovariance<5>());
624 BOOST_TEST_CHECKPOINT(
"Copy none");
625 auto tsa = mkts(PM::All);
626 auto tsb = mkts(PM::All);
627 tsa.copyFrom(tsb, PM::None);
630 auto ts1 = mkts(PM::Filtered | PM::Predicted);
631 ts1.filtered().setRandom();
632 ts1.filteredCovariance().setRandom();
633 ts1.predicted().setRandom();
634 ts1.predictedCovariance().setRandom();
637 auto ts2 = mkts(PM::Predicted);
638 ts2.predicted().setRandom();
639 ts2.predictedCovariance().setRandom();
642 BOOST_CHECK(ts1.predicted() != ts2.predicted());
643 BOOST_CHECK(ts1.predictedCovariance() != ts2.predictedCovariance());
646 BOOST_CHECK_THROW(ts2.copyFrom(ts1), std::runtime_error);
647 BOOST_CHECK(ts1.predicted() != ts2.predicted());
648 BOOST_CHECK(ts1.predictedCovariance() != ts2.predictedCovariance());
652 BOOST_CHECK(ts1.predicted() == ts2.predicted());
653 BOOST_CHECK(ts1.predictedCovariance() == ts2.predictedCovariance());
655 size_t i0 = mj.addTrackState();
656 size_t i1 = mj.addTrackState();
657 ts1 = mj.getTrackState(i0);
658 ts2 = mj.getTrackState(i1);
661 fillTrackState<trajectory_t>(rts1, TrackStatePropMask::All, ts1);
662 fillTrackState<trajectory_t>(rts2, TrackStatePropMask::All, ts2);
664 auto ots1 = mkts(PM::All);
665 auto ots2 = mkts(PM::All);
670 BOOST_CHECK_NE(ts1.predicted(), ts2.predicted());
671 BOOST_CHECK_NE(ts1.predictedCovariance(), ts2.predictedCovariance());
672 BOOST_CHECK_NE(ts1.filtered(), ts2.filtered());
673 BOOST_CHECK_NE(ts1.filteredCovariance(), ts2.filteredCovariance());
674 BOOST_CHECK_NE(ts1.smoothed(), ts2.smoothed());
675 BOOST_CHECK_NE(ts1.smoothedCovariance(), ts2.smoothedCovariance());
678 ts1.getUncalibratedSourceLink().template get<TestSourceLink>(),
679 ts2.getUncalibratedSourceLink().template get<TestSourceLink>());
682 constexpr
size_t measdim = decltype(
N)::
value;
683 BOOST_CHECK_NE(ts1.template calibrated<measdim>(),
684 ts2.template calibrated<measdim>());
685 BOOST_CHECK_NE(ts1.template calibratedCovariance<measdim>(),
686 ts2.template calibratedCovariance<measdim>());
689 BOOST_CHECK_NE(ts1.calibratedSize(), ts2.calibratedSize());
690 BOOST_CHECK_NE(ts1.projector(), ts2.projector());
692 BOOST_CHECK_NE(ts1.jacobian(), ts2.jacobian());
693 BOOST_CHECK_NE(ts1.chi2(), ts2.chi2());
694 BOOST_CHECK_NE(ts1.pathLength(), ts2.pathLength());
695 BOOST_CHECK_NE(&ts1.referenceSurface(), &ts2.referenceSurface());
699 BOOST_CHECK_EQUAL(ts1.predicted(), ts2.predicted());
700 BOOST_CHECK_EQUAL(ts1.predictedCovariance(), ts2.predictedCovariance());
701 BOOST_CHECK_EQUAL(ts1.filtered(), ts2.filtered());
702 BOOST_CHECK_EQUAL(ts1.filteredCovariance(), ts2.filteredCovariance());
703 BOOST_CHECK_EQUAL(ts1.smoothed(), ts2.smoothed());
704 BOOST_CHECK_EQUAL(ts1.smoothedCovariance(), ts2.smoothedCovariance());
707 ts1.getUncalibratedSourceLink().template get<TestSourceLink>(),
708 ts2.getUncalibratedSourceLink().template get<TestSourceLink>());
711 constexpr
size_t measdim = decltype(
N)::
value;
712 BOOST_CHECK_EQUAL(ts1.template calibrated<measdim>(),
713 ts2.template calibrated<measdim>());
714 BOOST_CHECK_EQUAL(ts1.template calibratedCovariance<measdim>(),
715 ts2.template calibratedCovariance<measdim>());
718 BOOST_CHECK_EQUAL(ts1.calibratedSize(), ts2.calibratedSize());
719 BOOST_CHECK_EQUAL(ts1.projector(), ts2.projector());
721 BOOST_CHECK_EQUAL(ts1.jacobian(), ts2.jacobian());
722 BOOST_CHECK_EQUAL(ts1.chi2(), ts2.chi2());
723 BOOST_CHECK_EQUAL(ts1.pathLength(), ts2.pathLength());
724 BOOST_CHECK_EQUAL(&ts1.referenceSurface(), &ts2.referenceSurface());
727 ts2 = mkts(PM::Predicted |
PM::Jacobian | PM::Calibrated);
728 ts2.copyFrom(ots2, PM::Predicted |
PM::Jacobian | PM::Calibrated);
732 BOOST_CHECK_NE(ts1.predicted(), ts2.predicted());
733 BOOST_CHECK_NE(ts1.predictedCovariance(), ts2.predictedCovariance());
736 constexpr
size_t measdim = decltype(
N)::
value;
737 BOOST_CHECK_NE(ts1.template calibrated<measdim>(),
738 ts2.template calibrated<measdim>());
739 BOOST_CHECK_NE(ts1.template calibratedCovariance<measdim>(),
740 ts2.template calibratedCovariance<measdim>());
743 BOOST_CHECK_NE(ts1.calibratedSize(), ts2.calibratedSize());
744 BOOST_CHECK_NE(ts1.projector(), ts2.projector());
746 BOOST_CHECK_NE(ts1.jacobian(), ts2.jacobian());
747 BOOST_CHECK_NE(ts1.chi2(), ts2.chi2());
748 BOOST_CHECK_NE(ts1.pathLength(), ts2.pathLength());
749 BOOST_CHECK_NE(&ts1.referenceSurface(), &ts2.referenceSurface());
754 BOOST_CHECK_EQUAL(ts1.predicted(), ts2.predicted());
755 BOOST_CHECK_EQUAL(ts1.predictedCovariance(), ts2.predictedCovariance());
758 constexpr
size_t measdim = decltype(
N)::
value;
759 BOOST_CHECK_EQUAL(ts1.template calibrated<measdim>(),
760 ts2.template calibrated<measdim>());
761 BOOST_CHECK_EQUAL(ts1.template calibratedCovariance<measdim>(),
762 ts2.template calibratedCovariance<measdim>());
765 BOOST_CHECK_EQUAL(ts1.calibratedSize(), ts2.calibratedSize());
766 BOOST_CHECK_EQUAL(ts1.projector(), ts2.projector());
768 BOOST_CHECK_EQUAL(ts1.jacobian(), ts2.jacobian());
769 BOOST_CHECK_EQUAL(ts1.chi2(), ts2.chi2());
770 BOOST_CHECK_EQUAL(ts1.pathLength(), ts2.pathLength());
771 BOOST_CHECK_EQUAL(&ts1.referenceSurface(),
772 &ts2.referenceSurface());
778 std::array<PM, 4>
values{PM::Predicted, PM::Filtered, PM::Smoothed,
783 auto mkts = [&](PM
mask) {
784 auto r = mj.getTrackState(mj.addTrackState(
mask));
787 auto mkts2 = [&](PM
mask) {
788 auto r = mj2.getTrackState(mj2.addTrackState(
mask));
794 for (PM
b : values) {
799 BOOST_CHECK_THROW(tsa.copyFrom(tsb), std::runtime_error);
800 BOOST_CHECK_THROW(tsb.copyFrom(tsa), std::runtime_error);
809 BOOST_CHECK_EQUAL(mj.size(), values.size() * values.size());
810 BOOST_CHECK_EQUAL(mj2.size(), values.size() * values.size());
812 auto ts1 = mkts(PM::Filtered | PM::Predicted);
813 ts1.filtered().setRandom();
814 ts1.filteredCovariance().setRandom();
815 ts1.predicted().setRandom();
816 ts1.predictedCovariance().setRandom();
819 auto ts2 = mkts2(PM::Predicted);
820 ts2.predicted().setRandom();
821 ts2.predictedCovariance().setRandom();
824 BOOST_CHECK(ts1.predicted() != ts2.predicted());
825 BOOST_CHECK(ts1.predictedCovariance() != ts2.predictedCovariance());
828 BOOST_CHECK_THROW(ts2.copyFrom(ts1), std::runtime_error);
829 BOOST_CHECK(ts1.predicted() != ts2.predicted());
830 BOOST_CHECK(ts1.predictedCovariance() != ts2.predictedCovariance());
834 BOOST_CHECK(ts1.predicted() == ts2.predicted());
835 BOOST_CHECK(ts1.predictedCovariance() == ts2.predictedCovariance());
838 BOOST_TEST_CHECKPOINT(
"Calib auto alloc");
839 auto tsa = mkts(PM::All);
840 auto tsb = mkts(PM::All);
841 tsb.allocateCalibrated(5);
842 tsb.template calibrated<5>().setRandom();
843 tsb.template calibratedCovariance<5>().setRandom();
844 tsa.copyFrom(tsb, PM::All);
845 BOOST_CHECK_EQUAL(tsa.template calibrated<5>(),
846 tsb.template calibrated<5>());
847 BOOST_CHECK_EQUAL(tsa.template calibratedCovariance<5>(),
848 tsb.template calibratedCovariance<5>());
852 BOOST_TEST_CHECKPOINT(
"Copy none");
853 auto tsa = mkts(PM::All);
854 auto tsb = mkts(PM::All);
855 tsa.copyFrom(tsb, PM::None);
862 auto i0 = t.addTrackState(kMask);
864 typename trajectory_t::TrackStateProxy
tp = t.getTrackState(i0);
865 typename trajectory_t::TrackStateProxy tp2{tp};
866 typename trajectory_t::ConstTrackStateProxy tp3{tp};
878 const auto idx_a = mj.addTrackState(PM::All);
879 const auto idx_b = mj.addTrackState(PM::All);
881 typename trajectory_t::TrackStateProxy mutableProxy =
882 mj.getTrackState(idx_a);
885 typename trajectory_t::ConstTrackStateProxy constProxy =
886 cmj.getTrackState(idx_b);
888 mutableProxy.copyFrom(constProxy);
899 size_t ia = traj.addTrackState(TrackStatePropMask::All);
900 size_t ib = traj.addTrackState(TrackStatePropMask::None);
902 auto tsa = traj.getTrackState(ia);
903 auto tsb = traj.getTrackState(ib);
905 fillTrackState<trajectory_t>(pc, TrackStatePropMask::All, tsa);
907 BOOST_CHECK(tsa.hasPredicted());
908 BOOST_CHECK(!tsb.hasPredicted());
909 tsb.shareFrom(tsa, TrackStatePropMask::Predicted);
910 BOOST_CHECK(tsa.hasPredicted());
911 BOOST_CHECK(tsb.hasPredicted());
912 BOOST_CHECK_EQUAL(tsa.predicted(), tsb.predicted());
913 BOOST_CHECK_EQUAL(tsa.predictedCovariance(), tsb.predictedCovariance());
915 BOOST_CHECK(tsa.hasFiltered());
916 BOOST_CHECK(!tsb.hasFiltered());
917 tsb.shareFrom(tsa, TrackStatePropMask::Filtered);
918 BOOST_CHECK(tsa.hasFiltered());
919 BOOST_CHECK(tsb.hasFiltered());
920 BOOST_CHECK_EQUAL(tsa.filtered(), tsb.filtered());
921 BOOST_CHECK_EQUAL(tsa.filteredCovariance(), tsb.filteredCovariance());
923 BOOST_CHECK(tsa.hasSmoothed());
924 BOOST_CHECK(!tsb.hasSmoothed());
925 tsb.shareFrom(tsa, TrackStatePropMask::Smoothed);
926 BOOST_CHECK(tsa.hasSmoothed());
927 BOOST_CHECK(tsb.hasSmoothed());
928 BOOST_CHECK_EQUAL(tsa.smoothed(), tsb.smoothed());
929 BOOST_CHECK_EQUAL(tsa.smoothedCovariance(), tsb.smoothedCovariance());
931 BOOST_CHECK(tsa.hasJacobian());
932 BOOST_CHECK(!tsb.hasJacobian());
934 BOOST_CHECK(tsa.hasJacobian());
935 BOOST_CHECK(tsb.hasJacobian());
936 BOOST_CHECK_EQUAL(tsa.jacobian(), tsb.jacobian());
941 size_t i = traj.addTrackState(TrackStatePropMask::All &
942 ~TrackStatePropMask::Filtered &
943 ~TrackStatePropMask::Smoothed);
945 auto ts = traj.getTrackState(i);
947 BOOST_CHECK(ts.hasPredicted());
948 BOOST_CHECK(!ts.hasFiltered());
949 BOOST_CHECK(!ts.hasSmoothed());
950 ts.predicted().setRandom();
951 ts.predictedCovariance().setRandom();
953 ts.shareFrom(TrackStatePropMask::Predicted, TrackStatePropMask::Filtered);
954 BOOST_CHECK(ts.hasPredicted());
955 BOOST_CHECK(ts.hasFiltered());
956 BOOST_CHECK(!ts.hasSmoothed());
957 BOOST_CHECK_EQUAL(ts.predicted(), ts.filtered());
958 BOOST_CHECK_EQUAL(ts.predictedCovariance(), ts.filteredCovariance());
960 ts.shareFrom(TrackStatePropMask::Predicted, TrackStatePropMask::Smoothed);
961 BOOST_CHECK(ts.hasPredicted());
962 BOOST_CHECK(ts.hasFiltered());
963 BOOST_CHECK(ts.hasSmoothed());
964 BOOST_CHECK_EQUAL(ts.predicted(), ts.filtered());
965 BOOST_CHECK_EQUAL(ts.predicted(), ts.smoothed());
966 BOOST_CHECK_EQUAL(ts.predictedCovariance(), ts.filteredCovariance());
967 BOOST_CHECK_EQUAL(ts.predictedCovariance(), ts.smoothedCovariance());
972 using namespace HashedStringLiteral;
975 using T = decltype(
value);
981 BOOST_CHECK(!traj.hasColumn(
h));
982 traj.template addColumn<T>(
col);
983 BOOST_CHECK(traj.hasColumn(
h));
985 BOOST_CHECK(!traj.hasColumn(
h2));
986 traj.template addColumn<T>(col2);
987 BOOST_CHECK(traj.hasColumn(
h2));
989 auto ts1 = traj.getTrackState(traj.addTrackState());
990 auto ts2 = traj.getTrackState(
991 traj.addTrackState(TrackStatePropMask::All, ts1.index()));
992 auto ts3 = traj.getTrackState(
993 traj.addTrackState(TrackStatePropMask::All, ts2.index()));
995 BOOST_CHECK(ts1.has(
h));
996 BOOST_CHECK(ts2.has(
h));
997 BOOST_CHECK(ts3.has(
h));
999 BOOST_CHECK(ts1.has(
h2));
1000 BOOST_CHECK(ts2.has(
h2));
1001 BOOST_CHECK(ts3.has(
h2));
1003 ts1.template component<T>(
col) =
value;
1004 BOOST_CHECK_EQUAL(ts1.template component<T>(
col),
value);
1007 test(
"uint32_t", uint32_t(1));
1008 test(
"uint64_t", uint64_t(2));
1009 test(
"int32_t", int32_t(-3));
1010 test(
"int64_t", int64_t(-4));
1011 test(
"float",
float(8.9));
1012 test(
"double",
double(656.2));
1015 traj.template addColumn<int>(
"extra_column");
1016 traj.template addColumn<float>(
"another_column");
1018 auto ts1 = traj.getTrackState(traj.addTrackState());
1019 auto ts2 = traj.getTrackState(
1020 traj.addTrackState(TrackStatePropMask::All, ts1.index()));
1021 auto ts3 = traj.getTrackState(
1022 traj.addTrackState(TrackStatePropMask::All, ts2.index()));
1024 BOOST_CHECK(ts1.template has<"extra_column"_hash>());
1025 BOOST_CHECK(ts2.template has<"extra_column"_hash>());
1026 BOOST_CHECK(ts3.template has<"extra_column"_hash>());
1028 BOOST_CHECK(ts1.template has<"another_column"_hash>());
1029 BOOST_CHECK(ts2.template has<"another_column"_hash>());
1030 BOOST_CHECK(ts3.template has<"another_column"_hash>());
1032 ts2.template component<int,
"extra_column"_hash>() = 6;
1034 BOOST_CHECK_EQUAL((ts2.template component<int, "extra_column"_hash>()), 6);
1036 ts3.template component<float,
"another_column"_hash>() = 7.2
f;
1037 BOOST_CHECK_EQUAL((ts3.template component<float, "another_column"_hash>()),
1042 auto runTest = [&](
auto&& fn) {
1044 std::vector<std::string> columns = {
"one",
"two",
"three",
"four"};
1045 for (
const auto&
c : columns) {
1046 BOOST_CHECK(!mt.hasColumn(fn(
c)));
1047 mt.template addColumn<int>(
c);
1048 BOOST_CHECK(mt.hasColumn(fn(
c)));
1050 for (
const auto&
c : columns) {
1051 auto ts1 = mt.getTrackState(mt.addTrackState());
1052 auto ts2 = mt.getTrackState(mt.addTrackState());
1053 BOOST_CHECK(ts1.has(fn(
c)));
1054 BOOST_CHECK(ts2.has(fn(
c)));
1055 ts1.template component<int>(fn(
c)) = 674;
1056 ts2.template component<int>(fn(
c)) = 421;
1057 BOOST_CHECK_EQUAL(ts1.template component<int>(fn(
c)), 674);
1058 BOOST_CHECK_EQUAL(ts2.template component<int>(fn(
c)), 421);