@@ -43,6 +43,9 @@ struct random_scatterer : actor {
43
43
std::random_device rd{};
44
44
std::mt19937_64 generator{rd ()};
45
45
46
+ // / Minimum momentum before simulation is stopped
47
+ scalar_type e_min_p = 10 .f * unit<scalar_type>::MeV;
48
+
46
49
// / most probable energy loss
47
50
scalar_type e_loss_mpv = 0 .f;
48
51
@@ -149,30 +152,37 @@ struct random_scatterer : actor {
149
152
bound_params.dir (),
150
153
bound_params.bound_local ())};
151
154
152
- sf.template visit_material <kernel>(simulator_state, ptc, bound_params,
153
- cos_inc_angle,
154
- bound_params.bound_local ()[0 ]);
155
+ const bool success = sf.template visit_material <kernel>(
156
+ simulator_state, ptc, bound_params, cos_inc_angle,
157
+ bound_params.bound_local ()[0 ]);
155
158
156
- // Get the new momentum
157
- const auto new_mom =
158
- attenuate (simulator_state.e_loss_mpv , simulator_state.e_loss_sigma ,
159
- ptc.mass (), bound_params.p (ptc.charge ()),
160
- simulator_state.generator );
159
+ if (success) {
160
+ // Get the new momentum
161
+ const auto new_mom = attenuate (
162
+ simulator_state.e_loss_mpv , simulator_state.e_loss_sigma ,
163
+ ptc.mass (), bound_params.p (ptc.charge ()),
164
+ simulator_state.generator );
161
165
162
- // Update Qop
163
- bound_params.set_qop (ptc.charge () / new_mom);
166
+ // Update Qop
167
+ bound_params.set_qop (ptc.charge () / new_mom);
164
168
165
- // Get the new direction from random scattering
166
- const auto new_dir = scatter (bound_params. dir (),
167
- simulator_state.projected_scattering_angle ,
168
- simulator_state.generator );
169
+ // Get the new direction from random scattering
170
+ const auto new_dir = scatter (
171
+ bound_params. dir (), simulator_state.projected_scattering_angle ,
172
+ simulator_state.generator );
169
173
170
- // Update Phi and Theta
171
- stepping.bound_params ().set_phi (vector::phi (new_dir));
172
- stepping.bound_params ().set_theta (vector::theta (new_dir));
174
+ // Update Phi and Theta
175
+ stepping.bound_params ().set_phi (vector::phi (new_dir));
176
+ stepping.bound_params ().set_theta (vector::theta (new_dir));
173
177
174
- // Flag renavigation of the current candidate
175
- prop_state._navigation .set_high_trust ();
178
+ if (bound_params.p (ptc.charge ()) < simulator_state.e_min_p ) {
179
+ // Particle below minimum p for simulation: stop
180
+ prop_state._heartbeat &= prop_state._navigation .abort ();
181
+ } else {
182
+ // Flag renavigation of the current candidate
183
+ prop_state._navigation .set_high_trust ();
184
+ }
185
+ }
176
186
}
177
187
178
188
// / @brief Get the new momentum from the landau distribution
0 commit comments