A single per-image ice_ring_score - the strongest hexagonal-ice ring band/shoulder intensity ratio from the azimuthal profile (1 = no ice) - computed in the CPU and FPGA analysis paths and the offline azint worker, then plumbed through every layer: DataMessage/EndMessage, CBOR (frame_serialize), HDF5 (/entry/MX/iceRingScore), ScanResult, receiver plots (PlotType::IceRingScore), the OpenAPI spec (plot_type + scan_result schema, with regenerated broker/gen and frontend client) and OpenAPIConvert, the reader + Qt viewer, and the React frontend plot. Documented in docs/CBOR.md, docs/HDF5.md and docs/CPU_DATA_ANALYSIS.md, with the general "add a per-image quantity" recipe added to CLAUDE.md. Verified in HDF5: lysoC (weak ice) mean 1.23, EP_cs_01-17 (heavy ice) mean 1.67 / max 2.23. This is a monitoring quantity - it does not gate scaling (which already excludes all ice rings) or merging (handled by the CC1/2 ring mask). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
53 lines
2.0 KiB
C++
53 lines
2.0 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#pragma once
|
|
|
|
#include <vector>
|
|
#include <mutex>
|
|
#include "MultiLinePlot.h"
|
|
|
|
#include "AzimuthalIntegrationMapping.h"
|
|
#include "../fpga/pcie_driver/jfjoch_fpga.h" // DeviceOutput
|
|
|
|
class AzimuthalIntegrationProfile {
|
|
mutable std::mutex m;
|
|
std::vector<float> sum;
|
|
std::vector<float> sum2;
|
|
std::vector<uint64_t> count;
|
|
std::vector<float> bin_to_q;
|
|
std::vector<float> bin_to_d;
|
|
std::vector<float> bin_to_2theta;
|
|
std::vector<float> bin_to_phi;
|
|
std::vector<float> bin_to_q_1d;
|
|
|
|
int32_t q_bins;
|
|
int32_t azim_bins;
|
|
std::string title;
|
|
|
|
const std::vector<float>& GetXAxis(PlotAzintUnit unit) const;
|
|
public:
|
|
explicit AzimuthalIntegrationProfile(const AzimuthalIntegrationMapping &mapping);
|
|
void Clear(const AzimuthalIntegrationMapping &mapping);
|
|
void SetTitle(const std::string& input);
|
|
void Add(const DeviceOutput &result);
|
|
void Add(const std::vector<float> &sum,
|
|
const std::vector<float> &sum2,
|
|
const std::vector<uint32_t> &count);
|
|
void Add(int64_t bin, int64_t value);
|
|
|
|
std::vector<float> GetResult() const;
|
|
std::vector<float> GetStd() const;
|
|
std::vector<uint64_t> GetPixelCount() const;
|
|
|
|
std::vector<float> GetResult1D() const;
|
|
|
|
float GetMeanValueOfBins(uint16_t min_bin, uint16_t max_bin) const;
|
|
float GetBkgEstimate(const AzimuthalIntegrationSettings& settings) const;
|
|
// Single per-image ice indicator: the strongest hexagonal-ice ring's band/shoulder intensity ratio
|
|
// (1 = no ice, >1 = ice above the local background). Max over the rings in range; 1 if none.
|
|
float GetIceRingScore(const AzimuthalIntegrationSettings& settings, float half_width_q) const;
|
|
MultiLinePlot GetPlot(bool force_1d = false, PlotAzintUnit plot_unit = PlotAzintUnit::Q_recipA) const;
|
|
AzimuthalIntegrationProfile& operator+=(const AzimuthalIntegrationProfile& profile); // Not thread safe
|
|
};
|