Files
Jungfraujoch/image_analysis/UpdateReflectionResolution.cpp
T

40 lines
1.2 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "UpdateReflectionResolution.h"
#include "IntegrationOutcome.h"
#include "../common/CrystalLattice.h"
ResolutionStats UpdateReflectionResolution(const UnitCell &cell, std::vector<IntegrationOutcome > &reflections) {
ResolutionStats ret;
CrystalLattice latt(cell);
const auto astar = latt.Astar();
const auto bstar = latt.Bstar();
const auto cstar = latt.Cstar();
for (auto &image: reflections) {
if (!image.reflections.empty()) {
ret.n_images++;
ret.n_reflections += image.reflections.size();
}
for (auto &r: image.reflections) {
Coord q = r.h * astar + r.k * bstar + r.l * cstar;
auto qlen = q.Length();
if (qlen > 1e-6) {
const float d = 1/qlen;
if (ret.d_high > d)
ret.d_high = d;
if (ret.d_low < d)
ret.d_low = d;
r.d = d;
r.image_scale_corr = r.rlp / r.partiality;
} else
r.d = NAN;
}
}
return ret;
}