@@ -149,30 +149,32 @@ struct random_scatterer : actor {
149
149
bound_params.dir (),
150
150
bound_params.bound_local ())};
151
151
152
- sf.template visit_material <kernel>(simulator_state, ptc, bound_params,
153
- cos_inc_angle,
154
- bound_params.bound_local ()[0 ]);
155
-
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 );
161
-
162
- // Update Qop
163
- bound_params.set_qop (ptc.charge () / new_mom);
164
-
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
-
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));
173
-
174
- // Flag renavigation of the current candidate
175
- prop_state._navigation .set_high_trust ();
152
+ const bool success = sf.template visit_material <kernel>(
153
+ simulator_state, ptc, bound_params, cos_inc_angle,
154
+ bound_params.bound_local ()[0 ]);
155
+
156
+ if (success) {
157
+ // Get the new momentum
158
+ const auto new_mom = attenuate (
159
+ simulator_state.e_loss_mpv , simulator_state.e_loss_sigma ,
160
+ ptc.mass (), bound_params.p (ptc.charge ()),
161
+ simulator_state.generator );
162
+
163
+ // Update Qop
164
+ bound_params.set_qop (ptc.charge () / new_mom);
165
+
166
+ // Get the new direction from random scattering
167
+ const auto new_dir = scatter (
168
+ bound_params.dir (), simulator_state.projected_scattering_angle ,
169
+ simulator_state.generator );
170
+
171
+ // Update Phi and Theta
172
+ stepping.bound_params ().set_phi (vector::phi (new_dir));
173
+ stepping.bound_params ().set_theta (vector::theta (new_dir));
174
+
175
+ // Flag renavigation of the current candidate
176
+ prop_state._navigation .set_high_trust ();
177
+ }
176
178
}
177
179
178
180
// / @brief Get the new momentum from the landau distribution
0 commit comments