@@ -326,13 +326,21 @@ __device__ void ElectronInteraction(int const globalSlot, SOAData const & /*soaD
326326 const int lvolID = volume->GetLogicalVolume ()->id ();
327327 const int theMCIndex = MCIndex[lvolID];
328328
329- auto survive = [&] { activeQueue->push_back (globalSlot); };
329+ __shared__ std::byte rngSM[ThreadsPerBlock * sizeof (RanluxppDouble)];
330+
331+ auto &rngState = reinterpret_cast <RanluxppDouble *>(rngSM)[threadIdx .x ];
332+ rngState = currentTrack.rngState ;
333+
334+ auto survive = [&] {
335+ currentTrack.rngState = rngState;
336+ activeQueue->push_back (globalSlot);
337+ };
330338
331339 const double energy = currentTrack.energy ;
332340 const double theElCut = g4HepEmData.fTheMatCutData ->fMatCutData [theMCIndex].fSecElProdCutE ;
333341
334- RanluxppDouble newRNG{currentTrack. rngState .Branch ()};
335- G4HepEmRandomEngine rnge{¤tTrack. rngState };
342+ RanluxppDouble newRNG{rngState.Branch ()};
343+ G4HepEmRandomEngine rnge{&rngState};
336344
337345 if constexpr (ProcessIndex == 0 ) {
338346 // Invoke ionization (for e-/e+):
@@ -397,7 +405,7 @@ __device__ void ElectronInteraction(int const globalSlot, SOAData const & /*soaD
397405
398406 gamma2.InitAsSecondary (/* parent=*/ currentTrack);
399407 // Reuse the RNG state of the dying track.
400- gamma2.rngState = currentTrack. rngState ;
408+ gamma2.rngState = rngState;
401409 gamma2.energy = theGamma2Ekin;
402410 gamma2.dir .Set (theGamma2Dir[0 ], theGamma2Dir[1 ], theGamma2Dir[2 ]);
403411
0 commit comments