Repository navigation
auto-hunt: TOF - 9 fixes (S1 1, S2 2, S4 6) - #1257
Conversation
Three lines in `DTOFHit_factory::BeginRun` (`libraries/TOF/DTOFHit_factory.cc`), before the walk-correction type is read: `USE_AMP_4WALKCORR`, `USE_NEWAMP_4WALKCORR` and `USE_NEW_WALK_NEW` are set to 0. The switch below then sets the one flag of the current run, as `Init` does for the first run. This is the minimal change: the flags are members, they are set only in that switch, and nothing else reads them before it. Type 1 keeps its meaning (no flag set, integral correction). `patches/master.patch` applies unchanged to release 5.9.0 (the file is identical there). Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-9c-tof-walk-flags-kept-across-runs/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r4-9c-tof-walk-flags-kept-across-runs Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed out) `patches/master.patch` restores the commented-out `continue` under `TOF:CHECK_FADC_ERRORS` in `DTOFHit_factory.cc`, so the switch does what its text says, as in the other detectors. It also drops overflowed in-time pulses (81 of the 83 TOF points above 0.0193 GeV). If the TOF experts keep the flagged pulses (the factory handles zero-peak and overflow pulses further on), the change should instead set the default to false or remove the switch. Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-12-tof-fadc-error-check-disabled/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r4-12-tof-fadc-error-check-disabled Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…her end of the same bar has any hit, even one outside the time coincidence, so neither a two-ended nor a one-ended paddle hit is made from i `libraries/TOF/DTOFPaddleHit_factory.cc`: the four "no match on the other end" loops use the pairing condition (same bar, time difference below `TIME_COINCIDENCE_CUT`, one end above `E_THRESHOLD`) instead of "same bar". A hit then becomes a one-ended paddle hit exactly when it was not paired, as the factory's comment says. Four conditions, no other line. The patch applies to release 5.9.0 unchanged. Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-28-tof-one-ended-hit-dropped-unpaired-partner/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r4-28-tof-one-ended-hit-dropped-unpaired-partner Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TOF/DTOFPaddleHit_factory.cc`, `BeginRun`: two lines set `TOF_POINT_TAG` to the empty tag and register it as `TOF:TOF_POINT_TAG`, the name the header documents. With the parameter unset the factory reads the untagged DTOFHit objects as before. The patch applies unchanged to release 5.9.0. Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-13-tof-point-tag-never-registered/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r4-13-tof-point-tag-never-registered Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hit twice and no ADC digihit `libraries/TOF/DTOFHit_factory.cc`, the duplicate branch of `Process`: the copy takes the ADC digihit of the hit it is copied from (`hit->GetSingle(adcdigihit)`) in place of the TDC digihit, which the common code after the branch associates anyway. Nothing else changes. `patches/master.patch` applies unchanged to release 5.9.0. Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-16-tof-duplicate-hit-no-adc-digihit/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r4-16-tof-duplicate-hit-no-adc-digihit Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TOF/DTOFPoint_factory.cc`, end of `Process`: the walk over the pointer set is replaced by two loops over the horizontal and the vertical spacetime-hit lists, in their insertion order. A hit makes an unmatched point when it is still in the unused set. The set itself and the time sort stay. The output no longer depends on the pointer values. The patch applies to release 5.9.0 without offset. Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-21c-tof-unmatched-points-pointer-order/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r4-21c-tof-unmatched-points-pointer-order Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…TOF flags, CDC DIGI_THRESHOLD) `COSMIC_DATA`, `OVERRIDE_HIGH_TIME_CUT`, `OVERRIDE_LOW_TIME_CUT` and `TOF_DEBUG` move from file scope in `libraries/TOF/DTOFHit_factory.cc` to members of `DTOFHit_factory` (declared in `DTOFHit_factory.h` with the same defaults). `DIGI_THRESHOLD` moves from file scope in `libraries/CDC/DCDCHit_factory.cc` to a member of `DCDCHit_factory`. Each thread's factory then writes and reads its own copy, which is what JANA's one instance per thread intends. No line that uses the names changes. `TOF_DEBUG` is named in no other file of halld_recon. `patches/master.patch` applies at master and at release 5.9.0 without offset (the four files are the same there, byte for byte). Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-21d-tof-cdc-statics-written-per-thread/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r4-21d-tof-cdc-statics-written-per-thread Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ype is missing, before FillCalibTable `patches/master.patch`, one line in `libraries/TOF/DTOFHit_factory.cc`: the plain `return` after "Error loading <dir>/walkcorr_type" becomes a `JException` that names the table and the run. JANA1 returned error 101 here; the throw is the JANA2 way to report an error from `BeginRun`. The run no longer goes on with the tables of the previous run or with empty ones. The authors may prefer to go on without walk correction. That needs the time offsets loaded outside the switch on the walk type, a larger change, and the run would then be processed with a partial calibration. Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-24-tof-walkcorr-missing-plain-return/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r4-24-tof-walkcorr-missing-plain-return Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o ForwardTOF (run 0 of a BOR-only skim), and segfaults `libraries/TOF/DTOFGeometry.cc`: after the three XPath queries, the constructor checks that each returned at least three values and throws a `JException` naming the missing ForwardTOF position otherwise. This is the minimal change: the constructor cannot work without the position, and an exception lets JANA report the cause and stop cleanly. `patches/master.patch` applies at master and at release 5.9.0. Card: https://pages.jlab.org/halld/auto-hunt/cards/r6-29-tof-geometry-missing-forwardtof-segfault/index.html Evidence folder: https://code.jlab.org/halld/auto-hunt/-/tree/main/bughunt/confirmed/halld_recon/TOF/r6-29-tof-geometry-missing-forwardtof-segfault Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
R4-9c S1 (commit e2487fc)In a job over two run periods, the TOF keeps the first run's time-walk correction and crashesWhat is wrong. At each run start the TOF hit step reads which time-walk correction the run uses and switches The code, shortened (on GitHub): Fixed, before the switch: What it does (raw data, 300 events of run 51030 then 300 of run 132404 in one job):
BH-928. Against the run alone. Bars 23-46 use the first run's channel map, another finding. Who is affected. Raw-data jobs over several runs that read a 2017 or 2018 run and then a run of the 46-bar TOF: Who is not.
The fix. Switch all three corrections off before choosing one. Grade S1 (most severe of four): such a job crashes. Jobs over one run, or over 2025 runs only, are not Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r4-9c-tof-walk-flags-kept-across-runs/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
R4-12 S2 (commit 4f9edd2)The TOF switch that rejects faulty ADC pulses does nothingWhat is wrong. The TOF has a switch, on by default, documented to drop ADC pulses the fADC250 flags as faulty. The code, shortened (on GitHub): Fixed as measured here: What it does (1000 events of a 2025-01 run):
Benchmark reactions with the line restored: 1M raw events of run 132404, master; same events, σ from events gained and lost:
Not moving: π⁰ → γγ, η → γγ, e⁺e⁻ and ω → π⁰γ (below 3σ: at most +0.3%, 0.8σ). Plot: BH-81: 1694 of 25905 TOF ADC pulses are flagged, and 1254 of them are used anyway BH-81. TOF ADC pulse times, 1000 raw events of a 2025-01 run: top, not flagged; bottom, flagged by the fADC. Limits: one run; which side is right is open. Most flagged pulses are random late pulses cut by the window end; the rest are in-time pulses that Who is affected.
Who is not. Simulation, which never runs this code. Photon reactions: net yields move by 2 events or less. The fix. For the TOF experts: restore the line, or keep the pulses and make the switch say so. Grade S2 (second of four levels of how widely an output moves) if the line is restored: TOF points change by Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r4-12-tof-fadc-error-check-disabled/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
R4-28 S2 (commit e45ca56)A TOF hit is lost when the other end of its bar fired at another timeWhat is wrong. A TOF bar is read at both ends. Two end hits close in time make a two-ended paddle hit; a hit The code. Shortened; the test stands four times (on GitHub): Fixed, with the pairing condition: What it does. Run 132404 (2025-01), 1000 raw events, 997 in both TOF printouts:
Benchmark reactions: No benchmark reaction moves beyond the run-to-run noise (1M raw events). BH-564. Each lost hit by its time to the other end of its bar. Orange: the bar gives no paddle hit today. Grey: an Who is affected. Studies of TOF paddle hits, efficiency and timing. Who is hardly affected. Track matching and charged-particle timing: one hypothesis of 10510 changes. The The fix. Count only an in-time partner as a match. Open: are late extra pulses particles or Grade S2 (second of four levels, S1 the most severe): the TOF paddle-hit count moves by +2.7%, over the 1% of Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r4-28-tof-one-ended-hit-dropped-unpaired-partner/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
R4-13 S4 (commit e17f837)The documented option to build TOF points from unsmeared simulated hits does nothingWhat is wrong. The TOF paddle-hit code documents an option, TOF:TOF_POINT_TAG=TRUTH, that makes it build TOF The code, shortened (on GitHub): Fixed, at the start of each run: What it does (1000 simulated events, option set to TRUTH):
BH-931. TOF point time with the option set: today, with the fix, and today without the option. Last bin: all Who is affected. Simulation studies that set the option to separate the TOF resolution from the Who is not.
The fix. Register the option the header describes. With the fix, 22% fewer points are built, mostly points seen in one TOF plane only, and the late points (above Grade S4 (lowest of four): an unused path. The option is not registered, so no job reaches the unsmeared Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r4-13-tof-point-tag-never-registered/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
R4-16 S4 (commit 1406e31)A TOF hit copied for a second TDC time loses the link to its ADC pulseWhat is wrong. When a second TDC time on one TOF bar end matches an ADC pulse that already has a TDC time, the The code, shortened (on GitHub): Fixed: What it does (the real hit step, one event with two TDC times on one bar end):
In 10 000 raw events of a 2025-01 run such a copy is made 4 times. Plot: BH-951: the copied TOF hit has 0 ADC links today and 1 with the fix BH-951. Raw records linked to each TOF hit of the bar end, today and with the fix. Who is affected. Code that follows a TOF hit back to its raw ADC record: a TOF online-monitoring plugin Who is not. Reconstruction, REST files and analyses: no reconstruction step reads this link, and the physics The fix. Link the copy to the ADC record of the hit it copies. Grade S4 (lowest of four): at most 4 of 10 000 events, and only a link that monitoring and a writer option Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r4-16-tof-duplicate-hit-no-adc-digihit/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
R4-21c S4 (commit b2b1923)TOF points with exactly equal times come out in an order set by memory addressesWhat is wrong. A TOF bar hit with no partner in the other plane becomes an unmatched TOF point. The code makes The code, shortened (on GitHub): Fixed: walk the horizontal, then the vertical hit list in hit order, and make a point from each hit still unused. What it does (the point step run three times on one event: three unmatched bars, equal times):
No benchmark reaction moves beyond the run-to-run noise (1M raw events). Plot: BH-954: the same event gives bars 5, 20, 35, then 35, 20, 5 today; 5, 20, 35 every time with the fix BH-954. Order of the unmatched TOF points when the step sees the same event three times. Who is affected. Code that takes the first of several TOF points with exactly equal times, and checks that Who is not. The content of every TOF point, the track-to-TOF match (it picks the closest point), and the physics The fix. Make unmatched points in hit order. Grade S4 (lowest of four): only the order of equal-time points changes; the benchmarks do not move. Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r4-21c-tof-unmatched-points-pointer-order/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
R4-21d S4 (commit 99f046e)TOF and CDC hit settings are shared by all threads, and every thread rewrites them at start-upWhat is wrong. The TOF and CDC hit steps keep a few user settings (the TOF time-cut overrides, cosmic mode and The code, TOF, shortened (on GitHub): Fixed: the four TOF variables and the CDC threshold become members of the step, one copy per thread. What it does (16 threads, 1000 raw events of a 2025-01 run, thread checker):
At 4 threads no report showed. The outputs of the two sides were not compared. Plot: BH-952: 4 data-race reports with 16 threads today, 0 with the fix BH-952. Thread-checker reports with an access in the TOF or CDC hit step, today and with the fix. Who is affected. Every multi-threaded job that makes TOF or CDC hits, production included, with no output change Who is not. One-thread jobs, the physics benchmark jobs among them: they cannot show a race. The fix. Make the settings members of each step. Grade S4 (lowest of four): no output change is expected in any event; the finding is the race itself. Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r4-21d-tof-cdc-statics-written-per-thread/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
R4-24 S4 (commit 1715711)Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r4-24-tof-walkcorr-missing-plain-return/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
|
Build status for this pull request: FAILURE Build log: make_auto-hunt_tof.log |
R6-29 S4 (commit a6a5ac8)Full card with plots and the evidence for the code owner: https://pages.jlab.org/halld/auto-hunt/cards/r6-29-tof-geometry-missing-forwardtof-segfault/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
|
R4-16: my first look at this particular issue suggests that the original code is correct and there is no problem.
|
|
R4-9c S1: I concur with the assessment and the proposed fix. However, this behavior would only happen if some analyzer would analyze two files from two different runs from two different run periods which certainly will never happen. But, from a "good programming" point of view this "bug" should be fixed. |
|
R4-12 S2: yes agree. |
|
R4-28 S2: yes, there needs to be an additional time difference condition added at each of the four conditions. with: if (bar==P1hitsR[j]->bar I propose to not use Energy Cut condition as there will be such a condition applied when forming the single end paddle HIT as follows: |
|
R4-13 S4: No, the flaged code should be REMOVED from the code base. The use of such a variable would imply that a factory with the TAG equals to TOF_POINT_TAG like "TRUTH" exists. However, this is not the case. So the proposal here is to remove the string definition TOF_POINT_TAG from the header file and remove its usage in the cc code. |
|
R4-16 S4: yes, agreed. The fix looks fine. |
|
R4-21c S4: Not pretending to understand the code the new proposed code looks more readable and understandable. |
|
R4-21d S4: YES, Defining variables at the top of the code in DTOFHit_factory.cc outside of any block is bad. This makes them "global" variables: Similarly in DCDCHit_factory.cc at outside of any code block there is the definition: why this code would interfere with each other is unclear but the coding is definitely not good. removal of these static global variables and put them into the class definitions in the header files is a good move. |
|
R4 -24: S4: YES, the code just terminate with a useful message if the walk correction type is not given. |
…dence only, no energy threshold `libraries/TOF/DTOFPaddleHit_factory.cc`: as the reviewer proposed, each of the four "no match on the other end" loops counts a hit on the other end as a match when it is on the same bar and within `TIME_COINCIDENCE_CUT`. The energy-threshold term of the first version is dropped: the one-ended paddle hit is made only above `E_THRESHOLD` anyway, so the result is the same. Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-28-tof-one-ended-hit-dropped-unpaired-partner/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`libraries/TOF/DTOFPaddleHit_factory.h` and `.cc`: as the reviewer asked, the `TOF_POINT_TAG` member, the header comment that documents `-PTOF:TOF_POINT_TAG=TRUTH`, and the parameter registration added by the first version of this fix are removed. The factory reads the untagged DTOFHit objects (`event->Get(hits)`), which is what every job did before, since the tag was always empty. Card: https://pages.jlab.org/halld/auto-hunt/cards/r4-13-tof-point-tag-never-registered/index.html Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
R6-29 S4: Yes, rather than just let the code crash, terminate it nicely when the TOF geometry is not found. |
|
Test status for this pull request: SUCCESS Summary: summary.txt Build log: make_auto-hunt_tof.log |
|
Thank you for the review. Two commits are added on top of the branch, no force-push:
For R4-13, one note: Checked with a syntax-only compile of every changed TOF and CDC source file against the release headers. All pass. The earlier CI failure was the clone step (the "/" in the branch name), which has since been fixed in the CI scripts. The new push should start a fresh build. Created by Autonomous HallD "auto-hunt" campaign (executed by Claude) |
Yes, upon closer look, the issue is recognized. Indeed the wrong object is added as associated object. It should be the ADC object and not the tdc object. => using the same name for two different object types is not a good idea. |
|
I think all changes now are ready for merge. |
zihlmann
left a comment
There was a problem hiding this comment.
Code was not tested but reviewed and deemed ok.
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
Overall gains
9 confirmed bugs fixed in this pull request (S1 1, S2 2, S4 6), one commit each, in the order of the commits (most serious first).
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)