Files
Jungfraujoch/image_analysis/SpotAnalysis.cpp
2025-07-08 20:19:59 +02:00

35 lines
1.1 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "SpotAnalysis.h"
void CountSpots(DataMessage &msg,
const DiffractionExperiment& experiment,
const std::vector<DiffractionSpot> &spots,
float d_min_A) {
int64_t low_res = 0;
int64_t ice_ring = 0;
auto geom = experiment.GetDiffractionGeometry();
for (auto &s: spots) {
double d = s.GetResolution(geom);
// Ice ring resolution taken from:
// Moreau, Atakisi, Thorne, Acta Cryst D77, 2021, 540,554
// https://journals.iucr.org/d/issues/2021/04/00/tz5104/index.html
double tol = 0.05;
if (fabs(d - 3.895) < tol
|| fabs(d - 3.661) < tol
|| fabs(d - 3.438) < tol
|| fabs(d - 2.667) < tol
|| fabs(d - 2.249) < tol
|| fabs(d - 2.068) < tol) {
ice_ring++;
}
if (d > d_min_A)
low_res++;
}
msg.spot_count = spots.size();
msg.spot_count_low_res = low_res;
msg.spot_count_ice_rings = ice_ring;
}