From 7a4e75efd38505996e12f0823dd3c0f309e7af44 Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Tue, 4 Jul 2023 11:45:17 +0200 Subject: [PATCH] CheckConversionWithGeomTransform: Use fill value for gaps consistent with JFJochReceiver --- tests/DetectorGeometryTest.cpp | 15 +++++++++++++++ tests/FPGAIntegrationTest.cpp | 17 ++++++++--------- tests/FPGAUnitTest.h | 6 ++++-- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/tests/DetectorGeometryTest.cpp b/tests/DetectorGeometryTest.cpp index 0b70958c..5f8d4b75 100644 --- a/tests/DetectorGeometryTest.cpp +++ b/tests/DetectorGeometryTest.cpp @@ -34,6 +34,21 @@ TEST_CASE("DetectorGeometry_Regular_1Module", "[DetectorGeometry]") { REQUIRE(pbuf.module_geometry(0).slow_direction_step() == CONVERTED_MODULE_COLS); } +TEST_CASE("DetectorGeometry_Regular_2Module", "[DetectorGeometry]") { + DetectorGeometry geometry(2, 2, 8, 36, false); + + const JFJochProtoBuf::DetectorGeometry pbuf = geometry; + REQUIRE(pbuf.module_geometry_size() == 2); + + REQUIRE(pbuf.width_pxl() == CONVERTED_MODULE_COLS * 2 + 8); + REQUIRE(pbuf.height_pxl() == CONVERTED_MODULE_LINES); + REQUIRE(pbuf.module_geometry(0).pixel0() == 0); + REQUIRE(pbuf.module_geometry(1).pixel0() == CONVERTED_MODULE_COLS + 8); + + REQUIRE(pbuf.module_geometry(0).fast_direction_step() == 1); + REQUIRE(pbuf.module_geometry(0).slow_direction_step() == CONVERTED_MODULE_COLS * 2 + 8); +} + TEST_CASE("DetectorGeometry_RegularMirror", "[DetectorGeometry]") { DetectorGeometry geometry(18, 3, 8, 36, true); diff --git a/tests/FPGAIntegrationTest.cpp b/tests/FPGAIntegrationTest.cpp index d20d3666..fb08881c 100644 --- a/tests/FPGAIntegrationTest.cpp +++ b/tests/FPGAIntegrationTest.cpp @@ -404,12 +404,11 @@ TEST_CASE("HLS_C_Simulation_check_convert_full_range", "[FPGA][Full]") { TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range", "[FPGA][Full]") { double energy = 6.0; - const uint16_t nmodules = 1; - DiffractionExperiment x((DetectorGeometry(nmodules))); + const uint16_t nmodules = 4; + DiffractionExperiment x((DetectorGeometry(nmodules, 2, 8, 36, true))); std::vector data(RAW_MODULE_SIZE); JFModulePedestal pedestal_g0, pedestal_g1, pedestal_g2; - std::vector gain(3 * RAW_MODULE_SIZE); for (int i = 0; i < RAW_MODULE_SIZE; i++) { pedestal_g0.GetPedestal()[i] = 0 + (i / 65536) * 1000 + 100 * (i % 5); @@ -428,12 +427,12 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range", "[FPG auto gain_from_file = GainCalibrationFromTestFile(); JFCalibration c(x); - c.Pedestal(0,0) = pedestal_g0; - c.Pedestal(0,1) = pedestal_g1; - c.Pedestal(0,2) = pedestal_g2; - - for (int i = 0; i < x.GetModulesNum(); i++) + for (int i = 0; i < x.GetModulesNum(); i++) { + c.Pedestal(i, 0) = pedestal_g0; + c.Pedestal(i, 1) = pedestal_g1; + c.Pedestal(i, 2) = pedestal_g2; c.GainCalibration(i) = gain_from_file; + } HLSSimulatedDevice test(0, 64); @@ -444,7 +443,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_convert_full_range", "[FPG REQUIRE_NOTHROW(test.OutputStream().read()); REQUIRE(test.OutputStream().size() == 0); - REQUIRE(test.GetBytesReceived() == 128 * JUNGFRAU_PACKET_SIZE_BYTES); + REQUIRE(test.GetBytesReceived() == nmodules * 128 * JUNGFRAU_PACKET_SIZE_BYTES); double mean_error = CheckConversion(x, c, data.data(), test.GetFrameBuffer(0,0)); diff --git a/tests/FPGAUnitTest.h b/tests/FPGAUnitTest.h index 3e8a476b..03d81cc8 100644 --- a/tests/FPGAUnitTest.h +++ b/tests/FPGAUnitTest.h @@ -66,8 +66,11 @@ template double CheckConversionWithGeomTransform(const DiffractionExpe const JFCalibration &calib, const uint16_t *raw, T *converted, size_t storage_cell = 0) { + T fill_value = INT16_MIN; + if (experiment.GetPixelDepth() == 4) + fill_value = INT32_MIN; std::vector conversion_ref(experiment.GetModulesNum() * RAW_MODULE_SIZE); - std::vector conversion_ref_transformed(experiment.GetPixelsNum()); + std::vector conversion_ref_transformed(experiment.GetPixelsNum(), fill_value); JFConversionFloatingPoint conversion; @@ -78,7 +81,6 @@ template double CheckConversionWithGeomTransform(const DiffractionExpe calib.Pedestal(m, 2, storage_cell), experiment.GetPhotonEnergy_keV()); conversion.ConvertFP(conversion_ref.data() + m * RAW_MODULE_SIZE, raw); - } RawToConvertedGeometryAdjustMultipixels(experiment, conversion_ref_transformed.data(), conversion_ref.data() );