@@ -73,28 +73,21 @@ struct ClusterNative {
7373 uint8_t sigmaTimePacked; // < Sigma of the time in packed format
7474 uint8_t sigmaPadPacked; // < Sigma of the pad in packed format
7575 uint16_t qMax; // < QMax of the cluster
76- uint16_t qTot; // < Total charge of the cluster
76+ uint16_t qTotPacked; // < Total charge of the cluster
7777
7878 GPUd () static uint16_t packPad (float pad) { return (uint16_t )(pad * scalePadPacked + 0.5 ); }
7979 GPUd () static uint32_t packTime (float time) { return (uint32_t )(time * scaleTimePacked + 0.5 ); }
8080 GPUd () static float unpackPad (uint16_t pad) { return float (pad) * (1 .f / scalePadPacked); }
8181 GPUd () static float unpackTime (uint32_t time) { return float (time) * (1 .f / scaleTimePacked); }
8282
8383 GPUdDefault () ClusterNative() = default ;
84- GPUd () ClusterNative(uint32_t time, uint8_t flags, uint16_t pad, uint8_t sigmaTime, uint8_t sigmaPad, uint16_t qmax, uint16_t qtot ) : padPacked(pad), sigmaTimePacked(sigmaTime), sigmaPadPacked(sigmaPad), qMax(qmax), qTot(qtot )
84+ 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 )
8585 {
8686 setTimePackedFlags (time, flags);
8787 }
8888
8989 GPUd () uint16_t getQmax () const { return qMax; }
90- GPUd () uint16_t getQtot () const
91- {
92- if (isSaturated ()) [[unlikely]] {
93- auto sQtot = getSaturatedQtot ();
94- return sQtot < USHRT_MAX ? sQtot : USHRT_MAX ;
95- }
96- return qTot;
97- }
90+ GPUd () uint32_t getQtot () const { return isSaturated () ? getSaturatedQtot () : (uint32_t )qTotPacked; }
9891 GPUd () uint8_t getFlags () const { return timeFlagsPacked >> 24 ; }
9992 GPUd () uint32_t getTimePacked () const { return timeFlagsPacked & 0xFFFFFF ; }
10093 GPUd () void setTimePackedFlags (uint32_t timePacked, uint8_t flags)
@@ -155,19 +148,19 @@ struct ClusterNative {
155148 sigmaPadPacked = tmp;
156149 }
157150
158- GPUd () bool isSaturated () const { return qTot > maxRegularQtot; }
151+ GPUd () bool isSaturated () const { return qTotPacked > maxRegularQtot; }
159152
160153 GPUd () void setSaturatedQtot (uint32_t qtot)
161154 {
162- this ->qTot = USHRT_MAX ;
155+ this ->qTotPacked = USHRT_MAX ;
163156 if (qtot < maxSaturatedQtot) {
164- this ->qTot = ((qtot + scaleSaturatedQtot / 2 ) / scaleSaturatedQtot) + maxRegularQtot;
157+ this ->qTotPacked = ((qtot + scaleSaturatedQtot / 2 ) / scaleSaturatedQtot) + maxRegularQtot;
165158 }
166159 }
167160
168161 GPUd () uint32_t getSaturatedQtot () const
169162 {
170- return uint32_t (qTot - maxRegularQtot) * scaleSaturatedQtot;
163+ return uint32_t (qTotPacked - maxRegularQtot) * scaleSaturatedQtot;
171164 }
172165
173166 GPUd () void setSaturatedTailLength (uint32_t tail)
@@ -192,8 +185,8 @@ struct ClusterNative {
192185 return (this ->sigmaPadPacked < rhs.sigmaPadPacked );
193186 } else if (this ->qMax != rhs.qMax ) {
194187 return (this ->qMax < rhs.qMax );
195- } else if (this ->qTot != rhs.qTot ) {
196- return (this ->qTot < rhs.qTot );
188+ } else if (this ->qTotPacked != rhs.qTotPacked ) {
189+ return (this ->getQtot () < rhs.getQtot () );
197190 } else {
198191 return (this ->getFlags () < rhs.getFlags ());
199192 }
@@ -206,7 +199,7 @@ struct ClusterNative {
206199 this ->sigmaTimePacked == rhs.sigmaTimePacked &&
207200 this ->sigmaPadPacked == rhs.sigmaPadPacked &&
208201 this ->qMax == rhs.qMax &&
209- this ->qTot == rhs.qTot &&
202+ this ->qTotPacked == rhs.qTotPacked &&
210203 this ->getFlags () == rhs.getFlags ();
211204 }
212205
0 commit comments