Where
What happens
GainCorrTable::Entry defaults to avg = 1.f. LoadGainCorrTimeSeries writes only b.corr.w[wi + 1], and no code anywhere writes GainCorrTable::g[]. As a result, gain_corr.g[id].avg is 1.0 for every PbGlass module in every batch of every run.
The effect:
- The raw replay writes
gain_factor = 1.0 for all 576 PbGlass channels (the count comes from database/hycal_map.json).
- Reconstruction (
ProcessWithRecon, ProcessRaw2Recon) feeds PbGlass hits to the clusterer with no LMS gain-drift correction.
- In
ProcessRaw2Recon, the gain == 1.0f fallback to in->gain_factor[j] finds 1.0 there as well.
The comment in Replay.cpp ("Gain correction is HyCal-only (PbGlass / PbWO4)") and the PbGlass branches suggest the correction is applied, but it never is, and nothing warns about it.
The data needed for the correction does not exist either:
- The header comment (gain_factor.h L17) already says G corrections are not stored.
GainCorrCompute fills histograms only for MOD_PbWO4 and MOD_LMS.
refGain_produce skips every type other than PbWO4/LMS.
- None of the 12 files in
database/gain_factor/ref_gain/*.dat has a G line.
gain_corr.root has only gain_W, gain_W_ref, gain_corr_W and fit_mean_W_lms.
So RefGainTable::g[] and the G parsing branch are dead code.
Evidence
// gain_factor.h L376-391: only the PbWO4 table is filled
for (int wi = 0; wi < kNW; ++wi) {
...
b.corr.w[wi + 1].corr[j] = v;
...
b.corr.w[wi + 1].avg = sum / static_cast<float>(kNLMS);
}
// Replay.cpp L574-575: always 1.0
} else if (mod_type == prad2::MOD_PbGlass) {
ev->gain_factor[nch] = gain_corr.g[mod_id].avg;
To reproduce, run any raw replay with a gain_corr.root present. The gain_factor branch is exactly 1.0 for every channel with module_type == PbGlass.
Suggested fix
Pick one of two directions:
- Add PbGlass correction. Keep the PbGlass LMS peaks in
refGain_produce and GainCorrCompute (write G lines, plus gain_G / gain_G_ref / gain_corr_G[900][3] branches). Then fill b.corr.g[gi + 1] in LoadGainCorrTimeSeries in the same way as w, and read RefGainTable::g[] where the reference ratio is built.
- If PbGlass correction is out of scope on purpose, make that explicit:
- Remove
RefGainTable::g[], GainCorrTable::g[] and the G parse branch.
- Return
1.f for PbGlass ids with a comment saying so.
- Fix the "PbGlass / PbWO4" comment in
Replay.cpp.
- Optionally, log once at load time that PbGlass channels are not gain-corrected.
Status
Still present on dedup-refactor. The call sites now go through GainCorrTable::ModuleGain(), which returns g[id].avg for PbGlass ids, and LoadGainCorrTimeSeries still fills only corr.w[].
Where
GainCorrTablehas a PbGlass tableg[MAX_G]: https://github.com/JeffersonLab/prad2evviewer/blob/d21ae9f/analysis/include/gain_factor.h#L168-L184LoadGainCorrTimeSeriesfills onlycorr.w[]: https://github.com/JeffersonLab/prad2evviewer/blob/d21ae9f/analysis/include/gain_factor.h#L376-L391LoadRefGainFileparsesGlines intoRefGainTable::g[], which nothing reads: https://github.com/JeffersonLab/prad2evviewer/blob/d21ae9f/analysis/include/gain_factor.h#L135-L141gain_corr.g[id].avgfor PbGlass:Process, thegain_factorbranch)ProcessWithRecon)ProcessRaw2Recon)What happens
GainCorrTable::Entrydefaults toavg = 1.f.LoadGainCorrTimeSerieswrites onlyb.corr.w[wi + 1], and no code anywhere writesGainCorrTable::g[]. As a result,gain_corr.g[id].avgis 1.0 for every PbGlass module in every batch of every run.The effect:
gain_factor = 1.0for all 576 PbGlass channels (the count comes fromdatabase/hycal_map.json).ProcessWithRecon,ProcessRaw2Recon) feeds PbGlass hits to the clusterer with no LMS gain-drift correction.ProcessRaw2Recon, thegain == 1.0ffallback toin->gain_factor[j]finds 1.0 there as well.The comment in
Replay.cpp("Gain correction is HyCal-only (PbGlass / PbWO4)") and the PbGlass branches suggest the correction is applied, but it never is, and nothing warns about it.The data needed for the correction does not exist either:
GainCorrComputefills histograms only forMOD_PbWO4andMOD_LMS.refGain_produceskips every type other than PbWO4/LMS.database/gain_factor/ref_gain/*.dathas aGline.gain_corr.roothas onlygain_W,gain_W_ref,gain_corr_Wandfit_mean_W_lms.So
RefGainTable::g[]and theGparsing branch are dead code.Evidence
To reproduce, run any raw replay with a
gain_corr.rootpresent. Thegain_factorbranch is exactly 1.0 for every channel withmodule_type == PbGlass.Suggested fix
Pick one of two directions:
refGain_produceandGainCorrCompute(writeGlines, plusgain_G/gain_G_ref/gain_corr_G[900][3]branches). Then fillb.corr.g[gi + 1]inLoadGainCorrTimeSeriesin the same way asw, and readRefGainTable::g[]where the reference ratio is built.RefGainTable::g[],GainCorrTable::g[]and theGparse branch.1.ffor PbGlass ids with a comment saying so.Replay.cpp.Status
Still present on
dedup-refactor. The call sites now go throughGainCorrTable::ModuleGain(), which returnsg[id].avgfor PbGlass ids, andLoadGainCorrTimeSeriesstill fills onlycorr.w[].