Indexing-ambiguity detection/resolution is no longer part of scaling: it
is a dedicated per-image step for stills (or a post-full-merge step for
rotation). Pull the stills per-image resolver out of ScaleOnTheFly into a
new ReindexAmbiguityResolver in ReindexAmbiguity.{h,cpp}, alongside the
existing rotation free functions (ChooseReindex / ReferenceIntensityCC).
Both workflows now share the operator generation and the best-op
selection (new file-local PickBestReindex helper); ChooseReindex is
rewired onto it. ScaleOnTheFly is now purely a scaling engine (no
ambiguity_ops, no resolve_ambiguity flag, no ResolveIndexingAmbiguity).
Pure refactor: behaviour is unchanged. IndexAndRefine now holds a
ReindexAmbiguityResolver and calls Resolve() at the same call site.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
45 lines
1.5 KiB
C++
45 lines
1.5 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 B = 0;
|
|
double G = 1.0;
|
|
double cc = NAN;
|
|
size_t cc_n = 0;
|
|
float time_s = 0.0;
|
|
bool succesful = false;
|
|
};
|
|
|
|
// 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 B-factor may be refined
|
|
// (Ceres); otherwise the fit is linear in G (a robust 1-D IRLS). Rotation self-scaling/merging offline
|
|
// uses the dedicated RotationScaleMerge path instead.
|
|
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;
|
|
[[nodiscard]] std::pair<double, size_t> CalculateGlobalCC(const std::vector<Reflection> &reflections) 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;
|
|
};
|
|
|