Skip to content

Extend end trajectory piece to the edge of the outermost domain - #232

Merged
brownd1978 merged 1 commit into
KFTrack:mainfrom
RobMina:extrapolate-end-domain
Oct 30, 2026
Merged

brownd1978 merged 1 commit into
KFTrack:mainfrom
RobMina:extrapolate-end-domain

Conversation

@RobMina

@RobMina RobMina commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Companion to Mu2e/Offline#2084

Problem

After a fit, the trajectory ends at its last active effect, but the outermost field domain usually extends
farther, because domains are built over the detector range including inactive hits. With field correction on,
Track::extrapolate starts the domain walk at the outermost domain edge (domains_.crbegin()->end()). The first
DomainWall stretches the old end piece across the gap and appends a new piece beyond it.

An extrapolation predicate that searches the end piece never sees the gap: before the first step the end piece
stops short of it, and afterwards the gap is on an interior piece. A material surface there is missed, and even
if found, Track::extrapolate(EXINGPTR) cannot add it, since its time is not in the end piece. With field
correction off the end piece is extended from its own end, so there is no gap.

In 10,000 Mu2e nightly off-spill cosmic events (CentralHelix, field correction on), the gap is positive at the
start of 1,408 forward and 9,350 backward extrapolations; 565 and 555 of them exceed 1 ns, enough to skip a
detector-solenoid shell (measured with a temporary print, not part of this PR).

Change

A private Track::coverEndDomain(TimeDir), called at the start of the field-corrected branch of
Track::extrapolate: if the end piece stops short of the outermost domain edge, its time range is extended to
that edge. The first DomainWall::extrapolate already samples the same piece at the edge, so no trajectory
parameter, nominal field or domain changes; only the predicate now searches the gap, and a crossing there is
inside the end piece, so its material can be added. No-op without domains or when the trajectory already reaches
the edge. The field-correction-off path is unchanged. Header-only (18 lines).

Validation

Mu2e Offline 473a2c54, KinKal v3.9.0 with and without this change, same 10,000 events. The same 1,175 tracks
(matched by raw hits) are fitted with identical fit status, chi-square, probability, hit counts and hit times.

Detector-solenoid shells per extrapolated leg, predicted from the leg's measured position and momentum (p > 500
MeV/c, shells more than 100 mm from an end), for legs whose identity-matched truth muon traverses the barrel:

v3.9.0 this change
legs 452 461
every expected shell found 320 336
an inner shell missing, outer ones found 12 1
outer shells missing 103 107

Over all scored legs, inner-shell misses fall from 65 to 6. The remaining outer-shell misses come from a separate
Mu2e search defect, addressed in Mu2e/Offline (companion PR); this change does not claim complete shell coverage.
The Mu2e/Offline#2076 LoopHelix event runs successfully with the change.

Together with the companion Offline PR, 5,000 conversion-electron events with 1BB pileup (four LoopHelix fits) run
without errors, and every fit summary matches Offline main, apart from 24 muon-hypothesis fits that the Offline PR's
range-out makes usable. On all 8 traced tracks where Offline main misses the TS downstream absorber plane, the cause
is this gap: the last domain step past the plane is not on the saved trajectory.

🤖 Generated with Claude Code

@oksuzian oksuzian left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Review Summary — #232

Reviewed at head 435af80df31d9b9896578a46b00f51f3a6f2b102. First pass.

Decision

  • 🟢 Approve. The change is small and private. It only extends the end piece's time range to a domain edge that the first DomainWall already samples. In Mu2e it removes a real failure, and it changes nothing where it is not needed.

Scope understood

  • Track::coverEndDomain(TimeDir) is new and private (Fit/Track.hh:166). It is called at the start of the field-corrected branch of Track::extrapolate. If the end piece stops short of the outermost domain edge, it extends the piece's range to that edge. It is header-only.

Findings

  1. ⚪ [S3] KinKal's own tests do not cover this
    • No test under Tests/ calls Track::extrapolate, so the green CI on this PR does not reach the new code. All the evidence is from Mu2e. A unit test would protect the change: fit with field correction, a last domain that extends past the last hit, then extrapolate and check that the end piece reaches the domain edge.

Checked, no action needed

  • 🟢 No effect where it is not needed. I built Mu2e/Offline#2084 (e27cd7fa) twice, with release KinKal v3.9.0 and with this PR's Fit/Track.hh in place of the release header. I confirmed that the module compiles against the PR's header.
    • On all 16,508 events of the nightly reco_03 job (on-spill CE reconstruction, four LoopHelix fits with field correction on), every KalSeed printout is identical with and without this change.
    • On 9,314 off-spill cosmics with the production KKCHmu setting (field correction off), they are also identical.
  • 🟢 It fixes the failure it targets. On the same cosmics with KKCHmu field correction on (Validation/offSpill.fcl), without this change 367 of 4,876 KKCHmu tracks end their extrapolation with "material crossing ( 85: DS_CryoInner ):0 at 9996.62 is not owned by the end piece Range [9995.52,9996.52]" (event 1430:0:310). With it, none do, and each DS shell gains 360 to 369 crossings.
  • 🟢 It works with KinKal#231.
    • The two PRs touch different files, and git merge of #231 into this head is clean.
    • Offline#2084 builds against the merged headers (Fit/Track.hh, General/TimeRange.hh, Trajectory/PiecewiseTrajectory.hh, each identical to the git merge).
    • The 16,508-event reco_03 job runs with exit code 0. Its output matches this PR alone except for one fit that is already unusable (1430:737:2858 KKDmu, whose t0 changes).
  • 🟢 Shared pieces are safe. The end piece is shared through shared_ptr with crossings that reference it, but the range only grows and no parameters change, so those references stay valid. It is a no-op without domains, and the field-correction-off path is untouched.

Validation check

  • Build/tests run: two Offline#2084 muse builds (p109), with this header overlaid on the release headers, alone and together with #231. I ran the full reco_03 job and the off-spill jobs listed above. I did not run KinKal's own test suite locally; CI ran it at this head (4 jobs, all pass).
  • Not run: Offline main (without #2084) with this change. The description's numbers for that case are taken as reported.

Residual risk

  • A Mu2e build needs a KinKal tag with this change and a new envset. Mu2e/Offline#2084 depends on it for its field-corrected KKCHmu validation.

Author follow-ups

  1. Optional: add a KinKal unit test for the end-domain gap.

@brownd1978 brownd1978 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes logical sense. Thanks Rob and Claude!

@brownd1978
brownd1978 merged commit 095b69a into KFTrack:main Oct 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants