Files
Jungfraujoch/tests/JFJochReceiverIntegrationTest.cpp
leonarski_f 4809c1622c
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 16m43s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 28m46s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 32m5s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 39m44s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 5m7s
Build Packages / Create release (push) Successful in 8s
Build Packages / Build documentation (push) Successful in 49s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 22m30s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 31m54s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 11m29s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 23m51s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 26m7s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 29m38s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 28m6s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 29m44s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 33m22s
Build Packages / Generate python client (push) Successful in 47s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 34m6s
Build Packages / Unit tests (push) Successful in 1h2m47s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 35m59s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 34m8s
Build Packages / Validation Battery (push) Successful in 38m31s
v1.0.0-rc.187 (#98)
* Rugnux: Refinement several times faster, one protocol on the CPU and the GPU, parts of it on the Apple GPU; its random draws are the same on every platform.
* Rugnux: Refinement follows common practice: the free set decides only the restraint weights and the displacement model (isotropic, TLS or anisotropic, by Hamilton's test), everything else is decided on the working set; lower R-free for placed and predicted models.
* Rugnux: Restraint dictionaries via `--restraints` (or among the inputs) and more built-in ligands; a model whose space group is a subgroup of the data's is refined in its own group; reflections plus a model select `--mode refine` on their own.
* Rugnux: `-C` fixes the crystal system on the axes as typed; `-S` alone fixes the space group only, the cell is still found and reduced; a space group or cell stored in the input file is ignored, with a line in the log.
* Rugnux: More reliable multi-sweep merging; `--mode scale` merges several stills runs as one; `_plot.txt` and the report name each input; a second crystal form is reported for stills given a cell.
* jfjoch_broker (experimental): Live Rugnux on FPGA detectors (JUNGFRAU) takes the same path as a DECTRIS stream, rotation and serial alike, model step included, with analysis threads per GPU; frames waiting for the analysis can be viewed; no host stage drops a frame - a source faster than the analysis is held at the card.
* jfjoch_broker: Summation of more than 256 frames per image is split between the card and the host (`summation_mode` is then `hybrid`), and live Rugnux runs on such collections; pedestal runs take a receiver of their own.
* jfjoch_broker (experimental): `stills_downsample` analyses 1 of every N serial images (chosen by a hash; the first 2000 all; the others written without analysis; reset to 1 by `/initialize`); `max_spot_count` left out means 250 for per-image indexing and up to 1000 for live stills; the live status gives the merge before the model work, the fitted resolution and the anomalous peak height of each unexplained blob.
* jfjoch_broker: Without a `pcie` entry the broker runs on a mock of the card instead of the HLS simulation; its spot, ROI and azimuthal results are zero then.
* Web frontend: Redesigned Rugnux live page; Vite 8, TypeScript 6, Mol* 5.13 and dependency security updates.
* Tools: `jfjoch_fpga_stills_test` measures live stills on the cards with a stored dataset; `jfjoch_fpga_test` loses the HLS-simulation option.
* Other: FFTW no longer fetched or linked (the CPU FFT indexer keeps the name `FFTW`); PCIe driver now GPL-2.0-or-later and third-party notices complete; several crash fixes.

Reviewed-on: #98
Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
2026-11-19 20:49:28 +01:00

1083 lines
39 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include <catch2/catch_all.hpp>
#include "../receiver/JFJochReceiverTest.h"
#include "MockCardOutput.h"
#include "../jungfrau/JFPedestalCalc.h"
#include "../image_pusher/TestImagePusher.h"
#include "../receiver/JFJochReceiverService.h"
using namespace std::literals::chrono_literals;
TEST_CASE("JFJochReceiverTest_Raw", "[JFJochReceiver]") {
DiffractionExperiment x(DetJF(4));
const uint16_t nthreads = 4;
x.Raw();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(100).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::NO_COMPRESSION);
Logger logger("JFJochReceiverTest_Raw");
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(output.status.compressed_ratio == 1.0);
REQUIRE(output.status.compressed_size == x.GetImageNum() * x.GetByteDepthImage() * x.GetPixelsNum());
REQUIRE(output.status.max_image_number_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
// Two cards running at the same time - not possible with the HLS simulation
TEST_CASE("JFJochReceiverTest_Raw_TwoDevices", "[JFJochReceiver]") {
DiffractionExperiment x(DetJF(4));
const uint16_t nthreads = 4;
x.Raw();
x.DataStreams(2);
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(100).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::NO_COMPRESSION);
REQUIRE(x.GetDataStreamsNum() == 2);
Logger logger("JFJochReceiverTest_Raw_TwoDevices");
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD);
REQUIRE(x.IsGeometryTransformed());
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_ForceCPUAzInt", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_ForceCPUAzInt");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(8).ImagesPerFile(10).IncidentEnergy_keV(12.4)
.JungfrauConvPhotonCnt(false).Compression(CompressionAlgorithm::NO_COMPRESSION);
// Request more azimuthal integration bins than the FPGA integration core can handle.
// This is only possible on the CPU backend - the FPGA path would throw on read-back.
AzimuthalIntegrationSettings azim;
azim.QSpacing_recipA(0.05).QRange_recipA(0.05, 6.05).AzimuthalBinCount(20)
.ForceCPUinFPGAWorkflow(true);
REQUIRE(azim.GetBinCount() > FPGA_INTEGRATION_BIN_COUNT);
x.ImportAzimuthalIntegrationSettings(azim);
std::vector<uint16_t> raw_image(RAW_MODULE_SIZE * x.GetModulesNum());
for (int i = 0; i < raw_image.size(); i++)
raw_image[i] = 1000 + i % 1000;
PixelMask mask(x);
std::vector<CardImage> images;
images.push_back(ConvertedImage(x, JFCalibration(x), mask, raw_image));
AcquisitionDeviceGroup aq_devices = MockDevices(x, images);
TestImagePusher pusher(x.GetImageNum() - 1);
JFJochReceiverService service(aq_devices, logger, pusher);
service.NumThreads(nthreads);
service.LoadInternalGeneratorImage(x, raw_image, 0);
service.Start(x, mask, nullptr);
auto output = service.Stop();
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
// The CPU backend produced the full-resolution profile (more bins than the FPGA supports)
auto azim_plot = service.GetDataProcessingPlot(PlotRequest{.type = PlotType::AzInt, .binning = 1});
REQUIRE(azim_plot.GetPlots().size() == 1);
REQUIRE(azim_plot.GetPlots()[0].x.size() == azim.GetBinCount());
}
TEST_CASE("JFJochReceiverTest_AzIntBinsExceedFPGA", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_AzIntBinsExceedFPGA");
DiffractionExperiment x(DetJF(2));
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(8).IncidentEnergy_keV(12.4);
// More bins than the FPGA can integrate, and the CPU backend is not forced.
AzimuthalIntegrationSettings azim;
azim.QSpacing_recipA(0.05).QRange_recipA(0.05, 6.05).AzimuthalBinCount(20);
REQUIRE(azim.GetBinCount() > FPGA_INTEGRATION_BIN_COUNT);
REQUIRE_FALSE(azim.IsForceCPUinFPGAWorkflow());
x.ImportAzimuthalIntegrationSettings(azim);
AcquisitionDeviceGroup aq_devices;
for (int i = 0; i < x.GetDataStreamsNum(); i++)
aq_devices.Add(std::make_unique<MockAcquisitionDevice>(i, 64));
PixelMask mask(x);
TestImagePusher pusher(0);
JFJochReceiverService service(aq_devices, logger, pusher);
// The limit is enforced at acquisition start, before any thread is spawned
REQUIRE_THROWS_AS(service.Start(x, mask, nullptr), JFJochException);
}
TEST_CASE("JFJochReceiverTest_Conversion_NoGeomTransform", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion_NoGeomTransform");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD)
.GeometryTransformation(false);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_Poisson", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion_Poisson");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(
CompressionAlgorithm::BSHUF_ZSTD);
x.LossyCompressionPoisson(1);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_Threshold", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion_Threshold");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(
CompressionAlgorithm::BSHUF_ZSTD);
x.PixelValueLowThreshold(50);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_ApplyMask", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion_ApplyMask");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD);
x.ApplyPixelMask(true).MaskChipEdges(true).MaskModuleEdges(true);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_Threshold_Summation", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion_Threshold");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(1).Summation(4).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(
CompressionAlgorithm::BSHUF_ZSTD);
x.PixelValueLowThreshold(10);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_FixedGainG1", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD)
.FixedGainG1(true);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_FixedGainG1_onlyG1", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD)
.FixedGainG1(true);
std::vector<uint16_t> input(RAW_MODULE_SIZE*2, 0x4000 + 3000);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask, input);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, input, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_U16", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD)
.BitDepthImage(16).PixelSigned(false);
REQUIRE(!x.IsPixelSigned());
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_U8", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion_U8");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD)
.BitDepthImage(8).PixelSigned(false);
REQUIRE(!x.IsPixelSigned());
REQUIRE(x.GetByteDepthImage() == 1);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_I32", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD)
.PixelSigned(true).BitDepthImage(32);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_Summation2", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD).Summation(2);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_Summation7_CPU", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(8).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD)
.Summation(7).CPUSummation(true);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
CHECK(ret);
CHECK(output.efficiency == 1.0);
CHECK(output.status.images_sent == x.GetImageNum());
CHECK(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Conversion_StorageCell", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Conversion_StorageCell");
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD).StorageCells(16);
REQUIRE(x.GetImageNum() == 16);
REQUIRE(x.GetStorageCellNumber() == 16);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_PedestalG1", "[JFJochReceiver]") {
const uint16_t nthreads = 4;
size_t nframes = 256;
// The card output repeats every distinct_frames frames
size_t distinct_frames = 32;
std::vector<uint16_t> pedestal_in(RAW_MODULE_SIZE * distinct_frames);
// Predictable random number generator
std::mt19937 g1(1900);
std::normal_distribution<double> distribution(14000, 100);
for (auto &i: pedestal_in) {
uint16_t number = distribution(g1);
if (number < 20) number = 20;
if (number > 16300) number = 16300;
i = 16384 | number;
}
DiffractionExperiment x(DetJF(1));
x.Mode(DetectorMode::PedestalG1).PedestalG0Frames(0)
.PedestalG1Frames(nframes).NumTriggers(1).UseInternalPacketGenerator(false)
.ImagesPerTrigger(0).IncidentEnergy_keV(12.4);
AcquisitionDeviceGroup aq_devices;
for (int i = 0; i < x.GetDataStreamsNum(); i++) {
auto test = std::make_unique<MockAcquisitionDevice>(i, 64);
for (int f = 0; f < distinct_frames; f++)
test->SetOutput(f, 0, *OutputWithPixels(pedestal_in.data() + f * RAW_MODULE_SIZE));
test->CreateJFPackets(x, 1, nframes, 0, nullptr);
test->CreateFinalPacket(x);
aq_devices.Add(std::move(test));
}
JFPedestalCalc pc(x);
for (int i = 0; i < nframes; i++)
pc.AnalyzeImage(pedestal_in.data() + (i % distinct_frames) * RAW_MODULE_SIZE);
Logger logger("JFJochReceiverTest_PedestalG1");
PixelMask mask(x);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(output.efficiency == 1.0);
JFModulePedestal ref_pedestal;
pc.Export(ref_pedestal, 0);
JFModulePedestal out_pedestal = output.pedestal_result.at(0);
REQUIRE(abs(ref_pedestal.Mean() - out_pedestal.Mean()) < 0.65);
REQUIRE(out_pedestal.CountMaskedPixels() == 0);
REQUIRE(out_pedestal.GetFrameCount() == nframes);
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_PedestalG2_storage_cell", "[JFJochReceiver]") {
const uint16_t nthreads = 4;
size_t nframes = 150;
// The card output repeats every 2 * distinct_frames frames
size_t distinct_frames = 25;
std::vector<uint16_t> pedestal_in(RAW_MODULE_SIZE * distinct_frames), pedestal_in2(RAW_MODULE_SIZE * distinct_frames);
// Predictable random number generator
std::mt19937 g2(1900);
std::normal_distribution<double> distribution1(13000, 100);
std::normal_distribution<double> distribution2(12000, 100);
for (auto &i: pedestal_in) {
uint16_t number = distribution1(g2);
if (number < 20) number = 20;
if (number > 16300) number = 16300;
i = 32768 | 16384 | number;
}
for (auto &i: pedestal_in2) {
uint16_t number = distribution2(g2);
if (number < 20) number = 20;
if (number > 16300) number = 16300;
i = 32768 | 16384 | number;
}
DiffractionExperiment x(DetJF(1));
x.Mode(DetectorMode::PedestalG2).PedestalG0Frames(0)
.PedestalG2Frames(nframes).NumTriggers(1).UseInternalPacketGenerator(false)
.ImagesPerTrigger(0).IncidentEnergy_keV(12.4).StorageCells(16);
REQUIRE(x.GetStorageCellNumber() == 2);
REQUIRE(x.GetFrameNum() == nframes * 2);
AcquisitionDeviceGroup aq_devices;
for (int i = 0; i < x.GetDataStreamsNum(); i++) {
auto test = std::make_unique<MockAcquisitionDevice>(i, nframes * 2);
for (int j = 0; j < distinct_frames; j++) {
test->SetOutput(2 * j, 0, *OutputWithPixels(pedestal_in2.data() + j * RAW_MODULE_SIZE));
test->SetOutput(2 * j + 1, 0, *OutputWithPixels(pedestal_in.data() + j * RAW_MODULE_SIZE));
}
for (int j = 0; j < nframes; j++) {
test->CreateJFPackets(x, 2 * j + 1, 1, 0, nullptr);
test->CreateJFPackets(x, 2 * j + 2, 1, 0, nullptr);
}
test->CreateFinalPacket(x);
aq_devices.Add(std::move(test));
}
JFPedestalCalc pc(x);
for (int i = 0; i < nframes; i++)
pc.AnalyzeImage(pedestal_in.data() + (i % distinct_frames) * RAW_MODULE_SIZE);
Logger logger("JFJochReceiverTest_PedestalG2_storage_cell");
PixelMask mask(x);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(output.efficiency == 1.0);
JFModulePedestal ref_pedestal;
pc.Export(ref_pedestal, 0);
JFModulePedestal out_pedestal = output.pedestal_result.at(0);
REQUIRE(abs(ref_pedestal.Mean() - out_pedestal.Mean()) < 0.65);
REQUIRE(out_pedestal.CountMaskedPixels() == 0);
}
TEST_CASE("JFJochReceiverTest_PedestalG0", "[JFJochReceiver]") {
DiffractionExperiment x(DetJF(1));
const uint16_t nthreads = 4;
size_t nframes = 500;
// The card output repeats every distinct_frames frames
size_t distinct_frames = 25;
std::vector<uint16_t> pedestal_in(RAW_MODULE_SIZE * distinct_frames);
// Predictable random number generator
std::mt19937 g1(1900);
std::normal_distribution<double> distribution(3000, 50);
for (auto &i: pedestal_in) {
uint16_t number = distribution(g1);
if (number < 20) number = 20;
if (number > 16300) number = 16300;
i = number;
}
x.Mode(DetectorMode::PedestalG0);
x.PedestalG0Frames(nframes)
.NumTriggers(1).UseInternalPacketGenerator(false)
.ImagesPerTrigger(0).IncidentEnergy_keV(12.4);
AcquisitionDeviceGroup aq_devices;
for (int i = 0; i < x.GetDataStreamsNum(); i++) {
auto test = std::make_unique<MockAcquisitionDevice>(i, 64);
for (int f = 0; f < distinct_frames; f++)
test->SetOutput(f, 0, *OutputWithPixels(pedestal_in.data() + f * RAW_MODULE_SIZE));
test->CreateJFPackets(x, 1, nframes, 0, nullptr);
test->CreateFinalPacket(x);
aq_devices.Add(std::move(test));
}
JFPedestalCalc pc(x);
for (int i = 0; i < nframes; i++)
pc.AnalyzeImage(pedestal_in.data() + (i % distinct_frames) * RAW_MODULE_SIZE);
PixelMask mask(x);
Logger logger("JFJochReceiverTest_PedestalG0");
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(output.efficiency == 1.0);
JFModulePedestal ref_pedestal;
pc.Export(ref_pedestal, 0);
JFModulePedestal out_pedestal = output.pedestal_result.at(0);
REQUIRE(abs(ref_pedestal.Mean() - out_pedestal.Mean()) < 0.65);
REQUIRE(out_pedestal.CountMaskedPixels() == 0);
REQUIRE(out_pedestal.GetFrameCount() == nframes);
}
TEST_CASE("JFJochReceiverTest_PedestalG0_StorageCell", "[JFJochReceiver]") {
DiffractionExperiment x(DetJF(1));
const uint16_t nthreads = 4;
size_t nframes = 140;
std::vector<uint16_t> pedestal_in_0(RAW_MODULE_SIZE);
std::vector<uint16_t> pedestal_in_1(RAW_MODULE_SIZE);
std::vector<uint16_t> pedestal_in_2(RAW_MODULE_SIZE);
std::vector<uint16_t> pedestal_in_3(RAW_MODULE_SIZE);
for (auto &i: pedestal_in_0) i = 5670;
for (auto &i: pedestal_in_1) i = 4560;
for (auto &i: pedestal_in_2) i = 3450;
for (auto &i: pedestal_in_3) i = 2000;
x.Mode(DetectorMode::PedestalG0).StorageCells(4);
x.PedestalG0Frames(nframes)
.NumTriggers(1).UseInternalPacketGenerator(false)
.ImagesPerTrigger(0).IncidentEnergy_keV(12.4);
AcquisitionDeviceGroup aq_devices;
auto test = std::make_unique<MockAcquisitionDevice>(0, 64);
test->SetOutput(0, 0, *OutputWithPixels(pedestal_in_0.data()));
test->SetOutput(1, 0, *OutputWithPixels(pedestal_in_1.data()));
test->SetOutput(2, 0, *OutputWithPixels(pedestal_in_2.data()));
test->SetOutput(3, 0, *OutputWithPixels(pedestal_in_3.data()));
test->CreateJFPackets(x, 1, nframes * 4, 0, nullptr);
test->CreateFinalPacket(x);
aq_devices.Add(std::move(test));
PixelMask mask(x);
Logger logger("JFJochReceiverTest_PedestalG0_StorageCell");
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.pedestal_result.size() == 4);
JFModulePedestal out_pedestal_0 = output.pedestal_result[0];
JFModulePedestal out_pedestal_1 = output.pedestal_result[1];
JFModulePedestal out_pedestal_2 = output.pedestal_result[2];
JFModulePedestal out_pedestal_3 = output.pedestal_result[3];
REQUIRE(out_pedestal_0.Mean() == Catch::Approx(5670));
REQUIRE(out_pedestal_0.GetFrameCount() == nframes);
REQUIRE(out_pedestal_1.Mean() == Catch::Approx(4560));
REQUIRE(out_pedestal_1.GetFrameCount() == nframes);
REQUIRE(out_pedestal_2.Mean() == Catch::Approx(3450));
REQUIRE(out_pedestal_2.GetFrameCount() == nframes);
REQUIRE(out_pedestal_3.Mean() == Catch::Approx(2000));
REQUIRE(out_pedestal_3.GetFrameCount() == nframes);
}
TEST_CASE("JFJochReceiverTest_PedestalFixedG1_StorageCell", "[JFJochReceiver]") {
DiffractionExperiment x(DetJF(1));
const uint16_t nthreads = 4;
size_t nframes = 140;
std::vector<uint16_t> pedestal_in_0(RAW_MODULE_SIZE);
std::vector<uint16_t> pedestal_in_1(RAW_MODULE_SIZE);
std::vector<uint16_t> pedestal_in_2(RAW_MODULE_SIZE);
std::vector<uint16_t> pedestal_in_3(RAW_MODULE_SIZE);
for (auto &i: pedestal_in_0) i = 16384 | 5670;
for (auto &i: pedestal_in_1) i = 16384 | 4560;
for (auto &i: pedestal_in_2) i = 16384 | 3450;
for (auto &i: pedestal_in_3) i = 16384 | 2000;
x.Mode(DetectorMode::PedestalG1).StorageCells(4).FixedGainG1(true);
x.PedestalG1Frames(nframes)
.NumTriggers(1).UseInternalPacketGenerator(false)
.ImagesPerTrigger(0).IncidentEnergy_keV(12.4);
REQUIRE(x.GetStorageCellNumber() == 4);
AcquisitionDeviceGroup aq_devices;
auto test = std::make_unique<MockAcquisitionDevice>(0, 64);
test->SetOutput(0, 0, *OutputWithPixels(pedestal_in_0.data()));
test->SetOutput(1, 0, *OutputWithPixels(pedestal_in_1.data()));
test->SetOutput(2, 0, *OutputWithPixels(pedestal_in_2.data()));
test->SetOutput(3, 0, *OutputWithPixels(pedestal_in_3.data()));
test->CreateJFPackets(x, 1, nframes * 4, 0, nullptr);
test->CreateFinalPacket(x);
aq_devices.Add(std::move(test));
PixelMask mask(x);
Logger logger("JFJochReceiverTest_PedestalFixedG1_StorageCell");
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.pedestal_result.size() == 4);
JFModulePedestal out_pedestal_0 = output.pedestal_result[0];
JFModulePedestal out_pedestal_1 = output.pedestal_result[1];
JFModulePedestal out_pedestal_2 = output.pedestal_result[2];
JFModulePedestal out_pedestal_3 = output.pedestal_result[3];
REQUIRE(out_pedestal_0.Mean() == Catch::Approx(5670));
REQUIRE(out_pedestal_0.GetFrameCount() == nframes);
REQUIRE(out_pedestal_1.Mean() == Catch::Approx(4560));
REQUIRE(out_pedestal_1.GetFrameCount() == nframes);
REQUIRE(out_pedestal_2.Mean() == Catch::Approx(3450));
REQUIRE(out_pedestal_2.GetFrameCount() == nframes);
REQUIRE(out_pedestal_3.Mean() == Catch::Approx(2000));
REQUIRE(out_pedestal_3.GetFrameCount() == nframes);
}
TEST_CASE("JFJochReceiverTest_PedestalG1_NoFrames", "[JFJochReceiver]") {
DiffractionExperiment x(DetJF(1));
const uint16_t nthreads = 4;
size_t nframes = 256;
std::vector<uint16_t> pedestal_in(RAW_MODULE_SIZE*nframes);
for (auto &i: pedestal_in) i = 16384 | 14000;
x.Mode(DetectorMode::PedestalG1);
x.PedestalG0Frames(0).PedestalG1Frames(256).NumTriggers(1)
.UseInternalPacketGenerator(false).ImagesPerTrigger(0).IncidentEnergy_keV(12.4);
AcquisitionDeviceGroup aq_devices;
for (int i = 0; i < x.GetDataStreamsNum(); i++) {
auto test = std::make_unique<MockAcquisitionDevice>(i, nframes + 8);
test->CreateFinalPacket(x);
aq_devices.Add(std::move(test));
}
PixelMask mask(x);
Logger logger("JFJochReceiverTest_PedestalG1_NoFrames");
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.expected_packets[0] != 0);
REQUIRE(output.received_packets[0] == 0);
REQUIRE(output.status.images_sent == 0);
REQUIRE(output.efficiency < 1.0);
JFModulePedestal out_pedestal = output.pedestal_result.at(0);
REQUIRE(out_pedestal.CountMaskedPixels() == RAW_MODULE_SIZE);
}
TEST_CASE("JFJochReceiverTest_PacketLost_Raw", "[JFJochReceiver]") {
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
std::vector<uint16_t> frame_in(RAW_MODULE_SIZE);
for (auto &i: frame_in) i = 776;
x.Raw();
x.PedestalG0Frames(0).NumTriggers(1)
.UseInternalPacketGenerator(false).ImagesPerTrigger(4).IncidentEnergy_keV(12.4)
.Compression(CompressionAlgorithm::NO_COMPRESSION);
PixelMask pixel_mask(x);
// The card writes the missing packet as UINT16_MAX
std::vector<uint16_t> frame_lost = frame_in;
for (int i = 127 * 4096; i < RAW_MODULE_SIZE; i++)
frame_lost[i] = UINT16_MAX;
AcquisitionDeviceGroup aq_devices;
for (int i = 0; i < x.GetDataStreamsNum(); i++) {
auto test = std::make_unique<MockAcquisitionDevice>(i, 64);
for (int image = 0; image < 4; image++) {
test->SetOutput(image, 0, *OutputWithPixels((image == 3) ? frame_lost.data() : frame_in.data()));
test->SetOutput(image, 1, *OutputWithPixels(frame_in.data()));
}
test->CreateJFPackets(x, 1, 1, 0, nullptr);
test->CreateJFPackets(x, 1, 1, 1, nullptr);
test->CreateJFPackets(x, 2, 1, 0, nullptr);
test->CreateJFPackets(x, 2, 1, 1, nullptr);
test->CreateJFPackets(x, 3, 1, 0, nullptr);
test->CreateJFPackets(x, 3, 1, 1, nullptr);
for (int j = 0; j < 127; j++)
test->CreateJFPacket(x, 4, j, 0, nullptr);
test->CreateJFPackets(x, 4, 1, 1, nullptr);
test->CreateFinalPacket(x);
aq_devices.Add(std::move(test));
}
Logger logger("JFJochReceiverTest_PacketLost_Raw");
JFCalibration calib(x);
TestImagePusher pusher(x.GetImageNum() - 1);
JFJochReceiverService service(aq_devices, logger, pusher);
service.NumThreads(nthreads);
service.Start(x, pixel_mask, &calib);
auto receiver_out = service.Stop();
const auto image = pusher.GetImage();
REQUIRE(aq_devices[0].GetBytesReceived() == (8*128-1) * 8192UL);
REQUIRE(image.size() == 2 * RAW_MODULE_SIZE * sizeof(uint16_t));
REQUIRE(pusher.GetCounter() == x.GetImageNum());
auto raw = (const uint16_t *) (image.data());
CHECK(raw[0] == 776);
CHECK(raw[256*1024+315] == 776);
CHECK(raw[RAW_MODULE_SIZE-4095] == UINT16_MAX);
CHECK(raw[RAW_MODULE_SIZE-1] == UINT16_MAX);
CHECK(raw[RAW_MODULE_SIZE+0] == 776);
CHECK(raw[RAW_MODULE_SIZE+256*1024+315] == 776);
CHECK(raw[2*RAW_MODULE_SIZE-1] == 776);
REQUIRE(receiver_out.efficiency < 1.0);
REQUIRE(receiver_out.status.images_sent == x.GetImageNum());
}
TEST_CASE("JFJochReceiverTest_Cancel", "[JFJochReceiver]") {
DiffractionExperiment x(DetJF(2));
const uint16_t nthreads = 4;
std::vector<uint16_t> frame_in(RAW_MODULE_SIZE);
for (auto &i: frame_in) i = 776;
x.Raw();
x.PedestalG0Frames(0).NumTriggers(1)
.UseInternalPacketGenerator(false).ImagesPerTrigger(4).IncidentEnergy_keV(12.4);
PixelMask pixel_mask(x);
AcquisitionDeviceGroup aq_devices;
for (int i = 0; i < x.GetDataStreamsNum(); i++) {
auto test = std::make_unique<MockAcquisitionDevice>(i, 64);
test->SetOutput(0, 0, *OutputWithPixels(frame_in.data()));
test->SetOutput(0, 1, *OutputWithPixels(frame_in.data()));
test->CreateJFPackets(x, 1, 1, 0, nullptr);
test->CreateJFPackets(x, 1, 1, 1, nullptr);
test->CreateJFPackets(x, 2, 1, 0, nullptr);
test->CreateJFPackets(x, 2, 1, 1, nullptr);
test->CreateJFPackets(x, 3, 1, 0, nullptr);
test->CreateJFPackets(x, 3, 1, 1, nullptr);
aq_devices.Add(std::move(test));
}
Logger logger("JFJochReceiverTest_Cancel");
JFCalibration calib(x);
TestImagePusher pusher(x.GetImageNum() - 1);
JFJochReceiverService service(aq_devices, logger, pusher);
service.NumThreads(nthreads);
service.Start(x, pixel_mask, &calib);
std::this_thread::sleep_for(std::chrono::seconds(1));
service.Cancel(false);
auto receiver_out = service.Stop();
REQUIRE(receiver_out.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_Pedestal_Cancel", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_Pedestal_Cancel");
DiffractionExperiment x(DetJF(1));
x.Mode(DetectorMode::PedestalG0);
x.PedestalG0Frames(100).NumTriggers(1).UseInternalPacketGenerator(false).IncidentEnergy_keV(12.4);
std::vector<uint16_t> frame_in(RAW_MODULE_SIZE, 1000);
// Only the first frames of the 100 arrive, and no final packet: the run waits until it is cancelled.
AcquisitionDeviceGroup aq_devices;
auto test = std::make_unique<MockAcquisitionDevice>(0, 64);
test->SetOutput(0, 0, *OutputWithPixels(frame_in.data()));
test->CreateJFPackets(x, 1, 10, 0, nullptr);
aq_devices.Add(std::move(test));
PixelMask pixel_mask(x);
TestImagePusher pusher(0);
JFJochReceiverService service(aq_devices, logger, pusher);
service.NumThreads(4);
service.Start(x, pixel_mask, nullptr);
std::this_thread::sleep_for(std::chrono::seconds(1));
service.Cancel(false);
auto output = service.Stop();
REQUIRE(output.status.cancelled);
REQUIRE(output.efficiency < 1.0);
REQUIRE(output.received_packets.at(0) > 0);
REQUIRE(output.received_packets.at(0) < output.expected_packets.at(0));
// Too few frames for a pedestal, so every pixel is reported as wrong
REQUIRE(output.pedestal_result.size() == 1);
REQUIRE(output.pedestal_result[0].CountMaskedPixels() == RAW_MODULE_SIZE);
REQUIRE(pusher.GetCounter() == 0);
}
TEST_CASE("JFJochReceiverTest_EIGER", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_EIGER");
DiffractionExperiment x(DetEIGER(2));
const uint16_t nthreads = 4;
x.Raw();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_EIGER_8bit", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_EIGER_8bit");
DiffractionExperiment x(DetEIGER(2));
const uint16_t nthreads = 4;
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD);
x.EigerBitDepth(8);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_EIGER_32bit", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_EIGER_32bit");
DiffractionExperiment x(DetEIGER(2));
const uint16_t nthreads = 4;
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD);
x.EigerBitDepth(32);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}
TEST_CASE("JFJochReceiverTest_EIGER_conversion", "[JFJochReceiver]") {
Logger logger("JFJochReceiverTest_EIGER_conversion");
DiffractionExperiment x(DetEIGER(2));
const uint16_t nthreads = 4;
x.Conversion();
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true)
.ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD);
PixelMask mask(x);
AcquisitionDeviceGroup aq_devices = ConvertingMocks(x, mask);
JFJochReceiverOutput output;
bool ret;
REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads));
REQUIRE(ret);
REQUIRE(output.efficiency == 1.0);
REQUIRE(output.status.images_sent == x.GetImageNum());
REQUIRE(!output.status.cancelled);
}