Skip to content

Commit 0833ce8

Browse files
committed
Adding direction vector as separate struct
1 parent 2efd2f2 commit 0833ce8

13 files changed

Lines changed: 164 additions & 71 deletions

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

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ struct ClusterNative {
6666
static constexpr int scaleSaturatedQtot = 8;
6767
static constexpr int maxRegularQtot = 25 * 1024;
6868
static constexpr int maxSaturatedQtot = (USHRT_MAX - maxRegularQtot) * scaleSaturatedQtot;
69-
static constexpr float scaleNNDirectionPacked = 2048.f;
70-
static constexpr int16_t invalidNNDirectionPacked = -32768;
71-
static constexpr float maxNNDirection = 32767.f / scaleNNDirectionPacked;
7269

7370
uint32_t timeFlagsPacked; //< Contains the time in the lower 24 bits in a packed format, contains the flags in the
7471
// upper 8 bits
@@ -77,40 +74,18 @@ struct ClusterNative {
7774
uint8_t sigmaPadPacked; //< Sigma of the pad in packed format
7875
uint16_t qMax; //< QMax of the cluster
7976
uint16_t qTotPacked; //< Total charge of the cluster
80-
int16_t nnDydxPacked = invalidNNDirectionPacked;
81-
int16_t nnDzdxPacked = invalidNNDirectionPacked;
8277

8378
GPUd() static uint16_t packPad(float pad) { return (uint16_t)(pad * scalePadPacked + 0.5); }
8479
GPUd() static uint32_t packTime(float time) { return (uint32_t)(time * scaleTimePacked + 0.5); }
8580
GPUd() static float unpackPad(uint16_t pad) { return float(pad) * (1.f / scalePadPacked); }
8681
GPUd() static float unpackTime(uint32_t time) { return float(time) * (1.f / scaleTimePacked); }
87-
GPUd() static int16_t packNNDirection(float v)
88-
{
89-
v = v < -maxNNDirection ? -maxNNDirection : (v > maxNNDirection ? maxNNDirection : v);
90-
return static_cast<int16_t>(v * scaleNNDirectionPacked + (v >= 0.f ? 0.5f : -0.5f));
91-
}
92-
GPUd() static float unpackNNDirection(int16_t v) { return float(v) * (1.f / scaleNNDirectionPacked); }
9382

9483
GPUdDefault() ClusterNative() = default;
9584
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)
9685
{
9786
setTimePackedFlags(time, flags);
9887
}
9988

100-
GPUd() bool hasNNDirection() const { return nnDydxPacked != invalidNNDirectionPacked && nnDzdxPacked != invalidNNDirectionPacked; }
101-
GPUd() float getNNDydx() const { return unpackNNDirection(nnDydxPacked); }
102-
GPUd() float getNNDzdx() const { return unpackNNDirection(nnDzdxPacked); }
103-
GPUd() void setNNDirection(float dydx, float dzdx)
104-
{
105-
nnDydxPacked = packNNDirection(dydx);
106-
nnDzdxPacked = packNNDirection(dzdx);
107-
}
108-
GPUd() void clearNNDirection()
109-
{
110-
nnDydxPacked = invalidNNDirectionPacked;
111-
nnDzdxPacked = invalidNNDirectionPacked;
112-
}
113-
11489
GPUd() uint16_t getQmax() const { return qMax; }
11590
GPUd() uint32_t getQtot() const { return isSaturated() ? getSaturatedQtot() : (uint32_t)qTotPacked; }
11691
GPUd() uint8_t getFlags() const { return timeFlagsPacked >> 24; }
@@ -212,10 +187,6 @@ struct ClusterNative {
212187
return (this->qMax < rhs.qMax);
213188
} else if (this->qTotPacked != rhs.qTotPacked) {
214189
return (this->getQtot() < rhs.getQtot());
215-
} else if (this->nnDydxPacked != rhs.nnDydxPacked) {
216-
return (this->nnDydxPacked < rhs.nnDydxPacked);
217-
} else if (this->nnDzdxPacked != rhs.nnDzdxPacked) {
218-
return (this->nnDzdxPacked < rhs.nnDzdxPacked);
219190
} else {
220191
return (this->getFlags() < rhs.getFlags());
221192
}
@@ -229,8 +200,6 @@ struct ClusterNative {
229200
this->sigmaPadPacked == rhs.sigmaPadPacked &&
230201
this->qMax == rhs.qMax &&
231202
this->qTotPacked == rhs.qTotPacked &&
232-
this->nnDydxPacked == rhs.nnDydxPacked &&
233-
this->nnDzdxPacked == rhs.nnDzdxPacked &&
234203
this->getFlags() == rhs.getFlags();
235204
}
236205

@@ -322,10 +291,42 @@ struct ClusterNative {
322291
}
323292
};
324293

294+
struct ClusterNativeNNDirection {
295+
static constexpr float scalePacked = 2048.f;
296+
static constexpr float maxDirection = 32767.f / scalePacked;
297+
static constexpr uint16_t invalidPacked = 0;
298+
299+
uint16_t dydxPacked = invalidPacked;
300+
uint16_t dzdxPacked = invalidPacked;
301+
302+
GPUd() static uint16_t pack(float v)
303+
{
304+
v = v < -maxDirection ? -maxDirection : (v > maxDirection ? maxDirection : v);
305+
const int32_t packedSigned = static_cast<int32_t>(v * scalePacked + (v >= 0.f ? 0.5f : -0.5f));
306+
return static_cast<uint16_t>(packedSigned + 32768);
307+
}
308+
GPUd() static float unpack(uint16_t v) { return static_cast<float>(static_cast<int32_t>(v) - 32768) * (1.f / scalePacked); }
309+
310+
GPUd() bool hasDirection() const { return dydxPacked != invalidPacked && dzdxPacked != invalidPacked; }
311+
GPUd() float getDydx() const { return unpack(dydxPacked); }
312+
GPUd() float getDzdx() const { return unpack(dzdxPacked); }
313+
GPUd() void set(float dydx, float dzdx)
314+
{
315+
dydxPacked = pack(dydx);
316+
dzdxPacked = pack(dzdx);
317+
}
318+
GPUd() void clear()
319+
{
320+
dydxPacked = invalidPacked;
321+
dzdxPacked = invalidPacked;
322+
}
323+
};
324+
325325
// This is an index struct to access TPC clusters inside sectors and rows. It shall not own the data, but just point to
326326
// the data inside a buffer.
327327
struct ClusterNativeAccess {
328328
const ClusterNative* clustersLinear;
329+
const ClusterNativeNNDirection* clustersLinearNNDirection = nullptr;
329330
const ClusterNative* clusters[constants::MAXSECTOR][constants::MAXGLOBALPADROW];
330331
const o2::dataformats::ConstMCTruthContainerView<o2::MCCompLabel>* clustersMCTruth;
331332
unsigned int nClusters[constants::MAXSECTOR][constants::MAXGLOBALPADROW];

GPU/GPUTracking/Definitions/GPUSettingsList.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ AddOptionRTC(dEdxClusterRejectionFlagMask, int8_t, o2::gpu::GPUTPCGMMergedTrackH
167167
AddOptionRTC(dEdxClusterRejectionFlagMaskAlt, int8_t, o2::gpu::GPUTPCGMMergedTrackHit::flagEdge, "", 0, "OR mask of TPC flags that will reject the cluster in alternative dEdx")
168168
AddOptionRTC(rejectEdgeClustersInSeeding, int8_t, 0, "", 0, "Reject edge clusters based on uncorrected track Y during seeding")
169169
AddOptionRTC(rejectEdgeClustersInTrackFit, int8_t, 0, "", 0, "Reject edge clusters based on uncorrected track Y during track fit")
170+
AddOptionRTC(useNNClusterDirection, int8_t, 0, "", 0, "Use TPC NN cluster direction estimate in track seeding")
170171
AddOptionRTC(tubeExtraProtectMinRow, uint8_t, 20, "", 0, "Increase Protection, decrease removal by factor 2, when below this row")
171172
AddOptionRTC(tubeExtraProtectEdgePads, uint8_t, 2, "", 0, "Increase Protection, decrease removal by factor 2, when on this number of pads from the edge")
172173

GPU/GPUTracking/Global/GPUChainTracking.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ namespace o2::tpc
4141
{
4242
struct ClusterNativeAccess;
4343
struct ClusterNative;
44+
struct ClusterNativeNNDirection;
4445
class CalibdEdxContainer;
4546
} // namespace o2::tpc
4647

@@ -313,7 +314,7 @@ class GPUChainTracking : public GPUChain
313314
void RunTPCClusterFilter(o2::tpc::ClusterNativeAccess* clusters, std::function<o2::tpc::ClusterNative*(size_t)> allocator, bool applyClusterCuts);
314315
bool NeedTPCClustersOnGPU();
315316
void WriteReducedClusters();
316-
void SortClusters(bool buildNativeGPU, bool propagateMCLabels, o2::tpc::ClusterNativeAccess* clusterAccess, o2::tpc::ClusterNative* clusters);
317+
void SortClusters(bool buildNativeGPU, bool propagateMCLabels, o2::tpc::ClusterNativeAccess* clusterAccess, o2::tpc::ClusterNative* clusters, o2::tpc::ClusterNativeNNDirection* directions);
317318
template <int32_t I>
318319
int32_t RunTRDTrackingInternal();
319320
uint32_t StreamForSector(uint32_t sector) const;

0 commit comments

Comments
 (0)