Skip to content

Commit

Permalink
make sum pos / neg after correction
Browse files Browse the repository at this point in the history
  • Loading branch information
wiechula committed Nov 14, 2024
1 parent caab206 commit 512b884
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions Detectors/TPC/base/src/CommonModeCorrection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ CommonModeCorrection::CMInfo CommonModeCorrection::getCommonMode(gsl::span<const
const float adcPad = adcPadRaw - pedestal;
const float adcPadNorm = (kCM > 0) ? adcPad / kCM : 0;

if (adcPad > mSumPosThreshold) {
cmInfo.sumPos += adcPad;
} else {
cmInfo.sumNeg += adcPadNorm;
++cmInfo.nNeg;
}

if (adcPadRaw > 1023.7) {
++cmInfo.nSaturation;
}
Expand Down Expand Up @@ -122,13 +115,23 @@ CommonModeCorrection::CMInfo CommonModeCorrection::getCommonMode(gsl::span<const
cmInfo.cmValueStd = commonModeStd;
cmInfo.nPadsUsed = entriesCM;

if (mOccupancyThreshold > 0) {
for (size_t iPad = 0; iPad < values.size(); ++iPad) {
const float kCM = mLimitKFactor ? fixedSizeToFloat<6>(floatToFixedSize<8, 6>(cmKValues[iPad])) : cmKValues[iPad];
const float pedestal = mLimitPedestal ? fixedSizeToFloat(floatToFixedSize(pedestals[iPad])) : pedestals[iPad];
const float adcPadRaw = values[iPad];
const float adcPad = adcPadRaw - pedestal;
if (adcPad - kCM * commonMode > mOccupancyThreshold) {
for (size_t iPad = 0; iPad < values.size(); ++iPad) {
const float kCM = mLimitKFactor ? fixedSizeToFloat<6>(floatToFixedSize<8, 6>(cmKValues[iPad])) : cmKValues[iPad];
const float pedestal = mLimitPedestal ? fixedSizeToFloat(floatToFixedSize(pedestals[iPad])) : pedestals[iPad];
const float adcPadRaw = values[iPad];
const float adcPad = adcPadRaw - pedestal;
const float adcPadNorm = (kCM > 0) ? adcPad / kCM : 0;
const float adcPadCorr = adcPad - kCM * commonMode;

if (adcPadCorr > mSumPosThreshold) {
cmInfo.sumPos += adcPadCorr;
} else {
cmInfo.sumNeg += adcPadNorm;
++cmInfo.nNeg;
}

if (mOccupancyThreshold > 0) {
if (adcPadCorr > mOccupancyThreshold) {
++cmInfo.nOccupancy;
}
}
Expand Down

0 comments on commit 512b884

Please sign in to comment.