v1.0.0-rc.34
This commit is contained in:
+161
-17
@@ -1064,7 +1064,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_mask", "[FPGA][Full]") {
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
std::vector<uint16_t> data(RAW_MODULE_SIZE);
|
||||
|
||||
|
||||
for (int i = 0; i < RAW_MODULE_SIZE; i++)
|
||||
data[i] = i % 7;
|
||||
|
||||
@@ -1072,7 +1072,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_mask", "[FPGA][Full]") {
|
||||
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1).UseInternalPacketGenerator(true).IncidentEnergy_keV(energy)
|
||||
.GeometryTransformation(false).PixelSigned(true).ApplyPixelMask(true);
|
||||
REQUIRE(x.GetIncidentEnergy_keV() == Catch::Approx(energy));
|
||||
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
std::vector<uint32_t> module_pixel_mask(RAW_MODULE_SIZE);
|
||||
@@ -1084,10 +1084,10 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_mask", "[FPGA][Full]") {
|
||||
test.SetInternalGeneratorFrame(data.data(), m);
|
||||
|
||||
REQUIRE_NOTHROW(test.InitializePixelMask(module_pixel_mask.data(), 1));
|
||||
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == nmodules * 128 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
|
||||
CHECK(test.GetDeviceOutput(0, 0)->pixels[0] == 0);
|
||||
@@ -1556,6 +1556,53 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_integration", "[FPGA][Full
|
||||
CHECK(integration_result[54].count == RAW_MODULE_SIZE);
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_integration_mask", "[FPGA][Full]") {
|
||||
Logger logger(Catch::getResultCapture().getCurrentTestName());
|
||||
|
||||
const uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(1).PedestalG0Frames(0).ApplyPixelMask(false);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
std::vector<uint32_t> mask(RAW_MODULE_SIZE, 0);
|
||||
mask[0] = 4;
|
||||
|
||||
std::vector<uint16_t> frame(RAW_MODULE_SIZE, 0);
|
||||
frame[0] = 2;
|
||||
frame[1] = 3;
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++) {
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
test.InitializePixelMask(mask.data(), m);
|
||||
}
|
||||
|
||||
std::vector<uint16_t> integration_map(nmodules * RAW_MODULE_SIZE, 1);
|
||||
|
||||
std::vector<float> weights(nmodules * RAW_MODULE_SIZE, 1.0);
|
||||
integration_map[0] = 0;
|
||||
integration_map[1] = 0;
|
||||
|
||||
test.InitializeIntegrationMap(x, integration_map, weights);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 128 * nmodules * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
|
||||
auto imageBuf = test.GetDeviceOutput(0, 0)->pixels;
|
||||
REQUIRE(memcmp(imageBuf, frame.data(), RAW_MODULE_SIZE * sizeof(uint16_t)) == 0);
|
||||
|
||||
auto integration_result = test.GetDeviceOutput(0, 0)->integration_result;
|
||||
CHECK(integration_result[0].sum == 3);
|
||||
CHECK(integration_result[0].count == 1);
|
||||
CHECK(integration_result[1].sum == 0);
|
||||
CHECK(integration_result[1].count == RAW_MODULE_SIZE - 2);
|
||||
}
|
||||
|
||||
bool spot_finder_output_contains(const SpotFindingResult& output, uint32_t number) {
|
||||
size_t byte = number / 8;
|
||||
size_t bit = number % 8;
|
||||
@@ -1623,14 +1670,21 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_mask", "[FPGA]
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(1).PedestalG0Frames(0);
|
||||
x.ApplyPixelMask(false);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
std::vector<uint32_t> mask(RAW_MODULE_SIZE, 0);
|
||||
mask[325*1024 + 463] = 4;
|
||||
|
||||
std::vector<uint16_t> frame(RAW_MODULE_SIZE, 0);
|
||||
// Module boundary
|
||||
frame [ 0*1024 + 0] = 50;
|
||||
frame [ 5*1024 + 0] = 50;
|
||||
frame [ 0*1024 + 5] = 50;
|
||||
frame [ 511*1024 + 5] = 50;
|
||||
|
||||
// Chip boundary
|
||||
frame [ 345*1024 + 1023] = 50;
|
||||
frame [ 346*1024 + 255] = 50;
|
||||
frame [ 347*1024 + 256] = 50;
|
||||
@@ -1640,13 +1694,19 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_mask", "[FPGA]
|
||||
frame [ 351*1024 + 768] = 50;
|
||||
frame [ 255*1024 + 234] = 50;
|
||||
frame [ 256*1024 + 876] = 50;
|
||||
|
||||
// "Normal" pixel
|
||||
frame [ 320*1024 + 400] = 50;
|
||||
|
||||
// Masked pixel
|
||||
frame [ 325*1024 + 463] = 50;
|
||||
|
||||
std::vector<float> d_map(RAW_MODULE_SIZE, 3.0);
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++) {
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
test.InitializeSpotFinderResolutionMap(d_map.data(), m);
|
||||
test.InitializePixelMask(mask.data(), m);
|
||||
}
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
@@ -2028,7 +2088,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_summation", "[FPGA][Full]"
|
||||
else if (test_frame_signed[m * RAW_MODULE_SIZE + i] == INT16_MIN)
|
||||
CHECK(imageBuf[i] == INT32_MIN);
|
||||
else
|
||||
REQUIRE(imageBuf[i] == test_frame_signed[m * RAW_MODULE_SIZE + i] * nsummation);
|
||||
REQUIRE(imageBuf[i] == test_frame_signed[m * RAW_MODULE_SIZE + i] * nsummation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2071,11 +2131,95 @@ TEST_CASE("HLS_C_Simulation_count_sat_and_err_pixels", "[FPGA][Full]") {
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.saturated_pixels == 2);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.err_pixels == 3);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.max_value == 30);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.load_calibration_destination == INT16_MIN + 25);
|
||||
CHECK(test.GetDeviceOutput(image, m)->module_statistics.min_value == INT16_MIN + 25);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_pixel_count_mask", "[FPGA][Full]") {
|
||||
Logger logger(Catch::getResultCapture().getCurrentTestName());
|
||||
|
||||
const uint16_t nmodules = 3;
|
||||
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(4).PedestalG0Frames(0).PixelSigned(true);
|
||||
x.ApplyPixelMask(false);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
std::vector<uint32_t> pixel_mask(RAW_MODULE_SIZE, 0);
|
||||
pixel_mask[0] = 2;
|
||||
pixel_mask[1] = 4;
|
||||
pixel_mask[2] = 1<<30;
|
||||
test.InitializePixelMask(pixel_mask.data(), 1);
|
||||
|
||||
std::vector<int16_t> v(RAW_MODULE_SIZE, 0);
|
||||
v[0] = INT16_MAX;
|
||||
v[1] = INT16_MIN;
|
||||
v[2] = 35;
|
||||
v[3] = 234;
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame((uint16_t *) v.data(), m);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
REQUIRE(test.GetBytesReceived() == 128 * nmodules * 4 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
|
||||
for (int image = 0; image < 4; image++) {
|
||||
CHECK(test.GetDeviceOutput(image, 1)->module_statistics.saturated_pixels == 0);
|
||||
CHECK(test.GetDeviceOutput(image, 1)->module_statistics.err_pixels == 0);
|
||||
CHECK(test.GetDeviceOutput(image, 1)->module_statistics.max_value == 234);
|
||||
CHECK(test.GetDeviceOutput(image, 1)->module_statistics.min_value == 0);
|
||||
CHECK(test.GetDeviceOutput(image, 1)->module_statistics.masked_pixels == 3);
|
||||
CHECK(test.GetDeviceOutput(image, 1)->module_statistics.pixel_sum == 234);
|
||||
CHECK(test.GetDeviceOutput(image, 1)->pixels[2] == 35);
|
||||
|
||||
CHECK(test.GetDeviceOutput(image, 0)->module_statistics.saturated_pixels == 1);
|
||||
CHECK(test.GetDeviceOutput(image, 0)->module_statistics.err_pixels == 1);
|
||||
CHECK(test.GetDeviceOutput(image, 0)->module_statistics.max_value == 234);
|
||||
CHECK(test.GetDeviceOutput(image, 0)->module_statistics.min_value == 0);
|
||||
CHECK(test.GetDeviceOutput(image, 0)->module_statistics.masked_pixels == 0);
|
||||
CHECK(test.GetDeviceOutput(image, 0)->module_statistics.pixel_sum == 35 + 234);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_count_pixel_sum", "[FPGA][Full]") {
|
||||
Logger logger(Catch::getResultCapture().getCurrentTestName());
|
||||
|
||||
const uint16_t nmodules = 3;
|
||||
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(4).PedestalG0Frames(0).PixelSigned(true);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
std::vector<int16_t> v_0(RAW_MODULE_SIZE, 123);
|
||||
std::vector<int16_t> v_1(RAW_MODULE_SIZE, 34);
|
||||
v_1[0] = INT16_MAX;
|
||||
v_1[1] = INT16_MIN;
|
||||
v_1[2] = 0;
|
||||
v_1[RAW_MODULE_SIZE-1] = -1234;
|
||||
std::vector<int16_t> v_2(RAW_MODULE_SIZE, -23);
|
||||
|
||||
test.SetInternalGeneratorFrame((uint16_t *) v_0.data(), 0);
|
||||
test.SetInternalGeneratorFrame((uint16_t *) v_1.data(), 1);
|
||||
test.SetInternalGeneratorFrame((uint16_t *) v_2.data(), 2);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
REQUIRE(test.GetBytesReceived() == 128 * nmodules * 4 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
|
||||
for (int image = 0; image < 4; image++) {
|
||||
CHECK(test.GetDeviceOutput(image, 0)->module_statistics.pixel_sum == 123 * RAW_MODULE_SIZE);
|
||||
CHECK(test.GetDeviceOutput(image, 1)->module_statistics.pixel_sum == 34 * (RAW_MODULE_SIZE - 4) - 1234);
|
||||
CHECK(test.GetDeviceOutput(image, 2)->module_statistics.pixel_sum == -23 * RAW_MODULE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_check_bunchid", "[FPGA][Full]") {
|
||||
Logger logger(Catch::getResultCapture().getCurrentTestName());
|
||||
|
||||
@@ -2425,16 +2569,16 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_roi_calc", "[FPGA][Full]")
|
||||
frame[812+RAW_MODULE_COLS*304] = 13;
|
||||
frame[813+RAW_MODULE_COLS*304] = 125;
|
||||
|
||||
std::vector<uint16_t> roi_map(RAW_MODULE_SIZE, UINT16_MAX);
|
||||
roi_map[12+RAW_MODULE_COLS*3] = 0;
|
||||
roi_map[13+RAW_MODULE_COLS*3] = 0;
|
||||
roi_map[12+RAW_MODULE_COLS*4] = 0;
|
||||
roi_map[13+RAW_MODULE_COLS*4] = 0;
|
||||
std::vector<uint16_t> roi_map(RAW_MODULE_SIZE, 0);
|
||||
roi_map[12+RAW_MODULE_COLS*3] = 1;
|
||||
roi_map[13+RAW_MODULE_COLS*3] = 1;
|
||||
roi_map[12+RAW_MODULE_COLS*4] = 1;
|
||||
roi_map[13+RAW_MODULE_COLS*4] = 1;
|
||||
|
||||
roi_map[812+RAW_MODULE_COLS*303] = 1;
|
||||
roi_map[813+RAW_MODULE_COLS*303] = 1;
|
||||
roi_map[812+RAW_MODULE_COLS*304] = 1;
|
||||
roi_map[813+RAW_MODULE_COLS*304] = 1;
|
||||
roi_map[812+RAW_MODULE_COLS*303] = (1<<5);
|
||||
roi_map[813+RAW_MODULE_COLS*303] = (1<<5);
|
||||
roi_map[812+RAW_MODULE_COLS*304] = (1<<5);
|
||||
roi_map[813+RAW_MODULE_COLS*304] = (1<<5);
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++) {
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
@@ -2458,8 +2602,8 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_roi_calc", "[FPGA][Full]")
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].max_value == 125);
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[0].good_pixels == 4);
|
||||
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[1].sum_x_weighted == Catch::Approx(83 * (812+6) + 95 * (813+6) + 13 * (812+6) + 125 * (813+6)));
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[1].sum_y_weighted == Catch::Approx(83 * (303+2) + 95 * (303+2) + 13 * (304+2) + 125 * (304+2)));
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[5].sum_x_weighted == Catch::Approx(83 * (812+6) + 95 * (813+6) + 13 * (812+6) + 125 * (813+6)));
|
||||
CHECK (test.GetDeviceOutput(i, m)->roi_counts[5].sum_y_weighted == Catch::Approx(83 * (303+2) + 95 * (303+2) + 13 * (304+2) + 125 * (304+2)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user