Files
Jungfraujoch/receiver/JFJochReceiverRugnuxRotation.cpp
leonarski_fandClaude Opus 5.5 0d26ecd134
Build Packages / Build documentation (push) Successful in 45s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 28m34s
Build Packages / Create release (push) Successful in 8s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 8m55s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 11m11s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 16m51s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 22m42s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 24m46s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 26m18s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 31m0s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 31m16s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 32m15s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 27m12s
Build Packages / Generate python client (push) Successful in 30s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 30m40s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 33m20s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 31m3s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 27m5s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 30m24s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 32m54s
Build Packages / Unit tests (push) Failing after 1h53m52s
Build Packages / Validation Battery (push) Successful in 46m47s
Receivers and pullers: comments to one line, names to the conventions of the 2025 code
Comments say what the next line does or why; names follow the rest of the receiver: <thing>_mutex, thread
bodies <What>Thread (FPGAImagePuller: AcquireThread, ModuleThread, CompressThread, FinalizeMeasurement),
no single letters for objects. Code does not change. JFJochReceiverFPGA and what the style review's "leave
alone" list names (deleters, exception_ptr, the condition variables, LiveModel) stay as they were.

Moved here from the comments:

Pre-pass size: of 100 frames of a collection indexed at 18%, 7 indexed at a distance 2.6% off and the
geometry refinement did not run; of 500, 34 did and refined it to 0.4%. With the broker's default fixed
threshold 3 points fewer frames index than with the adaptive one the analysis takes.

Preflight sends FillMessage alone, measured on a JUNGFRAU 9M at 1.4 kB against 543 kB for the start
message, and the whole of it rather than the fields the check reads today, so the writer sees the description
it will be given at start.

FFT indexers and cuFFT plans are kept for the life of the broker because every pass of every collection
builds the same pools, and making a plan takes a process-wide lock and took over a second on a card busy
with the online analysis.

The host memory budget subtracts the image buffer, which has to keep the whole collection and so is most of
the machine; at worst what could run side by side runs one part after the other.

The receiver is released before the indexer pool is rebuilt because a fresh GPU indexer next to a stale
receiver (after a failed start the receiver is stopped but not destroyed until the next Start) can fail
to initialise.

ReceiveRingBuffer: one image of a large detector is tens of megabytes, so a queue of a thousand of them is a
quantity of memory nobody chose. Regions are handed out and reclaimed in arrival order; a region released
early is only remembered, and republish holds at most its queue's worth, so that is as far as the reclaim
can lag. A message larger than the whole ring goes on the heap, so an oversized START or END cannot wedge
the receiver. Republish is capped at a share of the ring because it keeps the oldest unsent images and
would otherwise pin everything received after them, running the writer at the republish rate.

ZMQImagePuller: with a full ring the broker's pusher waits one second, then drops the image and sends without
waiting for the rest of the run, so a ring too small for the writer's stalls costs images. TCPImagePuller: a
full ring blocks the pusher's send; its BUSY heartbeats tell it apart from a dead writer, and it gives up
only after a minute in which no image was written. Keep-alive detection is about 60 s, both sides.

Stills model step: the step on a provisional merge still running when the next merge is made is cut, one not
started is replaced; a molecular replacement or a refinement not started is left out at the deadline, a
refinement running is cut short; each step starts from the last placement. Without a space group stated the
frames are merged in the model's where its cell is the run's consensus, otherwise the model is left out.

Rotation, stills and stills with a model end to end against the build before this work: MTZ data columns,
both maps, placed and refined models and blobs are byte for byte the same; only the MTZ history's build
stamp differs. Scan results are the same with times stripped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
2026-11-07 19:36:44 +01:00

442 lines
22 KiB
C++

// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "JFJochReceiverRugnuxRotation.h"
#include <cmath>
#include "spdlog/fmt/fmt.h"
#include "../common/HostMemory.h"
#include "../common/time_utc.h"
#include "../frame_serialize/CBORStream2Deserializer.h"
#include "../rugnux/RugnuxDefaults.h"
#include "../rugnux/RugnuxLive.h"
#include "../rugnux/ResultReport.h"
#include "../writer/RugnuxResultBlocks.h"
#include "RugnuxStructure.h"
namespace {
// Kept for the rest of the broker when the host memory rugnux plans against is decided
constexpr size_t RUGNUX_HOST_MEMORY_MARGIN = 16ULL * 1024 * 1024 * 1024;
// The machine's budget (HostMemory.h) less the image buffer and the margin; never 0, the whole machine's budget
size_t RugnuxHostBudget(const ImageBuffer &buffer) {
const size_t budget = DefaultHostMemoryBudget();
const size_t taken = buffer.GetBufferSize() + RUGNUX_HOST_MEMORY_MARGIN;
return budget > taken ? budget - taken : 1;
}
// A run reachable for Cut while it exists: registered in `slot`, cancelled at once where the cut came first
class Reachable {
std::mutex &slot_mutex;
Rugnux *&slot;
public:
Reachable(std::mutex &in_mutex, Rugnux *&slot, Rugnux &run, const bool &cut, const std::atomic<bool> &cancelled)
: slot_mutex(in_mutex), slot(slot) {
std::unique_lock ul(slot_mutex);
slot = &run;
if (cut || cancelled)
run.Cancel();
}
~Reachable() {
std::unique_lock ul(slot_mutex);
slot = nullptr;
}
};
// Per-image results of rugnux's canonical pass to the plots and scan result, its steps to the live status
class LiveObserver : public RugnuxObserver {
JFJochReceiverPlots &plots;
ScanResultGenerator &scan_result;
const AzimuthalIntegrationMapping &mapping;
RugnuxLiveStatus &status;
std::atomic<bool> canonical{false};
public:
LiveObserver(JFJochReceiverPlots &plots, ScanResultGenerator &scan_result,
const AzimuthalIntegrationMapping &mapping, RugnuxLiveStatus &status)
: plots(plots), scan_result(scan_result), mapping(mapping), status(status) {}
void OnImagePass(bool input) override { canonical = input; }
void OnImageProcessed(const DataMessage &msg) override {
if (!canonical)
return;
plots.Add(msg, AzimuthalIntegrationProfile(mapping));
scan_result.Add(msg);
}
void OnProgress(uint64_t done, uint64_t total) override { status.Progress(done, total); }
void OnStep(const std::string &title) override { status.Step(title); }
void OnNote(const std::string &text) override { status.Note(text); }
};
std::string StateName(RugnuxLiveState state) {
switch (state) {
case RugnuxLiveState::Idle: return "idle";
case RugnuxLiveState::Running: return "running";
case RugnuxLiveState::Done: return "done";
case RugnuxLiveState::Failed: return "failed";
case RugnuxLiveState::Cancelled: return "cancelled";
case RugnuxLiveState::Skipped: return "skipped";
}
return "unknown";
}
}
JFJochReceiverRugnuxRotation::JFJochReceiverRugnuxRotation(const DiffractionExperiment &in_experiment,
const PixelMask &in_pixel_mask,
ImagePuller &in_image_puller,
ImagePusher &in_image_pusher,
Logger &in_logger,
int64_t in_forward_nthreads,
int in_rugnux_nthreads,
std::shared_ptr<const RugnuxModel> in_model,
double in_deadline_s,
RugnuxLiveStatus &in_live_status,
const SpotFindingSettings &in_spot_finding_settings,
JFJochReceiverCurrentStatus &in_current_status,
JFJochReceiverPlots &in_plots,
ImageBuffer &in_image_buffer,
ZMQPreviewSocket *in_zmq_preview_socket,
ZMQMetadataSocket *in_zmq_metadata_socket)
: JFJochReceiverStream(in_experiment, in_pixel_mask, in_image_puller, in_image_pusher, in_logger,
in_forward_nthreads, in_spot_finding_settings, in_current_status, in_plots,
in_image_buffer, in_zmq_preview_socket, in_zmq_metadata_socket, nullptr),
reader(in_image_buffer),
rugnux_nthreads(in_rugnux_nthreads),
host_budget(RugnuxHostBudget(in_image_buffer)),
model(std::move(in_model)),
deadline_s(in_deadline_s),
live_status(in_live_status) {
// Indexers and cuFFT plans kept for the life of the broker; never destroyed, the CUDA runtime may be gone at exit
[[maybe_unused]] static const FFTIndexerReuse *fft_indexers = new FFTIndexerReuse;
[[maybe_unused]] static const FFTPlanReuse *fft_plans = new FFTPlanReuse;
logger.Info("rugnux live: starting {} forward threads; rugnux runs on {} threads while the images arrive, "
"planning against {:.1f} GB of host memory", nthreads, rugnux_nthreads,
static_cast<double>(host_budget) / 1e9);
StartThreads();
}
JFJochReceiverRugnuxRotation::~JFJochReceiverRugnuxRotation() {
cancelled = true;
reader.Ended();
{
std::unique_lock ul(rugnux_mutex);
if (rugnux != nullptr)
rugnux->Cancel();
if (probe != nullptr)
probe->Cancel();
}
JoinThreads();
}
void JFJochReceiverRugnuxRotation::OnStart(std::chrono::steady_clock::time_point received) {
SendStartMessage();
// Rugnux reads the images back from the buffer: without one slot per image the collection is only forwarded
const auto slots = image_buffer.GetStatus().total_slots;
// The image time as the detector produces images, summation included
const double image_time_s = std::chrono::duration<double>(experiment.GetImageTime()).count();
std::optional<double> expected_collection_s;
if (image_time_s > 0)
expected_collection_s = static_cast<double>(experiment.GetImageNum()) * image_time_s;
live_status.Start(experiment.GetImageNum(), expected_collection_s, received);
if (slots < experiment.GetImageNum()) {
skipped_warning = fmt::format("no rugnux analysis: the image buffer holds {} images, the collection "
"has {}", slots, experiment.GetImageNum());
logger.Error("{}", skipped_warning);
live_status.Finish(RugnuxLiveState::Skipped, "the image buffer cannot hold the whole collection");
} else
StartRugnux();
}
void JFJochReceiverRugnuxRotation::OnImage(uint32_t id, DataMessage &message, std::chrono::steady_clock::time_point received) {
live_status.ImageReceived(received);
CountImage(message);
StampImage(message, image_puller.GetCurrentFifoUtilization());
ForwardImage(message, image_buffer.GetImageSlot());
}
void JFJochReceiverRugnuxRotation::FinishCollection() {
reader.Ended();
// The latency runs from the last image in to every result in place
const auto last_image = live_status.LastImage();
logger.Info("Receiving finished, {} images", images_collected.load());
std::optional<double> done_s;
if (rugnux_out.valid()) {
// The fixed cutoff: the analysis gets deadline_s after the last image, then gives what it has.
if (deadline_s > 0 && rugnux_out.wait_for(std::chrono::duration<double>(deadline_s))
== std::future_status::timeout)
Cut("deadline");
rugnux_out.wait();
if (last_image)
done_s = SecondsSince(last_image.value());
}
if (probe_done.valid())
probe_done.wait();
current_status.SetProgress(1.0);
current_status.SetStatus(GetStatus());
SendEndMessage();
const double end_sent_s = last_image ? SecondsSince(last_image.value()) : 0.0;
CheckIfImagesSent();
WriterFinalize();
if (rugnux_out.valid()) {
// The run's outcome, in one line: its results are in the live status, the end message and the files.
const auto live = live_status.Get();
std::string outcome = "rugnux live: " + StateName(live.state);
if (!live.message.empty())
outcome += " (" + live.message + ")";
if (!live.cut.empty())
outcome += " (cut: " + live.cut + ")";
if (live.start_to_first_image_s && live.last_image_s && live.images_received > 1)
outcome += fmt::format("; START -> first image {:.2f} s, {} images in {:.2f} s ({:.1f} Hz)",
live.start_to_first_image_s.value(), live.images_received,
live.last_image_s.value(),
static_cast<double>(live.images_received - 1) / live.last_image_s.value());
if (done_s) {
const double written_s = SecondsSince(last_image.value());
live_status.Latency(written_s);
outcome += fmt::format("; done {:.2f} s after the last image, last image -> all written {:.2f} s "
"(end message sent at {:.2f} s)", done_s.value(), written_s, end_sent_s);
}
logger.Info("{}", outcome);
}
// The run's teardown, which went on beside the end message and the writer.
if (rugnux_done.valid())
rugnux_done.wait();
end_time = std::chrono::system_clock::now();
current_status.SetProgress({});
current_status.SetStatus(GetStatus());
}
void JFJochReceiverRugnuxRotation::StartRugnux() {
// A failure here costs the analysis only: the images go on to the writer as they would without it.
try {
// The start message as the writer gets it, so rugnux sees the dataset an HDF5 master states.
std::vector<uint8_t> start_cbor;
image_buffer.GetStartMessage(start_cbor);
reader.Open(CBORStream2Deserialize(start_cbor)->start_message.value());
rugnux_done = std::async(std::launch::async, &JFJochReceiverRugnuxRotation::RugnuxThread, this);
rugnux_out = rugnux_published.get_future();
probe_done = std::async(std::launch::async, &JFJochReceiverRugnuxRotation::ProbeThread, this);
} catch (const std::exception &e) {
logger.Error("rugnux live: cannot start - {}", e.what());
live_status.Finish(RugnuxLiveState::Failed, e.what());
}
}
void JFJochReceiverRugnuxRotation::RugnuxThread() {
bool published = false;
try {
const auto dataset = reader.GetDataset();
RugnuxLiveSetup setup = MakeRugnuxLiveSetup(*dataset, rugnux_nthreads, model);
setup.config.host_memory_budget_bytes = host_budget;
// Built beside the run, which waits for its first frames meanwhile; waited for when the run ends
auto gpu_warm_up = std::async(std::launch::async, [this, setup] {
try {
const auto t0 = std::chrono::steady_clock::now();
WarmUpRugnuxLiveGPU(setup);
logger.Debug("rugnux live: FFT indexers and plans ready in {:.2f} s", std::chrono::duration<double>(
std::chrono::steady_clock::now() - t0).count());
} catch (const std::exception &e) {
logger.Warning("rugnux live: building the FFT indexers ahead failed, they are built when used - {}",
e.what());
}
});
LiveObserver observer(plots, scan_result, *az_int_mapping, live_status);
// The run goes with its pinned buffers once its results are out (below), beside the end message
std::optional<Rugnux> process;
process.emplace(reader, setup.experiment, *dataset->pixel_mask, setup.config);
std::optional<Reachable> reachable;
reachable.emplace(rugnux_mutex, rugnux, *process, cut, cancelled);
ProcessResult result = process->Run(&observer);
// The verdict and summary of the report a `rugnux` run writes, without writing it.
const ReportDocument doc = BuildReportDocument(experiment.GetFilePrefix(), experiment.GetFilePrefix(),
setup.experiment, result);
std::vector<std::string> warnings;
for (const auto &warning: doc.warnings)
if (!warning.developer_only)
warnings.push_back(warning.text);
const double cc_anom = result.merge_statistics.overall.cc_anom;
live_status.Result(doc.verdict, doc.verdict_text, doc.summary_rows, warnings,
std::isfinite(cc_anom) && cc_anom > CC_ANOM_SIGNAL);
if (const auto live_model = LiveModel(result))
live_status.Model(*live_model);
// The numbers the summary's Space group, Resolution and Signal rows give
std::optional<double> d_min, isa;
if (result.has_merge_statistics)
if (std::isfinite(result.merge_statistics.overall.d_min))
d_min = result.merge_statistics.overall.d_min;
if (!result.merge_statistics.stills && result.error_model_isa_resolved && result.error_model_isa > 0.0)
isa = result.error_model_isa;
live_status.Headline(result.space_group ? result.space_group->xhm() : "", d_min, isa);
// For the broker's viewer routes; a copy of the map coefficients, as the end message takes the originals
if (result.outputs && result.outputs->placed_model) {
const RugnuxOutputs &outputs = *result.outputs;
PublishStructures(live_status, *outputs.placed_model, outputs.maps.get(),
outputs.refined_model ? &*outputs.refined_model : nullptr, outputs.refined_maps.get());
}
live_status.Finish(result.cancelled ? RugnuxLiveState::Cancelled : RugnuxLiveState::Done);
reachable.reset();
{
std::unique_lock ul(rugnux_mutex);
rugnux_result = std::move(result);
}
published = true;
rugnux_published.set_value();
process.reset();
Rugnux::ReleasePinnedPool();
} catch (const std::exception &e) {
logger.Error("rugnux live: {}", e.what());
live_status.Finish(RugnuxLiveState::Failed, e.what());
}
if (!published)
rugnux_published.set_value();
}
void JFJochReceiverRugnuxRotation::ProbeThread() {
// A small run of its own on the first degrees says early whether there is a crystal; it decides nothing
constexpr double PROBE_DEG = 60.0;
try {
const auto dataset = reader.GetDataset();
const auto gonio = dataset->experiment.GetGoniometer();
if (!gonio || gonio->GetIncrement_deg() == 0.0f)
return;
const int64_t frames = std::lround(PROBE_DEG / std::abs(gonio->GetIncrement_deg()));
if (2 * frames > static_cast<int64_t>(reader.GetNumberOfImages()))
return; // a sweep this short is decided on soon enough by the run itself
// A quarter of the threads: it runs beside the main run, and each of its workers holds GPU memory too.
RugnuxLiveSetup setup = MakeRugnuxLiveSetup(*dataset, std::max(2, rugnux_nthreads / 4), nullptr);
setup.config.host_memory_budget_bytes = host_budget; // the same as the main run's: one pool for both
setup.config.end_image = static_cast<int>(frames);
setup.config.rotation_postrefine_geometry = false;
setup.config.run_scaling = false;
// The file's centre only: the probe does not report one
setup.config.beam_center_check = false;
ProcessResult result;
{
Rugnux probe_run(reader, setup.experiment, *dataset->pixel_mask, setup.config);
Reachable reachable(rugnux_mutex, probe, probe_run, cut, cancelled);
result = probe_run.Run(nullptr);
}
if (result.consensus_cell && result.rotation_lattice_type) {
const auto &cell = *result.consensus_cell;
live_status.Probe(fmt::format("lattice on the first {:.0f} deg: {}-centred {}, {:.1f} {:.1f} {:.1f} "
"{:.1f} {:.1f} {:.1f}, {:.0f}% of the images indexed", PROBE_DEG,
result.rotation_lattice_type->centering,
gemmi::crystal_system_str(result.rotation_lattice_type->crystal_system),
cell.a, cell.b, cell.c, cell.alpha, cell.beta, cell.gamma,
100.0 * result.indexing_rate.value_or(0.0f)));
} else
live_status.Probe(fmt::format("no lattice on the first {:.0f} deg", PROBE_DEG));
} catch (const NoLatticeFound &e) {
live_status.Probe(fmt::format("no lattice on the first {:.0f} deg: {}", PROBE_DEG, e.reason));
} catch (const std::exception &e) {
logger.Warning("rugnux live: the lattice probe failed: {}", e.what());
}
logger.Debug("rugnux live: lattice probe - {}", live_status.Get().probe);
}
void JFJochReceiverRugnuxRotation::AddToEndMessage(EndMessage &message) {
JFJochReceiverStream::AddToEndMessage(message);
// A failure here costs the end message the analysis only: it goes out as the receiver made it.
try {
std::unique_lock ul(rugnux_mutex);
if (!rugnux_result)
return;
const EndMessage &rugnux_end = rugnux_result->end_message;
message.indexing_rate = rugnux_end.indexing_rate;
message.bkg_estimate = rugnux_end.bkg_estimate;
message.spindle_blind_fraction = rugnux_end.spindle_blind_fraction;
message.ice_ring_score_mean = rugnux_end.ice_ring_score_mean;
message.az_int_result = rugnux_end.az_int_result;
message.rotation_lattice = rugnux_end.rotation_lattice;
message.rotation_lattice_type = rugnux_end.rotation_lattice_type;
message.rotation_extra_lattices = rugnux_end.rotation_extra_lattices;
message.unit_cell = rugnux_end.unit_cell;
message.unit_cell_esd = rugnux_end.unit_cell_esd;
message.space_group_name = rugnux_end.space_group_name;
message.space_group_number = rugnux_end.space_group_number;
message.reindex_matrix = rugnux_end.reindex_matrix;
message.refined_beam_center_x = rugnux_end.refined_beam_center_x;
message.refined_beam_center_y = rugnux_end.refined_beam_center_y;
message.refined_poni_rot1 = rugnux_end.refined_poni_rot1;
message.refined_poni_rot2 = rugnux_end.refined_poni_rot2;
message.refined_poni_rot3 = rugnux_end.refined_poni_rot3;
message.refined_rotation_axis = rugnux_end.refined_rotation_axis;
// For the writer to write beside the master; moved, the result is not read again
if (!rugnux_result->outputs)
return;
RugnuxOutputs &outputs = *rugnux_result->outputs;
if (outputs.merged)
message.merged = std::move(outputs.merged->mtz);
if (outputs.maps)
message.map_coefficients = std::move(outputs.maps->coefficients);
if (outputs.placed_model)
message.placed_model = PlacedModelFromStructure(*outputs.placed_model->model, outputs.placed_model->cell,
outputs.placed_model->space_group.xhm());
// And the refinement's, as the CLI writes them (_refined_model.cif, _refined_maps.mtz, _blobs.json).
if (outputs.refined_model)
message.refined_model = PlacedModelFromStructure(*outputs.refined_model->model, outputs.refined_model->cell,
outputs.refined_model->space_group.xhm());
if (outputs.refined_maps)
message.refined_map_coefficients = std::move(outputs.refined_maps->coefficients);
if (outputs.blobs)
message.blobs = DensityBlobsToMessage(*outputs.blobs);
DropResultBlocksThatDoNotFit(message, &live_status, logger);
} catch (const std::exception &e) {
logger.Error("rugnux live: the end message goes without the analysis results - {}", e.what());
DropResultBlocks(message);
}
}
void JFJochReceiverRugnuxRotation::Cancel(bool silent) {
detector_finished = true;
// The silent cancel is the detector reading idle at the end of every collection: rugnux goes on.
if (silent)
return;
// Ends the collection while images still arrive; in every case the analysis is cut and the end message goes out
if (!end_message_received)
JFJochReceiver::Cancel(silent);
Cut("cancel");
}
void JFJochReceiverRugnuxRotation::Cut(const std::string &reason) {
std::unique_lock ul(rugnux_mutex);
if (cut || rugnux_result)
return;
cut = true;
reader.Ended(); // no image is waited for any more
if (rugnux != nullptr)
rugnux->Cancel();
if (probe != nullptr)
probe->Cancel();
live_status.Cut(reason);
logger.Debug("rugnux live: analysis cut ({}) - the end message carries what is established", reason);
}
void JFJochReceiverRugnuxRotation::SetSpotFindingSettings(const SpotFindingSettings &in_spot_finding_settings) {
// A rotation run takes rugnux's own spot finding
}
JFJochReceiverOutput JFJochReceiverRugnuxRotation::GetFinalStatistics() const {
JFJochReceiverOutput ret = JFJochReceiver::GetFinalStatistics();
ret.analysis_warning = skipped_warning;
// The receiver's own rotation indexer sees no image here: the lattice is rugnux's.
std::unique_lock ul(rugnux_mutex);
if (rugnux_result) {
const EndMessage &rugnux_end = rugnux_result->end_message;
ret.scan_result.rotation_lattice = rugnux_end.rotation_lattice;
if (rugnux_end.rotation_lattice_type) {
ret.scan_result.rotation_crystal_system = rugnux_end.rotation_lattice_type->crystal_system;
ret.scan_result.rotation_centering = rugnux_end.rotation_lattice_type->centering;
}
}
return ret;
}