Skip to content

Commit b2814bc

Browse files
fweigdavidrohr
authored andcommitted
GPU/TPC: Clamp gain correction of raw ADCs to 1022
1 parent 90ce82d commit b2814bc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

GPU/GPUTracking/TPCClusterFinder/GPUTPCCFDecodeZS.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,10 @@ GPUd() void GPUTPCCFDecodeZSLinkBase::WriteCharge(processorType& clusterer, floa
478478
positions[positionOffset] = pos;
479479

480480
// Only apply gain correction if ADC not fully saturated
481-
if (charge < 1023.f) {
482-
charge *= clusterer.GetConstantMem()->calibObjects.tpcPadGain->getGainCorrection(sector, padAndRow.getRow(), padAndRow.getPad());
481+
// and ensure gain correction doesn't accidentally saturate the ADC
482+
if (charge < 1023.f) [[likely]] {
483+
auto gain = clusterer.GetConstantMem()->calibObjects.tpcPadGain->getGainCorrection(sector, padAndRow.getRow(), padAndRow.getPad());
484+
charge = CAMath::Min(charge * gain, 1022.f);
483485
}
484486

485487
chargeMap[pos] = PackedCharge(charge);

0 commit comments

Comments
 (0)