diff --git a/GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx b/GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx index 29bbf34b46135..c26968513611a 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx @@ -711,7 +711,7 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) if (fragment.index == 0) { runKernel({GetGridAutoStep(lane, RecoStep::TPCClusterFinding)}, clustererShadow.mPpadIsNoisy, TPC_PADS_IN_SECTOR * sizeof(*clustererShadow.mPpadIsNoisy)); } - DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Zeroed Charges", doGPU); + DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Zeroed Charges"); if (doGPU) { if (mIOPtrs.tpcZS && mCFContext->nPagesSector[iSlice] && mCFContext->zsVersion != -1) { @@ -799,8 +799,8 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) if (!mIOPtrs.tpcZS) { runKernel({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSlice}}); } - if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpDigits, *mDebugFile)) { - clusterer.DumpChargeMap(*mDebugFile, "Charges", doGPU); + if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 1, clusterer, &GPUTPCClusterFinder::DumpDigits, *mDebugFile)) { + clusterer.DumpChargeMap(*mDebugFile, "Charges"); } if (propagateMCLabels) { @@ -818,11 +818,13 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) } runKernel({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSlice}}); - DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpPeaks, *mDebugFile); + if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 2, clusterer, &GPUTPCClusterFinder::DumpPeaks, *mDebugFile)) { + clusterer.DumpPeakMap(*mDebugFile, "Peaks"); + } RunTPCClusterizer_compactPeaks(clusterer, clustererShadow, 0, doGPU, lane); TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane); - DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpPeaksCompacted, *mDebugFile); + DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 2, clusterer, &GPUTPCClusterFinder::DumpPeaksCompacted, *mDebugFile); } GPUCA_OPENMP(parallel for if(!doGPU && GetProcessingSettings().ompKernels != 1) num_threads(mRec->SetAndGetNestedLoopOmpFactor(!doGPU, GetProcessingSettings().nTPCClustererLanes))) for (int lane = 0; lane < maxLane; lane++) { @@ -837,11 +839,13 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) } runKernel({GetGrid(clusterer.mPmemory->counters.nPeaks, lane), {iSlice}}); runKernel({GetGrid(clusterer.mPmemory->counters.nPeaks, lane), {iSlice}}); - DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpSuppressedPeaks, *mDebugFile); + if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 3, clusterer, &GPUTPCClusterFinder::DumpSuppressedPeaks, *mDebugFile)) { + clusterer.DumpPeakMap(*mDebugFile, "Suppressed Peaks"); + } RunTPCClusterizer_compactPeaks(clusterer, clustererShadow, 1, doGPU, lane); TransferMemoryResourceLinkToHost(RecoStep::TPCClusterFinding, clusterer.mMemoryId, lane); - DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpSuppressedPeaksCompacted, *mDebugFile); + DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 3, clusterer, &GPUTPCClusterFinder::DumpSuppressedPeaksCompacted, *mDebugFile); } GPUCA_OPENMP(parallel for if(!doGPU && GetProcessingSettings().ompKernels != 1) num_threads(mRec->SetAndGetNestedLoopOmpFactor(!doGPU, GetProcessingSettings().nTPCClustererLanes))) for (int lane = 0; lane < maxLane; lane++) { @@ -862,7 +866,7 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) } runKernel({GetGrid(clusterer.mPmemory->counters.nPositions, lane), {iSlice}}); - DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Split Charges", doGPU); + DoDebugAndDump(RecoStep::TPCClusterFinding, 262144 << 4, clusterer, &GPUTPCClusterFinder::DumpChargeMap, *mDebugFile, "Split Charges"); runKernel({GetGrid(clusterer.mPmemory->counters.nClusters, lane), {iSlice}}, 0); if (doGPU && propagateMCLabels) { @@ -878,9 +882,8 @@ int GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) TransferMemoryResourcesToHost(RecoStep::TPCClusterFinding, &clusterer, lane); laneHasData[lane] = true; - if (DoDebugAndDump(RecoStep::TPCClusterFinding, 262144, clusterer, &GPUTPCClusterFinder::DumpCountedPeaks, *mDebugFile)) { - clusterer.DumpClusters(*mDebugFile); - } + // Include clusters in default debug mask, exclude other debug output by default + DoDebugAndDump(RecoStep::TPCClusterFinding, 131072, clusterer, &GPUTPCClusterFinder::DumpClusters, *mDebugFile); } mRec->SetNestedLoopOmpFactor(1); } diff --git a/GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinder.h b/GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinder.h index 4488d7cd1a711..ca89053797a47 100644 --- a/GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinder.h +++ b/GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinder.h @@ -143,12 +143,12 @@ class GPUTPCClusterFinder : public GPUProcessor #ifndef GPUCA_GPUCODE void DumpDigits(std::ostream& out); - void DumpChargeMap(std::ostream& out, std::string_view, bool doGPU); + void DumpChargeMap(std::ostream& out, std::string_view); + void DumpPeakMap(std::ostream& out, std::string_view); void DumpPeaks(std::ostream& out); void DumpPeaksCompacted(std::ostream& out); void DumpSuppressedPeaks(std::ostream& out); void DumpSuppressedPeaksCompacted(std::ostream& out); - void DumpCountedPeaks(std::ostream& out); void DumpClusters(std::ostream& out); #endif }; diff --git a/GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinderDump.cxx b/GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinderDump.cxx index de8583f8cd9e7..389209d9bb884 100644 --- a/GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinderDump.cxx +++ b/GPU/GPUTracking/TPCClusterFinder/GPUTPCClusterFinderDump.cxx @@ -22,23 +22,29 @@ using namespace GPUCA_NAMESPACE::gpu::tpccf; void GPUTPCClusterFinder::DumpDigits(std::ostream& out) { - out << "\nClusterer - Digits - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << mPmemory->counters.nPositions << "\n"; + const auto nPositions = mPmemory->counters.nPositions; + + out << "\nClusterer - Digits - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << nPositions << "\n"; out << std::hex; for (size_t i = 0; i < mPmemory->counters.nPositions; i++) { - out << mPpositions[i].time() << " " << mPpositions[i].gpad << '\n'; + const auto& pos = mPpositions[i]; + out << pos.time() << " " << pos.gpad << '\n'; } out << std::dec; } -void GPUTPCClusterFinder::DumpChargeMap(std::ostream& out, std::string_view title, bool doGPU) +void GPUTPCClusterFinder::DumpChargeMap(std::ostream& out, std::string_view title) { out << "\nClusterer - " << title << " - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << "\n"; Array2D map(mPchargeMap); out << std::hex; - for (TPCFragmentTime i = 0; i < TPC_MAX_FRAGMENT_LEN_PADDED(mRec->GetProcessingSettings().overrideClusterizerFragmentLen); i++) { + TPCFragmentTime start = 0; + TPCFragmentTime end = TPC_MAX_FRAGMENT_LEN_PADDED(mRec->GetProcessingSettings().overrideClusterizerFragmentLen); + + for (TPCFragmentTime i = start; i < end; i++) { int zeros = 0; for (GlobalPad j = 0; j < TPC_NUM_OF_PADS; j++) { ushort q = map[{j, i}]; @@ -61,11 +67,47 @@ void GPUTPCClusterFinder::DumpChargeMap(std::ostream& out, std::string_view titl out << std::dec; } +void GPUTPCClusterFinder::DumpPeakMap(std::ostream& out, std::string_view title) +{ + out << "\nClusterer - " << title << " - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << "\n"; + + Array2D map(mPpeakMap); + + out << std::hex; + + TPCFragmentTime start = 0; + TPCFragmentTime end = TPC_MAX_FRAGMENT_LEN_PADDED(mRec->GetProcessingSettings().overrideClusterizerFragmentLen); + + for (TPCFragmentTime i = start; i < end; i++) { + int zeros = 0; + + out << i << ":"; + for (GlobalPad j = 0; j < TPC_NUM_OF_PADS; j++) { + uchar q = map[{j, i}]; + zeros += (q == 0); + if (q != 0) { + if (zeros > 0) { + out << " z" << zeros; + zeros = 0; + } + + out << " p" << int{q}; + } + } + if (zeros > 0) { + out << " z" << zeros; + } + out << '\n'; + } + + out << std::dec; +} + void GPUTPCClusterFinder::DumpPeaks(std::ostream& out) { out << "\nClusterer - Peaks - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << "\n"; for (unsigned int i = 0; i < mPmemory->counters.nPositions; i++) { - out << (int)mPisPeak[i] << " "; + out << int{mPisPeak[i]}; if ((i + 1) % 100 == 0) { out << "\n"; } @@ -74,17 +116,23 @@ void GPUTPCClusterFinder::DumpPeaks(std::ostream& out) void GPUTPCClusterFinder::DumpPeaksCompacted(std::ostream& out) { - out << "\nClusterer - Compacted Peaks - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << mPmemory->counters.nPeaks << "\n"; - for (size_t i = 0; i < mPmemory->counters.nPeaks; i++) { - out << mPpeakPositions[i].time() << ", " << (int)mPpeakPositions[i].pad() << ", " << (int)mPpeakPositions[i].row() << "\n"; + const auto nPeaks = mPmemory->counters.nPeaks; + + out << "\nClusterer - Compacted Peaks - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << nPeaks << "\n"; + for (size_t i = 0; i < nPeaks; i++) { + const auto& pos = mPpeakPositions[i]; + out << pos.time() << " " << int{pos.pad()} << " " << int{pos.row()} << "\n"; } } void GPUTPCClusterFinder::DumpSuppressedPeaks(std::ostream& out) { - out << "\nClusterer - NoiseSuppression - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << mISlice << "\n"; - for (unsigned int i = 0; i < mPmemory->counters.nPeaks; i++) { - out << (int)mPisPeak[i] << " "; + const auto& fragment = mPmemory->fragment; + const auto nPeaks = mPmemory->counters.nPeaks; + + out << "\nClusterer - NoiseSuppression - Slice " << mISlice << " - Fragment " << fragment.index << mISlice << "\n"; + for (unsigned int i = 0; i < nPeaks; i++) { + out << int{mPisPeak[i]}; if ((i + 1) % 100 == 0) { out << "\n"; } @@ -93,17 +141,13 @@ void GPUTPCClusterFinder::DumpSuppressedPeaks(std::ostream& out) void GPUTPCClusterFinder::DumpSuppressedPeaksCompacted(std::ostream& out) { - out << "\nClusterer - Noise Suppression Peaks Compacted - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << ": " << mPmemory->counters.nClusters << "\n"; - for (size_t i = 0; i < mPmemory->counters.nClusters; i++) { - out << i << ": " << mPfilteredPeakPositions[i].time() << ", " << (int)mPfilteredPeakPositions[i].pad() << ", " << (int)mPfilteredPeakPositions[i].row() << "\n"; - } -} + const auto& fragment = mPmemory->fragment; + const auto nPeaks = mPmemory->counters.nClusters; -void GPUTPCClusterFinder::DumpCountedPeaks(std::ostream& out) -{ - out << "\nClusterer - Peak Counts - Slice " << mISlice << " - Fragment " << mPmemory->fragment.index << "\n"; - for (int i = 0; i < GPUCA_ROW_COUNT; i++) { - out << i << ": " << mPclusterInRow[i] << "\n"; + out << "\nClusterer - Noise Suppression Peaks Compacted - Slice " << mISlice << " - Fragment " << fragment.index << ": " << nPeaks << "\n"; + for (size_t i = 0; i < nPeaks; i++) { + const auto& peak = mPfilteredPeakPositions[i]; + out << peak.time() << " " << int{peak.pad()} << " " << int{peak.row()} << "\n"; } } @@ -113,15 +157,15 @@ void GPUTPCClusterFinder::DumpClusters(std::ostream& out) for (int i = 0; i < GPUCA_ROW_COUNT; i++) { size_t N = mPclusterInRow[i]; - out << "Row: " << i << ": " << N << "\n"; - std::vector sortedCluster(N); - tpc::ClusterNative* row = &mPclusterByRow[i * mNMaxClusterPerRow]; - std::copy(row, &row[N], sortedCluster.begin()); + const tpc::ClusterNative* row = &mPclusterByRow[i * mNMaxClusterPerRow]; + std::vector sortedCluster; + sortedCluster.insert(sortedCluster.end(), row, row + N); std::sort(sortedCluster.begin(), sortedCluster.end()); + out << "Row: " << i << ": " << N << "\n"; for (const auto& cl : sortedCluster) { - out << std::hex << cl.timeFlagsPacked << std::dec << ", " << cl.padPacked << ", " << (int)cl.sigmaTimePacked << ", " << (int)cl.sigmaPadPacked << ", " << cl.qMax << ", " << cl.qTot << "\n"; + out << std::hex << cl.timeFlagsPacked << std::dec << " " << cl.padPacked << " " << int{cl.sigmaTimePacked} << " " << int{cl.sigmaPadPacked} << " " << cl.qMax << " " << cl.qTot << "\n"; } } }