Skip to content

auto-hunt: TRACKING minor issues - 22 fixes (S4 22) - #1264

Open
DraTeots wants to merge 22 commits into
masterfrom
auto-hunt/tracking-s4
Open

DraTeots wants to merge 22 commits into
masterfrom
auto-hunt/tracking-s4

Conversation

@DraTeots

@DraTeots DraTeots commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

These fixes come from the Hall D bug hunt, an autonomous campaign that read the GlueX software, built a test for every suspect line, and kept only findings confirmed by a measurement: a test run of the program on data or simulation, or a direct call of the code against a known answer. Each commit below fixes one finding and is named by its finding id and grade (S1 most serious, S4 least). Every commit has a comment in this pull request with the finding's card: what is wrong, the code, the measured effect, who is affected and the fix. Full cards with plots are on the campaign pages (JLab login): https://pages.jlab.org/halld/auto-hunt/index.html, by library: https://pages.jlab.org/halld/auto-hunt/libraries.html

Split out of #1259 at the reviewer's request. #1259 first held all 49 tracking findings. It now holds the production-tracking fixes (S1 to S3); the straight-line (field-off) fixes and the minor (S4) fixes are in two separate pull requests, #1263 (straight-line) and this one. The commits are the same changes as before, cherry-picked onto the current master without conflicts; the three pull requests merge together in any order, and their combination equals the former #1259 branch file for file.

Overall gains

22 confirmed bugs fixed in this pull request (S4 22), one commit each, in the order of the commits (most serious first).

finding grade what was wrong the fix
R3-11 S4 After a central track is fitted, the smoother walks back along it and, at each CDC hit, computes the pull: residual over the error of hit minus track. To get the track error at the wire it moves the track's error matrix there in place, so the moved matrix travels on to the next hit as if it belonged to the trajectory. The track state is moved in a copy; the error matrix is not. Move a copy of the error matrix to the wire.
R3-13 S4 The track finder refits candidates that join CDC and FDC hits. When the straight-line part of that refit fails, a starting slope taken from the forward candidate stays in use. The formula takes the arctangent of the angle where its cotangent belongs, so any forward angle from 0 to 30 degrees becomes 32.5 to 42.6 degrees. Use the cotangent of the forward candidate's angle.
R3-15 S4 The CDC has seven rings of wire layers, called super layers. Where one super layer's hits are too dense, the track finder drops the seeds there and remembers that stretch of angle, so the outer super layers start no track in it. It never stores the last stretch of a super layer, stores the others one number low, and can begin the first at a seed that was not dropped. Store every stretch, the last one included, under its own super layer and with its true edges.
R3-17 S4 The CDC track finder fits a circle to each track seed. When that fit fails, a second circle fit takes over, and the code then picks the sense of rotation, and with it the charge, by comparing the hits with a helix of each sense. That comparison needs the track's dip slope, which is not fitted yet and is still zero. The result is "not a number", and the code falls to the same sense for any hits. Take the charge from the circle in the fallback too.
R3-21 S4 The track finder joins forward (FDC) track pieces to central (CDC) track candidates. Once a pair matches, both are marked as used, but the search goes on through the remaining central candidates with the same forward piece. A second central candidate that passes the cuts gets a copy of the same forward hits, so one forward track ends up in two candidates. Stop the search once a forward piece is joined.
R3-22 S4 The track finder gives CDC hits that no candidate uses ("stray" hits) to a forward (FDC) candidate. With three or more it refits the circle and takes the new circle and momentum, but copies fit quality (chi-square, degrees of freedom) and charge from the old FDC-only fit. The quality ignores every CDC hit, and the charge need not match the curvature. After a refit, take chi-square, degrees of freedom and charge from the refit.
R3-25 S4 The track fitter's fast helical step can apply an energy-loss term at its end. The central (CDC) version copies this line from the forward version, where the fifth track parameter is the momentum term. In a central track it is z, so the term moves the track along the beam line and leaves its momentum unchanged. Today the one call passes no energy loss, so the line never runs. Write the term into q/pt.
R3-3 S4 The track finder ends with a pass that joins forward (FDC) track pieces to candidates that already have hits. It keeps one working list of the candidate's CDC hits and hands it over to the candidate at the first join. After that the list is empty, so a second join leaves the candidate with no CDC hits, and a second piece is tested against no CDC hits at all. Copy the list instead of handing it over.
R3-34 S4 For an FDC segment linked to no other, the track finder makes a stub whose start momentum comes from the segment's circle radius and the field along the beam, Bz, taken with its sign. The field direction is already handled through the charge and the sense of rotation, so a negative Bz turns the momentum around a second time: a forward track points backward. The production solenoid maps in use since 2016 have a positive Bz, so nothing changes. Use the size of Bz.
R3-34b S4 For an FDC segment linked to no other, the track finder puts the stub's start point 1 cm upstream of the first hit, stepping along the segment's circle in the direction of the charge alone. A track turns by its charge and the field direction together, so in a reversed field the step goes the wrong way. The production solenoid maps in use since 2016 have a positive field, where the fix changes nothing. Turn the step with the field sign as well as the charge.
R3-39 S4 By default, before the wire-based fit, each track candidate is swum through the detector, and every step stores running sums of multiple scattering. They set how far a CDC or FDC hit near that step may lie from the track. When a step leaves the tracking volume, the loop stops before writing these sums. The step memory is reused from track to track, so the last step keeps the sums of an earlier track. Write the sums for the last step too.
R3-43a S4 A tracking routine swims a track to its closest approach to a line and corrects the momentum for the energy lost in the material on the way. The direction of the swim enters twice, once in the sign of the loss rate and once in the sign of the step, so the two cancel. A backward swim regains momentum, as it should; a forward swim gains momentum too. The reconstruction only swims backward with it. Take the direction from the loss rate alone.
R3-43b S4 A routine of the track fitter carries a track from its first wire back to the target and puts back the momentum lost in the material. It asks for a backward swim, which already steps backward, and also reverses the momentum and the charge. The direction is reversed twice, so the swim runs outward from the wire. The routine's only call is commented out. Keep the backward swim and drop the two manual reversals.
R3-43c S4 The tracking swim can carry a track's error matrix along the track, step by step. Each step should use the track's position and momentum at that step; the code uses the ones at the start of the swim. As the track turns in the field, its errors keep being carried along the first direction. No caller passes an error matrix, so this code never runs today. Pass the position and momentum of the current step.
R3-43e S4 A tracking routine returns the length of track inside one CDC straw: it finds the two points where the straight track line enters and leaves the straw's cylinder and measures between them. Each of the three coefficients of that quadratic misses a square or a factor 2, so the two points and the length are wrong. One optional plugin calls the routine; the reconstruction does not. Use the three coefficients of a line crossing a cylinder.
R3-43f S4 operator= keeps a smaller buffer but copies max_swim_steps see the commit
R3-43g S4 swim_steps[Nswim_steps-1] read with Nswim_steps==0 in GetIntersectionWithRadius/Plane see the commit
R3-55 S4 DHelicalFit::FitTrack declares a local float dzdphi that hides the member, so FillTrackParams uses a stale or zero dz/dphi for theta, phi and the charge see the commit
R3-57 S4 In simulation one can switch on a hit selector that uses the truth: each track gets the hits of the thrown particle closest to it in momentum and angles. The search for that particle never stores the best match found so far, so it returns the last thrown particle that is not far off, nearly always the last one in the list. Every track of the event then gets that one particle's hits. Store the best match. It ships with the companion fix, which looks the hits up by the thrown particle's number: alone, this fix loses 7% of the time-based tracks.
R3-61 S4 The THROWN hit selector filters truth hits by DMCTrackHit::track (the Geant4 track number) where the thrown id is itrack, so truth hit lists of THROWN tracks miss or mix hits after any intermediate particle see the commit
R3-66 S4 The code that refits the generated (thrown) tracks asks for the magnetic field without naming a run, so it gets the field of run 1. Every other tracking code names the event's run. Today a service quirk hides this by returning a second copy of the right map; once that is fixed, these tracks get no field. Pass the event's run to the field request; merge it with the geometry-service fix.
R3-15b S4 Where the CDC hits of one super layer are too dense, the track finder drops the track seeds there and stores that stretch of azimuth, so that the outer super layers start no new track in it. It takes the stretch from the first to the last dropped seed in the order the seeds were numbered, and that order is not the order in angle. The stored stretch can then be a sliver that misses most of the dense group. This sits on top of the earlier finding that stores the stretches under the wrong layer; the two fixes ship together. Store, per dense group, the smallest arc that holds all its seeds.

Related findings and commits that belong together

  • R3-15b and R3-15: R3-15b corrects the region that R3-15's fix pushes (the region of the whole group, not of its first and last seed); merge both.
  • R3-15b: ported by hand onto this branch because an earlier commit edits the same lines: written on top of R3-15; R3-15's comment on the 1-based key is kept on the group-region push_back.
  • R3-66 and R8-3: R3-66's thrown-track field lookup uses the per-run geometry service that R8-3 fixes; merge with R8-3 (HDGEOMETRY pull request).
  • R3-57 and R3-61: both fix the THROWN hit selector; R3-57's card says it should ship with its companion fix.
  • This pull request and auto-hunt: TRACKING - 19 fixes (S1 1, S2 6, S3 12) #1259 edit some of the same files (DTrackFitterKalmanSIMD.cc, DReferenceTrajectory.cc, DTrackFitter.cc, DHelicalFit.cc, DTrackCandidate_factory_FDCCathodes.cc) in different places; they merge without conflict in either order.

How it was tested

Each finding's card says how it was confirmed (a run of the program before and after the fix on the same events, or a direct call of the function). The commits were rebased on the current default branch; every changed source file compiles (syntax check against the release headers). A full build and a physics benchmark of this combination of commits has not been run on the new base.


Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

DraTeots and others added 22 commits December 1, 2026 18:15
…h its doca-propagated copy

`libraries/TRACKING/DTrackFitterKalmanSIMD.cc`, `SmoothCentral`: the covariance propagated to the point of closest
approach goes into a local `myCs`, and `V_track` is computed from it; `Cs` stays the smoother's covariance at the
trajectory point, as the state `Ss` already does through its copy `myS`. Two lines. `patches/master.patch` for master,
`patches/r5.9.0.patch` for release 5.9.0 (same lines, 12 lines earlier).
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-11-smoothcentral-overwrites-smoothed-covariance/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-11-smoothcentral-overwrites-smoothed-covariance

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One line in `libraries/TRACKING/DTrackCandidate_factory.cc`, `DoRefit`: `fit.tanl=M_PI_2-atan(theta);` becomes
`fit.tanl=tan(M_PI_2-theta);`, the definition of tanl used in the rest of the file. Nothing else changes. Release 5.9.0
does not have the refit.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-13-dorefit-tanl-fallback-wrong-formula/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-13-dorefit-tanl-fallback-wrong-formula

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad; bogus first region; last region never pushed

`libraries/TRACKING/DTrackCandidate_factory_CDC.cc`, the loop that records the rejected phi regions:

- the region is stored under `locSuperLayer`, the key both readers use (was `locSuperLayer - 1`);
- `locPreviousIndex` and `locEndIndex` start at the first rejected seed, so no region is pushed against seed 0;
- after the loop the last region is pushed.

Nothing else changes. `patches/master.patch` applies unchanged to release 5.9.0.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-15-cdc-rejected-phi-regions-misindexed/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-15-cdc-rejected-phi-regions-misindexed

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…0, so the charge is always +

One line in `libraries/TRACKING/DTrackCandidate_factory_CDC.cc`: after a successful fallback `FitCircle`, the factory
calls `GuessChargeFromCircleFit()` in place of `FindSenseOfRotation()`. `FindSenseOfRotation` needs `tanl`, which no
fit has set at this point, and returns +1 for any hits; `GuessChargeFromCircleFit` uses the circle alone and is what
the Riemann branch right below already calls. Nothing else changes. `patches/master.patch` applies unchanged to
release 5.9.0.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-17-cdc-fallback-circle-charge-fixed/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-17-cdc-fallback-circle-charge-fixed

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One line in `libraries/TRACKING/DTrackCandidate_factory.cc`: `break;` after `fdc_matches[i]=1; cdc_matches[j]=1;` in
the first CDC/FDC matching loop, so an FDC candidate that has been merged is not merged again into a later CDC
candidate. The later matching loop of the factory already skips used FDC candidates. Nothing else changes. Release
5.9.0 has a different matcher without these lines; the patch is for master only.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-21-fdc-candidate-merged-into-several-cdc/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-21-fdc-candidate-merged-into-several-cdc

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… FDC candidate after a refit

`libraries/TRACKING/DTrackCandidate_factory.cc`, the step that attaches unused CDC hits to an unmatched FDC
candidate: when the step refits (`num_axial>2`), the new candidate takes `fit.chisq`, `fit.ndof` and
`FactorForSenseOfRotation*fit.h`, as the matched branch above already does; without a refit it keeps the FDC
candidate's values as before. The same condition as the refit itself, three assignments, no other line touched.

Releases 5.10.0 and master (= 5.16.0 of version set 7.10.0) (`patches/master.patch`): release 5.9.0 has an older candidate finder whose stray-hit step does not
refit, so it has no such mismatch and the patch does not apply there.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-22-unused-cdc-refit-takes-fdc-values/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-22-unused-cdc-refit-takes-fdc-values

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TRACKING/DTrackFitterKalmanSIMD.cc`, central `FastStep`: the loss term updates `S(state_q_over_pt)` in
place of `S(state_q_over_p)`, which is `state_z` in the central state vector. The term keeps `one_over_p` of the start
of the step, as the forward `FastStep` does. Nothing else changes. Release 5.9.0 has the line two lines earlier:
`patches/r5.9.0.patch`.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-25-central-faststep-eloss-into-z/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-25-central-faststep-eloss-into-z

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ond match empties it

One line in `libraries/TRACKING/DTrackCandidate_factory.cc`: `mData[i]->cdchits=std::move(cdchits);` becomes a copy,
`mData[i]->cdchits=cdchits;`. The local list is read again when the loop over the FDC candidates finds a second
match; a copy keeps it intact. Nothing else changes. Release 5.9.0 does not have the final matching pass.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-3-final-fdc-match-empties-cdc-hits/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-3-final-fdc-match-empties-cdc-hits

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TRACKING/DTrackCandidate_factory_FDCCathodes.cc`, `GetPositionAndMomentum(segment, pos, mom)`: the field
taken for pt becomes `fabs(bfield->GetBz(x,y,zmin))`, as in the twin routine for a helical fit. The direction is
already set by the charge and `FactorForSenseOfRotation`. One line. The patch applies to release 5.9.0 with an offset
of 74 lines and was built and run there.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-34-fdc-cathode-momentum-signed-bz/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-34-fdc-cathode-momentum-signed-bz

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… charge, so in a reversed field it goes the wrong way round the circle

`libraries/TRACKING/DTrackCandidate_factory_FDCCathodes.cc`, `GetPositionAndMomentum(segment, pos, mom)`: the step
angle becomes `-FactorForSenseOfRotation*dz*q_over_rc_tanl`, with a comment. `FactorForSenseOfRotation` is -1 for
positive Bz, so with the 2025 maps the step is the same as before; in a reversed field it now goes the same way round
the circle as the trajectory. One line. The patch applies to release 5.9.0 with an offset of 74 lines (patch dry run;
not built at 5.9.0). It is independent of the fix of the momentum sign in the same routine (`fabs(Bz)`); the two
patches touch different lines and apply in either order.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-34b-fdc-cathode-start-step-charge-sign/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-34b-fdc-cathode-start-step-charge-sign

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tiple-scattering fields

`libraries/TRACKING/DReferenceTrajectory.cc`, `FastSwimForHitSelection`: in the branch that ends the swim when a step
leaves the tracking volume, the step gets the running sums `itheta02`, `itheta02s`, `itheta02s2` and
`invX0=Nswim_steps/X0sum` before the break, the same four lines every other step gets at the end of the loop. Nothing
else changes. `patches/master.patch` for master; `patches/r5.9.0.patch` for release 5.9.0 (same lines, 5 lines
later; the 5.9.0 step applied the master patch with that offset).
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-39-fastswim-last-step-stale-scattering/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-39-fastswim-last-step-stale-scattering

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TRACKING/DReferenceTrajectory.cc`, `FastSwim(..., origin, dir, smax)`: `ptot+=dP_dx*ds` becomes
`ptot-=dP_dx*fabs(ds)`. `dP_dx` already holds the direction sign, so the step length enters without its sign. One line.
The patch applies to release 5.9.0 with an offset of 5 lines.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-43a-fastswim-forward-gains-momentum/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43a-fastswim-forward-gains-momentum

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TRACKING/DTrackFitter.cc`, `CorrectForELoss`: the back-swim keeps `kBackward` and passes the momentum and
charge as they are; the final `mom = -mom` goes. `kBackward` alone steps backwards and restores the loss. Keeping
`-mom`, `-q` with `kForward` instead would reverse once but lose momentum on the way back, so the patch keeps
`kBackward`. Nothing else changes. Release 5.9.0 has the code five lines later: `patches/r5.9.0.patch`.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-43b-correctforeloss-direction-reversed-twice/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43b-correctforeloss-direction-reversed-twice

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TRACKING/DReferenceTrajectory.cc`, `Swim`: `PropagateCovariance` gets `swim_step->mom` and
`swim_step->origin`, the state at the start of the current step, in place of the arguments of `Swim`. Nothing else
changes. Release 5.9.0 has the line at 812: `patches/r5.9.0.patch`.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-43c-swim-covariance-start-state/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43c-swim-covariance-start-state

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TRACKING/DReferenceTrajectory.cc`, `Straw_dx`: `a = |B|^2`, `b = 2 A.B`, `c = |A|^2 - r^2`, the
coefficients of the intersection of the line with the cylinder. Nothing else changes. Release 5.9.0 has the lines at
2247: `patches/r5.9.0.patch`.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-43e-straw-dx-wrong-quadratic/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43e-straw-dx-wrong-quadratic

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TRACKING/DReferenceTrajectory.cc`, `operator=`: the owned buffer is freed and reallocated when it is
smaller than `rt.max_swim_steps`, the capacity the operator then records, in place of `rt.Nswim_steps`. Keeping the
owned buffer with its own capacity would also be safe but would cut later swims short; the patch keeps the recorded
capacity and makes the buffer match it. Nothing else changes. Release 5.9.0 has the code four lines later:
`patches/r5.9.0.patch`.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-43f-reftraj-assignment-keeps-small-buffer/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43f-reftraj-assignment-keeps-small-buffer

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tersectionWithRadius/Plane

`libraries/TRACKING/DReferenceTrajectory.cc`:

- `GetIntersectionWithRadius`: the existing `Nswim_steps<1` branch now returns `VALUE_OUT_OF_RANGE` after its message.
- `GetIntersectionWithPlane`: the early-return test becomes `Nswim_steps<1 || origin.z()>...`, so the last step is
  read only when it exists.

Both changes use the return value the functions already give for "no intersection". Two lines. The patch applies to
release 5.9.0 with an offset of 37 lines.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-43g-intersection-reads-empty-trajectory/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43g-intersection-reads-empty-trajectory

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es the member, so FillTrackParams uses a stale or zero dz/dphi for theta, phi and the charge

`libraries/TRACKING/DHelicalFit.cc`, `FitTrack()`: `float dzdphi = Syy/Sxy;` becomes `dzdphi = Syy/Sxy;`, so the
fitted slope goes into the member that `FillTrackParams()` reads, as `FitTrack_FixedZvertex()` already does. One
line. The patch applies to release 5.9.0 with an offset of 3 lines (patch dry run; not built at 5.9.0).
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-55-helicalfit-dzdphi-local-hides-member/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-55-helicalfit-dzdphi-local-hides-member

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hisq, so it returns the last thrown particle with chisq < 1e8 rather than the best match

`libraries/TRACKING/DTrackHitSelectorTHROWN.cc`, `FindTrackNumber`: set `min_chisq = chisq` together with
`myid`, so the loop returns the thrown particle closest to the track. One cause, two lines. The patch applies to
release 5.9.0 unchanged.

This fix should go in with the separate fix of `GetMCTrackHit` (`patches/companion-reader-itrack.patch`: filter
the truth hits by `itrack`, the thrown id, instead of `track`, the Geant4 track number). Without it the corrected id
selects the hits of another particle. The hit-filter fix is filed as its own finding (R3-61).
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-57-thrown-hit-selector-min-chisq-never-updated/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-57-thrown-hit-selector-min-chisq-never-updated

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rack (the Geant4 track number) where the thrown id is itrack, so truth hit lists of THROWN tracks miss or mix hits after any intermediate particle

`libraries/TRACKING/DTrackHitSelectorTHROWN.cc`, `GetMCTrackHit`: compare the filter with `DMCTrackHit::itrack`
instead of `DMCTrackHit::track`, and drop the `primary` test (a positive `itrack` equal to the thrown id already means
the particle itself). Three lines. The patch applies to release 5.9.0 unchanged. It should go in with the fix of
`FindTrackNumber` (R3-57), which picks the thrown id this filter uses.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-61-thrown-hit-selector-filters-geant4-track/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-61-thrown-hit-selector-filters-geant4-track

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tBfield() default argument) whatever the event's run; today the sticky BFIELD_MAP (R8-3) hands it a second copy of the run's map, with R8-3 fixed it gets run 1's NoField

`src/libraries/TRACKING/DTrackTimeBased_factory_THROWN.cc` line 73: `GetBfield()` becomes `GetBfield(runnumber)`,
as in DTrackWireBased_factory_THROWN.cc. `patches/master.patch` applies with `git apply -p1` at current halld_recon
master. Merge it together with any change that stops BFIELD_MAP from sticking to its first value.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-66-thrown-tracks-take-field-of-run-1/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-66-thrown-tracks-take-field-of-run-1

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rst to the last rejected seed in seed-index order, not over the group's phi, so some seeds lie outside it (2 of 17 super layers)

`libraries/TRACKING/DTrackCandidate_factory_CDC.cc`, `Reject_SuperLayerSeeds_HighSeedDensity`: keep, for the group
being formed, the smallest arc whose ends are seed edges and which holds every seed range of the group, and store that
arc as the group's region (instead of the first seed's first phi and the last seed's last phi in index order). When
the ranges wrap the circle the region is the whole circle. The R3-15 patch and then this one apply to release 5.9.0.
Card: https://pages.jlab.org/halld/auto-hunt/cards/r3-15b-cdc-rejected-region-index-order-not-phi/index.html
Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-15b-cdc-rejected-region-index-order-not-phi

Ported by hand onto this branch: written on top of R3-15; R3-15's comment on the 1-based key is kept on the group-region push_back

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-11 S4 (commit 9241a29)

CDC hit pulls get their track error from a matrix the smoother has already overwritten

What is wrong. After a central track is fitted, the smoother walks back along it and, at each CDC hit, computes
the pull: residual over the error of hit minus track. To get the track error at the wire it moves the track's error
matrix there in place, so the moved matrix travels on to the next hit as if it belonged to the trajectory. The track
state is moved in a copy; the error matrix is not.

The code (on GitHub):

DMatrix5x1 myS=Ss;                   // the state goes to the wire in a copy
...
double Vhit=cdc_updates[id].variance;
Cs=Jc*Cs*Jc.Transpose();             // <-- the smoother's own error matrix is overwritten
double Vtrack=H*Cs*H_T;

With the fix:

DMatrix5x5 myCs=Jc*Cs*Jc.Transpose();   // a copy, as for the state
double Vtrack=H*myCs*H_T;

What it does (1000 raw events of run 132404, 2025-01):

today with the fix
CDC hits whose track error comes from the overwritten matrix 18322 of 19598 0
CDC hits whose pull error is undefined (negative variance) 296 97
monitoring pulls: half width of the central 68% (error about 0.008) 0.9895 0.9883
events with a changed track, shower or particle 0 of 998 0 of 998

Plot: BH-881: 18322 of 19598 CDC hits get their track error from an overwritten matrix; 0 with the fix

BH-881. Smoothed CDC hits of 1000 raw events, today and with the fix. Dashed: the count expected from the
smoother's own matrix.

Who is affected.

  • Anyone using CDC pulls: the tracking-pull monitoring and the CDC alignment plugins, in the 2025-01 pass (release
    5.9.0) and the current release. By reading the code, these skip a whole track when one pull error is undefined.

Who is not. Tracks, showers, particles, reduced (REST) files and analysis trees: the smoother feeds only the
pulls. No benchmark reaction moves beyond the run-to-run noise (1M raw events).

The fix. Move a copy of the error matrix to the wire.

Grade S4 (lowest of four): 0 of 998 events change a reconstructed object; only monitoring and alignment inputs
move.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-11-smoothcentral-overwrites-smoothed-covariance/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-11-smoothcentral-overwrites-smoothed-covariance

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-13 S4 (commit 29dc053)

A rare fallback of the track finder gives forward track candidates a polar angle of 32 to 43 degrees

What is wrong. The track finder refits candidates that join CDC and FDC hits. When the straight-line part of
that refit fails, a starting slope taken from the forward candidate stays in use. The formula takes the arctangent
of the angle where its cotangent belongs, so any forward angle from 0 to 30 degrees becomes 32.5 to 42.6 degrees.

The code (on GitHub):

// Initialize fit.tanl in case new line fit does not work
fit.tanl=M_PI_2-atan(fdccan->dMomentum.Theta());   // <-- pi/2 minus the arctangent of an angle
fit.FitLineRiemann();                               // leaves this slope as it is when it fails

With the fix, the cotangent, the form the same code uses elsewhere for this slope:

fit.tanl=tan(M_PI_2-fdccan->dMomentum.Theta());

What it does (track candidates that take the fallback):

today with the fix
2025-01 data, 99 998 events: polar angle of the 6 changed candidates 32.6 to 42.6 deg 0.5 to 30.0 deg
constructed candidates at 5, 10, 20 deg 34.0, 35.6, 39.0 deg 5, 10, 20 deg
same data: events whose final charged tracks change 2 of 99 998

Plot: BH-887: all 6 changed candidates sit at 32.6 to 42.6 deg today; with the fix 0.5 to 30.0 deg

BH-887. The 6 track candidates the fix changes in the first 100 000 events of a 2025-01 raw file, today and with
the fix (event numbers are the run's own and go past 100 000). Grey band: the only angles today's fallback can give.

Who is affected.

  • Anyone who studies track finding: the candidate's angle and momentum seed the first track fit.

Who is not. Physics results: no benchmark reaction moves beyond the run-to-run noise (1M raw events, 2025-01
data). The 2025-01 pass (release 5.9.0) used an older finder without this fallback.

The fix. Use the cotangent of the forward candidate's angle.

Grade S4 (lowest of four): candidates change in 6 of 99 998 events, final tracks in 2; which side is closer to
the true track is not resolved.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-13-dorefit-tanl-fallback-wrong-formula/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-13-dorefit-tanl-fallback-wrong-formula

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-15 S4 (commit f4e0445)

Dense CDC regions are mostly not remembered, so outer layers start tracks there anyway

What is wrong. The CDC has seven rings of wire layers, called super layers. Where one super layer's hits are
too dense, the track finder drops the seeds there and remembers that stretch of angle, so the outer super layers
start no track in it. It never stores the last stretch of a super layer, stores the others one number low, and can
begin the first at a seed that was not dropped.

The code (on GitHub):

int locBeginIndex = -1, locPreviousIndex = 0, ...;   // <-- previous seed starts at seed 0
for(; locRejectIterator != locSeedsToReject.end(); ++locRejectIterator)
{
    ...
    // seed not next to the previous one: the stretch ends here
    dRejectedPhiRegions[locSuperLayer - 1].push_back(...);   // <-- stored one layer too low
    ...
}                                                            // <-- last stretch never stored

// the readers, later:
for(size_t loc_j = 1; loc_j < locOuterSuperLayer; ++loc_j)  ... dRejectedPhiRegions[loc_j] ...
... dRejectedPhiRegions[locSearchSuperLayer] ...

With the fix every stretch, the last included, is stored under its own number, from its first dropped seed.

What it does (1000 raw events of a 2025-01 run):

dense super layers (17, in 11 events) today with the fix
stretch stored under its own number 0 17
nothing stored (its only stretch is the last) 14 0
stretch stored one number low 3 0
events with changed candidates; final tracks 2; 1 of 998

Plot: BH-893: dense CDC super layers whose stretch is stored under their own number, 0 of 17 today, 17 of 17 with the fix

BH-893 version 2. Every dense super layer in 1000 raw events and what is stored for it. The three faults were not
run apart. Limits: one run at 2025-01 rate.

Who is affected.

  • Track finding in events with dense CDC hits: in the 2025-01 pass (release 5.9.0) and in the current release
    (version set 7.10.0).

Who is not. Physics analyses at 2025-01 rate: no benchmark reaction moves beyond the run-to-run noise (1M raw
events). Higher rate was not checked.

The fix. Store every stretch, the last one included, under its own super layer and with its true edges.

Grade S4 (lowest of four): track candidates change in 2 of 998 events (0.2%), final tracks in 1. It says nothing
about physics weight.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-15-cdc-rejected-phi-regions-misindexed/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-15-cdc-rejected-phi-regions-misindexed

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-17 S4 (commit 67191e7)

A rare fallback of the CDC track finder gives every circle it fits the same charge

What is wrong. The CDC track finder fits a circle to each track seed. When that fit fails, a second circle fit
takes over, and the code then picks the sense of rotation, and with it the charge, by comparing the hits with a helix
of each sense. That comparison needs the track's dip slope, which is not fitted yet and is still zero. The result is
"not a number", and the code falls to the same sense for any hits.

The code (on GitHub):

if(locFit->FitCircleRiemann(TARGET_Z, locBeamRMS) != NOERROR)
{
    if(locFit->FitCircle() != NOERROR)
    {
        ...                                   // straight-line fit, or give up
    }
    else
        locFit->FindSenseOfRotation();        // <-- needs the dip slope, still 0 here
}
else
    locFit->GuessChargeFromCircleFit(); // for Riemann fit

With the fix, the fallback takes the charge from the circle, as the first fit does:

        locFit->GuessChargeFromCircleFit();

What it does:

today with the fix
constructed tracks and their mirror images: same sense for both 3 of 3 0 of 3
2025-01 data, 998 events: candidates that change 1, charge -1 to +1
that candidate starts moving toward the beam line away from it
same data: tracks that change 0

Plot: BH-889: the one candidate the fix changes in 998 events, today moving inward, with the fix outward

BH-889. The changed candidate (5 CDC hits) seen along the beam, start point and direction today and with the fix.
The finder assumes its hits come from the outgoing part of the track.

Who is affected.

  • Anyone who studies CDC track finding: the branch is rare, and its candidates are short.

Who is not. Final tracks and physics: the changed candidate makes no track, and no benchmark reaction moves
beyond the run-to-run noise (1M raw events, 2025-01 data).

The fix. Take the charge from the circle in the fallback too.

Grade S4 (lowest of four): one candidate changes in 1 of 998 events, nothing downstream. Present in release 5.9.0
of the 2025-01 pass.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-17-cdc-fallback-circle-charge-fixed/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-17-cdc-fallback-circle-charge-fixed

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-21 S4 (commit dfb847e)

One forward track piece can be joined to two central track candidates at once

What is wrong. The track finder joins forward (FDC) track pieces to central (CDC) track candidates. Once a pair
matches, both are marked as used, but the search goes on through the remaining central candidates with the same
forward piece. A second central candidate that passes the cuts gets a copy of the same forward hits, so one forward
track ends up in two candidates.

The code (on GitHub):

for (unsigned int i=0;i<fdctrackcandidates.size();i++){      // forward pieces
  if (fdc_matches[i]) continue;
  ...
  for (unsigned int j=0;j<cdctrackcandidates.size();j++){    // central candidates
    if (cdc_matches[j]) continue;          // <-- only the central side is checked
    ...
    if (num_matches>=3){
      ...                                  // joined candidate gets the forward hits
      Insert(can);
      fdc_matches[i]=1;
      cdc_matches[j]=1;
                                           // <-- no break: the same piece is tried on the next j
    }
  }
}

With the fix the inner loop stops after the first match:

      break; // this FDC candidate is used up

What it does (998 raw events of a 2025-01 run):

today with the fix
forward pieces in two candidates 2 0
events with changed tracks 2

Plot: BH-878: a forward piece joined to a second central candidate; chi-square per degree of freedom 39.5 and 1.34 today, 0.84 and 1.03 with the fix

BH-878. The two candidates that take a forward piece a second time, today and with the fix. Today's and fixed
values are fits of different hit sets; the simulation truth does not decide. Limits: two events, one run.

Who is affected.

  • Anyone studying track finding where forward and central track pieces meet, in the current release (version set
    7.10.0).

Who is not. Physics analyses: no benchmark reaction moves beyond the run-to-run noise (1M raw events). The number
of final charged tracks does not change. The 2025-01 pass (release 5.9.0) joins pieces with older code.

The fix. Stop the search once a forward piece is joined.

Grade S4 (lowest of four): tracks change in 2 of 998 events (0.2%). It says nothing about physics weight.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-21-fdc-candidate-merged-into-several-cdc/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-21-fdc-candidate-merged-into-several-cdc

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-22 S4 (commit f0538c6)

Forward track candidates that pick up stray CDC hits keep the fit quality and charge of the FDC fit alone

What is wrong. The track finder gives CDC hits that no candidate uses ("stray" hits) to a forward (FDC)
candidate. With three or more it refits the circle and takes the new circle and momentum, but copies fit quality
(chi-square, degrees of freedom) and charge from the old FDC-only fit. The quality ignores every CDC hit, and the
charge need not match the curvature.

The code (on GitHub):

if (num_axial>2){ // Refit if we added several cdc axial hits
  DoRefit(fit,fdccan,fdchits,cdchits,mom,pos);   // new circle, momentum and sense of rotation
...
can->chisq=fdccan->chisq;       // <-- taken from the FDC-only fit, after the refit
can->Ndof=fdccan->Ndof;
can->dCharge=fdccan->dCharge;

With the fix, after a refit (as the code already does for the other matching step a few lines above):

can->chisq=fit.chisq;
can->Ndof=fit.ndof;
can->dCharge=FactorForSenseOfRotation*fit.h;

What it does (track candidates the fix changes):

today with the fix
simulation, 4000 events: candidates whose degrees of freedom count all their CDC hits 0 of 749 591 of 749
2025-01 data, 998 events: the same 0 of 90 62 of 90
simulation: median chi-square of these candidates 15.58 18.55
simulation: candidates that change charge 7 of 749

Plot: BH-525: today no changed candidate counts its CDC hits; with the fix 591 of 749 count them all

BH-525. Candidates by CDC hits the fit quality leaves out. With the fix these are, by reading, stereo hits, added
after the circle fit.

Who is affected.

  • Anyone who reads or cuts on track-candidate fit quality, or studies track finding.

Who is not. Final tracks and physics. Later fits start from the candidate's charge but refit the hits: a charge
change altered a first-pass fit in 1 of 4000 simulated events and no final track. No benchmark reaction moves beyond
the run-to-run noise (1M raw events), on 2025-01 data. The 2025-01 pass (release 5.9.0) used an older finder.

The fix. After a refit, take chi-square, degrees of freedom and charge from the refit.

Grade S4 (lowest of four): the changed values stay inside the reconstruction; no file or final track carries
them.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-22-unused-cdc-refit-takes-fdc-values/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-22-unused-cdc-refit-takes-fdc-values

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-25 S4 (commit d1aaf37)

The central track step puts its energy-loss correction into the track's z position

What is wrong. The track fitter's fast helical step can apply an energy-loss term at its end. The central (CDC)
version copies this line from the forward version, where the fifth track parameter is the momentum term. In a central
track it is z, so the term moves the track along the beam line and leaves its momentum unchanged. Today the one call
passes no energy loss, so the line never runs.

The code (on GitHub):

// forward step: parameter 5 is q/p
S(state_q_over_p)-=S(state_q_over_p)*one_over_p_sq*E*dEdx*ds;
...
// central step: parameter 5 is z
if (fabs(dEdx)>EPS){
  ...
  S(state_q_over_p)-=S(state_q_over_pt)*one_over_p_sq*E*dEdx*ds;   // <-- lands in z
}

With the fix:

  S(state_q_over_pt)-=S(state_q_over_pt)*one_over_p_sq*E*dEdx*ds;

What it does (the step called directly on a constructed track, 2 T field, pion mass; a 1 cm step backward with
the energy-loss term, as the fitter steps back toward the target):

today with the fix
z, minus the same step without the term -0.0018 cm 0
q/pt, minus the same step without the term 0 -0.0018 per GeV/c
test cases that match the forward step's formula (3 with the term, 1 without) 1 of 4 4 of 4

Plot: BH-883: today the loss term moves z and leaves q/pt unchanged; with the fix it changes q/pt by the same amount

BH-883. One step of the same track state, in the three test cases with the term. Signs follow the code: stepping
back, the momentum rises.

Who is affected.

  • Nobody today. Code that passes an energy loss to the central step would get tracks whose z drifts and whose
    momentum ignores the loss.

Who is not. Every reconstruction and simulation output: the line ran in no event of this study. No physics
benchmark can reach it; with 12 other low-grade tracking fixes in one test, none of the seven reactions moved (1M raw
events).

The fix. Write the term into q/pt.

Grade S4 (lowest of four): the line runs in no event; the grade does not say how wrong the line is.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-25-central-faststep-eloss-into-z/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-25-central-faststep-eloss-into-z

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-3 S4 (commit 323f72f)

A track candidate extended twice in the forward direction ends with no CDC hits

What is wrong. The track finder ends with a pass that joins forward (FDC) track pieces to candidates that already
have hits. It keeps one working list of the candidate's CDC hits and hands it over to the candidate at the first join.
After that the list is empty, so a second join leaves the candidate with no CDC hits, and a second piece is tested
against no CDC hits at all.

The code (on GitHub):

// Do a final pass to match unmatched FDC candidates to other candidates
for (unsigned int i=0;i<mData.size();i++){
  vector<const DCDCTrackHit*>cdchits=mData[i]->cdchits;   // working list, made once per candidate
  for (unsigned int j=0;j<fdctrackcandidates.size();j++){
    ...                                                    // test FDC piece j against cdchits
    if (num_matches>=3){
      ...
      mData[i]->cdchits=std::move(cdchits);   // <-- hands the list over: cdchits is now empty,
      ...                                     //     and the loop goes on to the next piece with it

With the fix the list is copied:

      mData[i]->cdchits=cdchits;

What it does (998 raw events of a 2025-01 run):

today with the fix
candidates joined twice today that keep their CDC hits 0 of 3 3 of 3
events with a changed track candidate 4
final charged tracks 2797 2796

Plot: BH-875: today 3 of 4 changed track candidates end with no CDC hits; the fix keeps 1, 10 and 1

BH-875. CDC hits on each candidate the fix changes, today and with the fix. The track fit then picks its own hits
from the candidate's direction and charge, so only one change reaches a final track. Limits: four events, one run.

Who is affected.

  • Anyone studying forward tracks that cross from the CDC into the FDC, in the current release (version set
    7.10.0).

Who is not. Physics analyses: no benchmark reaction moves beyond the run-to-run noise (1M raw events). The
2025-01 pass (release 5.9.0) has no such final pass.

The fix. Copy the list instead of handing it over.

Grade S4 (lowest of four): track candidates change in 4 of 998 events (0.4%), final charged tracks in 1. It says
nothing about physics weight.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-3-final-fdc-match-empties-cdc-hits/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-3-final-fdc-match-empties-cdc-hits

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-34 S4 (commit 7aada3f)

FDC track stubs would point backward in a reversed solenoid field

What is wrong. For an FDC segment linked to no other, the track finder makes a stub whose start momentum
comes from the segment's circle radius and the field along the beam, Bz, taken with its sign. The field direction is
already handled through the charge and the sense of rotation, so a negative Bz turns the momentum around a second
time: a forward track points backward. The production solenoid maps in use since 2016 have a positive Bz, so
nothing changes.

The code. The real lines, shortened (on GitHub):

if (FactorForSenseOfRotation*segment->q<0) dphi1+=M_PI;  // field direction handled here

// Find Bz at x,y,zmin
double Bz=bfield->GetBz(x,y,zmin);   // <-- signed: negative in a reversed field

// Momentum
double pt=0.003*Bz*segment->rc;      // pt < 0 turns px, py and pz around
double px=pt*sin(dphi1);
double py=pt*cos(dphi1);
double pz=pt*segment->tanl;

Fixed, as the routine for linked segments does:

double Bz=fabs(bfield->GetBz(x,y,zmin));

What it does (one forward segment, momentum in GeV/c; the charge flips with the field, so both are the same
trajectory):

field now with the fix
+1.9 T (0.1475, -0.0478, 0.3876) (0.1475, -0.0478, 0.3876)
-1.9 T (-0.1489, 0.0434, -0.3876) (0.1489, -0.0434, 0.3876)

The small transverse difference left is a separate slip, with its own finding.

Plot: BH-277: a forward FDC candidate in a reversed field gets pz -0.3876 GeV/c before the fix, +0.3876 after

BH-277. Momentum of one forward FDC segment in both field directions, before and after the fix. Limits: constant
field; no reversed-field data.

Who is affected. Reconstruction or simulation with a reversed solenoid field: single-segment FDC stubs start
backward. The effect on found tracks was not measured.

Who is not. Every run with the standard field direction: 0 of 998 raw events change.

The fix. Use the size of Bz.

Grade S4 (lowest of four): 0 of 998 events of the output change. Benchmark jobs run this line, but with a
positive field the fix changes nothing; the farm run of its group is still being measured.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-34-fdc-cathode-momentum-signed-bz/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-34-fdc-cathode-momentum-signed-bz

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-34b S4 (commit ddf2c90)

FDC track stubs would start off their track in a reversed solenoid field

What is wrong. For an FDC segment linked to no other, the track finder puts the stub's start point 1 cm upstream
of the first hit, stepping along the segment's circle in the direction of the charge alone. A track turns by its
charge and the field direction together, so in a reversed field the step goes the wrong way. The production solenoid
maps in use since 2016 have a positive field, where the fix changes nothing.

The code. The real lines (on GitHub):

double zmin=zhit-dz;                                  // 1 cm upstream of the first hit
double phi1=atan2(yhit-segment->yc,xhit-segment->xc);
double q_over_rc_tanl=segment->q/(segment->rc*segment->tanl);
double dphi_s=dz*q_over_rc_tanl;     // <-- the charge alone sets the turn
double dphi1=phi1-dphi_s;
double x=segment->xc+segment->rc*cos(dphi1);
double y=segment->yc+segment->rc*sin(dphi1);

Fixed, with the field sign the routine already reads (-1 for a positive field):

double dphi_s=-FactorForSenseOfRotation*dz*q_over_rc_tanl;

What it does (one forward segment, start point in cm; the charge flips with the field, so both are the same
trajectory):

field now with the fix
+1.9 T (18.3814, 5.8796, 229.00) (18.3814, 5.8796, 229.00)
-1.9 T (17.6168, 6.1148, 229.00) (18.3814, 5.8796, 229.00)

Plot: BH-278: in a reversed field the start point of a forward FDC stub lands 0.80 cm off before the fix, on the same point after

BH-278. Start point of one forward FDC segment in both field directions, before and after the fix. Limits: constant
field; no reversed-field data.

Who is affected. Reconstruction or simulation with a reversed solenoid field: single-segment FDC stubs start
0.80 cm off their circle for this segment. The effect on found tracks was not measured.

Who is not. Every run with the standard field direction: the fixed line is the same expression there.

The fix. Turn the step with the field sign as well as the charge.

Grade S4 (lowest of four): no output can change with a positive field. A companion finding fixes the stub's
momentum sign in the same routine.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-34b-fdc-cathode-start-step-charge-sign/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-34b-fdc-cathode-start-step-charge-sign

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-39 S4 (commit bb90058)

The swim that picks track hits keeps stale scattering errors in its last step

What is wrong. By default, before the wire-based fit, each track candidate is swum through the detector, and
every step stores running sums of multiple scattering. They set how far a CDC or FDC hit near that step may lie from the track.
When a step leaves the tracking volume, the loop stops before writing these sums. The step memory is reused from track
to track, so the last step keeps the sums of an earlier track.

The code. The real lines, shortened (on GitHub):

if (z>345. || z<0. || Rsq>60.*60.){
  Nswim_steps++; break;        // <-- the last step leaves before its sums are written
}
...
swim_step->itheta02 = itheta02;      // multiple-scattering sums of this step
swim_step->itheta02s = itheta02s;
swim_step->itheta02s2 = itheta02s2;
swim_step->invX0=Nswim_steps/X0sum;

Fixed: the same four lines also inside the exit branch, before the break.

What it does (a direct call with three test tracks; 1000 raw events of a 2025-01 run):

now with the fix
scattering sum of the exit step, pi+ of 0.3 GeV/c 6.8251e-05, from the track before 2.9118e-04, as the step before
the one changed track, release 5.9.0 (better side unknown) chi2 37.42 for 26 degrees of freedom chi2 59.88 for 12

Plot: BH-900: the last swim step keeps an earlier track's scattering sums; tracks change in 0 of 998 events at master, 1 at 5.9.0

BH-900. Exit-step scattering sums of three test tracks, and the tracks that change in 1000 raw events of a 2025-01
run, today and with the fix. Limits: one run.

Who is affected. Wire-based track fits, for a hit whose nearest step is the exit step: rare, one event in 998 at
release 5.9.0 and none at master.

Who is not. All other hits. No benchmark reaction moves beyond the run-to-run noise (1 000 000 raw events).

The fix. Write the sums for the last step too.

Grade S4 (lowest of four): tracks change in 0 of 998 events of the output at master and in 1 of 998 at release
5.9.0, under 1%.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-39-fastswim-last-step-stale-scattering/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-39-fastswim-last-step-stale-scattering

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-43a S4 (commit f1bd19a)

A forward swim to a line gains momentum where it should lose it

What is wrong. A tracking routine swims a track to its closest approach to a line and corrects the momentum for
the energy lost in the material on the way. The direction of the swim enters twice, once in the sign of the loss rate
and once in the sign of the step, so the two cancel. A backward swim regains momentum, as it should; a forward swim
gains momentum too. The reconstruction only swims backward with it.

The code. The real lines, shortened (on GitHub):

if (ploss_direction==kBackward) my_step_size*=-1.;   // backward: the step is negative
...
double ds=stepper.Step(NULL);
...
double ptot=mymom.Mag();
ptot+=dP_dx*ds;     // <-- the loss rate is already negative for a backward swim:
                    //     the signs cancel, and a forward swim adds the loss

// in the loss rate:  if(ploss_direction==kBackward)dP_dx = -dP_dx;

Fixed:

ptot-=dP_dx*fabs(ds);

What it does (a 1 GeV/c pi+ swum 40 cm through the field and material of a 2025-01 run):

change of momentum now with the fix
forward swim, should drop +2.317 MeV/c -2.317 MeV/c
backward swim, should rise +2.760 MeV/c +2.760 MeV/c

Plot: BH-902: a forward swim gains 2.317 MeV/c today; the backward swim is right before and after the fix

BH-902. Momentum change over the two test swims, today and with the fix. Limits: constructed tracks, no event data.

Who is affected. Nobody today. Code that would swim forward with this routine, in a plugin or a later change,
would add the energy loss.

Who is not. Reconstruction, REST files and analyses: the track factories swim backward only, and 0 of 998 raw
events change with the fix.

The fix. Take the direction from the loss rate alone.

Grade S4 (lowest of four): 0 of 998 events of the output change; no caller takes the wrong branch. Measured
together with 12 other tracking fixes on 1 000 000 raw events; none of the seven benchmark reactions moved.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-43a-fastswim-forward-gains-momentum/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43a-fastswim-forward-gains-momentum

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-43b S4 (commit ba2b859)

An unused energy-loss correction of the track fitter swims the wrong way

What is wrong. A routine of the track fitter carries a track from its first wire back to the target and puts back
the momentum lost in the material. It asks for a backward swim, which already steps backward, and also reverses the
momentum and the charge. The direction is reversed twice, so the swim runs outward from the wire. The routine's only
call is commented out.

The code. The real lines (on GitHub):

// Swim backwards to target, setting momentum to *increase* due to material
rt->SetMass(mass);
rt->SetPLossDirection(DReferenceTrajectory::kBackward);   // this already steps backward
rt->FastSwim(pos,-mom,pos,mom,-starting_params.charge(), 1000.0,
             &target);                // <-- momentum and charge reversed: a second reversal
rt->SetPLossDirection(DReferenceTrajectory::kForward);

// Reverse momentum
mom = -mom;

Fixed:

rt->FastSwim(pos,mom,pos,mom,starting_params.charge(), 1000.0,
             &target);                // and no reversal of mom afterwards

What it does (four test tracks from the beam line to a wire 20 cm out, then back):

returned point now with the fix
distance from the beam line, where the track started 20.39 to 22.15 cm 0.04 to 0.12 cm
cosine to the start direction 0.9364 to 0.9797 1.0000

Plot: BH-903: today the swim back ends near the wire; with the fix it returns to the start

BH-903. Returned point of four test tracks, today and with the fix. Limits: constructed tracks, no event data.

Who is affected. Nobody today. Turned back on as it stands, the call would return a point near the first wire,
as in all four test tracks.

Who is not. Reconstruction, REST files and analyses: the track factories use their own energy-loss corrections,
and this routine runs in no event.

The fix. Keep the backward swim and drop the two manual reversals.

Grade S4 (lowest of four): the routine runs in no event of the program's samples. Measured together with 12
other tracking fixes on 1 000 000 raw events; none of the seven benchmark reactions moved.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-43b-correctforeloss-direction-reversed-twice/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43b-correctforeloss-direction-reversed-twice

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-43c S4 (commit 69eba1b)

A swim that carries a track's errors uses the start point at every step

What is wrong. The tracking swim can carry a track's error matrix along the track, step by step. Each step should
use the track's position and momentum at that step; the code uses the ones at the start of the swim. As the track
turns in the field, its errors keep being carried along the first direction. No caller passes an error matrix, so
this code never runs today.

The code. The real lines, shortened (on GitHub):

void DReferenceTrajectory::Swim(const DVector3 &pos, const DVector3 &mom, double q,
                                const TMatrixFSym *cov, ...)
...
    double ds=stepper.Step(NULL,&swim_step->B);
    if (cov){
      PropagateCovariance(ds,q,mass_sq,mom,pos,swim_step->B,mycov);
                          // <-- mom, pos: the arguments, the start of the swim
      swim_step->cov_t_t=mycov(6,6);
      ...
    }

Fixed:

      PropagateCovariance(ds,q,mass_sq,swim_step->mom,swim_step->origin,swim_step->B,mycov);

What it does (a 0.15 GeV/c pi+ in 2 T, momentum error 0.01 GeV/c across the start direction; the exact
flight-time variance is 0):

flight-time variance after now with the fix
10.1 cm 8.1063e-06 ns2 4.5e-12 ns2
140.1 cm, most of a turn 3.0571e-01 ns2 1.4e-07 ns2

Plot: BH-904: an error across the momentum should give no flight-time variance; today it grows along the turn

BH-904. Flight-time variance at four points of the swim, for an error along and across the start momentum: exact,
today, with the fix. Along p the fix is up to 0.4% low, the accuracy of the step-by-step propagation. Limits: one
constructed track, constant field.

Who is affected. Nobody today. A caller that passes an error matrix would get flight-time errors that grow with
the turning angle.

Who is not. Reconstruction, REST files and analyses: every caller swims without an error matrix.

The fix. Pass the position and momentum of the current step.

Grade S4 (lowest of four): the code runs in no event of the program's samples. Measured together with 12 other
tracking fixes on 1 000 000 raw events; none of the seven benchmark reactions moved.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-43c-swim-covariance-start-state/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43c-swim-covariance-start-state

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-43e S4 (commit 787684f)

Length of a track inside a CDC straw comes from the wrong quadratic

What is wrong. A tracking routine returns the length of track inside one CDC straw: it finds the two points where
the straight track line enters and leaves the straw's cylinder and measures between them. Each of the three
coefficients of that quadratic misses a square or a factor 2, so the two points and the length are wrong. One optional
plugin calls the routine; the reconstruction does not.

The code. The real lines, shortened (on GitHub):

DVector3 A = udir.Cross(pos-wire->origin);   // track point, seen across the wire
DVector3 B = udir.Cross(momdir);              // track direction, seen across the wire
...
double a = B.Mag();             // <-- needs |B| squared
double b = A.Dot(B);            // <-- needs 2 A.B
double c = A.Mag() - radius;    // <-- needs |A| squared minus radius squared
double d = sqrt(b*b - 4.0*a*c);

Fixed:

double a = B.Mag2();
double b = 2.0*A.Dot(B);
double c = A.Mag2() - radius*radius;

What it does (straight test tracks past a wire, straw radius 0.8 cm):

track exact chord now with the fix
0.027 cm from the wire, at right angles 1.5991 cm 1.7584 cm 1.5991 cm
0.48 cm from the wire, at 45 deg 1.8082 cm 1.3435 cm 1.8082 cm

Plot: BH-906: the length in the straw is wrong in all five test crossings; the fix gives the exact chord

BH-906. Length in the straw for five constructed crossings: exact chord, today, with the fix. Limits: test tracks,
no event data.

Who is affected. Users of the optional plugin cdc_hists on simulated events: it writes this length for each CDC
hit near the thrown track into its hit tree, and its dE/dx histograms divide the charge by it.

Who is not. Reconstruction, REST files and analyses: no library calls the routine, and no default build
includes the plugin.

The fix. Use the three coefficients of a line crossing a cylinder.

Grade S4 (lowest of four): unused path; no default build includes the only caller. Measured together with 12
other tracking fixes on 1 000 000 raw events; no benchmark reaction moved.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-43e-straw-dx-wrong-quadratic/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43e-straw-dx-wrong-quadratic

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-43f S4 (commit cd9499a)


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-43f-reftraj-assignment-keeps-small-buffer/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43f-reftraj-assignment-keeps-small-buffer

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-43g S4 (commit f011d63)


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-43g-intersection-reads-empty-trajectory/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-43g-intersection-reads-empty-trajectory

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-55 S4 (commit 1ca8ce7)


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-55-helicalfit-dzdphi-local-hides-member/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-55-helicalfit-dzdphi-local-hides-member

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-57 S4 (commit 6603535)

The truth-based hit selector gives every track the hits of the last thrown particle

What is wrong. In simulation one can switch on a hit selector that uses the truth: each track gets the hits of the
thrown particle closest to it in momentum and angles. The search for that particle never stores the best match found
so far, so it returns the last thrown particle that is not far off, nearly always the last one in the list. Every
track of the event then gets that one particle's hits.

The code. The real lines, shortened (on GitHub):

int myid = 0;
double min_chisq=1.0E8;
for(unsigned int i=0; i<throwns.size(); i++){
    ...
    double chisq = pow(delta_pt/0.04, 2.0) + pow(delta_theta/20.0, 2.0) + pow(delta_phi/20.0, 2.0);
    if(chisq<min_chisq)myid = thrown->myid;   // <-- min_chisq is never lowered
}
return myid;

Fixed:

    if(chisq<min_chisq){ min_chisq = chisq; myid = thrown->myid; }

What it does (1000 simulated events, 16607 searches; hits looked up as the companion fix does, in both columns):

now with the fix
searches that pick the closest particle 934 16607
truth hits owned by the picked particles 78314 266643
time-based tracks 13060 13850
wire-based fit chi2 per degree of freedom, paired change -0.113 ± 0.019

Plot: BH-1278: the truth-based selector picks the closest thrown particle in 934 of 16607 searches before the fix

BH-1278. Choices of the selector in 1000 simulated events, before and after the fix. Limits: one generator.

Who is affected. Simulation studies that switch this selector on, to separate hit finding from fitting.

Who is not. The standard reconstruction and real data: they never use this selector.

The fix. Store the best match. It ships with the companion fix, which looks the hits up by the thrown particle's
number: alone, this fix loses 7% of the time-based tracks.

Grade S2 (second of four; S1 is the most severe), on jobs that choose this selector: tracks change in 287 of 1000
events with this fix alone, and the time-based track count by 7%.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-57-thrown-hit-selector-min-chisq-never-updated/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-57-thrown-hit-selector-min-chisq-never-updated

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-61 S4 (commit 94e9139)


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-61-thrown-hit-selector-filters-geant4-track/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-61-thrown-hit-selector-filters-geant4-track

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-66 S4 (commit cd5788e)

Simulated (thrown) tracks ask for the magnetic field of run 1, not of the event's run

What is wrong. The code that refits the generated (thrown) tracks asks for the magnetic field without naming a run, so it gets the field of run 1. Every other tracking code names the event's run. Today a service quirk hides this by returning a second copy of the right map; once that is fixed, these tracks get no field.

The code (on GitHub):

bfield = geo_manager->GetBfield();                // run 1 (the default argument)
bfield = geo_manager->GetBfield(runnumber);       // the fix: the event's run, as the other factories

What it does (run 132404):

request field returned cost
today, as coded second copy of the run's map +325 MB, 2.2 s
service fixed, as coded no field: Bz 0 against 1.6238 T zero field
either build, with this fix the run's own map none

Plot: Service fixed: coded request gets no field, fixed request the run map

Limits: the factory was not compiled; its two calls were run on the geometry service.

Who is affected. Simulation jobs with a plugin that asks for the refit thrown tracks.

Who is not. Raw-data jobs and the standard simulation benchmark jobs.

The fix. Pass the event's run to the field request; merge it with the geometry-service fix.

Grade S4: today no output changes; the cost is memory and 2 s per job.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-66-thrown-tracks-take-field-of-run-1/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-66-thrown-tracks-take-field-of-run-1

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

R3-15b S4 (commit 09c68c4)

Dense CDC regions are stored over the wrong stretch of angle, so they can miss the seeds they should cover

What is wrong. Where the CDC hits of one super layer are too dense, the track finder drops the track seeds there
and stores that stretch of azimuth, so that the outer super layers start no new track in it. It takes the stretch
from the first to the last dropped seed in the order the seeds were numbered, and that order is not the order in
angle. The stored stretch can then be a sliver that misses most of the dense group. This sits on top of the earlier
finding that stores the stretches under the wrong layer; the two fixes ship together.

The code (on GitHub), with the earlier fix in place:

for(; locRejectIterator != locSeedsToReject.end(); ++locRejectIterator)  // dropped seeds, by number
{
    ...
    // a new group starts here: store the stretch of the group that ended
    dRejectedPhiRegions[locSuperLayer].push_back(pair<double, double>(
        locMapPhiRanges[locBeginIndex].first,         // <-- first angle of the first seed by number
        locMapPhiRanges[locPreviousIndex].second));   // <-- last angle of the last seed by number
    ...
}

With the fix each group keeps the smallest arc that holds every one of its seeds, and stores that.

What it does (1000 raw events of a 2025-01 run, 17 dense super layers):

earlier fix alone with this fix
dense super layers with dropped seeds outside the stretch 6 of 17 0 of 17
worst case: width of the stretch, seeds inside 0.009 rad, 0 of 17 0.71 rad, 17 of 17
events with changed track candidates 2 of 998

Plot: BH-1301: dense CDC regions, dropped seeds outside the stored stretch in 6 of 17 super layers today, 0 with the fix

BH-1301. The six dense super layers whose stretch changes. Limits: one run at 2025-01 rate; with the fix 5 of the 6
stretches cover nearly the whole circle, which follows from how the finder computes a seed's range near azimuth 0
(open for the authors).

Who is affected.

  • Track finding in events with dense CDC hits, in the 2025-01 pass (release 5.9.0) and in master, once the earlier
    fix makes the finder read the stretches.

Who is not. Physics analyses at 2025-01 rate: with both fixes no benchmark reaction moves beyond the run-to-run
noise (1M raw events).

The fix. Store, per dense group, the smallest arc that holds all its seeds.

Grade S4 (lowest of four): track candidates change in 2 of 998 events (0.2%). It says nothing about physics weight.


Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r3-15b-cdc-rejected-region-index-order-not-phi/index.html
Evidence folder (tests, patches, review): https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TRACKING/r3-15b-cdc-rejected-region-index-order-not-phi

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@DraTeots

DraTeots commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

This pull request was split out of #1259 at your request. It collects the 22 minor (S4) tracking findings, from R3-11 (9241a293d) to R3-15b (09c68c4ac). Each is the commit of #1259 unchanged, cherry-picked onto the current master without conflicts. The changed files pass a syntax-only compile against the release headers. The branch merges with #1259 without conflict in either order, although both edit some of the same files.


Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)

@gluex

gluex commented Dec 1, 2026

Copy link
Copy Markdown

Test status for this pull request: SUCCESS

Summary: summary.txt
Logs: results/log

Build log: make_auto-hunt_tracking-s4.log
Build report: report_auto-hunt_tracking-s4.txt

@nsjarvis nsjarvis removed their assignment Dec 2, 2026

@staylorjlab staylorjlab 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.

R3-13: Yes, this fixes a mix-up between tan(lambda) and lambda.

@staylorjlab staylorjlab 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.

R3-34, R3-34b. These are fine. We don't plan to reverse the solenoid field, but the consistency with other parts of the code is improved.

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.

4 participants