Repository navigation
TrkCrvMatch: geometric candidates for straight-line tracks that miss every CRV sector - #2149
Conversation
|
☀️ The build tests passed at 5913529.
N.B. These results were obtained from a build of this Pull Request at 5913529 after being merged into the base branch at 7024300. For more information, please check the job page here. |
oksuzian
left a comment
There was a problem hiding this comment.
PR Review Summary — #2149
Reviewed at head 591352984eda31df998c4ab28813df3f0ceb4ee4. First pass.
Decision
- 🟢 approve
Scope understood
- For a
KKLinefit (KalSeed::kinematicLineFit()) with no CRVKalIntersectionandDoGeometrictrue,TrkCrvMatchTool::matchprojects the line from the intersection nearest in path onto the extended mid-plane of each sector that holds a cluster. Out-of-bounds projections becomeTrkCrvXings withinBounds_ = false, candidates are formed by the existing code, and projected crossings that no geometric candidate uses are dropped. - Tracks with a CRV crossing, helix fits and the FHiCL configuration are unchanged;
TrkCrvMatch.hhchanges in comments only.
Findings
-
🟡 [S2] Offline's own summaries, and EventNtuple's documentation, still treat every crossing as one the extrapolation found
- Evidence:
CRVResponse/src/TrkCrvMatchMCMaker_module.cc:385counts everyxings_entry as a reco crossing, and:398counts a true crossing as found when any reco crossing matched it. In my A/B below, its end-of-job summary goes from found 8188 / missed 1309 to found 8410 / missed 1087 over all sectors. OnCRV_EX, "missed" drops from 438 to 229, so the column no longer measures the extrapolation.Validationfills the same way (ValTrkCrvMatch.cc:67,:108;ValTrkCrvMatchMC.cc:47,:60). In EventNtuplemain(428345c),utils/trkcrv_example.py:83-87printsnxings > 0as "crossing the CRV".inc/TrkCrvInfo.hh:11,inc/TrkCrvXingInfo.hh:2,inc/TrkCrvTrueXingInfoMC.hh:29anddoc/branches.md:78describecrvxingsas the extrapolation's crossings. - Suggested fix: in the MC maker summary, skip
!inBounds_crossings or give them their own column. In EventNtuple, update the comments,doc/branches.mdand the example to useinbounds. The EventNtuple code needs no change, but its documentation does.
- Evidence:
-
🟡 [S2] The chi2 of projected candidates is on a different scale from extrapolated ones
- Evidence: in the head ntuples, I took own-particle candidates inside the description's peak cuts. The 126 projected candidates have median chi2/ndof 1.17 and median |dv| 83.5 mm. The 7,158 extrapolated same-sector candidates have median chi2/ndof 0.54 and median |dv| 23.3 mm. The error model (
prolog_v12.fcl:421-422) was fitted on extrapolated crossings (:393). So a chi2 cut tuned on extrapolated candidates removes more projected ones, andresolve()compares the two scales directly when they share a cluster. - Suggested fix: no code change asked. Please state this in the description or in the
TrkCrvXingcomment, so analyses separate the two byinbounds. One possible cause, which I did not investigate: the straight step from the starting intersection adds no scattering.
- Evidence: in the head ntuples, I took own-particle candidates inside the description's peak cuts. The 126 projected candidates have median chi2/ndof 1.17 and median |dv| 83.5 mm. The 7,158 extrapolated same-sector candidates have median chi2/ndof 0.54 and median |dv| 23.3 mm. The error model (
-
⚪ [S3] A few comments and one diagnostic still describe only extrapolated crossings
- Three comments are out of date for projections:
- The
DoGeometricComment (TrkCrvMatchTool.hh:42) still reads "from CRV KalIntersections". TrkCrvCandidate::cov_(TrkCrvMatch.hh:78) says the covariance is "carried from the reference crossing". For a projected candidate it starts at the intersection (TrkCrvMatchTool.cc:330).TrkCrvXing::mom_(TrkCrvMatch.hh:53) is described as the momentum "at the crossing". For a projection it is the starting intersection's (TrkCrvMatchTool.cc:189).
- The
- The
diagLevel > 0pull printout inTrkCrvMatchMCMaker_module.cc:448-457steps fromrx.pos_. For a projected crossing that point is already on the plane, soteu/tevprint the starting intersection's error without the step. - The parallel cut
1e-3now appears in four places:TrkCrvMatchTool.cc:168and:309,TrkCrvPlaneError.hh:26, andTrkCrvMatchMCMaker_module.cc:453. One named constant would keep them in step.
- Three comments are out of date for projections:
Verified
- 🟢 Crossing indices after the drop.
cand.xing_is remapped before the candidates are sorted, and each candidate keeps itsxing_through the sort (TrkCrvMatchTool.cc:359-368).x.best_is set after the remap (:390-393). The MC maker and EventNtuple build their crossing-parallel arrays from the finalxings_. Two tests confirmed this:- A/B (below): every candidate that points at a projected crossing has the same sector as that crossing. No projected crossing is left unused.
bestalways points at a geometric candidate of its own sector.crvxingsmchas the same length ascrvxings.crvtruexingsmc.recoxingalways lands on a crossing of the same sector. - Remap test: the head build with
KeepAllClusters : truekeeps all 1,451 projected crossings, on 970 tracks. With the windows on, 1,171 of them are dropped, and 706 tracks lose all of theirs. The 280 kept are the matching subset, in order, with identical content. Each of the 280 candidates has the same crossing, residuals, chi2 and covariance as withKeepAllClusters.
- A/B (below): every candidate that points at a projected crossing has the same sector as that crossing. No projected crossing is left unused.
- 🟢 Unchanged paths. The new code runs only under
doGeometric_ && m.xings_.empty() && ks.kinematicLineFit()(:270). Every other track takes the old loop (:302-313). For an extrapolated crossing,dsCovequalsds, becausex.sid_is the intersection's ownSurfaceId(:247,:330). In the A/B, all 5,849 tracks with a crossing are identical in everytrkcrv*field, and every other ntuple branch is identical. - 🟢 Geometry.
- The step to the plane is signed (
:169). Position, time (:185), crossing covariance (:187) and candidate step (:330) all use that sign, astrkCrvPlaneCovarianceexpects. Units are mm and ns. - The
dEdgeU_/dEdgeV_convention (:177) matches:261-262and the MC maker (:277-278). - A line parallel to a sector cannot divide by zero: intersections with |d·w| < 1e-3 are skipped (
:168), and the candidate uses the same plane. - In the A/B, every new crossing has
inbounds == false, and no extrapolated crossing does.
- The step to the plane is signed (
- 🟢
kinematicLineFit()testsTrkFitFlag::KKLine(KalSeed.hh:70), which onlyKinematicLineFit_module.cc:324,328sets.RegrowKinematicLinekeeps the flag, but its output is still a line.- Helix fits take their flags from helix or line-finder seeds, which never carry the flag.
- Production runs
KKLineonly inReconstruction.NoFieldPath(JobConfig/reco/prolog.fcl:283-285,:352-354).
- 🟢 Data product: with the
//comments removed,TrkCrvMatch.hhis identical to its base.classes_def.xmlis untouched. - 🟢 Offline#2147:
git merge-treeof591352984with4914d1dereports no conflict.- CRVReco with both PRs merged on
main70243009builds cleanly. - Projected candidates use the same
resolution()calls (:332-333) under the samedoGeometric_condition, so #2147'sbeginRuncheck covers them.
Validation check
- CI: FNALbuild build 3606 is green at this head. It merged into
70243009and posted at 2026-11-12 19:46:02 UTC. The whitespace check passed, and the FIXME/TODO count is 0. The two clang-tidy errors are in cetlib. Thetriggerrow fails with return code 2. Its block of 36 path messages is identical to build 3605 (Offline#2148, ExtMon shielding) at the same base, apart from the timing lines. Those messages are the fourapr_protonrenames plus count changes on 32 paths. No TrkCrv module runs in that job, so nothing in the row comes from this PR. - Local A/B:
- Builds: CRVReco as sparse muse workdirs on CI build
main/70243009_dc19af05_1dc8ee40, once at70243009and once with this PR merged, each with EventNtuplemain428345c. - Reco:
Production/JobConfig/recoMC/Extracted.fclon one MDC2025bb extracted-cosmic dig file, read in place (30,311 events). - Ntuple:
EventNtuple/fcl/from_mcs-extracted.fclin both workdirs on that same reco output. - Result: 20,296 tracks, of which 5,849 have a crossing and are unchanged. 264 of the 14,447 tracks without a crossing gain 280 projected crossings and 280 geometric candidates; these were time-only candidates before. The candidate cluster sets and time fields are unchanged. 79% of the new candidates come from the track's own particle; the description reports 75%.
- Builds: CRVReco as sparse muse workdirs on CI build
- Config contract: pass (no FHiCL change).
- Cross-repo consistency: needs a follow-up in EventNtuple (finding 1).
Residual risk
- Not checked:
- CRT data, the description's data arm.
- Non-extracted geometries.
- The layer-probe content of projected crossings.
- A projection that lands in bounds when the extrapolation recorded no crossing. That cluster stays time-only, as before.
Author follow-ups
- Keep projected crossings out of the MC maker's found/missed summary, or give them their own column. Update the EventNtuple comments,
doc/branches.mdandutils/trkcrv_example.pyto useinbounds(finding 1). - Note the chi2 scale of projected candidates in the description or in the
TrkCrvXingcomment (finding 2). - Optional: the comments, the diagnostic printout and the shared parallel cut (finding 3).
…idation; comments, shared parallel cut (review)
|
Thanks for the review. All three findings are addressed in 8775fa3:
|
|
@FNALbuild run build test |
|
⌛ The following tests have been triggered for 8775fa3: build (Build queue - API unavailable) |
|
☀️ The build tests passed at 8775fa3.
N.B. These results were obtained from a build of this Pull Request at 8775fa3 after being merged into the base branch at 7024300. For more information, please check the job page here. |
oksuzian
left a comment
There was a problem hiding this comment.
PR Review Summary — #2149
Reviewed at head 8775fa36352fc73ff7df755fd442613b8e08ba84. Re-review of 5913529.
Decision
- 🟢 approve
What changed since 5913529
- One commit,
8775fa36, in 9 files. The track-CRV products do not change: on my A/B sample everyTrkCrvMatchandTrkCrvMatchMCelement is byte-identical to the previous head. - The
TrkCrvMatchMCMakerend-of-job summary andValTrkCrvMatch/ValTrkCrvMatchMC(now version 2) count projected crossings apart from extrapolated ones. - Comments in
TrkCrvMatchTool.hhandTrkCrvMatch.hhare updated, the pull printout steps from the KalIntersection, and the parallel cut is one constant,trkCrvMinCosToNormal. - The description now has the chi2 note. The EventNtuple part is in Mu2e/EventNtuple#447.
Prior findings
- 🟢 [was S2] Offline's summaries counted projections as extrapolated crossings — FIXED in 8775fa3, verified.
- MC maker: projections skip the extrapolation's counts (
TrkCrvMatchMCMaker_module.cc:389,:402-407). Summed over my A/B sample, the 12 columns that base prints are identical to base in all 11 sectors: reco 9,748, found 8,188, missed 1,309, miss:nbr 180. The projections appear only in the new columns: proj 280, proj:true 272, miss:proj 222. The previous head's counts (reco 10,028, found 8,410, missed 1,087) are exactly the new head's plus these. - On the cluster line,
chi2nd,projandchi2ndProjequal base in every sector. The projected candidates are innoxing(209 on CRV_EX, 4 on CRV_T1, 9 on CRV_T2). - Validation: identical to base for the in-bounds histograms; see the Validation check.
- EventNtuple: addressed in Mu2e/EventNtuple#447, which I review separately.
- MC maker: projections skip the extrapolation's counts (
- 🟢 [was S2] The chi2 of projected candidates is on a different scale — ADDRESSED. No code change was asked. The description's Notes give the numbers (median chi2/ndof 1.92 for 243 projected candidates, 0.57 for 24,038 extrapolated ones) and say to separate them by
inbounds. TheTrkCrvXing::inBounds_comment says the same (TrkCrvMatch.hh:55), and Validation now fillschi2ndofProjapart. - 🟢 [was S3] Comments, the pull printout and the parallel cut — FIXED in 8775fa3, verified by reading.
- The
DoGeometricComment (TrkCrvMatchTool.hh:42),TrkCrvXing::mom_(TrkCrvMatch.hh:53) andTrkCrvCandidate::cov_(:78) now cover projections. - The pull printout steps from the KalIntersection (
TrkCrvMatchMCMaker_module.cc:455). For an extrapolated crossing that point is the crossing itself. I did not run it withdiagLevel > 0. trkCrvMinCosToNormal(TrkCrvPlaneError.hh:13, 1e-3 as before) is used atTrkCrvPlaneError.hh:27,TrkCrvMatchTool.cc:168and:309, andTrkCrvMatchMCMaker_module.cc:459. One more copy,ValTrkCrvMatch.cc:101, comes from base and was not in my first list. Optional.
- The
Findings
- ⚪ [S3] Optional: a few places still mix projected candidates with extrapolated ones, and
projnow names two things- The cluster line's
geom,exclusiveandbeststill count projected candidates, butchi2ndno longer sums them (TrkCrvMatchMCMaker_module.cc:417-428). On CRV_EX,geomgoes from 4,952 at base to 5,161, which is 4,952 plus 209noxing. So the mean chi2/ndof is nowchi2nd / (geom - noxing), notchi2nd / geom. - In the same printout,
projin the sector table is a projected crossing (:485,:490).projon the cluster line is a candidate from another sector's crossing (:110,:424,:496), and the cluster line calls projected candidatesnoxing. One name for one thing would remove the clash, for examplenoxingin the table too. ValTrkCrvMatch.cc:85splitschi2ndof, butdtXing,du,dv(:86-88) anddvVsSlope_*(:101), filled for the same candidates, still include the projected ones.dvhas 8,415 entries against 8,135 forchi2ndof. The projected candidates have a larger |dv| (finding 2 of my first review), so a split would keepdvequal to base, aschi2ndofnow is.
- The cluster line's
Validation check
- CI: FNALbuild build 3610 passed every row at this head, merged into
70243009(posted 2026-11-13 14:17:01 UTC), includingtrigger. The whitespace check passes, and the FIXME/TODO count is 0 in 10 files. The 4 clang-tidy errors are all the same cetlib error (LibraryManager.h:43), once per checked file. Its 222 warnings are mostly thesetwwidths and narrowing conversions of the summary printout, in the style of the code around them. - Local A/B, on the sample of my first review:
- Builds: sparse muse workdirs on CI build
main/70243009_dc19af05_1dc8ee40. Base and the previous head (CRVReco) use EventNtuplemain428345c. This head, merged onto70243009(CRVReco, CRVResponse, Validation), uses EventNtuple#447's head1395fed4. It builds with no compiler warnings. - Jobs:
Production/JobConfig/recoMC/Extracted.fclat this head on one MDC2025bb extracted-cosmic dig file, read in place (30,311 events). The matcher and the MC maker run only in the ntuple job. So I ranEventNtuple/fcl/from_mcs-extracted.fclin all three workdirs on the same reco output, adding theValidationanalyzer and an output that keeps the two TrkCrv products. On the reco output of this head and of base, the ntuple job gives identicalTrkCrvMatchproducts (4 of 4 files). - Products: I compared an MD5 hash of each element's ROOT serialization. All 20,296
TrkCrvMatchand all 20,296TrkCrvMatchMCelements are identical to the previous head. Against base, 264 elements of each differ: the tracks that gain projections. - MC summary: as in prior finding 1.
- Validation version 2, summed over the four files:
- Identical to base, bin for bin:
NXing,XingShield,XingGeomShield,chi2ndof, the sevenProbe*histograms,RecoXing,RecoXingTrue,TrueXingFound,XingDistandXingDt. - The new histograms fill only from projections. For
XingShield,chi2ndof,RecoXing,RecoXingTrue,TrueXingFoundandXingDist, the in-bounds histogram plus its*Projpartner equals the previous head's mixed histogram, bin for bin. Entries:XingProjShield280,chi2ndofProj280,NXingProj264 tracks holding 280 projections,RecoXingProj280,RecoXingProjTrue272,TrueXingProj222,XingDistProj222. Vergoes from 1 to 2. The candidate histograms (dtXing,du,dv,dvVsSlope_*,NGeom,Flags,PredMatched,dtRefBest,TrueCluGeom,TrueCluBestand the relation histograms) differ from base, as they did at the previous head, because the projected candidates are new geometric candidates.
- Identical to base, bin for bin:
- Nightly validation: no nightly job makes a
TrkCrvMatchtoday.Production/Validation/nightly/extracted_*.fclrunsJobConfig/recoMC/Extracted.fcl, and no Production config schedules a TrkCrv module, at the CI build'sdc19af05or at currentmain. These histograms will appear once Mu2e/Production#595 schedules the matcher.valComparewill not break then:TValCompare::Analyzecompares only histograms present in both files and skips the others (Validation/root/TValCompare.cc:166-177). Against an older reference, a new*Projhistogram is not compared, andVeris flagged, which is what the version number is for. Other Validation classes change it the same way:dd63eb174added one histogram toValKalSeedand movedVerfrom 2 to 3.
- Builds: sparse muse workdirs on CI build
- Config contract: no FHiCL change.
- Cross-repo: Mu2e/EventNtuple#447 carries the documentation. It should merge with or after this PR.
Residual risk
inBounds_ == falsemarks a projection because the extrapolation keeps only in-bounds CRV crossings (ExtrapolateSweep.hh:70,:428) and the line fit samples only tracker surfaces (Mu2eKinKal/fcl/prolog.fcl:467-471). A line fit configured to sample CRV sectors withSampleInBounds : falsewould break that. On this sample, every crossing at base is in bounds.- Not checked: the
diagLevel > 0printout, CRT data and other geometries.
Author follow-ups
- Optional: the cluster-line counts, the two meanings of
proj, and the candidate histograms in Validation (finding 1).
brownd1978
left a comment
There was a problem hiding this comment.
This adds a valid fix for 'near miss' extrapolation intersection. I expect that fix will be mostly unnecessary after a planned upgrade to KinKal::Intersect to allow recording 'near the edge' intersections is implemented; in particular the projectXing method should become native to Intersect. I suggest marking that function at least as a stand-in for an upcoming core KinKal extension.
Follow-up to #2106 (track-CRV association).
Problem
TrkCrvMatchToolforms a geometric candidate only by projecting from one of the track's CRV crossings (CRVKalIntersections). The extrapolation records a CRV intersection only when the track crosses a sector rectangle. A track
whose line passes just outside every sector therefore has no crossing at all. The cluster the muon did make at the
sector edge is then stored as a time-only candidate (
xing = -1, no residuals, no chi2).In the extracted-cosmic samples below, about 1 in 80 tracks without a CRV crossing has such a cluster: 553 of 45,417
in MC and 315 of 19,396 in CRT data. Tracks that miss one sector but cross another are not affected: they are
projected from the other sector's crossing, and the candidate is flagged
outOfBounds. Without a residual and a chi2,these edge clusters cannot be used in the geometric matching, or in efficiency and residual studies near the sector
edges.
Change
For a straight-line fit (
KalSeed::kinematicLineFit()) with no CRV crossing, and withDoGeometricon:path onto the sector's extended mid-plane. If that crossing is outside the sector rectangle, it is recorded as a
TrkCrvXingwithinBounds_ = false, its edge distancesdEdgeU_/dEdgeV_(negative outside), andinter_pointing at the intersection it starts from. In-bounds crossings stay the extrapolation's job and are not
projected.
space+time chi2, the storage windows and the flags (
outOfBoundswhen the point on the cluster plane is outside thesector,
sameSector). The candidate covariance is the starting intersection's covariance carried over the wholestraight step.
xings_holds only crossings in use.Unchanged:
KKCHmuand the LoopHelix fitsare not projected.
prolog_v12.fcl.TrkCrvMatch.hhchanges in comments only, and EventNtuple needs no change. In<trk>crvxings,inbounds == falsemarks a projected crossing, since extrapolated CRV crossings are always in bounds. The truth(
TrkCrvMatchMCMaker) matches reco crossings by sector, so projected crossings get their true crossing too.Summaries that count crossings keep the projections apart, so their crossing counts still describe the extrapolation:
TrkCrvMatchMCMakerend-of-job summary:recoandfound/missedcount only crossings the extrapolation found.New columns:
projandproj:true(projected crossings, and those with a true crossing in the same sector), andmiss:proj(true crossings the extrapolation missed but a projection matched). In the cluster line,chi2ndsumsonly candidates from extrapolated crossings, and
noxing/chi2ndNoXinghold the projected ones.TrkCrvMatchMCMakerdiagLevel > 0pull printout: the step to the plane starts at the KalIntersection the crossingcomes from, which is the crossing itself for an extrapolated one.
Validation(ValTrkCrvMatch,ValTrkCrvMatchMC, version 2):NXing,XingShield, the layer-probe histograms,chi2ndof,RecoXing,RecoXingTrue,TrueXingFound,XingDistandXingDtuse extrapolated crossings only.New histograms:
NXingProj,XingProjShield,chi2ndofProj,RecoXingProj,RecoXingProjTrue,TrueXingProj,XingDistProj.trkCrvMinCosToNormalinTrkCrvPlaneError.hh, used bythe matcher, the covariance and the MC maker.
Files:
CRVReco/src/TrkCrvMatchTool.cc,CRVReco/inc/TrkCrvMatchTool.hh,CRVReco/inc/TrkCrvPlaneError.hh,CRVReco/src/TrkCrvMatcher_module.cc(description),RecoDataProducts/inc/TrkCrvMatch.hh(comments),CRVResponse/src/TrkCrvMatchMCMaker_module.cc,Validation/{inc,src}/ValTrkCrvMatch{,MC}.{hh,cc}.EventNtuple: documentation only, in Mu2e/EventNtuple#447. It updates the
crvxings/nxings/recoxingcommentsand
doc/branches.md, andutils/trkcrv_example.pynow selects tracks that reach the CRV withinbounds.Validation
A/B on the FNAL grid with the same inputs through both arms: reco (
reco_kkts_extrap_v06.fclfor MC,Combined_Pass1with KPP_reco v1_3 for data) and the ntuple with the association (
from_mcs-extracted.fcl,from_rec-combined.fcl).All jobs processed every event, with no failures. Both arms have the same entry counts and the same event sequence.
¹ |dtXing| < 30 ns, |dv| < 250 mm and, for two-ended clusters, |du| < 1.5 m.
trkcrv*are bit-identical (386 leaves in MC, 185 in data).So are all
trkcrv*leaves of the tracks that have a CRV crossing.candidate cluster sets are unchanged in every file: no cluster outside the
DtRefWindowenters through the geometricwindows.
inbounds == false), as intended, and every recovered candidate isprojected onto its own sector (
sameSector). 98 % are also flaggedoutOfBoundsat the cluster plane; the rest areinside the sector there because the line is inclined.
peak (243 of 296). Most of the rest come from the particle's parent, or from an earlier simulation stage of the same
particle. 96 % of the projected crossings (569 of 593) match a true crossing of the same sector.
and −0.7 mm (data), dtXing median 0.2 ns (MC) and 1.0 ns (data), chi2 median 10.1 (MC) and 9.3 (data), mostly
for 3 degrees of freedom. Lines far outside a sector (metres past the bar ends) give large residuals and chi2, and
are removed by the analysis's own windows.
Notes
xings_(projected,inBounds_ = false). An analysis thatcounted
nxings > 0as "the track reached a CRV sector" should addinbounds.near the peak (cuts as in the table). The 243 projected ones have median chi2/ndof 1.92 and median |dv| 51 mm. The
24,038 extrapolated same-sector ones have 0.57 and 22 mm. The error model (
TrackErrorScale,TrackPosErrQuad) wastuned on extrapolated crossings, so a chi2 cut tuned on those removes more projected candidates.
resolve()alsocompares the two scales directly when they share a cluster. Analyses should separate them by
inbounds. A possiblecause, not investigated here: the straight step from the starting intersection adds no multiple scattering.
the field-off line fits it applies to.
🤖 Generated with Claude Code