Integration: the radial background correction carries the corrected background into var_bkg (D14)

The correction moved bkg and I but left the non-signal variance carried to the merge at the ring's
level. var_bkg = g (n bkg + n^2 bkg_var): its first term is the Poisson share of the background under
the signal disk, which is the corrected background, so it now moves with it (CPU, CUDA; Metal runs
the CPU correction). The second term - the noise of the ring estimate - and sigma, which is taken
from the counts in the disk, do not depend on the curve and are unchanged. Not touched: the strong
flag and the centroid are still taken at the uncorrected pedestal.

Only reflections the correction is applied to change; tests: the corrected empty aperture's var_bkg
moves by n_inner times the background change (CPU), and GPU var_bkg matches the CPU with a curve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
(cherry picked from commit 6d85d594a4199e86d67c779b5301e88e48a3ad49)
This commit is contained in:
leonarski_f committed 2026-10-23 21:21:46 +02:00
1 parent e866262ed6
commit 6940718cf5
4 files changed
+17 -6

No files matched your search

+7 -3
View File
@@ -194,12 +194,16 @@ TEST_CASE("BraggIntegrationEngineCPU_RadialCurveFromRings", "[Integration][porta
REQUIRE(!engine.GetRadialBackground().empty());
const auto out = engine.Run(image, predicted, predicted.size(), 0);
REQUIRE(out.size() == 1);
return out[0].I;
return out[0];
};
// The curvature is along the radius only, so the error is n_inner x 0.05 x (<u^2>_ring - <u^2>_disk)
// with u the radial offset: 49 px x 0.05 x ((6^2 + 13^2) / 4 - 4^2 / 4) = 116 counts read too low.
CHECK(integrate(false) < -80.0f);
CHECK(std::fabs(integrate(true)) < 5.0f);
const Reflection plain = integrate(false), corrected = integrate(true);
CHECK(plain.I < -80.0f);
CHECK(std::fabs(corrected.I) < 5.0f);
// The non-signal variance follows the corrected background under the signal disk (45 pixels at
// r1 = 4); the ring's own estimate noise is the same either way.
CHECK(corrected.var_bkg - plain.var_bkg == Catch::Approx(45.0 * (corrected.bkg - plain.bkg)).epsilon(1e-4));
// An empty profile hands the curve back to the reflections' own rings.
BraggIntegrationEngineCPU engine(experiment, PixelMask(experiment));