Core correctness: CovMatrix stride, eigenvector guard, std::abs - #307
Draft
gavinsdavies wants to merge 1 commit into
Draft
Core correctness: CovMatrix stride, eigenvector guard, std::abs#307gavinsdavies wants to merge 1 commit into
gavinsdavies wants to merge 1 commit into
Conversation
…ctor division, use std::abs in Geometry
4 tasks
Collaborator
|
✔️ CI build for EMPHATIC Succeeded on slf7 for maxopt -- details available through the CI dashboard |
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.
Part of #303.
Fixes
RecoBase/DwnstrTrack.h— covariance stride mismatch.CovMatrix(i,j)always readfCovXY[5*i+j], but for no-magnet 4-parameter tracksReset(true)resizesfCovXYto 16 and the producer (SSDRecDwnstrTracksAutre) fills it with stride 4 (SetCovarianceMatrix(i*nPars + j)). So every off-diagonal read on 4-param tracks returned the wrong element, and(3,3)read index 18 of a 16-element vector (out of bounds). The getter now usesNumParams()*i + j, matching the setter. A full call-site audit (all two-argumentCovMatrix(uses are inSSDDVertexFitFCNAutre.cxx) confirmed all callers pass logical indices and none compensates for the old stride; the 5-parameter/magnet path is byte-for-byte unchanged. No other RecoBase class has this pattern (VertexAutreuses a true 2-D array).RecoUtils/RecoUtils.cxx— degenerate eigenvector guard.findLinedivides by the principal eigenvector's z-component without a guard; an xy-collinear point set givesn[2] ≈ 0and infinite endpoints. Added an early return (epsilon 1e-12 on a unit-normalized vector — far below any physical slope, above eigen-decomposition round-off) in the same style and output contract as the existingel == -1check:lfirst/llaststay zero-initialized, which the callers inSingleTrackAlgoalready tolerate.Geometry/Geometry.cxx— portablestd::abs.Detector::View()used unqualifiedabs(sin(...))on doubles (×4). It currently resolves to a floating overload under GCC/libstdc++, but if it ever resolves to Cint abs(int)(other toolchain/include order), every comparison< 0.2collapses and all sensors classify as X_VIEW. Nowstd::abs, with an explicit<cmath>include.Verification
The CovMatrix change is a deliberate correctness change for 4-param tracks only (audit in the description above); everything else is behavior-preserving. No local build environment and no repo CI — a collaborator build before undrafting would be appreciated.
🤖 Assisted by Claude Code (claude-fable-5)