Skip to content

Commit 3c709e1

Browse files
author
miranov25
committed
TPC TimeSeries: fix silent track loss from binning overflow
Bin indices for tgl, phi, qPt, and multiplicity were used as implicit track selection cuts: tracks outside histogram range were silently dropped (return). Replace with std::clamp — edge bins become overflow bins (standard ROOT convention). No change for tracks within range. Bug: changing --max-qPt or --mult-max removed tracks from ALL outputs (DCA, dEdx, etc.), not just the binned histograms.
1 parent be5a2bb commit 3c709e1

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

Detectors/TPC/workflow/src/TPCTimeSeriesSpec.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,21 +1179,21 @@ class TPCTimeSeries : public Task
11791179
return;
11801180
}
11811181

1182-
const int tglBin = mTglBins * std::abs(trackTmp.getTgl()) / mMaxTgl + mPhiBins;
1183-
const int phiBin = mPhiBins * trackTmp.getPhi() / o2::constants::math::TwoPI;
1182+
const int tglBin = std::clamp(static_cast<int>(mTglBins * std::abs(trackTmp.getTgl()) / mMaxTgl) + mPhiBins,
1183+
mPhiBins, mPhiBins + mTglBins - 1);
1184+
const int phiBin = std::clamp(static_cast<int>(mPhiBins * trackTmp.getPhi() / o2::constants::math::TwoPI),
1185+
0, mPhiBins - 1);
11841186

11851187
const int offsQPtBin = mPhiBins + mTglBins;
1186-
const int qPtBin = offsQPtBin + mQPtBins * (trackTmp.getQ2Pt() + mMaxQPt) / (2 * mMaxQPt);
1188+
const int qPtBin = std::clamp(offsQPtBin + static_cast<int>(mQPtBins * (trackTmp.getQ2Pt() + mMaxQPt) / (2 * mMaxQPt)),
1189+
offsQPtBin, offsQPtBin + mQPtBins - 1);
11871190
const int localMult = mNTracksWindow[iTrk];
11881191

11891192
const int offsMult = offsQPtBin + mQPtBins;
1190-
const int multBin = offsMult + mMultBins * localMult / mMultMax;
1193+
const int multBin = std::clamp(offsMult + static_cast<int>(mMultBins * localMult / mMultMax),
1194+
offsMult, offsMult + mMultBins - 1);
11911195
const int nBins = getNBins();
11921196

1193-
if ((phiBin < 0) || (phiBin > mPhiBins) || (tglBin < mPhiBins) || (tglBin > offsQPtBin) || (qPtBin < offsQPtBin) || (qPtBin > offsMult) || (multBin < offsMult) || (multBin > offsMult + mMultBins)) {
1194-
return;
1195-
}
1196-
11971197
float sigmaY2 = 0;
11981198
float sigmaZ2 = 0;
11991199
const int sector = o2::math_utils::angle2Sector(trackTmp.getPhiPos());

0 commit comments

Comments
 (0)