@@ -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.
327327struct 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 ];
0 commit comments