9 #include <boost/test/unit_test.hpp>
51 auto plane = Surface::makeShared<PlaneSurface>(
Vector3D{0., 0., 0.},
56 mCov << 1, 2, 3, 4, 5, 6, 7, 8, 9;
61 mPar[0], mPar[1], mPar[2]};
63 auto fm = std::make_unique<FittableMeasurement<SourceLink>>(meas);
72 predPar << 1, 2,
M_PI / 4.,
M_PI / 2., 5, 0.;
79 ts.parameter.predicted = pred;
83 filtPar << 6, 7,
M_PI / 4.,
M_PI / 2., 10, 0.;
90 ts.parameter.filtered =
filt;
94 smotPar << 11, 12,
M_PI / 4.,
M_PI / 2., 15, 0.;
101 ts.parameter.smoothed = smot;
104 ts.measurement.calibrated =
108 meas.parameters()[0],
109 meas.parameters()[1],
110 meas.parameters()[2]};
116 ts.parameter.jacobian = jac;
118 ts.parameter.chi2 = 78;
119 ts.parameter.pathLength = 42;
121 return std::make_tuple(ts, std::move(
fm), meas);
136 std::vector<size_t> act;
137 auto collect = [&](
auto p) {
138 act.push_back(
p.index());
140 BOOST_CHECK(!
p.hasUncalibrated());
141 BOOST_CHECK(!
p.hasCalibrated());
142 BOOST_CHECK(!
p.hasFiltered());
143 BOOST_CHECK(!
p.hasSmoothed());
144 BOOST_CHECK(!
p.hasJacobian());
145 BOOST_CHECK(!
p.hasProjector());
148 std::vector<size_t> exp = {i2a, i1a, i0};
150 BOOST_CHECK_EQUAL_COLLECTIONS(act.begin(), act.end(), exp.begin(), exp.end());
153 exp = {i2b, i1b, i0};
155 BOOST_CHECK_EQUAL_COLLECTIONS(act.begin(), act.end(), exp.begin(), exp.end());
159 BOOST_CHECK_EQUAL_COLLECTIONS(act.begin(), act.end(), exp.begin(), exp.end());
175 BOOST_CHECK_EQUAL(n, 1
u);
180 if (ts.index() == i1) {
185 BOOST_CHECK_EQUAL(n, 2
u);
192 BOOST_CHECK_EQUAL(n, 3
u);
196 namespace PM = TrackStatePropMask;
226 BOOST_CHECK(ts.hasPredicted());
227 BOOST_CHECK(ts.hasFiltered());
228 BOOST_CHECK(ts.hasSmoothed());
229 BOOST_CHECK(ts.hasUncalibrated());
230 BOOST_CHECK(ts.hasCalibrated());
231 BOOST_CHECK(ts.hasProjector());
232 BOOST_CHECK(ts.hasJacobian());
235 BOOST_CHECK(!ts.hasPredicted());
236 BOOST_CHECK(!ts.hasFiltered());
237 BOOST_CHECK(!ts.hasSmoothed());
238 BOOST_CHECK(!ts.hasUncalibrated());
239 BOOST_CHECK(!ts.hasCalibrated());
240 BOOST_CHECK(!ts.hasProjector());
241 BOOST_CHECK(!ts.hasJacobian());
244 BOOST_CHECK(ts.hasPredicted());
245 BOOST_CHECK(!ts.hasFiltered());
246 BOOST_CHECK(!ts.hasSmoothed());
247 BOOST_CHECK(!ts.hasUncalibrated());
248 BOOST_CHECK(!ts.hasCalibrated());
249 BOOST_CHECK(!ts.hasProjector());
250 BOOST_CHECK(!ts.hasJacobian());
253 BOOST_CHECK(!ts.hasPredicted());
254 BOOST_CHECK(ts.hasFiltered());
255 BOOST_CHECK(!ts.hasSmoothed());
256 BOOST_CHECK(!ts.hasUncalibrated());
257 BOOST_CHECK(!ts.hasCalibrated());
258 BOOST_CHECK(!ts.hasProjector());
259 BOOST_CHECK(!ts.hasJacobian());
262 BOOST_CHECK(!ts.hasPredicted());
263 BOOST_CHECK(!ts.hasFiltered());
264 BOOST_CHECK(ts.hasSmoothed());
265 BOOST_CHECK(!ts.hasUncalibrated());
266 BOOST_CHECK(!ts.hasCalibrated());
267 BOOST_CHECK(!ts.hasProjector());
268 BOOST_CHECK(!ts.hasJacobian());
271 BOOST_CHECK(!ts.hasPredicted());
272 BOOST_CHECK(!ts.hasFiltered());
273 BOOST_CHECK(!ts.hasSmoothed());
274 BOOST_CHECK(ts.hasUncalibrated());
275 BOOST_CHECK(!ts.hasCalibrated());
276 BOOST_CHECK(!ts.hasProjector());
277 BOOST_CHECK(!ts.hasJacobian());
280 BOOST_CHECK(!ts.hasPredicted());
281 BOOST_CHECK(!ts.hasFiltered());
282 BOOST_CHECK(!ts.hasSmoothed());
283 BOOST_CHECK(!ts.hasUncalibrated());
284 BOOST_CHECK(ts.hasCalibrated());
285 BOOST_CHECK(ts.hasProjector());
286 BOOST_CHECK(!ts.hasJacobian());
289 BOOST_CHECK(!ts.hasPredicted());
290 BOOST_CHECK(!ts.hasFiltered());
291 BOOST_CHECK(!ts.hasSmoothed());
292 BOOST_CHECK(!ts.hasUncalibrated());
293 BOOST_CHECK(!ts.hasCalibrated());
294 BOOST_CHECK(!ts.hasProjector());
295 BOOST_CHECK(ts.hasJacobian());
307 auto cts = ct.getTrackState(0);
311 BOOST_CHECK_EQUAL(cts.chi2(), 78
u);
312 BOOST_CHECK_EQUAL(ts.chi2(), 78
u);
313 BOOST_CHECK_EQUAL(cts.pathLength(), 42
u);
314 BOOST_CHECK_EQUAL(ts.pathLength(), 42
u);
321 BOOST_CHECK_EQUAL(cts.predicted(),
v);
323 ts.predictedCovariance() = cov;
324 BOOST_CHECK_EQUAL(cts.predictedCovariance(), cov);
328 BOOST_CHECK_EQUAL(cts.filtered(),
v);
330 ts.filteredCovariance() = cov;
331 BOOST_CHECK_EQUAL(cts.filteredCovariance(), cov);
335 BOOST_CHECK_EQUAL(cts.smoothed(),
v);
337 ts.smoothedCovariance() = cov;
338 BOOST_CHECK_EQUAL(cts.smoothedCovariance(), cov);
341 auto fm2 = std::make_unique<FittableMeasurement<SourceLink>>(*fm);
343 ts.uncalibrated() = sl2;
344 BOOST_CHECK_EQUAL(cts.uncalibrated(), sl2);
345 BOOST_CHECK_NE(cts.uncalibrated(),
SourceLink{fm.get()});
348 newMeasCov.setRandom();
349 ts.calibratedCovariance() = newMeasCov;
350 BOOST_CHECK_EQUAL(cts.calibratedCovariance(), newMeasCov);
353 newMeasPar.setRandom();
354 ts.calibrated() = newMeasPar;
355 BOOST_CHECK_EQUAL(cts.calibrated(), newMeasPar);
357 size_t measdim = ts.effectiveCalibrated().rows();
361 ts.effectiveCalibratedCovariance() = eff;
362 BOOST_CHECK_EQUAL(cts.effectiveCalibratedCovariance(), eff);
363 newMeasCov.topLeftCorner(eff.rows(), eff.rows()) = eff;
364 BOOST_CHECK_EQUAL(cts.calibratedCovariance(), newMeasCov);
369 BOOST_CHECK_EQUAL(cts.jacobian(), jac);
372 BOOST_CHECK_EQUAL(cts.chi2(), 98
u);
374 ts.pathLength() = 66;
375 BOOST_CHECK_EQUAL(cts.pathLength(), 66
u);
389 BOOST_CHECK_EQUAL(ts.calibratedSize(), meas.size());
390 BOOST_CHECK_EQUAL(ts.effectiveCalibrated(), meas.parameters());
391 BOOST_CHECK_EQUAL(ts.effectiveCalibratedCovariance(), meas.covariance());
392 BOOST_CHECK_EQUAL(ts.effectiveProjector(), meas.projector());
400 meas.referenceSurface().getSharedPtr(), {}, mCov, mPar[0], mPar[1]};
402 ts.setCalibrated(
m2);
404 BOOST_CHECK_EQUAL(ts.calibratedSize(), 2
u);
405 BOOST_CHECK_EQUAL(ts.effectiveCalibrated(), mPar);
406 BOOST_CHECK_EQUAL(ts.effectiveCalibratedCovariance(), mCov);
407 BOOST_CHECK_EQUAL(ts.effectiveProjector(),
m2.projector());
412 mParFull.head(2) = mPar;
413 BOOST_CHECK_EQUAL(ts.calibrated(), mParFull);
417 mCovFull.topLeftCorner(2, 2) = mCov;
418 BOOST_CHECK_EQUAL(ts.calibratedCovariance(), mCovFull);
422 projFull.topLeftCorner(
m2.size(), maxmeasdim) =
m2.projector();
423 BOOST_CHECK_EQUAL(ts.projector(), projFull);
438 BOOST_CHECK(tsProxy.hasPredicted());
439 BOOST_CHECK_EQUAL(ts.parameter.predicted->parameters(), tsProxy.predicted());
440 BOOST_CHECK_EQUAL(*ts.parameter.predicted->covariance(),
441 tsProxy.predictedCovariance());
443 BOOST_CHECK(tsProxy.hasFiltered());
444 BOOST_CHECK_EQUAL(ts.parameter.filtered->parameters(), tsProxy.filtered());
445 BOOST_CHECK_EQUAL(*ts.parameter.filtered->covariance(),
446 tsProxy.filteredCovariance());
448 BOOST_CHECK(tsProxy.hasSmoothed());
449 BOOST_CHECK_EQUAL(ts.parameter.smoothed->parameters(), tsProxy.smoothed());
450 BOOST_CHECK_EQUAL(*ts.parameter.smoothed->covariance(),
451 tsProxy.smoothedCovariance());
453 BOOST_CHECK_EQUAL(&tsProxy.referenceSurface(), &ts.referenceSurface());
455 BOOST_CHECK(tsProxy.hasJacobian());
456 BOOST_CHECK_EQUAL(tsProxy.jacobian(), *ts.parameter.jacobian);
458 BOOST_CHECK(tsProxy.hasProjector());
460 [&](
const auto& meas) {
461 BOOST_CHECK_EQUAL(tsProxy.effectiveProjector(), meas.projector());
463 BOOST_CHECK(tsProxy.hasCalibrated());
464 BOOST_CHECK_EQUAL(meas.parameters(), tsProxy.effectiveCalibrated());
467 mParFull.head(meas.size()) = meas.parameters();
468 BOOST_CHECK_EQUAL(mParFull, tsProxy.calibrated());
470 BOOST_CHECK_EQUAL(meas.covariance(),
471 tsProxy.effectiveCalibratedCovariance());
474 mCovFull.topLeftCorner(meas.size(), meas.size()) = meas.covariance();
475 BOOST_CHECK_EQUAL(mCovFull, tsProxy.calibratedCovariance());
478 BOOST_CHECK_EQUAL(meas.sourceLink(), tsProxy.calibratedSourceLink());
481 BOOST_CHECK(tsProxy.hasUncalibrated());
482 BOOST_CHECK_EQUAL(meas.sourceLink(), tsProxy.uncalibrated());
487 fullProj.topLeftCorner(
490 BOOST_CHECK_EQUAL(tsProxy.projector(), fullProj);
494 BOOST_CHECK_EQUAL(tsProxy.effectiveProjector(), meas.projector());
496 *ts.measurement.calibrated);