Skip to content

Store the KalSeed fit-flag bitmask in TrkInfo (trk.fitflag) - #436

Merged
sophiemiddleton merged 1 commit into
Mu2e:mainfrom
RobMina:kkextrap-sweep-base
Oct 30, 2026
Merged

sophiemiddleton merged 1 commit into
Mu2e:mainfrom
RobMina:kkextrap-sweep-base

Conversation

@RobMina

@RobMina RobMina commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Motivation

TrkInfo reduces the KalSeed's TrkFitFlag to a few derived fields (status, goodfit, seedalg, fitalg), so
any other flag bit is invisible in the ntuple. The KKExtrap extrapolation-sweep PR (Mu2e/Offline, companion) adds two
per-track bits that analyses need to select on: ExtrapFailed ("ExtrapolationFailed", an extrapolation direction
ended early on a problem with this track) and RangedOut (the forwards extrapolation ended where the particle stops
in material). Storing the whole mask covers those and any future bit without another ntuple change.

Change

  • TrkInfo gains unsigned fitflag, the KalSeed's TrkFitFlag bitmask (bit numbers in
    Offline/RecoDataProducts/inc/TrkFitFlag.hh), filled in InfoStructHelper::fillTrkInfo. BitMap exposes its value
    only as a hex string, so the fill parses kseed.status().hex().
  • No other field changes. Select on a bit with, for example, (trk.fitflag >> 29) & 1 for RangedOut.

The field is independent of the Offline PR: with Offline main it carries the existing bits.

Validation

10,000 nightly off-spill cosmic events, CentralHelix fit, with the Offline extrapolation-sweep PR; field correction
on and off:

Check Field correction on Off
Tracks 1,175 1,367
KKCentralHelix bit (22) set 1,175 1,367
trk.status equal to the value derived from bits 12 (kalmanConverged) and 5 (kalmanOK) 1,175 1,367
BFCorr bit (14) set 1,175 0
RangedOut bit (29) set, vs KalSeed printout (printKalSeed.fcl) 125 (125) 93 (93)
ExtrapolationFailed bit (28) set 0 0

🤖 Generated with Claude Code

@oksuzian oksuzian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PR Review Summary — #436

Reviewed at head 5f82c8c27ce9342770f66832f563c522a25f0d66. First pass.

Decision

  • 🟢 Approve. One field, filled correctly, documented where branches.md sends readers.

Scope understood

  • TrkInfo gains unsigned fitflag, the KalSeed's whole TrkFitFlag mask, parsed from kseed.status().hex() in InfoStructHelper::fillTrkInfo. Nothing else changes.

Findings

  1. ⚪ [S3] The nightly validation does not look at the new field
    • validation/create_val_file_rooutil.C fills one histogram per trk field (h_trk_goodfit, h_trk_seedalg and so on), but none for fitflag. A bit-occupancy histogram would let the nightly comparison see a change in the RangedOut or ExtrapolationFailed rate once Mu2e/Offline#2084 is in.

Checked, no action needed

  • 🟢 The parse is exact for every mask. toHex uses std::showbase, so it writes 0 for an empty mask and 0x… otherwise, and std::stoul(..., 16) accepts both. TrkFitFlag::mask_type is unsigned, so nothing is lost in the cast. I ran the PR's exact expression on real TrkFitFlag objects: an empty flag gives 0, FitOK|RangedOut gives 0x20008000, and FitOK|ExtrapFailed|RangedOut|MCSeed gives 0xb0008000 (bit 31 included), each equal to the expected value. BitMap has no public accessor for the raw value, so going through hex() is the only option without changing Offline.
  • 🟢 It builds and fills against Mu2e/Offline#2084. EventNtuple at this head builds against Offline#2084 (muse, rc 0). An ntuple job over 2,752 events of an Offline#2084 reco_03 output ran with rc 0, using the track branches only, because TrkQual and TrkPID need ArtAnalysis. Every one of the 2,736 trk rows has fitflag bit 15 (FitOK) set and status > 0, and no row has a zero mask.
  • 🟢 It works with Offline main. The diff uses only hex(), which has not changed, so the field carries the existing bits on Offline main.
  • 🟢 No other copies need updating. TrkInfo is written through its dictionary (src/classes_def.xml), not a leaf list. RooUtil's Track holds a TrkInfo*, so there is no mirror struct to update. doc/branches.md points to inc/TrkInfo.hh, where the new comment is. The PR merges cleanly with EventNtuple main 4889010.

Validation check

  • Build/tests run: the muse build against Offline#2084, the ntuple job and the parse check described above.
  • Not run: a build against Offline main, and the RooUtil examples.

Residual risk

  • The field comment names ExtrapolationFailed and RangedOut, which exist only once Mu2e/Offline#2084 merges. Until then the field carries only the existing bits.

Author follow-ups

  1. Optional: add a fitflag histogram to the validation script.

@sophiemiddleton
sophiemiddleton merged commit d05f8a2 into Mu2e:main Oct 30, 2026
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