@@ -217,16 +217,14 @@ struct TableDiffWake {
217217 uint64_t substituteP = 0 ;
218218 uint8_t uppermostBit = 20 ;
219219 uint8_t lowermostBit = 0 ;
220+ uint64_t bitmask20Bits = 0b11111111111111111111 ;
220221
221222 int64_t particlePx = (track.px () * 6000 );
222223 if (particlePx < 0 )
223224 substituteP |= static_cast <uint64_t >1 << uppermostBit;
224225 if (particlePx < 0 )
225226 particlePx = (-1 ) * particlePx;
226- for (int8_t i_bit = lowermostBit; i_bit < uppermostBit; i_bit++) {
227- if ((particlePx & (static_cast <int64_t >1 << i_bit)))
228- substituteP |= static_cast <uint64_t >1 << i_bit;
229- }
227+ substituteP |= (particlePx & bitmask20Bits) << lowermostBit;
230228
231229 uppermostBit = 41 ;
232230 lowermostBit = 21 ;
@@ -235,10 +233,7 @@ struct TableDiffWake {
235233 substituteP |= static_cast <uint64_t >1 << uppermostBit;
236234 if (particlePy < 0 )
237235 particlePy = (-1 ) * particlePy;
238- for (int8_t i_bit = lowermostBit; i_bit < uppermostBit; i_bit++) {
239- if ((particlePy & (static_cast <int64_t >1 << (i_bit - lowermostBit))))
240- substituteP |= static_cast <uint64_t >1 << i_bit;
241- }
236+ substituteP |= (particlePy & bitmask20Bits) << lowermostBit;
242237
243238 uppermostBit = 62 ;
244239 lowermostBit = 42 ;
@@ -247,10 +242,7 @@ struct TableDiffWake {
247242 substituteP |= static_cast <uint64_t >1 << uppermostBit;
248243 if (particlePz < 0 )
249244 particlePz = (-1 ) * particlePz;
250- for (int8_t i_bit = lowermostBit; i_bit < uppermostBit; i_bit++) {
251- if ((particlePz & (static_cast <int64_t >1 << (i_bit - lowermostBit))))
252- substituteP |= static_cast <uint64_t >1 << i_bit;
253- }
245+ substituteP |= (particlePz & bitmask20Bits) << lowermostBit;
254246
255247 // dEdx
256248 uint16_t substituteDEDX = static_cast <uint16_t >(track.tpcSignal () * 10 );
0 commit comments