Bragg integration: size each image's reflection list to what is kept

Finalize reserved npredicted reflections and kept only the ones whose fit succeeded. On a dense
long-axis pattern more than half the predicted reflections lose their background ring, so each
retained per-image vector carried more dead capacity than data for the rest of the pass. Count the
kept ones first and reserve exactly that. No result changes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nW6FNRP1bBJJ8pfHiByAT
This commit is contained in:
leonarski_fandClaude Opus 5 committed 2026-09-19 18:27:14 +02:00
1 parent bd386ba0f2
commit e6e506809f
1 file changed
+7 -1
@@ -215,8 +215,14 @@ std::vector<Reflection> BraggIntegrationEngine::Finalize(const std::vector<Refle
size_t npredicted,
const std::vector<BraggFitResult> &results,
int64_t image_number) const {
// Sized to what is kept, not to what was predicted: this vector is the one every image holds to the
// end of the pass, and a background ring lost to the neighbours drops a reflection here - on a
// dense pattern more than half of them, which a reserve of npredicted would carry as dead capacity.
size_t n_ok = 0;
for (size_t i = 0; i < npredicted; ++i)
n_ok += results[i].ok ? 1 : 0;
std::vector<Reflection> out;
out.reserve(npredicted);
out.reserve(n_ok);
for (size_t i = 0; i < npredicted; ++i) {
const auto &fr = results[i];
if (!fr.ok)