Skip to content

R4-20: unused GetConstant overloads with off-by-one indexing (FDC, SC, TOF) - #1271

Merged
zihlmann merged 2 commits into
masterfrom
auto-hunt/getconstant-r4-20
Dec 3, 2026
Merged

zihlmann merged 2 commits into
masterfrom
auto-hunt/getconstant-r4-20

Conversation

@DraTeots

@DraTeots DraTeots commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Some GetConstant overloads index their tables off by one:

  • DFDCHit_factory::GetConstant (gPlane, element) and (DFDCHit): the element bound reads the_table[gPlane] while the value is read at the_table[gPlane-1]. One more hunk fixes the BeginRun wire-count error message, which printed the size of another chamber's entry (message only).
  • DSCHit_factory::GetConstant (DSCDigiHit) and (DSCHit): sectors are checked as 0..MAX_SECTORS-1 and read at sector, while sectors are numbered 1..MAX_SECTORS. Now checked as 1..MAX_SECTORS and read at sector-1.
  • DTOFHit_factory::GetConstant (plane, bar, end): planes are now checked as 0..TOF_NUM_PLANES-1 and bars read at bar-1.

The indexing then matches the factories' own processing paths.

None of these overloads has a caller in halld_recon. Every GetConstant hit in the three factories is a definition, a declaration or an error message, except the TOF calls with a digihit, which use other overloads that this PR does not touch:

$ grep -rn 'GetConstant' src | grep -E 'DFDCHit_factory|DSCHit_factory|DTOFHit_factory' \
    | grep -v -E 'sprintf|::GetConstant\(|const double GetConstant|// GetConstant'
src/libraries/TOF/DTOFHit_factory.cc:397:    int adc_quality = GetConstant(adc_bad_channels,digihit);
src/libraries/TOF/DTOFHit_factory.cc:435:    double pedestal = GetConstant(adc_pedestals, digihit); // get mean pedestal from DB in case we need it
src/libraries/TOF/DTOFHit_factory.cc:479:    T =  t_scale * T - GetConstant(adc_time_offsets, digihit) + t_base;
src/libraries/TOF/DTOFHit_factory.cc:526:      << GetConstant(adc_time_offsets, digihit) << " " 
src/libraries/TOF/DTOFHit_factory.cc:527:      << t_scale*GetConstant(adc_time_offsets, digihit) << " " << hit->t << endl;
src/libraries/TOF/DTOFHit_factory.cc:547:      int tdc_quality = GetConstant(tdc_bad_channels,digihit);
src/libraries/TOF/DTOFHit_factory.cc:555:      T += t_base_tdc - GetConstant(tdc_time_offsets, digihit) + tdc_adc_time_offset;
src/libraries/TOF/DTOFHit_factory.cc:562:	<< T << "  " << GetConstant(tdc_time_offsets, digihit) << endl;

Nothing in the tree calls a GetConstant through an object or pointer:

$ grep -rnE '(->|\.)\s*GetConstant\s*\(' src
$

No output changes. The fix is kept so that a future caller gets the right element.

This was split from #1236 at the CDC expert's request: that PR now changes only CDC code, and there the unused DCDCHit_factory_Calib::GetConstant overloads are removed instead of fixed.

Created by Autonomous HallD "auto-hunt" campaign (executed by Claude)
🤖 Generated with Claude Code

…SC, TOF)

- `libraries/FDC/DFDCHit_factory.cc`, two overloads: the element bound is `the_table[gPlane-1].size()`. One more
  hunk corrects the error message of the wire-count check in `BeginRun`, which printed the size of another chamber's
  entry (message only).
- `libraries/START_COUNTER/DSCHit_factory.cc`, two overloads: sectors are checked as 1..`MAX_SECTORS` and read at
  `sector-1`.
- `libraries/TOF/DTOFHit_factory.cc`, the plane, bar, end overload: planes are checked as 0..`TOF_NUM_PLANES`-1 and
  bars read at `bar-1`.

The indexing then matches the factories' own processing paths. These overloads have no callers in halld_recon today.
Split from #1236, which now carries only the CDC part (the CDC overloads are removed there).

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

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

gluex commented Dec 2, 2026

Copy link
Copy Markdown

Test status for this pull request: SUCCESS

Summary: summary.txt
Logs: results/log

Build log: make_auto-hunt_getconstant-r4-20.log
Build report: report_auto-hunt_getconstant-r4-20.txt

@zihlmann

zihlmann commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

in DFDCHit_factory.cc and DFDCHit_factory.h the method GetConstant() and all its overloaded methods are not use at all anywhere, so it can simply be removed from the code base.

same in DSCHit_factory.cc and DSCHit_factory.h, the method GetConstat() and all its overloaded methods are never used anywhere, so it can be removed.

in DTOFHit_factory.cc and DTOFHit_factory.h the GetConstant() method is used in all cases where the overloded method only takes two input parameters. The case where GetConstant() requires four input parameters is not used anywhere in the code base and can be removed.

@zihlmann zihlmann self-assigned this Dec 2, 2026
… unused 4-argument TOF overload

As the TOF expert asked in #1271: no code calls them.

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

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

DraTeots commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Thank you. Done in 32ec53e, as you suggested:

  • FDC: all DFDCHit_factory::GetConstant() overloads removed (declarations, definitions and the commented-out translation-table version).
  • SC: all DSCHit_factory::GetConstant() overloads removed, the same way.
  • TOF: only the four-argument GetConstant(table, plane, bar, end) removed; the overloads in use stay.

No other code calls the removed methods. The three files pass a compile check; nothing was run.

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

@gluex

gluex commented Dec 3, 2026

Copy link
Copy Markdown

Test status for this pull request: SUCCESS

Summary: summary.txt
Logs: results/log

Build log: make_auto-hunt_getconstant-r4-20.log
Build report: report_auto-hunt_getconstant-r4-20.txt

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

the changes look as expected.

@zihlmann
zihlmann merged commit 5beb448 into master Dec 3, 2026
2 checks passed
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.

3 participants