Files
Jungfraujoch/common/JFJochReceiverPlots.h
T
leonarski_f 84228bf8be
Build Packages / Create release (push) Successful in 24s
Build Packages / build:viewer:macos-arm64:nocuda (push) Successful in 3m29s
Build Packages / build:rugnux:macos-arm64:nocuda (push) Successful in 2m43s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 8m27s
Build Packages / build:rugnux:linux-x86_64:cuda (push) Successful in 9m53s
Build Packages / build:viewer:linux-x86_64:nocuda (push) Successful in 9m58s
Build Packages / build:viewer:linux-x86_64:cuda (push) Successful in 11m22s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 13m39s
Build Packages / build:viewer:windows-x86_64:nocuda (push) Successful in 18m37s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 16m32s
Build Packages / build:viewer:windows-x86_64:cuda (push) Successful in 24m11s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 25m30s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 19m3s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 20m23s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 19m41s
Build Packages / Generate python client (push) Successful in 50s
Build Packages / Build documentation (push) Successful in 1m16s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 21m0s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 18m38s
Build Packages / build:rugnux:windows-x86_64:cuda (push) Successful in 14m33s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 17m55s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 20m50s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 18m38s
Build Packages / Unit tests (push) Successful in 1h46m14s
v1.0.0-rc.173 (#83)
* jfjoch_broker: Optional per-dataset authentication - statistics, images and plots can require a bearer token, which jfjoch_viewer supports.
* jfjoch_viewer: Dark mode and a theme-matched colour scheme, a magnifier panel, and simpler contrast and background controls.
* Rugnux: Multiple performance improvements on GPU and CPU (CPU-only processing up to 40% faster, faster image decoding on ARM), with unchanged results.
* Rugnux: `--model` rigid-body refinement runs on the GPU, and the model-validation check is faster and more reliable.
* Rugnux: Improved scaling and merging - error model, outlier rejection, absorption correction and French-Wilson amplitudes now agree more closely with XDS and ctruncate.
* Rugnux: Improved integration - radial background on powder and ice rings, crowded rotation data keep their reflections, and CPU-only builds integrate large unit cells as GPU builds do.
* Rugnux: More robust detector geometry - measured beam centre, X-ray bandwidth and goniometer rate, and geometry refinement accepted only on significant evidence.
* Rugnux: Merged files are written in the standard setting, or in the setting of a reference MTZ, structure-factor mmCIF or model, with its free-R flags.
* Rugnux: Richer report - ice and powder rings, further lattices, superstructure candidates and mosaicity, with warnings worded as prompts to check.
* Rugnux: Clear error messages when a data set needs more GPU or host memory than is available.

Reviewed-on: #83
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-09-29 15:57:32 +02:00

153 lines
5.8 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <map>
#include <shared_mutex>
#include <string>
#include "StatusVector.h"
#include "Histogram.h"
#include "ADUHistogram.h"
#include "AutoIncrVector.h"
#include "DiffractionExperiment.h"
#include "AzimuthalIntegrationProfile.h"
#include "JFJochMessages.h"
#include "Plot.h"
#include "ScanResult.h"
struct MeanProcessingTime {
float compression;
float preprocessing;
float azint;
float spot_finding;
float indexing;
float refinement;
float integration;
float bragg_prediction;
float processing;
float indexing_analysis;
float image_scale;
};
class JFJochReceiverPlots {
mutable std::mutex m; // protects xfel_pulse_id, xfel_event_code and az_int_profile
std::optional<GoniometerAxis> goniometer;
std::optional<GridScanSettings> grid_scan;
int64_t default_binning = 1;
std::unique_ptr<AzimuthalIntegrationProfile> az_int_profile;
AutoIncrVector<uint64_t> xfel_pulse_id;
AutoIncrVector<uint64_t> xfel_event_code;
StatusVector bkg_estimate;
StatusVector spindle_blind_fraction;
StatusVector ice_ring_score;
StatusVector spot_count;
StatusVector spot_count_low_res;
StatusVector spot_count_indexed;
StatusVector spot_count_ice;
StatusVector spot_count_ice_control;
StatusVector indexing_solution;
StatusVector indexing_lattice_count;
StatusVector indexing_uc_a;
StatusVector indexing_uc_b;
StatusVector indexing_uc_c;
StatusVector indexing_uc_alpha;
StatusVector indexing_uc_beta;
StatusVector indexing_uc_gamma;
StatusVector error_pixels;
StatusVector saturated_pixels;
StatusVector strong_pixels;
StatusVector receiver_delay;
StatusVector receiver_buf_available;
StatusVector receiver_buf_in_sending;
StatusVector receiver_buf_in_preparation;
StatusVector image_collection_efficiency;
StatusVector packets_received;
StatusVector max_value;
StatusVector resolution_estimate;
StatusVector integrated_reflections;
StatusVector image_scale_factor;
StatusVector image_scale_cc;
StatusVector compression_ratio;
// StatusVector objects are fully thread-safe (protected by internal mutex)
// It is OK to have concurrent access to StatusVector
// roi_m lock is needed to make sure that std::map<std::string, ROIStatus> is not mutable within critical section
// so no new elements added outside of a unique lock, but it is OK to modify ROIStatus under shared lock
struct ROIStatus {
StatusVector sum;
StatusVector max_count;
StatusVector pixels;
StatusVector x;
StatusVector y;
StatusVector mean;
};
mutable std::shared_mutex roi_m;
std::map<std::string, ROIStatus> roi_status;
StatusVector profile_radius;
StatusVector mosaicity_deg;
StatusVector b_factor;
StatusVector pixel_sum;
StatusVector beam_center_x;
StatusVector beam_center_y;
StatusVector spot_finding_time;
StatusVector indexing_time;
StatusVector refinement_time;
StatusVector integration_time;
StatusVector bragg_prediction_time;
StatusVector total_processing_time;
StatusVector preprocessing_time;
StatusVector compression_time;
StatusVector azint_time;
StatusVector indexing_analysis_time;
StatusVector image_scale_time;
MultiLinePlot GetROIPlot(PlotType type, int64_t nbins, float start, float incr,
const std::optional<float> &fill_value) const;
void ClearVectors_i(size_t reserve);
public:
void Setup(const DiffractionExperiment& experiment, const AzimuthalIntegrationMapping& mapping);
// Drop the previous run's plots (nothing to plot until the next Setup).
void Clear();
void Add(const DataMessage& msg, const AzimuthalIntegrationProfile &profile);
void AddEmptyImage(const DataMessage& msg);
MultiLinePlot GetPlots(const PlotRequest& request);
void GetXFELPulseID(std::vector<uint64_t>& v) const;
void GetXFELEventCode(std::vector<uint64_t>& v) const;
std::optional<float> GetIndexingRate() const;
std::optional<float> GetBkgEstimate() const;
// Run mean of the per-image spindle severity, over the frames that had one; nothing when none did.
std::optional<float> GetSpindleBlindFraction() const;
std::optional<float> GetIceRingScore() const;
// Pooled over the run: spots on the hexagonal rings over the same q width of ice-free control
// flanks. 1 = spots spread evenly, > 1 = they pile up on the rings (textured ice).
[[nodiscard]] std::optional<float> GetIceRingSpotRatio() const;
// The run's spot-finding resolution estimate: the MEDIAN of the per-image estimates. A median and
// not a mean - a few blank or badly-shot frames pull a mean a long way and leave the median where
// the run actually is.
[[nodiscard]] std::optional<float> GetResolutionEstimate() const;
std::vector<float> GetIceRingScoreArray() const;
std::vector<float> GetAzIntProfile() const;
// The run-summed profile object itself, rather than the array GetAzIntProfile() flattens it to.
// Powder calibration reads the ring positions off it and wants its own GetResult(), which leaves a
// bin no pixel fell in as NaN - as 0 it would read as a deep hole in the ring instead. Null before
// Setup(); not synchronised, so use it once the run is over rather than while images arrive.
[[nodiscard]] const AzimuthalIntegrationProfile *GetAzIntProfileObject() const { return az_int_profile.get(); }
MultiLinePlot GetAzIntProfilePlot(bool force_1d = false, PlotAzintUnit azint_unit = PlotAzintUnit::Q_recipA) const;
MeanProcessingTime GetMeanProcessingTime() const;
void GetPlotRaw(std::vector<float> &v, PlotType type, const std::string &roi);
};