9 #include <boost/test/unit_test.hpp>
39 using namespace Acts::UnitLiterals;
69 const std::vector<TestSourceLink>& sourceLinks) {
70 std::vector<Acts::SourceLink> result;
72 std::back_inserter(result),
80 throw std::invalid_argument(
"At least 1 surfaces needs to be created.");
86 std::vector<CuboidVolumeBuilder::SurfaceConfig> surfaceConfig;
87 for (
unsigned int i = 1;
i <= nSurfaces;
i++) {
93 double rotationAngle = M_PI * 0.5;
94 Vector3 xPos(cos(rotationAngle), 0., sin(rotationAngle));
96 Vector3 zPos(-sin(rotationAngle), 0., cos(rotationAngle));
103 std::make_shared<const RectangleBounds>(
RectangleBounds(0.5_m, 0.5_m));
107 cfg.
surMat = std::make_shared<HomogeneousSurfaceMaterial>(matProp);
114 const std::shared_ptr<const RectangleBounds>&
bounds,
118 surfaceConfig.push_back(cfg);
122 std::vector<CuboidVolumeBuilder::LayerConfig> layerConfig;
123 for (
auto& sCfg : surfaceConfig) {
130 layerConfig.push_back(cfg);
135 volumeConfig.
length = {(nSurfaces + 1) * 1_m, 1_m, 1_m};
137 volumeConfig.
layerCfg = layerConfig;
138 volumeConfig.
name =
"Test volume";
142 config.
length = {(nSurfaces + 1) * 1_m, 1_m, 1_m};
151 [=](
const auto& context,
const auto& inner,
const auto&) {
157 std::unique_ptr<const TrackingGeometry>
detector =
167 BOOST_AUTO_TEST_SUITE(Gx2fTest)
179 std::default_random_engine
rng(42);
182 const size_t nSurfaces = 5;
186 auto startParametersFit =
makeParameters(7_mm, 11_mm, 15_mm, 42_ns, 10_degree,
187 80_degree, 1_GeV, 1_e);
194 using SimPropagator =
198 simPropagator, geoCtx, magCtx, parametersMeasurements, resolutions, rng);
203 Gx2Fitter fitter(simPropagator,
gx2fLogger->clone());
205 const Surface* rSurface = ¶metersMeasurements.referenceSurface();
209 .connect<&testSourceLinkCalibrator<VectorMultiTrajectory>>();
212 .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor);
222 auto res = fitter.fit(sourceLinks.begin(), sourceLinks.end(),
223 startParametersFit, gx2fOptions,
tracks);
225 BOOST_REQUIRE(res.ok());
229 BOOST_CHECK(track.hasReferenceSurface());
230 BOOST_CHECK_EQUAL(track.nMeasurements(), 0
u);
231 BOOST_CHECK_EQUAL(track.nHoles(), 0
u);
232 BOOST_CHECK_EQUAL(track.parameters(), startParametersFit.parameters());
233 BOOST_CHECK_EQUAL(track.covariance(), BoundMatrix::Identity());
240 ACTS_INFO(
"*** Test: Fit5Iterations -- Start");
246 const size_t nSurfaces = 5;
252 auto startParametersFit =
makeParameters(7_mm, 11_mm, 15_mm, 42_ns, 10_degree,
253 80_degree, 1_GeV, 1_e);
259 std::default_random_engine
rng(42);
266 using SimPropagator =
270 simPropagator, geoCtx, magCtx, parametersMeasurements, resolutions, rng);
272 ACTS_VERBOSE(
"sourceLinks.size() = " << sourceLinks.size());
274 BOOST_REQUIRE_EQUAL(sourceLinks.size(), nSurfaces);
277 ACTS_VERBOSE(
"startParameter unsmeared:\n" << parametersMeasurements);
278 ACTS_VERBOSE(
"startParameter fit:\n" << startParametersFit);
280 const Surface* rSurface = ¶metersMeasurements.referenceSurface();
283 const auto recoPropagator =
284 makeConstantFieldPropagator<RecoStepper>(detector.
geometry, 0_T);
286 using RecoPropagator = decltype(recoPropagator);
289 Gx2Fitter fitter(recoPropagator,
gx2fLogger->clone());
292 extensions.calibrator
293 .connect<&testSourceLinkCalibrator<VectorMultiTrajectory>>();
295 extensions.surfaceAccessor
296 .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor);
309 auto res = fitter.fit(sourceLinks.begin(), sourceLinks.end(),
310 startParametersFit, gx2fOptions,
tracks);
312 BOOST_REQUIRE(res.ok());
315 BOOST_CHECK_EQUAL(track.tipIndex(), nSurfaces - 1);
316 BOOST_CHECK(track.hasReferenceSurface());
317 BOOST_CHECK_EQUAL(track.nMeasurements(), nSurfaces);
318 BOOST_CHECK_EQUAL(track.nHoles(), 0
u);
321 BOOST_CHECK_CLOSE(track.parameters()[
eBoundLoc0], -11., 7e0);
322 BOOST_CHECK_CLOSE(track.parameters()[
eBoundLoc1], -15., 6e0);
323 BOOST_CHECK_CLOSE(track.parameters()[
eBoundPhi], 1
e-5, 1e3);
324 BOOST_CHECK_CLOSE(track.parameters()[
eBoundTheta], M_PI / 2, 1
e-3);
326 BOOST_CHECK_CLOSE(track.parameters()[
eBoundTime], 12591.2832360000, 1
e-6);
327 BOOST_CHECK_CLOSE(track.covariance().determinant(), 1
e-27, 4e0);
329 ACTS_INFO(
"*** Test: Fit5Iterations -- Finish");
334 ACTS_INFO(
"*** Test: MixedDetector -- Start");
340 const size_t nSurfaces = 7;
346 auto startParametersFit =
makeParameters(7_mm, 11_mm, 15_mm, 42_ns, 10_degree,
347 80_degree, 1_GeV, 1_e);
353 std::default_random_engine
rng(42);
369 using SimPropagator =
373 simPropagator, geoCtx, magCtx, parametersMeasurements, resolutions, rng);
375 ACTS_VERBOSE(
"sourceLinks.size() = " << sourceLinks.size());
377 BOOST_REQUIRE_EQUAL(sourceLinks.size(), nSurfaces);
380 ACTS_VERBOSE(
"startParameter unsmeared:\n" << parametersMeasurements);
381 ACTS_VERBOSE(
"startParameter fit:\n" << startParametersFit);
383 const Surface* rSurface = ¶metersMeasurements.referenceSurface();
386 const auto recoPropagator =
387 makeConstantFieldPropagator<RecoStepper>(detector.
geometry, 0_T);
389 using RecoPropagator = decltype(recoPropagator);
392 Gx2Fitter fitter(recoPropagator,
gx2fLogger->clone());
395 extensions.calibrator
396 .connect<&testSourceLinkCalibrator<VectorMultiTrajectory>>();
398 extensions.surfaceAccessor
399 .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor);
412 auto res = fitter.fit(sourceLinks.begin(), sourceLinks.end(),
413 startParametersFit, gx2fOptions,
tracks);
415 BOOST_REQUIRE(res.ok());
418 BOOST_CHECK_EQUAL(track.tipIndex(), nSurfaces - 1);
419 BOOST_CHECK(track.hasReferenceSurface());
420 BOOST_CHECK_EQUAL(track.nMeasurements(), nSurfaces);
421 BOOST_CHECK_EQUAL(track.nHoles(), 0
u);
424 BOOST_CHECK_CLOSE(track.parameters()[
eBoundLoc0], -11., 7e0);
425 BOOST_CHECK_CLOSE(track.parameters()[
eBoundLoc1], -15., 6e0);
426 BOOST_CHECK_CLOSE(track.parameters()[
eBoundPhi], 1
e-5, 1e3);
427 BOOST_CHECK_CLOSE(track.parameters()[
eBoundTheta], M_PI / 2, 1
e-3);
429 BOOST_CHECK_CLOSE(track.parameters()[
eBoundTime], 12591.2832360000, 1
e-6);
430 BOOST_CHECK_CLOSE(track.covariance().determinant(), 2
e-28, 1e0);
432 ACTS_INFO(
"*** Test: MixedDetector -- Finish");
435 BOOST_AUTO_TEST_SUITE_END()