Files
Jungfraujoch/image_analysis/scale_merge/ScaleOnTheFly.h
T
leonarski_fandClaude Opus 5 a95aca382c Remove dead code left behind by recent changes
None of this has a reader:

- ScalingSettings::scaling_regularize and its setter/getter
- ScaleOnTheFlyResult::succesful (never set) and ::time_s (set, never read),
  with the timing that only fed the latter
- JFJochImage::last_fit_viewport_ (written twice, read nowhere) and the
  comment claiming the retry uses it - the retry keys off initial_fit_done_
- JFJochDiffractionImage::ice_ring_width_Q_recipA, and a QtConcurrent include
  in a file that uses none
- an unused gemmi::Op accumulator in the spindle-angle helper
- <random> in Merge.{h,cpp}, from before the half-set split became a hash
- an orphaned comment describing the Ceres B-factor residual deleted in
  014e43a4c, and two trailing comments that had collided on one line

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 11:29:42 +02:00

45 lines
1.6 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include "HKLKey.h"
#include "Merge.h"
#include "../../common/DiffractionExperiment.h"
#include "../IntegrationOutcome.h"
#include <map>
#include <vector>
struct ScaleOnTheFlyResult {
double G = 1.0;
double cc = NAN;
size_t cc_n = 0;
};
// Per-image reference scaling with the FIXED partiality model: each reflection's stored partiality is
// used as-is (it is 1 for stills and the zeta/erf rocking-curve value already set at prediction for
// rotation data). No partiality recompute, no mosaicity or wedge refinement: the fit is linear in G, a
// robust 1-D IRLS. Rotation self-scaling/merging offline uses the dedicated RotationScaleMerge path.
class ScaleOnTheFly {
constexpr static size_t MIN_REFLECTIONS = 20;
const ScalingSettings s;
const HKLKeyGenerator hkl_key_generator;
std::map<HKLKey, double> reference_data;
bool Accept(const Reflection &r) const;
public:
ScaleOnTheFly(const DiffractionExperiment &x, const std::vector<MergedReflection> &ref);
void Scale(IntegrationOutcome &integration_outcome) const;
void Scale(std::vector<IntegrationOutcome> &integration_outcome, size_t nthreads = 0) const;
// Leave an image unscaled when its fitted scale collapsed far below the run median (see the .cpp).
// Called by the multi-image Scale, which is where the run median exists; public so a caller that
// scales images one at a time can apply it once it has them all.
static void RejectCollapsedScales(std::vector<IntegrationOutcome> &integration);
};