Skip to content

Commit

Permalink
mcxtrace: Fluo: stop multi fluo when weighting gets very low
Browse files Browse the repository at this point in the history
  • Loading branch information
farhi committed Dec 11, 2023
1 parent f462176 commit 22a171d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mcxtrace-comps/samples/Fluorescence.comp
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ off_struct thread_offdata = offdata;
#define thread_offdata offdata
#endif

double ki_x,ki_y,ki_z,ki,Ei;
double ki_x,ki_y,ki_z,ki,Ei, pi;
double kf_x,kf_y,kf_z,kf,Ef;

/* Store Initial photon state */
Expand All @@ -565,6 +565,7 @@ ki_z = kz;
ki = sqrt(kx*kx+ky*ky+kz*kz); // Angs-1
kf = ki;
Ei = K2E*ki; // keV
pi = p; // used to test for multiple fluo weighting and order cutoff

do { /* while (intersect) Loop over multiple scattering events */

Expand Down Expand Up @@ -874,7 +875,8 @@ do { /* while (intersect) Loop over multiple scattering events */

/* exit if multiple scattering order has been reached */
if (!order) break; // skip final absorption
if (order && event_counter >= order) { force_transmit=1; }
// stop when order has been reached, or weighting is very low
if (order && (event_counter >= order || p/pi < 1e-7)) { force_transmit=1; }

} // if intersect (scatter)
} while(intersect); /* end do (intersect) (multiple scattering loop) */
Expand Down

0 comments on commit 22a171d

Please sign in to comment.