Add correlated K/Kpri scoring and scatter-dominant mode to egs_kerma - #1442
Open
mainegra wants to merge 3 commits into
Open
Add correlated K/Kpri scoring and scatter-dominant mode to egs_kerma#1442mainegra wants to merge 3 commits into
mainegra wants to merge 3 commits into
Conversation
Introduce is_scatter_correction flag (default true = score Kpri) and input key "scatter correction = no" to switch to scatter-dominant mode (score Kscat instead of Kpri), computing K/Kpri = K/(K-Kscat). Both modes accumulate the cross-term Sum(K*q) per region in scg_kp[][], enabling a correlated ratio estimate that eliminates the large positive covariance between K and Kpri/Kscat. The correlated uncertainty formula is σ_BUF/BUF = sqrt(δ_K² + δ_q² - 2·rc) for scatter-correction mode, and |BUF-1|·sqrt(δ_K² + δ_S² - 2·rc) for scatter-dominant mode (delta method applied to BUF = 1/(1-ρ) where ρ = Kscat/K). scg_kp is fully serialized in outputData/readData/addState/resetCounter for correct parallel job combination. Column header "K/Kpri" replaces "BUF" in all output strings; code variable names BUF/dBUF are unchanged. Co-Authored-By: Claude Sonnet 4.6
rc = cov(K,q)/(K*q) — it is unbounded and should never be clamped to [-1,1]. Add a comment at both rc sites so a future reader does not "fix" it by treating it as a Pearson coefficient. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mainegra
requested review from
ftessier and
rtownson
and removed request for
a team
July 30, 2026 14:41
Completes propagation of 409e460 to the top of the stack. This is the branch the cluster builds from, so results produced before this merge carry the splitting-rate-dependent bias and are not comparable with results produced after it. Verified after the fix: the map dependence at 15 mfp drops from 12.8 sigma to 1.7 sigma, and both maps agree with two independent calculations that use no importance sampling (30.671 and 30.217 against 30.304 and 30.328). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
via a per-region cross-term array
scg_kp[j][ir]accumulated once per history in
endHistory.scatter correction = no) that scoresand derives
Default (
scatter correction = yes) scoresphotons) directly.
Physics
Both modes report$R = K / K_\text{pri}$ . They differ in what secondary$q$ is scored and how $K_\text{pri}$ is obtained from it.
quantity
Scatter-correction mode (
scatter correction = yes, default)Applying the delta method to$R = K/q$ :
where$\delta_X = \sigma_X / \bar X$ is the relative standard deviation$r_c = cov(K,q)/(\bar K \bar q)$ is the
and
relative covariance (not the Pearson coefficient; unbounded).
Scatter-dominant mode (
scatter correction = no)Applying the delta method to$R = K/(K-q)$ :
where$r_c = cov(K, K_\text{scat})/(\bar K \bar K_\text{scat})$ .
The$(R-1)^2$ prefactor makes this mode dramatically less efficient at$R \approx 86$ , so even near-perfect$K$ and $K_\text{scat}$ is insufficient to overcome$\approx 85\times$ amplification of any residual decorrelation.${\sim}5.7\times$ less
depth: at 30 mfp in iron
correlation between
the
Benchmark runs show scatter-dominant mode is
efficient per history than scatter-correction mode at 30 mfp.
Note on$r_c$
estimated from the cross-term array as
It is not the Pearson correlation coefficient and is not bounded to
$[-1,1]$ . Do not clamp it.
Input
Implementation notes
scg_kpis allocated only whenscore primaries = yes; fullyserialized in
outputData/readData/addState/resetCounterfor correct parallel job combination.
kerma_pstores eitheron
is_scatter_correction; the latch condition at scoring time is!latch(correction mode) orlatch != 0(scatter mode).