ShadowFinder: the deficit and the reflection guard in photons on a detector read in ADU
The shadow is a ratio and does not depend on the units, but two tests in the shadow finder are made in counts: the Poisson significance of a pixel's deficit against its ring, and the maximum a pixel must reach (25) to have recorded a reflection that is never masked. On a frame analysed in ADU at a gain g > 1 the first was overstated by sqrt(g) and the second fired on a few photons - on a stop that lets a little through, the whole stop was given back as "reflections". Both are now taken in photons: the counts behind the deficit divided by the gain, the reflection count multiplied by it. CPU and CUDA alike (ShadowMaskSetup carries the gain). g = 1 (every photon-counting input) is bit-identical by construction. Tests: ShadowFinder_ADetectorReadInADUGivesThePhotonMask (the photon scene times 9 at gain 9 gives the photon mask; at gain 1 the stop is given back), and a device-vs-host section on the same scene. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu (cherry picked from commit 148177e3e54c9ac3a129c6ff3cd4fa24e6d34b07)
This commit is contained in:
1 parent
a9215fe652
commit
e866262ed6
8 files changed
+81
-20
No files matched your search
@@ -112,6 +112,37 @@ TEST_CASE("ShadowFinder_FindsAnInjectedBeamStop", "[ShadowFinder]") {
|
||||
CHECK(std::count(mask.begin(), mask.end(), 1u) == 2612);
|
||||
}
|
||||
|
||||
// A detector read in ADU is the photon scene times its gain, and with the gain given the mask is the
|
||||
// photon scene's. The stop here lets three photons a frame through: at nine ADU a photon that is 27
|
||||
// counts, which a photon threshold would take for a recorded reflection and give the whole stop back.
|
||||
TEST_CASE("ShadowFinder_ADetectorReadInADUGivesThePhotonMask", "[ShadowFinder]") {
|
||||
constexpr int32_t gain = 9;
|
||||
const auto mask_of = [](int32_t scale, float pixel_gain) {
|
||||
DiffractionExperiment x = TestExperiment();
|
||||
BraggIntegrationSettings bis = x.GetBraggIntegrationSettings();
|
||||
bis.PixelGain(pixel_gain);
|
||||
x.ImportBraggIntegrationSettings(bis);
|
||||
const PixelMask pixel_mask(x);
|
||||
ShadowFinder finder(x, pixel_mask);
|
||||
std::vector<std::vector<int32_t>> frames;
|
||||
std::vector<uint8_t> buffer;
|
||||
for (int f = 0; f < NFRAMES; f++) {
|
||||
std::vector<int32_t> frame = Scene(/*cross=*/false, /*reflection=*/false);
|
||||
for (auto &v : frame)
|
||||
v = scale * (v == 0 ? 3 : 12);
|
||||
frames.push_back(std::move(frame));
|
||||
DataMessage msg{};
|
||||
msg.image = CompressedImage(frames.back(), W, H);
|
||||
finder.AddImage(msg, buffer);
|
||||
}
|
||||
return finder.GetMask();
|
||||
};
|
||||
const auto photons = mask_of(1, 1.0f);
|
||||
REQUIRE(photons[I(C, C)] == 1);
|
||||
CHECK(mask_of(gain, static_cast<float>(gain)) == photons);
|
||||
CHECK(mask_of(gain, 1.0f)[I(C, C)] == 0);
|
||||
}
|
||||
|
||||
// A holder arm that lets part of the beam through, on a background bright enough that every pixel
|
||||
// reaches the reflection guard's count, crossing a module gap wider than the bridge. Each of the
|
||||
// three hid the arm on its own: the partly transmitting stretch never reaches SHADOW_RATIO, the gap
|
||||
@@ -680,6 +711,23 @@ TEST_CASE("ShadowFinder_DeviceMaskMatchesHost", "[ShadowFinder]") {
|
||||
CHECK(std::count(r.host_mask.begin(), r.host_mask.end(), ShadowFinder::TRANSMITTING) > 0);
|
||||
CHECK(r.device_mask == r.host_mask);
|
||||
}
|
||||
|
||||
SECTION("a stop that lets a little through, read in ADU at the gain") {
|
||||
constexpr int32_t gain = 9;
|
||||
DiffractionExperiment x = TestExperiment();
|
||||
BraggIntegrationSettings bis = x.GetBraggIntegrationSettings();
|
||||
bis.PixelGain(static_cast<float>(gain));
|
||||
x.ImportBraggIntegrationSettings(bis);
|
||||
std::vector<std::vector<int32_t>> frames;
|
||||
for (int f = 0; f < NFRAMES; f++) {
|
||||
frames.push_back(Scene(false, false));
|
||||
for (auto &v : frames.back())
|
||||
v = gain * (v == 0 ? 3 : 12);
|
||||
}
|
||||
const auto r = MaskBothWays(x, frames);
|
||||
CHECK(r.host_mask[I(C, C)] == 1);
|
||||
CHECK(r.device_mask == r.host_mask);
|
||||
}
|
||||
}
|
||||
|
||||
// The pre-scan keeps one accumulator per card and folds them together when the mask is read. Two
|
||||
|
||||
Reference in new issue
Block a user