Skip to content

Commit e5093ee

Browse files
committed
TPC: Cluster filter for PbPb 2023
1 parent f68c7bf commit e5093ee

File tree

6 files changed

+78
-12
lines changed

6 files changed

+78
-12
lines changed

GPU/GPUTracking/Debug/GPUTPCClusterFilter.cxx

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,61 @@
1212
/// \file GPUTPCClusterFilter.cxx
1313
/// \author David Rohr
1414

15+
#include "Framework/Logger.h"
1516
#include "GPUTPCClusterFilter.h"
1617
#include "DataFormatsTPC/ClusterNative.h"
1718

1819
using namespace o2::gpu;
1920

20-
GPUTPCClusterFilter::GPUTPCClusterFilter(const o2::tpc::ClusterNativeAccess& clusters)
21+
GPUTPCClusterFilter::GPUTPCClusterFilter(const o2::tpc::ClusterNativeAccess& clusters, uint8_t filterType)
22+
: mFilterType(filterType)
2123
{
22-
// Could initialize private variables based on the clusters here
24+
if (filterType == 1) {
25+
// Custom filter settings go here
26+
27+
} else if (filterType == 2) {
28+
// PbPb23 filter
29+
static bool called = false;
30+
if (!called) {
31+
LOGP(info, "GPUTPCClusterFilter called for PbPb 2023 settings");
32+
called = true;
33+
}
34+
35+
for (uint32_t iSector = 0; iSector < GPUCA_NSECTORS; iSector++) {
36+
for (uint32_t iRow = 0; iRow < GPUCA_ROW_COUNT; iRow++) {
37+
const uint32_t globalStack = getGlobalStack(iSector, iRow);
38+
mClusterStats[globalStack].resize(mMaxTimeBin);
39+
40+
for (uint32_t k = 0; k < clusters.nClusters[iSector][iRow]; k++) {
41+
const o2::tpc::ClusterNative& cl = clusters.clusters[iSector][iRow][k];
42+
const int clTime = static_cast<int>(cl.getTime());
43+
const float clQmax = cl.getQmax();
44+
45+
if (clQmax < 12) {
46+
if (clTime >= mMaxTimeBin) {
47+
mClusterStats[globalStack].resize(mClusterStats[globalStack].size() + 445);
48+
}
49+
++mClusterStats[globalStack][clTime];
50+
}
51+
}
52+
}
53+
}
54+
}
2355
}
2456

2557
bool GPUTPCClusterFilter::filter(uint32_t sector, uint32_t row, o2::tpc::ClusterNative& cl)
2658
{
2759
// Return true to keep the cluster, false to drop it.
2860
// May change cluster properties by modifying the cl reference.
2961
// Note that this function might be called multiple times for the same cluster, in which case the final modified cl reference goes into the output clusters.
62+
if (mFilterType == 2) {
63+
const uint32_t globalStack = getGlobalStack(sector, row);
64+
const int clTime = static_cast<int>(cl.getTime());
65+
const float clQmax = cl.getQmax();
66+
if ((mClusterStats[globalStack][clTime] > 40 && clQmax < 12) || (mClusterStats[globalStack][clTime] > 200)) {
67+
return false;
68+
}
69+
}
70+
3071
return true;
3172
}

GPU/GPUTracking/Debug/GPUTPCClusterFilter.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#define GPUTPCCLUSTERFILTER_H
1717

1818
#include <cstdint>
19+
#include <vector>
20+
#include "GPUDefConstantsAndSettings.h"
1921

2022
namespace o2::tpc
2123
{
@@ -28,8 +30,29 @@ namespace o2::gpu
2830
class GPUTPCClusterFilter
2931
{
3032
public:
31-
GPUTPCClusterFilter(const o2::tpc::ClusterNativeAccess& clusters);
33+
GPUTPCClusterFilter(const o2::tpc::ClusterNativeAccess& clusters, uint8_t filterType);
3234
bool filter(uint32_t sector, uint32_t row, o2::tpc::ClusterNative& cl);
35+
36+
private:
37+
uint32_t mMaxTimeBin = 14256;
38+
uint8_t mFilterType = 0; //< 0: off, 1: custom, 2: PbPb23
39+
static constexpr int MaxStacks = GPUCA_NSECTORS * 4;
40+
41+
std::vector<int> mClusterStats[MaxStacks]; //< Number of clusters per stack and time bin
42+
43+
uint32_t getGlobalStack(uint32_t sector, uint32_t row) const
44+
{
45+
int stack = 3;
46+
if (row < 63) {
47+
stack = 0;
48+
} else if (row < 97) {
49+
stack = 1;
50+
} else if (row < 127) {
51+
stack = 2;
52+
}
53+
54+
return sector * 4 + stack;
55+
};
3356
};
3457
} // namespace o2::gpu
3558

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ AddOption(tpcDownscaledEdx, uint8_t, 0, "", 0, "If != 0, downscale dEdx processi
291291
AddOption(tpcMaxAttachedClustersPerSectorRow, uint32_t, 51000, "", 0, "Maximum number of TPC attached clusters which can be decoded per SectorRow")
292292
AddOption(tpcUseOldCPUDecoding, bool, false, "", 0, "Enable old CPU-based TPC decoding")
293293
AddOption(tpcApplyCFCutsAtDecoding, bool, false, "", 0, "Apply cluster cuts from clusterization during decoding of compressed clusters")
294-
AddOption(tpcApplyDebugClusterFilter, bool, false, "", 0, "Apply custom cluster filter of GPUTPCClusterFilter class")
294+
AddOption(tpcApplyClusterFilterOnCPU, uint8_t, 0, "", 0, "Apply custom cluster filter of GPUTPCClusterFilter class, 0: off, 1: debug, 2: PbPb23")
295295
AddOption(RTCcacheFolder, std::string, "./rtccache/", "", 0, "Folder in which the cache file is stored")
296296
AddOption(RTCprependCommand, std::string, "", "", 0, "Prepend RTC compilation commands by this string")
297297
AddOption(RTCoverrideArchitecture, std::string, "", "", 0, "Override arhcitecture part of RTC compilation command line")

GPU/GPUTracking/Global/GPUChainTracking.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ bool GPUChainTracking::ValidateSettings()
302302
GPUError("Invalid tpcCompressionGatherMode for compression on CPU");
303303
return false;
304304
}
305-
if (GetProcessingSettings().tpcApplyDebugClusterFilter == 1 && (GetRecoStepsGPU() & GPUDataTypes::RecoStep::TPCClusterFinding || GetProcessingSettings().delayedOutput || GetProcessingSettings().runMC)) {
306-
GPUError("tpcApplyDebugClusterFilter cannot be used with GPU clusterization or with delayedOutput for GPU or with MC labels");
305+
if (GetProcessingSettings().tpcApplyClusterFilterOnCPU > 0 && (GetRecoStepsGPU() & GPUDataTypes::RecoStep::TPCClusterFinding || GetProcessingSettings().delayedOutput || GetProcessingSettings().runMC)) {
306+
GPUError("tpcApplyClusterFilterOnCPU cannot be used with GPU clusterization or with delayedOutput for GPU or with MC labels");
307307
return false;
308308
}
309309
if (GetRecoSteps() & RecoStep::TRDTracking) {
@@ -815,7 +815,7 @@ int32_t GPUChainTracking::RunChainFinalize()
815815

816816
PrintDebugOutput();
817817

818-
//PrintMemoryRelations();
818+
// PrintMemoryRelations();
819819

820820
if (GetProcessingSettings().eventDisplay) {
821821
if (!mDisplayRunning) {

GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ std::pair<uint32_t, uint32_t> GPUChainTracking::TPCClusterizerDecodeZSCount(uint
149149
uint32_t endpointAdcSamples[GPUTrackingInOutZS::NENDPOINTS];
150150
memset(endpointAdcSamples, 0, sizeof(endpointAdcSamples));
151151
bool doGPU = mRec->GetRecoStepsGPU() & GPUDataTypes::RecoStep::TPCClusterFinding;
152-
int32_t firstHBF = (mIOPtrs.settingsTF && mIOPtrs.settingsTF->hasTfStartOrbit) ? mIOPtrs.settingsTF->tfStartOrbit : (mIOPtrs.tpcZS->sector[iSector].count[0] && mIOPtrs.tpcZS->sector[iSector].nZSPtr[0][0]) ? o2::raw::RDHUtils::getHeartBeatOrbit(*(const o2::header::RAWDataHeader*)mIOPtrs.tpcZS->sector[iSector].zsPtr[0][0]) : 0;
152+
int32_t firstHBF = (mIOPtrs.settingsTF && mIOPtrs.settingsTF->hasTfStartOrbit) ? mIOPtrs.settingsTF->tfStartOrbit : (mIOPtrs.tpcZS->sector[iSector].count[0] && mIOPtrs.tpcZS->sector[iSector].nZSPtr[0][0]) ? o2::raw::RDHUtils::getHeartBeatOrbit(*(const o2::header::RAWDataHeader*)mIOPtrs.tpcZS->sector[iSector].zsPtr[0][0])
153+
: 0;
153154

154155
for (uint16_t j = 0; j < GPUTrackingInOutZS::NENDPOINTS; j++) {
155156
#ifndef GPUCA_NO_VC
@@ -635,7 +636,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
635636
if (mWaitForFinalInputs) {
636637
GPUFatal("Cannot use waitForFinalInput callback without delayed output");
637638
}
638-
if (!GetProcessingSettings().tpcApplyDebugClusterFilter) {
639+
if (!GetProcessingSettings().tpcApplyClusterFilterOnCPU) {
639640
AllocateRegisteredMemory(mInputsHost->mResourceClusterNativeOutput, mSubOutputControls[GPUTrackingOutputs::getIndex(&GPUTrackingOutputs::clustersNative)]);
640641
tmpNativeClusters = mInputsHost->mPclusterNativeOutput;
641642
} else {
@@ -1021,7 +1022,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput)
10211022
tmpNativeAccess->clustersMCTruth = mcLabelsConstView;
10221023
tmpNativeAccess->setOffsetPtrs();
10231024
mIOPtrs.clustersNative = tmpNativeAccess;
1024-
if (GetProcessingSettings().tpcApplyDebugClusterFilter) {
1025+
if (GetProcessingSettings().tpcApplyClusterFilterOnCPU) {
10251026
auto allocator = [this, &tmpNativeClusters](size_t size) {
10261027
this->mInputsHost->mNClusterNative = size;
10271028
this->AllocateRegisteredMemory(this->mInputsHost->mResourceClusterNativeOutput, this->mSubOutputControls[GPUTrackingOutputs::getIndex(&GPUTrackingOutputs::clustersNative)]);

GPU/GPUTracking/Global/GPUChainTrackingDebugAndProfiling.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ void GPUChainTracking::SanityCheck()
295295

296296
void GPUChainTracking::RunTPCClusterFilter(o2::tpc::ClusterNativeAccess* clusters, std::function<o2::tpc::ClusterNative*(size_t)> allocator, bool applyClusterCuts)
297297
{
298-
GPUTPCClusterFilter clusterFilter(*clusters);
298+
const uint8_t filterType = GetProcessingSettings().tpcApplyClusterFilterOnCPU;
299+
GPUTPCClusterFilter clusterFilter(*clusters, filterType);
299300
o2::tpc::ClusterNative* outputBuffer = nullptr;
300301
for (int32_t iPhase = 0; iPhase < 2; iPhase++) {
301302
uint32_t countTotal = 0;
@@ -312,7 +313,7 @@ void GPUChainTracking::RunTPCClusterFilter(o2::tpc::ClusterNativeAccess* cluster
312313
if (param().tpcCutTimeBin > 0) {
313314
keep = keep && cl.getTime() < param().tpcCutTimeBin;
314315
}
315-
keep = keep && (!GetProcessingSettings().tpcApplyDebugClusterFilter || clusterFilter.filter(iSector, iRow, cl));
316+
keep = keep && (!filterType || clusterFilter.filter(iSector, iRow, cl));
316317
if (iPhase && keep) {
317318
outputBuffer[countTotal] = cl;
318319
}

0 commit comments

Comments
 (0)