Skip to content

Commit ec79da3

Browse files
committed
GPU: Process dEdx with full qTot range
1 parent 91c2ccd commit ec79da3

22 files changed

Lines changed: 47 additions & 119 deletions

DataFormats/Detectors/TPC/include/DataFormatsTPC/ClusterNative.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,28 +73,21 @@ struct ClusterNative {
7373
uint8_t sigmaTimePacked; //< Sigma of the time in packed format
7474
uint8_t sigmaPadPacked; //< Sigma of the pad in packed format
7575
uint16_t qMax; //< QMax of the cluster
76-
uint16_t qTot; //< Total charge of the cluster
76+
uint16_t qTotPacked; //< Total charge of the cluster
7777

7878
GPUd() static uint16_t packPad(float pad) { return (uint16_t)(pad * scalePadPacked + 0.5); }
7979
GPUd() static uint32_t packTime(float time) { return (uint32_t)(time * scaleTimePacked + 0.5); }
8080
GPUd() static float unpackPad(uint16_t pad) { return float(pad) * (1.f / scalePadPacked); }
8181
GPUd() static float unpackTime(uint32_t time) { return float(time) * (1.f / scaleTimePacked); }
8282

8383
GPUdDefault() ClusterNative() = default;
84-
GPUd() ClusterNative(uint32_t time, uint8_t flags, uint16_t pad, uint8_t sigmaTime, uint8_t sigmaPad, uint16_t qmax, uint16_t qtot) : padPacked(pad), sigmaTimePacked(sigmaTime), sigmaPadPacked(sigmaPad), qMax(qmax), qTot(qtot)
84+
GPUd() ClusterNative(uint32_t time, uint8_t flags, uint16_t pad, uint8_t sigmaTime, uint8_t sigmaPad, uint16_t qmax, uint16_t qtotPacked) : padPacked(pad), sigmaTimePacked(sigmaTime), sigmaPadPacked(sigmaPad), qMax(qmax), qTotPacked(qtotPacked)
8585
{
8686
setTimePackedFlags(time, flags);
8787
}
8888

8989
GPUd() uint16_t getQmax() const { return qMax; }
90-
GPUd() uint16_t getQtot() const
91-
{
92-
if (isSaturated()) [[unlikely]] {
93-
auto sQtot = getSaturatedQtot();
94-
return sQtot < USHRT_MAX ? sQtot : USHRT_MAX;
95-
}
96-
return qTot;
97-
}
90+
GPUd() uint32_t getQtot() const { return isSaturated() ? getSaturatedQtot() : (uint32_t)qTotPacked; }
9891
GPUd() uint8_t getFlags() const { return timeFlagsPacked >> 24; }
9992
GPUd() uint32_t getTimePacked() const { return timeFlagsPacked & 0xFFFFFF; }
10093
GPUd() void setTimePackedFlags(uint32_t timePacked, uint8_t flags)
@@ -155,19 +148,19 @@ struct ClusterNative {
155148
sigmaPadPacked = tmp;
156149
}
157150

158-
GPUd() bool isSaturated() const { return qTot > maxRegularQtot; }
151+
GPUd() bool isSaturated() const { return qTotPacked > maxRegularQtot; }
159152

160153
GPUd() void setSaturatedQtot(uint32_t qtot)
161154
{
162-
this->qTot = USHRT_MAX;
155+
this->qTotPacked = USHRT_MAX;
163156
if (qtot < maxSaturatedQtot) {
164-
this->qTot = ((qtot + scaleSaturatedQtot / 2) / scaleSaturatedQtot) + maxRegularQtot;
157+
this->qTotPacked = ((qtot + scaleSaturatedQtot / 2) / scaleSaturatedQtot) + maxRegularQtot;
165158
}
166159
}
167160

168161
GPUd() uint32_t getSaturatedQtot() const
169162
{
170-
return uint32_t(qTot - maxRegularQtot) * scaleSaturatedQtot;
163+
return uint32_t(qTotPacked - maxRegularQtot) * scaleSaturatedQtot;
171164
}
172165

173166
GPUd() void setSaturatedTailLength(uint32_t tail)
@@ -192,8 +185,8 @@ struct ClusterNative {
192185
return (this->sigmaPadPacked < rhs.sigmaPadPacked);
193186
} else if (this->qMax != rhs.qMax) {
194187
return (this->qMax < rhs.qMax);
195-
} else if (this->qTot != rhs.qTot) {
196-
return (this->qTot < rhs.qTot);
188+
} else if (this->qTotPacked != rhs.qTotPacked) {
189+
return (this->getQtot() < rhs.getQtot());
197190
} else {
198191
return (this->getFlags() < rhs.getFlags());
199192
}
@@ -206,7 +199,7 @@ struct ClusterNative {
206199
this->sigmaTimePacked == rhs.sigmaTimePacked &&
207200
this->sigmaPadPacked == rhs.sigmaPadPacked &&
208201
this->qMax == rhs.qMax &&
209-
this->qTot == rhs.qTot &&
202+
this->qTotPacked == rhs.qTotPacked &&
210203
this->getFlags() == rhs.getFlags();
211204
}
212205

DataFormats/Detectors/TPC/include/DataFormatsTPC/ClusterNativeHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ class ClusterNativeHelper
312312
sigmaTime = rhs.getSigmaTime();
313313
sigmaPad = rhs.getSigmaPad();
314314
qMax = rhs.qMax;
315-
qTot = rhs.qTot;
315+
qTot = rhs.qTotPacked;
316316
flags = rhs.getFlags();
317317
return *this;
318318
}

Detectors/Align/src/AlignableDetectorTPC.cxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,18 @@ int AlignableDetectorTPC::processPoints(GIndex gid, int npntCut, bool inv)
166166
// mController->getTPCCorrMaps()->Transform(sector, row, cl->getPad(), cl->getTime(), x, y, z, tOffset);
167167
currentRow = row;
168168
currentSector = sector;
169-
charge = cl->qTot;
169+
charge = cl->getQtot();
170170
clusterState = nextState;
171171
combRow = row;
172172
LOGP(debug, "starting a supercluster at row {} of sector {} -> {},{},{}", currentRow, currentSector, x, y, z);
173173
} else {
174174
// float xx, yy, zz;
175175
// mController->getTPCCorrMaps()->Transform(sector, row, cl->getPad(), cl->getTime(), xx, yy, zz, tOffset);
176-
x += xTmp * cl->qTot;
177-
y += yTmp * cl->qTot;
178-
z += zTmp * cl->qTot;
179-
combRow += row * cl->qTot;
180-
charge += cl->qTot;
176+
x += xTmp * cl->getQtot();
177+
y += yTmp * cl->getQtot();
178+
z += zTmp * cl->getQtot();
179+
combRow += row * cl->getQtot();
180+
charge += cl->getQtot();
181181
clusterState |= nextState;
182182
npntCut--;
183183
LOGP(debug, "merging cluster #{} at row {} to a supercluster starting at row {} ", clusters + 1, row, currentRow);

Detectors/TPC/calibration/SpacePoints/src/TrackInterpolation.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ void TrackInterpolation::interpolateTrack(int iSeed)
506506
float clusterTimeBinOffset = mTrackTimes[iSeed] / mTPCTimeBinMUS;
507507

508508
// store the TPC cluster positions in the cache, as well as dedx info
509-
std::array<std::pair<uint16_t, uint16_t>, constants::MAXGLOBALPADROW> mCacheDEDX{};
509+
std::array<std::pair<uint32_t, uint16_t>, constants::MAXGLOBALPADROW> mCacheDEDX{};
510510
std::array<short, constants::MAXGLOBALPADROW> multBins{};
511511
for (int iCl = trkTPC.getNClusterReferences(); iCl--;) {
512512
uint8_t sector, row;

Detectors/TPC/calibration/include/TPCCalibration/TrackDump.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class TrackDump
4444
float gx{};
4545
float gy{};
4646
uint16_t qMax; //< QMax of the cluster
47-
uint16_t qTot; //< Total charge of the cluster
47+
uint32_t qTot; //< Total charge of the cluster
4848
uint8_t sector = 0;
4949
uint8_t padrow = 0;
5050

51-
ClassDefNV(ClusterGlobal, 1);
51+
ClassDefNV(ClusterGlobal, 2);
5252
};
5353

5454
struct ClusterNativeAdd : public ClusterNative {

Detectors/TPC/calibration/src/CalculatedEdx.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void CalculatedEdx::calculatedEdx(o2::tpc::TrackTPC& track, dEdxInfo& output, fl
245245
}
246246

247247
// get charge values
248-
float chargeTot = cl.qTot;
248+
float chargeTot = cl.getQtot();
249249
float chargeMax = cl.qMax;
250250

251251
// get threshold

Detectors/TPC/calibration/src/CalibPadGainTracks.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void CalibPadGainTracks::processTrack(o2::tpc::TrackTPC track, o2::gpu::GPUO2Int
100100
}
101101

102102
const int region = Mapper::REGION[rowIndex];
103-
const float charge = (mChargeType == ChargeType::Max) ? cl.qMax : cl.qTot;
103+
const float charge = (mChargeType == ChargeType::Max) ? (float)cl.qMax : (float)cl.getQtot();
104104
const float effectiveLength = mCalibTrackTopologyPol ? getTrackTopologyCorrectionPol(track, cl, region, charge) : getTrackTopologyCorrection(track, region);
105105

106106
const unsigned char pad = std::clamp(static_cast<unsigned int>(cl.getPad() + 0.5f), static_cast<unsigned int>(0), Mapper::PADSPERROW[region][Mapper::getLocalRowFromGlobalRow(rowIndex)] - 1); // the left side of the pad is defined at e.g. 3.5 and the right side at 4.5

Detectors/TPC/calibration/src/TrackDump.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void TrackDump::filter(const gsl::span<const TrackTPC> tracks, ClusterNativeAcce
7373
excludes[sector][padrow].emplace_back(clusterIndexInRow);
7474

7575
if (clustersGlobal) {
76-
auto& clGlobal = clustersGlobal->emplace_back(ClusterGlobal{clInfo.gx(), clInfo.gy(), cl.qMax, cl.qTot, sector, padrow});
76+
auto& clGlobal = clustersGlobal->emplace_back(ClusterGlobal{clInfo.gx(), clInfo.gy(), cl.qMax, cl.getQtot(), sector, padrow});
7777
}
7878
}
7979
}

Detectors/TPC/reconstruction/src/HardwareClusterDecoder.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int HardwareClusterDecoder::decodeClusters(std::vector<std::pair<const ClusterHa
8787
cOut.setSigmaPad(std::sqrt(cIn.getSigmaPad2()));
8888
cOut.setSigmaTime(std::sqrt(cIn.getSigmaTime2()));
8989
cOut.qMax = cIn.getQMax();
90-
cOut.qTot = cIn.getQTot();
90+
cOut.qTotPacked = cIn.getQTot();
9191
mIntegrator->integrateCluster(sector, padRowGlobal, pad, cIn.getQTot());
9292
if (outMCLabels) {
9393
auto& mcOut = outMCLabelContainers[containerRowCluster[sector][padRowGlobal]];

Detectors/TPC/reconstruction/test/testGPUCATracking.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ BOOST_AUTO_TEST_CASE(CATracking_test1)
9595
cont[i].clusters[0].setSigmaTime(1);
9696
cont[i].clusters[0].setSigmaPad(1);
9797
cont[i].clusters[0].qMax = 10;
98-
cont[i].clusters[0].qTot = 50;
98+
cont[i].clusters[0].qTotPacked = 50;
9999
}
100100
std::unique_ptr<ClusterNative[]> clusterBuffer;
101101
std::unique_ptr<ClusterNativeAccess> clusters = ClusterNativeHelper::createClusterNativeIndex(clusterBuffer, cont, nullptr, nullptr);

0 commit comments

Comments
 (0)