9 #include <boost/test/unit_test.hpp>
51 using namespace ActsAlignment;
52 using namespace Acts::Test;
53 using namespace Acts::UnitLiterals;
63 using KalmanFitterType =
66 KalmanUpdater kfUpdater;
67 KalmanSmoother kfSmoother;
74 std::normal_distribution<double> normalDist(0., 1.);
75 std::default_random_engine
rng(42);
80 .connect<&testSourceLinkCalibrator<VectorMultiTrajectory>>();
91 struct TelescopeDetector {
95 TelescopeDetector(std::reference_wrapper<const GeometryContext>
gctx)
103 rBounds = std::make_shared<const RectangleBounds>(0.1_m, 0.1_m);
108 surfaceMaterial = std::make_shared<HomogeneousSurfaceMaterial>(matProp);
114 std::shared_ptr<const TrackingGeometry> operator()() {
115 using namespace UnitLiterals;
117 unsigned int nLayers = 6;
118 std::vector<ActsScalar>
positions = {-500_mm, -300_mm, -100_mm,
119 100_mm, 300_mm, 500_mm};
122 std::vector<LayerPtr> layers(nLayers);
123 for (
unsigned int i = 0;
i < nLayers; ++
i) {
127 auto detElement = std::make_shared<DetectorElementStub>(
128 trafo,
rBounds, 1._um, surfaceMaterial);
130 auto surface = detElement->surface().getSharedPtr();
132 detectorStore.push_back(
std::move(detElement));
133 std::unique_ptr<SurfaceArray> surArray(
new SurfaceArray(surface));
138 auto mutableSurface =
const_cast<Surface*
>(surface.get());
145 VolumeBoundsPtr boundsVol = std::make_shared<const CuboidVolumeBounds>(
146 rBounds->halfLengthX() + 10._mm, rBounds->halfLengthY() + 10._mm,
153 for (
unsigned int i = 0;
i < nLayers;
i++) {
154 layVec.push_back(layers[
i]);
158 std::unique_ptr<const LayerArray> layArr(layArrCreator.layerArray(
165 nullptr, {},
"Telescope");
167 return std::make_shared<const TrackingGeometry>(trackVolume);
171 std::shared_ptr<const RectangleBounds> rBounds =
nullptr;
172 std::shared_ptr<const ISurfaceMaterial> surfaceMaterial =
nullptr;
174 std::vector<std::shared_ptr<DetectorElementStub>> detectorStore;
176 std::reference_wrapper<const GeometryContext>
geoContext;
181 std::shared_ptr<const TrackingGeometry> geo) {
183 cfg.resolvePassive =
false;
184 cfg.resolveMaterial =
true;
185 cfg.resolveSensitive =
true;
193 std::shared_ptr<const TrackingGeometry> geo,
double bz,
194 std::unique_ptr<const Logger>
logger) {
196 cfg.resolvePassive =
false;
197 cfg.resolveMaterial =
true;
198 cfg.resolveSensitive =
true;
200 auto field = std::make_shared<ConstantBField>(
Vector3(0.0, 0.0, bz));
239 struct KalmanFitterInputTrajectory {
241 std::vector<TestSourceLink> sourcelinks;
243 std::optional<CurvilinearTrackParameters> startParameters;
249 std::vector<KalmanFitterInputTrajectory> createTrajectories(
250 std::shared_ptr<const TrackingGeometry> geo,
size_t nTrajectories) {
254 std::vector<KalmanFitterInputTrajectory> trajectories;
255 trajectories.reserve(nTrajectories);
257 for (
unsigned int iTrack = 0; iTrack < nTrajectories; iTrack++) {
264 KalmanFitterInputTrajectory traj;
265 traj.startParameters =
start;
266 traj.sourcelinks = measurements.sourceLinks;
284 const auto kfZeroPropagator =
286 auto kfZero = KalmanFitterType(kfZeroPropagator);
293 const auto& trajectories = createTrajectories(
geometry, 10);
300 .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor);
311 kfOptions, voidAlignUpdater);
315 unsigned int iSurface = 0;
316 std::unordered_map<const Surface*, size_t> idxedAlignSurfaces;
318 for (
auto& det : detector.detectorStore) {
319 const auto& surface = det->surface();
320 if (surface.geometryId().layer() != 8) {
322 idxedAlignSurfaces.emplace(&surface, iSurface);
328 const auto& inputTraj = trajectories.front();
329 kfOptions.
referenceSurface = &(*inputTraj.startParameters).referenceSurface();
331 auto evaluateRes = alignZero.evaluateTrackAlignmentState(
332 kfOptions.
geoContext, inputTraj.sourcelinks, *inputTraj.startParameters,
333 kfOptions, idxedAlignSurfaces, AlignmentMask::All);
334 BOOST_CHECK(evaluateRes.ok());
336 const auto& alignState = evaluateRes.value();
340 BOOST_CHECK_EQUAL(alignState.measurementDim, 12);
341 BOOST_CHECK_EQUAL(alignState.trackParametersDim, 36);
343 BOOST_CHECK_EQUAL(alignState.alignmentDof, 30);
344 BOOST_CHECK_EQUAL(alignState.alignedSurfaces.size(), 5);
346 BOOST_CHECK_EQUAL(alignState.measurementCovariance.rows(), 12);
348 alignState.measurementCovariance.block<2, 2>(2, 2);
350 cov2D << 30_um * 30_um, 0, 0, 50_um * 50_um;
354 BOOST_CHECK_EQUAL(alignState.trackParametersCovariance.rows(), 36);
356 BOOST_CHECK_EQUAL(alignState.projectionMatrix.rows(), 12);
357 BOOST_CHECK_EQUAL(alignState.projectionMatrix.cols(), 36);
362 BOOST_CHECK_EQUAL(alignState.residual.size(), 12);
364 BOOST_CHECK_EQUAL(alignState.residualCovariance.rows(), 12);
366 BOOST_CHECK_EQUAL(alignState.alignmentToResidualDerivative.rows(), 12);
367 BOOST_CHECK_EQUAL(alignState.alignmentToResidualDerivative.cols(), 30);
369 BOOST_CHECK_EQUAL(alignState.alignmentToChi2Derivative.size(), 30);
370 BOOST_CHECK_EQUAL(alignState.alignmentToChi2SecondDerivative.rows(), 30);
373 std::vector<std::vector<TestSourceLink>> trajCollection;
374 trajCollection.reserve(10);
375 std::vector<CurvilinearTrackParameters> sParametersCollection;
376 sParametersCollection.reserve(10);
377 for (
const auto& traj : trajectories) {
378 trajCollection.push_back(traj.sourcelinks);
379 sParametersCollection.push_back(*traj.startParameters);
382 alignZero.align(trajCollection, sParametersCollection, alignOptions);