Skip to content

Commit 4076009

Browse files
committed
GPU: Process dEdx with full qTot range
1 parent f526ea6 commit 4076009

20 files changed

Lines changed: 44 additions & 116 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/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) ? cl.qMax : 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);

GPU/GPUTracking/Base/GPUReconstructionConvert.cxx

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -48,43 +48,6 @@ using namespace o2::tpc;
4848
using namespace o2::tpc::constants;
4949
using namespace std::string_literals;
5050

51-
void GPUReconstructionConvert::ConvertNativeToClusterData(o2::tpc::ClusterNativeAccess* native, std::unique_ptr<GPUTPCClusterData[]>* clusters, uint32_t* nClusters, const TPCFastTransformPOD* transform, int32_t continuousMaxTimeBin)
52-
{
53-
memset(nClusters, 0, NSECTORS * sizeof(nClusters[0]));
54-
uint32_t offset = 0;
55-
for (uint32_t i = 0; i < NSECTORS; i++) {
56-
uint32_t nClSector = 0;
57-
for (uint32_t j = 0; j < GPUTPCGeometry::NROWS; j++) {
58-
nClSector += native->nClusters[i][j];
59-
}
60-
nClusters[i] = nClSector;
61-
clusters[i].reset(new GPUTPCClusterData[nClSector]);
62-
nClSector = 0;
63-
for (uint32_t j = 0; j < GPUTPCGeometry::NROWS; j++) {
64-
for (uint32_t k = 0; k < native->nClusters[i][j]; k++) {
65-
const auto& clin = native->clusters[i][j][k];
66-
float x = 0, y = 0, z = 0;
67-
if (continuousMaxTimeBin == 0) {
68-
transform->Transform(i, j, clin.getPad(), clin.getTime(), x, y, z);
69-
} else {
70-
transform->TransformInTimeFrame(i, j, clin.getPad(), clin.getTime(), x, y, z, continuousMaxTimeBin);
71-
}
72-
auto& clout = clusters[i].get()[nClSector];
73-
clout.x = x;
74-
clout.y = y;
75-
clout.z = z;
76-
clout.row = j;
77-
clout.amp = clin.qTot;
78-
clout.flags = clin.getFlags();
79-
clout.id = offset + k;
80-
nClSector++;
81-
}
82-
native->clusterOffset[i][j] = offset;
83-
offset += native->nClusters[i][j];
84-
}
85-
}
86-
}
87-
8851
void GPUReconstructionConvert::ConvertRun2RawToNative(o2::tpc::ClusterNativeAccess& native, std::unique_ptr<ClusterNative[]>& nativeBuffer, const AliHLTTPCRawCluster** rawClusters, uint32_t* nRawClusters)
8952
{
9053
memset((void*)&native, 0, sizeof(native));
@@ -110,7 +73,7 @@ void GPUReconstructionConvert::ConvertRun2RawToNative(o2::tpc::ClusterNativeAcce
11073
c.setSigmaTime(CAMath::Sqrt(org.GetSigmaTime2()));
11174
c.setSigmaPad(CAMath::Sqrt(org.GetSigmaPad2()));
11275
c.qMax = org.GetQMax();
113-
c.qTot = org.GetCharge();
76+
c.qTotPacked = org.GetCharge();
11477
}
11578
}
11679
}

GPU/GPUTracking/Base/GPUReconstructionConvert.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class GPUReconstructionConvert
5050
{
5151
public:
5252
constexpr static uint32_t NSECTORS = o2::tpc::constants::MAXSECTOR;
53-
static void ConvertNativeToClusterData(o2::tpc::ClusterNativeAccess* native, std::unique_ptr<GPUTPCClusterData[]>* clusters, uint32_t* nClusters, const TPCFastTransformPOD* transform, int32_t continuousMaxTimeBin = 0);
5453
static void ConvertRun2RawToNative(o2::tpc::ClusterNativeAccess& native, std::unique_ptr<o2::tpc::ClusterNative[]>& nativeBuffer, const AliHLTTPCRawCluster** rawClusters, uint32_t* nRawClusters);
5554
template <class S>
5655
static void RunZSEncoder(const S& in, std::unique_ptr<uint64_t[]>* outBuffer, uint32_t* outSizes, o2::raw::RawFileWriter* raw, const o2::InteractionRecord* ir, const GPUParam& param, int32_t version, bool verify, float threshold = 0.f, bool padding = false, std::function<void(std::vector<o2::tpc::Digit>&)> digitsFilter = nullptr);

0 commit comments

Comments
 (0)