Files
Jungfraujoch/common/JFJochReceiverPlots.h
T
leonarski_fandClaude Opus 5 942e978ffc
Build Packages / build:viewer-tgz:cpu (push) Successful in 18m43s
Build Packages / build:viewer-tgz:cuda (push) Successful in 19m50s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 21m55s
Build Packages / build:rpm (rocky9_nocuda) (push) Successful in 23m26s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 27m42s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 29m0s
Build Packages / build:rpm (rocky8_sls9) (push) Successful in 28m33s
Build Packages / build:rpm (rocky9_sls9) (push) Successful in 21m8s
Build Packages / XDS test (durin plugin) (push) Successful in 10m55s
Build Packages / build:rpm (rocky8) (push) Successful in 25m7s
Build Packages / build:rpm (rocky9) (push) Successful in 21m53s
Build Packages / Generate python client (push) Successful in 37s
Build Packages / Create release (push) Skipped
Build Packages / Build documentation (push) Successful in 2m2s
Build Packages / build:rpm (ubuntu2404) (push) Successful in 20m45s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 25m31s
Build Packages / DIALS test (push) Successful in 20m46s
Build Packages / XDS test (JFJoch plugin) (push) Successful in 10m23s
Build Packages / XDS test (neggia plugin) (push) Successful in 9m32s
Build Packages / Unit tests (push) Successful in 2h32m3s
Build Packages / build:windows:nocuda (push) Canceled after 0s
Build Packages / build:windows:cuda (push) Canceled after 0s
common: expose the run-summed azimuthal profile object
Belongs with the previous commit - powder calibration reads the ring positions
off the accumulated profile, and without this accessor rugnux/Rugnux.cpp does not
compile. It was left out of that commit by a staging mistake, not by intent.

GetAzIntProfile() flattens the profile to an array; the calibration wants the
object's own GetResult(), which leaves a bin no pixel fell in as NaN. Flattened to
zero, such a bin reads as a deep hole in the ring rather than as no measurement.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 10:03:02 +02:00

143 lines
5.2 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 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;
public:
void Setup(const DiffractionExperiment& experiment, const AzimuthalIntegrationMapping& mapping);
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;
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;
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);
};