diff --git a/rugnux/RugnuxScaleMerge.cpp b/rugnux/RugnuxScaleMerge.cpp index eb55df05b..3ee74f930 100644 --- a/rugnux/RugnuxScaleMerge.cpp +++ b/rugnux/RugnuxScaleMerge.cpp @@ -406,16 +406,26 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { // drops the whole rocking event) - they are the strongest reflections, mostly at low resolution, // and what a model's low-resolution terms rest on. { - for (const auto &io : indexer->GetIntegrationOutcome()) - for (const auto &r : io.reflections) { + // Integer counts, one image per task: the totals do not depend on the split. + const auto &outcomes = indexer->GetIntegrationOutcome(); + std::atomic n_all{0}, n_low{0}, n_over{0}, n_over_low{0}; + ParallelFor(static_cast(outcomes.size()), config_.nthreads, [&](int o) { + int64_t all = 0, low = 0, over = 0, over_low = 0; + for (const auto &r : outcomes[o].reflections) { const bool low_res = r.d >= OVERLOAD_LOW_RES_A; - ++result.integrated_reflections; - result.integrated_reflections_low_res += low_res; + ++all; + low += low_res; if (r.overloaded) { - ++result.overloaded_reflections; - result.overloaded_reflections_low_res += low_res; + ++over; + over_low += low_res; } } + n_all += all; n_low += low; n_over += over; n_over_low += over_low; + }); + result.integrated_reflections += n_all; + result.integrated_reflections_low_res += n_low; + result.overloaded_reflections += n_over; + result.overloaded_reflections_low_res += n_over_low; if (result.integrated_reflections > 0) logger.Info("Overloads: {} of {} integrated reflections ({:.3f}%) held a saturated pixel, {:.3f}% of " "the {} coarser than {:.0f} A", result.overloaded_reflections, @@ -460,15 +470,20 @@ bool Rugnux::ScaleMergeAndSymmetry(PipelineLocals &p) { *ice_score, ice_min_score, ice_spot_ratio.value_or(NAN), ice_min_spot_ratio); } else if (experiment_.IsDetectIceRings()) { const float ice_width = config_.spot_finding.ice_ring_width_Q_recipA; - size_t total = 0, flagged = 0; - for (auto &outcome : indexer->GetIntegrationOutcome()) { - for (auto &r : outcome.reflections) { - ++total; + auto &outcomes = indexer->GetIntegrationOutcome(); + std::atomic n_total{0}, n_flagged{0}; + ParallelFor(static_cast(outcomes.size()), config_.nthreads, [&](int o) { + size_t all = 0, on_ice = 0; + for (auto &r : outcomes[o].reflections) { + ++all; r.on_ice_ring = IsOnIceRing(r.d, ice_width); if (r.on_ice_ring) - ++flagged; + ++on_ice; } - } + n_total += all; + n_flagged += on_ice; + }); + const size_t total = n_total, flagged = n_flagged; result.ice_rings_detected = true; result.ice_flagged_fraction = total > 0 ? static_cast(flagged) / total : 0.0; logger.Info("Ice-ring handling: ice score {:.2f} (gate {:.2f}), spot ratio {:.2f} (gate "