@@ -420,8 +420,18 @@ BOOST_AUTO_TEST_CASE(ASlicePlanHoldsTheSlicesBoundsAndGate)
420420 const auto plan = tracker->planTimeframe (*fixture.frame , {}, 3 , 0 .);
421421 const auto & frame = *fixture.frame ;
422422 BOOST_TEST (plan.slices .size () == static_cast <std::size_t >((fixture.geometry .blockCount () + 2 ) / 3 ));
423- // The toys' blocks start at 0 and are whole picoseconds.
424- const auto reach = sliceReach (frameBounds (frame), fixture.geometry ).gatePS ();
423+ // The toys' blocks start at 0 and are whole picoseconds. The gate is the
424+ // iterations' chains' (`chainReach`): the toy's rows are boxes of one width,
425+ // not frames, so a link reaches that width and so does a triplet's two, and
426+ // along the eight layers a chain drifts 4 widths each way -- 7 pairwise.
427+ const std::vector<IterationParameters<Det>> parameters{tracker->iteration (0U ), tracker->iteration (1U )};
428+ const auto chains = chainReach (frameBounds (frame), fixture.geometry , takenLinks<Det>(iterations ().front ()));
429+ BOOST_TEST (seedingReach (frameBounds (frame), fixture.geometry , std::span<const IterationParameters<Det>>{parameters}).gatePS == chains.gatePS ());
430+ const std::int64_t boxPS = test::kToyBoxWidthPS ;
431+ BOOST_TEST (chains.forwardPS == 4 * boxPS);
432+ BOOST_TEST (chains.backwardPS == 4 * boxPS);
433+ BOOST_TEST (sliceReach (frameBounds (frame), fixture.geometry ).forwardPS == 7 * boxPS);
434+ const auto reach = chains.gatePS ();
425435 const auto width = fixture.geometry .blockWidth ();
426436 BOOST_REQUIRE (fixture.geometry .partsPerPS () == 1 );
427437 for (const auto & slicePlan : plan.slices ) {
@@ -714,9 +724,9 @@ struct FramedRun {
714724 std::int64_t haloPS = 0 ;
715725};
716726
717- FramedRun trackFramed (const Fixture& fixture, std::int32_t widthBlocks)
727+ FramedRun trackFramed (const Fixture& fixture, std::int32_t widthBlocks, const std::vector<IterationSettings>& settings = iterations() )
718728{
719- auto tracker = makeTracker (iterations () , false );
729+ auto tracker = makeTracker (settings , false );
720730 const auto result = tracker->run (*fixture.frame , tracker->planTimeframe (*fixture.frame , {}, widthBlocks, 0 .));
721731 BOOST_REQUIRE (result.status == StageStatus::kComplete );
722732 FramedRun run{.tracks = found (result), .times = std::vector<TimeEstPS>(kCrossingBC .size ()), .haloPS = result.iterations .front ().haloPS };
@@ -776,6 +786,103 @@ BOOST_AUTO_TEST_CASE(TwoFrameLengthsSliceWithOneOuterFrameOfHalo)
776786 }
777787}
778788
789+ // / The two-length toy with one outer layer of narrow boxes, as a TOF layer
790+ // / between two of the same frames: its grid frames 1 BC, each hit's box the
791+ // / BC before its time, [t - 1 BC, t], at the hit's picosecond, not a frame.
792+ // / The crossings at 81, 162, 243, 324 and 648 BC -- outer frames' starts,
793+ // / blocks' at 162, 324, 648 -- give narrow boxes straddling an outer frame's
794+ // / edge, and a block's. A triplet's third box overlaps its first, so through
795+ // / the narrow layer the two outer layers beside it stay in one frame.
796+ // /
797+ // / On the outer layers alone (3-7, every frame 81 BC, as ALICE 3's ML 3-7
798+ // / pass with the iTOF): pairwise every link into the narrow layer reaches the
799+ // / long frame forward and the narrow box backward, every link out of it the
800+ // / reverse, `R+ = R- = long + narrow`. The chains: into the narrow layer the
801+ // / long frame forward and its box backward; after it, the next layer back in
802+ // / the frame before it, 0. Out of the narrow layer a chain starting on it
803+ // / reaches the long frame backward -- if a link goes on from its target
804+ // / (narrow layer 5: 5 -> 6 -> 7), not for the last link alone (6 -> 7,
805+ // / a tracklet no triplet takes). And on every layer, both iterations: less
806+ // / than pairwise. Each way the slices give the one-slice tracks.
807+ BOOST_AUTO_TEST_CASE (ANarrowBoxLayerBetweenLayersOfTheSameFrames)
808+ {
809+ constexpr std::array<std::int64_t , 12 > kCrossings {5 , 81 , 100 , 162 , 170 , 243 , 324 , 400 , 480 , 520 , 648 , 700 };
810+ const auto longPS = psOfBC (kOuterFrameBC );
811+ const auto narrowPS = psOfBC (1 );
812+ auto outer = iterations ();
813+ for (auto & iteration : outer) {
814+ iteration.layerMask = 0xF8U ;
815+ }
816+ for (const LayerID narrow : {LayerID{6 }, LayerID{5 }}) {
817+ BOOST_TEST_CONTEXT (" narrow layer " << int {narrow})
818+ {
819+ auto params = twoLengthGrid ();
820+ params.frames [narrow] = {.lengthBC = 1 , .firstStartBC = 0 };
821+ const auto boxOf = [&](const Hit& hit) {
822+ if (hit.point .layer != narrow) {
823+ return frameOf (hit, 0 );
824+ }
825+ const auto t = std::llround (hit.timeNS * 1000 .);
826+ return TimeEstPS{.start = static_cast <std::uint32_t >(t - narrowPS), .width = static_cast <std::uint32_t >(narrowPS)};
827+ };
828+ std::vector<Hit> hits;
829+ for (std::size_t track = 0 ; track < kCrossings .size (); ++track) {
830+ const auto k = static_cast <double >(track);
831+ const double pt = stiff (track) ? 2 . + (0.2 * static_cast <double >(track % 5U )) : 0.4 + (0.06 * static_cast <double >(track % 5U ));
832+ const auto one = sensorHelixHits (std::fmod (0.3 + (0.9 * k), 2 * std::numbers::pi_v<double >), 0.03 * std::cos (1.3 * k), pt, (static_cast <double >(kCrossings [track]) * kBunchNS ) + 5 .);
833+ BOOST_REQUIRE (one.size () == kLayers );
834+ hits.insert (hits.end (), one.begin (), one.end ());
835+ }
836+ const Fixture fixture{hits, kFramedDurationNS , params, boxOf};
837+ const auto bounds = frameBounds (*fixture.frame );
838+ BOOST_TEST (!bounds.rowsAreFrames [narrow]);
839+ BOOST_TEST (bounds.widthPS [narrow] == narrowPS);
840+ const auto & geometry = fixture.geometry ;
841+ std::size_t acrossFrame = 0 , acrossBlock = 0 ;
842+ for (const auto & hit : hits) {
843+ if (hit.point .layer == narrow) {
844+ const auto box = boxOf (hit);
845+ // The BC a picosecond lies in, rounded down (bcOfPS rounds up: it inverts psOfBC).
846+ const auto bcAt = [](std::int64_t ps) { return (ps * kPSPerBCDenominator ) / kPSPerBCNumerator ; };
847+ acrossFrame += bcAt (box.start ) / kOuterFrameBC != bcAt (box.start + box.width - 1 ) / kOuterFrameBC ;
848+ acrossBlock += geometry.blockOfPS (box.start ) != geometry.blockOfPS (box.start + box.width - 1 );
849+ }
850+ }
851+ BOOST_TEST (acrossFrame >= 4U );
852+ BOOST_TEST (acrossBlock >= 2U );
853+
854+ const auto outerTracker = makeTracker (outer, false );
855+ const auto taken = takenLinks<Det>(outer.front ());
856+ for (std::size_t link = 0 ; link < nLinks<Det>; ++link) {
857+ BOOST_TEST (taken[link] == (Det::layerLinks[link].from >= 3 ));
858+ }
859+ const auto pairwise = sliceReach (bounds, geometry, &taken);
860+ BOOST_TEST (pairwise.forwardPS == longPS + narrowPS);
861+ BOOST_TEST (pairwise.backwardPS == longPS + narrowPS);
862+ const auto chains = chainReach (bounds, geometry, taken);
863+ BOOST_TEST (chains.forwardPS == longPS);
864+ BOOST_TEST (chains.backwardPS == (narrow == 6 ? narrowPS : longPS));
865+ BOOST_TEST (outerTracker->planTimeframe (*fixture.frame , {}, 1 , 0 ).haloPS == chains.haloPS ());
866+ BOOST_TEST (chains.haloPS () < pairwise.haloPS ());
867+ const auto every = makeTracker (iterations (), false )->planTimeframe (*fixture.frame , {}, 1 , 0 ).haloPS ;
868+ BOOST_TEST (every < sliceReach (bounds, geometry).haloPS ());
869+
870+ const auto everyLayer = iterations ();
871+ for (const auto * settings : std::array<const std::vector<IterationSettings>*, 2 >{&outer, &everyLayer}) {
872+ const auto & chosen = *settings;
873+ BOOST_TEST_CONTEXT ((settings == &outer ? " layers 3-7" : " every layer" ))
874+ {
875+ const auto whole = trackFramed (fixture, geometry.blockCount (), chosen);
876+ BOOST_TEST (whole.tracks .size () == kCrossings .size ());
877+ for (const std::int32_t width : {1 , 2 , 3 }) {
878+ BOOST_TEST_CONTEXT (" slices of " << width << " blocks" ) { BOOST_TEST ((trackFramed (fixture, width, chosen).tracks == whole.tracks )); }
879+ }
880+ }
881+ }
882+ }
883+ }
884+ }
885+
779886// / The same toy with its boxes widened by a margin while the grid still
780887// / declares the frames -- as a dump keeps the boxes its producer widened,
781888// / whatever margin the tracking is configured with: the rows are not their
0 commit comments