// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only #pragma once #include "../common/DiffractionExperiment.h" #include "bragg_prediction/BraggPrediction.h" #include "indexing/IndexerThreadPool.h" #include "spot_finding/StrongPixelSet.h" #include "azint/AzIntEngineCPU.h" #include "IndexAndRefine.h" class MXAnalysisAfterFPGA { mutable std::mutex read_from_cpu_mutex; const DiffractionExperiment &experiment; const AzimuthalIntegrationMapping &integration; IndexAndRefine &indexer; std::unique_ptr prediction; std::unique_ptr cpu_azint; bool find_spots = false; std::vector spots; constexpr static const float spot_distance_threshold_pxl = 2.0f; std::vector arr_mean; std::vector arr_sttdev; std::vector arr_valid_count; std::vector arr_strong_pixel; enum class State {Idle, Disabled, Enabled} state = State::Idle; std::chrono::duration spot_finding_time_total{0.0}; bool spot_finding_timing_active = false; public: MXAnalysisAfterFPGA(const DiffractionExperiment& experiment, const AzimuthalIntegrationMapping &integration, IndexAndRefine &indexer); void ReadFromFPGA(const DeviceOutput* output, const SpotFindingSettings& settings, size_t module_number); void ReadFromCPU(DeviceOutput *output, const SpotFindingSettings &settings, size_t module_number); // Computes the azimuthal integration profile on the CPU from the assembled image. // Only active when the settings force the CPU backend; otherwise a no-op (the FPGA // fills the profile). image points to the uncompressed image of GetByteDepthImage() pixels. void RunAzimuthalIntegration(const void *image, AzimuthalIntegrationProfile &profile); void Process(DataMessage &message, const SpotFindingSettings& settings); };