CheckConversionWithGeomTransform: Use fill value for gaps consistent with JFJochReceiver

This commit is contained in:
2023-07-04 11:45:17 +02:00
parent 9d35660cf4
commit 7a4e75efd3
3 changed files with 27 additions and 11 deletions

View File

@@ -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);

View File

@@ -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<uint16_t> data(RAW_MODULE_SIZE);
JFModulePedestal pedestal_g0, pedestal_g1, pedestal_g2;
std::vector<double> 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));

View File

@@ -66,8 +66,11 @@ template <class T> 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<float> conversion_ref(experiment.GetModulesNum() * RAW_MODULE_SIZE);
std::vector<float> conversion_ref_transformed(experiment.GetPixelsNum());
std::vector<float> conversion_ref_transformed(experiment.GetPixelsNum(), fill_value);
JFConversionFloatingPoint conversion;
@@ -78,7 +81,6 @@ template <class T> 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() );