@@ -135,10 +135,18 @@ __device__ void GammaInteraction(int const globalSlot, SOAData const &soaData, i
135
135
const int theMCIndex = MCIndex[lvolID];
136
136
const auto energy = currentTrack.energy ;
137
137
138
- auto survive = [&] { activeQueue-> push_back (globalSlot); } ;
138
+ __shared__ std::byte rngSM[ThreadsPerBlock * sizeof (RanluxppDouble)] ;
139
139
140
- RanluxppDouble newRNG{currentTrack.rngState .Branch ()};
141
- G4HepEmRandomEngine rnge{¤tTrack.rngState };
140
+ auto &rngState = reinterpret_cast <RanluxppDouble *>(rngSM)[threadIdx .x ];
141
+ rngState = currentTrack.rngState ;
142
+
143
+ auto survive = [&] {
144
+ currentTrack.rngState = rngState;
145
+ activeQueue->push_back (globalSlot);
146
+ };
147
+
148
+ RanluxppDouble newRNG{rngState.Branch ()};
149
+ G4HepEmRandomEngine rnge{&rngState};
142
150
143
151
if constexpr (ProcessIndex == 0 ) {
144
152
// Invoke gamma conversion to e-/e+ pairs, if the energy is above the threshold.
@@ -169,7 +177,7 @@ __device__ void GammaInteraction(int const globalSlot, SOAData const &soaData, i
169
177
170
178
positron.InitAsSecondary (/* parent=*/ currentTrack);
171
179
// Reuse the RNG state of the dying track.
172
- positron.rngState = currentTrack. rngState ;
180
+ positron.rngState = rngState;
173
181
positron.energy = posKinEnergy;
174
182
positron.dir .Set (dirSecondaryPos[0 ], dirSecondaryPos[1 ], dirSecondaryPos[2 ]);
175
183
0 commit comments