- JFJochReceiverFPGA no longer attaches the uncompressed image before the analysis; only the removed CPU integrator read it. - JFJochReceiverFPGA drops its branches for a run with no images; pedestal runs have their own receiver and a standard run has at least one image. - SummationThread returns nothing instead of an unused 0. - JFJochReceiverOutput loses master_file_name and images_written (never set or never read), the base receiver its always-empty images_written. - JFJochReceiverCurrentStatus::SetEfficiency is gone: its only call was overwritten on the next line. - ImageMetadata::IsBunchIDConsistent had no caller; an inconsistent frame still gets pulse ID UINT64_MAX. - DarkMaskAnalysis::AnalyzeImage takes the decompression buffer by reference, so the per-thread buffer of the dark mask receiver is reused. - The pedestal and dark mask receivers no longer take the indexer pool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "DarkMaskAnalysis.h"
|
|
#include "../../common/JFJochException.h"
|
|
|
|
DarkMaskAnalysis::DarkMaskAnalysis(const DarkMaskSettings &settings, size_t det_size)
|
|
: max_allowed_value(settings.GetMaxCounts()),
|
|
max_frames_with_signal(settings.GetMaxFramesWithCounts()),
|
|
mask(det_size, 0) {}
|
|
|
|
template<class T>
|
|
void DarkMaskAnalysis::check(const T *ptr) {
|
|
std::unique_lock ul(m);
|
|
for (int i = 0; i < mask.size(); i++) {
|
|
auto v64 = static_cast<int64_t>(ptr[i]);
|
|
if (v64 > max_allowed_value)
|
|
mask[i]++;
|
|
}
|
|
}
|
|
|
|
void DarkMaskAnalysis::AnalyzeImage(const DataMessage &data, std::vector<uint8_t> &buffer) {
|
|
if (data.image.GetWidth() * data.image.GetHeight() != mask.size())
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "Invalid size of input image");
|
|
|
|
auto ptr = data.image.GetUncompressedPtr(buffer);
|
|
|
|
switch (data.image.GetMode()) {
|
|
case CompressedImageMode::Int8:
|
|
check(reinterpret_cast<const int8_t *>(ptr));
|
|
break;
|
|
case CompressedImageMode::Uint8:
|
|
check(reinterpret_cast<const uint8_t *>(ptr));
|
|
break;
|
|
case CompressedImageMode::Int16:
|
|
check(reinterpret_cast<const int16_t *>(ptr));
|
|
break;
|
|
case CompressedImageMode::Uint16:
|
|
check(reinterpret_cast<const uint16_t *>(ptr));
|
|
break;
|
|
case CompressedImageMode::Int32:
|
|
check(reinterpret_cast<const int32_t *>(ptr));
|
|
break;
|
|
case CompressedImageMode::Uint32:
|
|
check(reinterpret_cast<const uint32_t *>(ptr));
|
|
break;
|
|
default:
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "RGB/float image mode not supported");
|
|
}
|
|
}
|
|
|
|
std::vector<uint32_t> DarkMaskAnalysis::GetMask() const {
|
|
std::unique_lock ul(m);
|
|
std::vector<uint32_t> tmp(mask.size(), 0);
|
|
for (int i = 0; i < mask.size(); i++)
|
|
tmp[i] = (mask[i] > max_frames_with_signal) ? 1 : 0;
|
|
return tmp;
|
|
}
|