Skip to content

Commit 4344c80

Browse files
fweigdavidrohr
authored andcommitted
TPC Cluster finder: Update debug mode.
- Adjust debug masks, ensure only clusters are dumped with default masks. - Dump peak map in debug mode. - Some code cleanup
1 parent 9d3b9a0 commit 4344c80

File tree

3 files changed

+86
-39
lines changed

3 files changed

+86
-39
lines changed

GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
711711
if (fragment.index == 0) {
712712
runKernel<GPUMemClean16>({GetGridAutoStep(lane, RecoStep::TPCClusterFinding)}, clustererShadow.mPpadIsNoisy, TPC_PADS_IN_SECTOR * sizeof(*clustererShadow.mPpadIsNoisy));
713713
}
714-
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Zeroed Charges", doGPU);
714+
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Zeroed Charges");
715715

716716
if (doGPU) {
717717
if (mIOPtrs.tpcZS && mCFContext->nPagesSector[iSlice] && mCFContext->zsVersion != -1) {
@@ -799,8 +799,8 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
799799
if (!mIOPtrs.tpcZS) {
800800
runKernel<GPUTPCCFChargeMapFiller, GPUTPCCFChargeMapFiller::fillFromDigits>({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSlice}});
801801
}
802-
if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpDigits, *mDebugFile)) {
803-
clusterer.DumpChargeMap(*mDebugFile, "Charges", doGPU);
802+
if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 1, clusterer, &GPUTPCClusterFinder::DumpDigits, *mDebugFile)) {
803+
clusterer.DumpChargeMap(*mDebugFile, "Charges");
804804
}
805805

806806
if (propagateMCLabels) {
@@ -818,11 +818,13 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
818818
}
819819

820820
runKernel<GPUTPCCFPeakFinder>({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSlice}});
821-
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpPeaks, *mDebugFile);
821+
if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 2, clusterer, &GPUTPCClusterFinder::DumpPeaks, *mDebugFile)) {
822+
clusterer.DumpPeakMap(*mDebugFile, "Peaks");
823+
}
822824

823825
RunTPCClusterizer_compactPeaks(clusterer, clustererShadow, 0, doGPU, lane);
824826
TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane);
825-
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpPeaksCompacted, *mDebugFile);
827+
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 2, clusterer, &GPUTPCClusterFinder::DumpPeaksCompacted, *mDebugFile);
826828
}
827829
GPUCA_OPENMP(parallel for if(!doGPU && GetProcessingSettings().ompKernels != 1) num_threads(mRec->SetAndGetNestedLoopOmpFactor(!doGPU, GetProcessingSettings().nTPCClustererLanes)))
828830
for (int lane = 0; lane < maxLane; lane++) {
@@ -837,11 +839,13 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
837839
}
838840
runKernel<GPUTPCCFNoiseSuppression, GPUTPCCFNoiseSuppression::noiseSuppression>({GetGrid(clusterer.mPmemory->counters.nPeaks, lane), {iSlice}});
839841
runKernel<GPUTPCCFNoiseSuppression, GPUTPCCFNoiseSuppression::updatePeaks>({GetGrid(clusterer.mPmemory->counters.nPeaks, lane), {iSlice}});
840-
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpSuppressedPeaks, *mDebugFile);
842+
if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 3, clusterer, &GPUTPCClusterFinder::DumpSuppressedPeaks, *mDebugFile)) {
843+
clusterer.DumpPeakMap(*mDebugFile, "Suppressed Peaks");
844+
}
841845

842846
RunTPCClusterizer_compactPeaks(clusterer, clustererShadow, 1, doGPU, lane);
843847
TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane);
844-
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpSuppressedPeaksCompacted, *mDebugFile);
848+
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 3, clusterer, &GPUTPCClusterFinder::DumpSuppressedPeaksCompacted, *mDebugFile);
845849
}
846850
GPUCA_OPENMP(parallel for if(!doGPU && GetProcessingSettings().ompKernels != 1) num_threads(mRec->SetAndGetNestedLoopOmpFactor(!doGPU, GetProcessingSettings().nTPCClustererLanes)))
847851
for (int lane = 0; lane < maxLane; lane++) {
@@ -862,7 +866,7 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
862866
}
863867

864868
runKernel<GPUTPCCFDeconvolution>({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSlice}});
865-
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Split Charges", doGPU);
869+
DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 4, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Split Charges");
866870

867871
runKernel<GPUTPCCFClusterizer>({GetGrid(clusterer.mPmemory->counters.nClusters, lane), {iSlice}}, 0);
868872
if (doGPU && propagateMCLabels) {
@@ -878,9 +882,8 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
878882

879883
TransferMemoryResourcesToHost(RecoStep::TPCClusterFinding, &clusterer, lane);
880884
laneHasData[lane] = true;
881-
if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpCountedPeaks, *mDebugFile)) {
882-
clusterer.DumpClusters(*mDebugFile);
883-
}
885+
// Include clusters in default debug mask, exclude other debug output by default
886+
DoDebugAndDump(RecoStep::TPCClusterFinding, 131072, clusterer, &GPUTPCClusterFinder::DumpClusters, *mDebugFile);
884887
}
885888
mRec->SetNestedLoopOmpFactor(1);
886889
}

GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,12 @@ class GPUTPCClusterFinder : public GPUProcessor
143143

144144
#ifndef GPUCA_GPUCODE
145145
void DumpDigits(std::ostream& out);
146-
void DumpChargeMap(std::ostream& out, std::string_view, bool doGPU);
146+
void DumpChargeMap(std::ostream& out, std::string_view);
147+
void DumpPeakMap(std::ostream& out, std::string_view);
147148
void DumpPeaks(std::ostream& out);
148149
void DumpPeaksCompacted(std::ostream& out);
149150
void DumpSuppressedPeaks(std::ostream& out);
150151
void DumpSuppressedPeaksCompacted(std::ostream& out);
151-
void DumpCountedPeaks(std::ostream& out);
152152
void DumpClusters(std::ostream& out);
153153
#endif
154154
};

GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinderDump.cxx

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,29 @@ using namespace GPUCA_NAMESPACE::gpu::tpccf;
2222

2323
void GPUTPCClusterFinder::DumpDigits(std::ostream& out)
2424
{
25-
out << "\nClusterer - Digits - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << mPmemory->counters.nPositions << "\n";
25+
const auto nPositions = mPmemory->counters.nPositions;
26+
27+
out << "\nClusterer - Digits - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << nPositions << "\n";
2628

2729
out << std::hex;
2830
for (size_t i = 0; i < mPmemory->counters.nPositions; i++) {
29-
out << mPpositions[i].time() << " " << mPpositions[i].gpad << '\n';
31+
const auto& pos = mPpositions[i];
32+
out << pos.time() << " " << pos.gpad << '\n';
3033
}
3134
out << std::dec;
3235
}
3336

34-
void GPUTPCClusterFinder::DumpChargeMap(std::ostream& out, std::string_view title, bool doGPU)
37+
void GPUTPCClusterFinder::DumpChargeMap(std::ostream& out, std::string_view title)
3538
{
3639
out << "\nClusterer - " << title << " - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << "\n";
3740
Array2D<ushort> map(mPchargeMap);
3841

3942
out << std::hex;
4043

41-
for (TPCFragmentTime i = 0; i < TPC_MAX_FRAGMENT_LEN_PADDED(mRec->GetProcessingSettings().overrideClusterizerFragmentLen); i++) {
44+
TPCFragmentTime start = 0;
45+
TPCFragmentTime end = TPC_MAX_FRAGMENT_LEN_PADDED(mRec->GetProcessingSettings().overrideClusterizerFragmentLen);
46+
47+
for (TPCFragmentTime i = start; i < end; i++) {
4248
int zeros = 0;
4349
for (GlobalPad j = 0; j < TPC_NUM_OF_PADS; j++) {
4450
ushort q = map[{j, i}];
@@ -61,11 +67,47 @@ void GPUTPCClusterFinder::DumpChargeMap(std::ostream& out, std::string_view titl
6167
out << std::dec;
6268
}
6369

70+
void GPUTPCClusterFinder::DumpPeakMap(std::ostream& out, std::string_view title)
71+
{
72+
out << "\nClusterer - " << title << " - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << "\n";
73+
74+
Array2D<uchar> map(mPpeakMap);
75+
76+
out << std::hex;
77+
78+
TPCFragmentTime start = 0;
79+
TPCFragmentTime end = TPC_MAX_FRAGMENT_LEN_PADDED(mRec->GetProcessingSettings().overrideClusterizerFragmentLen);
80+
81+
for (TPCFragmentTime i = start; i < end; i++) {
82+
int zeros = 0;
83+
84+
out << i << ":";
85+
for (GlobalPad j = 0; j < TPC_NUM_OF_PADS; j++) {
86+
uchar q = map[{j, i}];
87+
zeros += (q == 0);
88+
if (q != 0) {
89+
if (zeros > 0) {
90+
out << " z" << zeros;
91+
zeros = 0;
92+
}
93+
94+
out << " p" << int{q};
95+
}
96+
}
97+
if (zeros > 0) {
98+
out << " z" << zeros;
99+
}
100+
out << '\n';
101+
}
102+
103+
out << std::dec;
104+
}
105+
64106
void GPUTPCClusterFinder::DumpPeaks(std::ostream& out)
65107
{
66108
out << "\nClusterer - Peaks - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << "\n";
67109
for (unsigned int i = 0; i < mPmemory->counters.nPositions; i++) {
68-
out << (int)mPisPeak[i] << " ";
110+
out << int{mPisPeak[i]};
69111
if ((i + 1) % 100 == 0) {
70112
out << "\n";
71113
}
@@ -74,17 +116,23 @@ void GPUTPCClusterFinder::DumpPeaks(std::ostream& out)
74116

75117
void GPUTPCClusterFinder::DumpPeaksCompacted(std::ostream& out)
76118
{
77-
out << "\nClusterer - Compacted Peaks - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << mPmemory->counters.nPeaks << "\n";
78-
for (size_t i = 0; i < mPmemory->counters.nPeaks; i++) {
79-
out << mPpeakPositions[i].time() << ", " << (int)mPpeakPositions[i].pad() << ", " << (int)mPpeakPositions[i].row() << "\n";
119+
const auto nPeaks = mPmemory->counters.nPeaks;
120+
121+
out << "\nClusterer - Compacted Peaks - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << nPeaks << "\n";
122+
for (size_t i = 0; i < nPeaks; i++) {
123+
const auto& pos = mPpeakPositions[i];
124+
out << pos.time() << " " << int{pos.pad()} << " " << int{pos.row()} << "\n";
80125
}
81126
}
82127

83128
void GPUTPCClusterFinder::DumpSuppressedPeaks(std::ostream& out)
84129
{
85-
out << "\nClusterer - NoiseSuppression - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << mISlice << "\n";
86-
for (unsigned int i = 0; i < mPmemory->counters.nPeaks; i++) {
87-
out << (int)mPisPeak[i] << " ";
130+
const auto& fragment = mPmemory->fragment;
131+
const auto nPeaks = mPmemory->counters.nPeaks;
132+
133+
out << "\nClusterer - NoiseSuppression - Slice " << mISlice << " - Fragment " << fragment.index << mISlice << "\n";
134+
for (unsigned int i = 0; i < nPeaks; i++) {
135+
out << int{mPisPeak[i]};
88136
if ((i + 1) % 100 == 0) {
89137
out << "\n";
90138
}
@@ -93,17 +141,13 @@ void GPUTPCClusterFinder::DumpSuppressedPeaks(std::ostream& out)
93141

94142
void GPUTPCClusterFinder::DumpSuppressedPeaksCompacted(std::ostream& out)
95143
{
96-
out << "\nClusterer - Noise Suppression Peaks Compacted - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << mPmemory->counters.nClusters << "\n";
97-
for (size_t i = 0; i < mPmemory->counters.nClusters; i++) {
98-
out << i << ": " << mPfilteredPeakPositions[i].time() << ", " << (int)mPfilteredPeakPositions[i].pad() << ", " << (int)mPfilteredPeakPositions[i].row() << "\n";
99-
}
100-
}
144+
const auto& fragment = mPmemory->fragment;
145+
const auto nPeaks = mPmemory->counters.nClusters;
101146

102-
void GPUTPCClusterFinder::DumpCountedPeaks(std::ostream& out)
103-
{
104-
out << "\nClusterer - Peak Counts - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << "\n";
105-
for (int i = 0; i < GPUCA_ROW_COUNT; i++) {
106-
out << i << ": " << mPclusterInRow[i] << "\n";
147+
out << "\nClusterer - Noise Suppression Peaks Compacted - Slice " << mISlice << " - Fragment " << fragment.index << ": " << nPeaks << "\n";
148+
for (size_t i = 0; i < nPeaks; i++) {
149+
const auto& peak = mPfilteredPeakPositions[i];
150+
out << peak.time() << " " << int{peak.pad()} << " " << int{peak.row()} << "\n";
107151
}
108152
}
109153

@@ -113,15 +157,15 @@ void GPUTPCClusterFinder::DumpClusters(std::ostream& out)
113157

114158
for (int i = 0; i < GPUCA_ROW_COUNT; i++) {
115159
size_t N = mPclusterInRow[i];
116-
out << "Row: " << i << ": " << N << "\n";
117-
std::vector<tpc::ClusterNative> sortedCluster(N);
118-
tpc::ClusterNative* row = &mPclusterByRow[i * mNMaxClusterPerRow];
119-
std::copy(row, &row[N], sortedCluster.begin());
160+
const tpc::ClusterNative* row = &mPclusterByRow[i * mNMaxClusterPerRow];
120161

162+
std::vector<tpc::ClusterNative> sortedCluster;
163+
sortedCluster.insert(sortedCluster.end(), row, row + N);
121164
std::sort(sortedCluster.begin(), sortedCluster.end());
122165

166+
out << "Row: " << i << ": " << N << "\n";
123167
for (const auto& cl : sortedCluster) {
124-
out << std::hex << cl.timeFlagsPacked << std::dec << ", " << cl.padPacked << ", " << (int)cl.sigmaTimePacked << ", " << (int)cl.sigmaPadPacked << ", " << cl.qMax << ", " << cl.qTot << "\n";
168+
out << std::hex << cl.timeFlagsPacked << std::dec << " " << cl.padPacked << " " << int{cl.sigmaTimePacked} << " " << int{cl.sigmaPadPacked} << " " << cl.qMax << " " << cl.qTot << "\n";
125169
}
126170
}
127171
}

0 commit comments

Comments
 (0)