TrkHitReco: fix defects found by a static sweep of the package - #1957
Open
oksuzian wants to merge 1 commit into
Open
TrkHitReco: fix defects found by a static sweep of the package#1957oksuzian wants to merge 1 commit into
oksuzian wants to merge 1 commit into
Conversation
CombineStrawHits set the output ComboHitCollection's parent to the original input handle, but in the Unsorted branch it permuted the hits into a local chcolsort and combined from that, so every index stored by ComboHit::init and ComboHit::addIndex was a position in the permutation while resolving against the unsorted original. Per-hit provenance was silently wrong, and wrong precisely when the permutation is non-trivial, which is the only reason that branch exists. It is live on VST data processing via Production/Processing/vstdata_epilog.fcl, which sets makePH.Unsorted:true; the prolog default is false, so MC reco is unaffected. combine() now takes the index mapping and stores original-collection indices in both branches. The four FilterHits cuts in the same loop used `if(_filter)break;`, which abandons every later hit in the event rather than dropping the hit that failed the cut. Dormant, since no committed fcl sets makePH.FilterHits:true. StrawHitReco called flagCrossTalk inside the per-digi loop, where it rescans the whole collection, so it ran once per digi instead of once per event. It also dereferences shCol, which is only allocated when WriteStrawHitCollection is true, so FlagCrossTalk:true with WriteStrawHitCollection:false null-dereferences a unique_ptr. Hoist the call out of the loop and reject that configuration in the constructor. Both are dormant: every committed config sets FlagCrossTalk:false. StereoLineTest declared its random angle as `uniform_int_distribution<int> phirange(-M_PI,M_PI)`, which truncates to [-3,3], so the stereo stress test only ever sampled 7 discrete orientations. Deliberately not included, and offered as follow-ups: the ComboHit quality chi-square at CombineStrawHits_module.cc:296 looks dimensionally inconsistent but needs a physics sign-off on the intended formula; and six defects in FlagBkgHits, TNTClusterer, Chi2Clusterer and DBSClusterer, which no committed configuration reaches -- both Production and the trigger bind flagPH to CalPatRec DeltaFinder. Found by a static review of the package at 0ef02a6. Not built locally -- relying on CI for the build. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Collaborator
|
☀️ The build tests passed at dcb0886.
N.B. These results were obtained from a build of this Pull Request at dcb0886 after being merged into the base branch at 0ef02a6. For more information, please check the job page here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Four defects found by a static review of
TrkHitRecoat0ef02a66d. I have not built this locally — relying onmu2e/buildtest.1. 🔴
CombineStrawHits: ComboHit parent and stored indices reference two different collectionssrc/CombineStrawHits_module.cc:131binds the output to the original input handle:chcolNew->setParent(chcH);but the
Unsorted:truebranch (:133-151) permutes the hits into a localchcolsortand then callscombine(ewm, chcolsort, *chcolNew). Inside,combohit.init(hit1,ich)andcombohit.addIndex(jch)storeich/jch— positions in the permutation — while every consumer resolves them againstchcOrig. Per-hit provenance is silently wrong, and wrong precisely when the permutation is non-trivial, which is the only reason the branch exists.Live via
Production/Processing/vstdata_epilog.fcl:5(physics.producers.makePH.Unsorted : true). The prolog default isfalse(prolog.fcl:116, "sim data are sorted, VST currently not"), so MC reconstruction is unaffected — this is VST data processing only.Fixed by threading the original-index mapping into
combine()and storing original-collection indices in both branches. Which hits get combined is unchanged; only the recorded provenance index changes.2. 🟡
FilterHitsabandons the event instead of dropping the hitThe four cuts at
:209,217,223,229areif(_filter)break;inside the per-eventfor (size_t ich...)loop, so one failed cut discards every later panel's hits rather than the hit that failed.continueis what the surrounding code means. Dormant — no committed fcl setsmakePH.FilterHits:true.3. 🟡
StrawHitReco:flagCrossTalkruns per digi, and null-dereferences whenWriteStrawHitCollectionis falseTwo problems at the same call site (
:217-219):flagCrossTalkrescans the entire collection (StrawHitRecoUtils.cc:44-62), so it runs N times per event instead of once.shCol, which:190-193only allocates when_writeshis true.FlagCrossTalk:truewithWriteStrawHitCollection:falsenull-dereferences aunique_ptr.Hoisted the call out of the loop, and rejected the impossible configuration in the constructor rather than silently skipping the flagging. Both are dormant: every committed config sets
FlagCrossTalk : false.4. 🟡
StereoLineTest: integer distribution over[-M_PI, M_PI]src/StereoLineTest_main.cc:80—std::uniform_int_distribution<int> phirange(-M_PI,M_PI).M_PItruncates to3, so the stereo stress test only ever sampled 7 discrete orientations instead of a continuous angle. Changed touniform_real_distribution<double>.Validation
buildtestbe the arbiter.vstdata_epilog.fcl, comparing a ComboHit's resolved parent hit against the straw it actually came from.:296,chisq = wacc2 - wacc/wwtsum, looks dimensionally inconsistent —_qualis frequently negative soTMath::Probreturns 0 for every multi-hit ComboHit. I did not touch it because the intended formula needs a physics sign-off, and the confirmed consumers are diagnostic.FlagBkgHits,TNTClusterer,Chi2ClustererandDBSClusterer(unclamped writes into a fixed 256-bucket array; an unsigned underflow defeating animin=0clamp; atbin_==0.0divide-by-zero path; per-event bounds held in never-reset members; a deadcperr2_;std::prevon an empty vector). No committed configuration reaches any of it —PrepareHitsends inflagPH, whichProduction/JobConfig/reco/prolog.fcl:34andmu2e-trig-config/core/producers/trigTrkProducers.fcl:70both bind to CalPatRecDeltaFinder, with theFlagBkgHitsalternative commented out; the trigger CI reference log confirmsTrigFlagPH:DeltaFinderis what runs. Whether ~1300 lines of unreached code should be fixed, deleted or revived is a maintainer call, not one for this PR.PeakFitfamily, whichStrawHitRecoUtils.cc:29-30makes unreachable (it throws unlessFitType∈ {1,2,5}; every committed config sets 1 or 5, nevercombopeakfit(3)orpeakfit(4)).MakeStereoHitsandProtonBunchTimeFromStrawDigisproduced no findings that survived adversarial verification. Read that as "nothing found", not "verified clean".