File writer and spot finding improvements
This commit is contained in:
@@ -1461,21 +1461,9 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_integration", "[FPGA][Full
|
||||
}
|
||||
|
||||
bool spot_finder_output_contains(const SpotFindingResult& output, uint32_t number) {
|
||||
bool ret = false;
|
||||
for (const auto &i: output.strong_pixel_number) {
|
||||
if ((i & (((1<<21UL) - 1))) == number)
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool spot_finder_output_connectivity(const SpotFindingResult& output, uint32_t number, uint8_t bit) {
|
||||
bool ret = false;
|
||||
for (const auto &i: output.strong_pixel_number) {
|
||||
if ((i & (((1<<21UL) - 1))) == number)
|
||||
ret = i & (1LU << (24 + bit));
|
||||
}
|
||||
return ret;
|
||||
size_t byte = number / 8;
|
||||
size_t bit = number % 8;
|
||||
return ((output.strong_pixel[byte] & (1 << bit)) != 0);
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_count_threshold", "[FPGA][Full]") {
|
||||
@@ -1501,7 +1489,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_count_threshol
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 0.0,
|
||||
.photon_count_threshold = 10,
|
||||
.photon_count_threshold = 9,
|
||||
.min_pix_per_spot = 1
|
||||
};
|
||||
test.SetSpotFinderParameters(parameters);
|
||||
@@ -1519,94 +1507,13 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_count_threshol
|
||||
auto spot_finder_result = test.GetDeviceOutput(0, 0)->spot_finding_result;
|
||||
REQUIRE (spot_finder_result.strong_pixel_count == 3);
|
||||
REQUIRE (spot_finder_result.snr_threshold == 0);
|
||||
REQUIRE (spot_finder_result.count_threshold == 10);
|
||||
REQUIRE (spot_finder_result.count_threshold == 9);
|
||||
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 0));
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 123*1024 + 578));
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 121*1024 + 800));
|
||||
}
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_connectivity", "[FPGA][Full]") {
|
||||
const uint16_t nmodules = 4;
|
||||
|
||||
DiffractionExperiment x((DetectorGeometry(nmodules)));
|
||||
|
||||
x.Mode(DetectorMode::Raw);
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(1).PedestalG0Frames(0);
|
||||
|
||||
HLSSimulatedDevice test(0, 64);
|
||||
|
||||
std::vector<uint16_t> frame(RAW_MODULE_SIZE, 0);
|
||||
frame [ 0] = 11;
|
||||
frame [ 1] = 10;
|
||||
frame [ 1024] = 12;
|
||||
frame [2*1024] = 12;
|
||||
|
||||
frame [ 99*1024+200] = 12;
|
||||
frame [100*1024+200] = 11;
|
||||
frame [100*1024+201] = 10;
|
||||
frame [101*1024+200] = 12;
|
||||
frame [RAW_MODULE_SIZE - 1] = 20;
|
||||
|
||||
for (int m = 0; m < x.GetModulesNum(); m++)
|
||||
test.SetInternalGeneratorFrame(frame.data(), m);
|
||||
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 0.0,
|
||||
.photon_count_threshold = 10,
|
||||
.min_pix_per_spot = 1
|
||||
};
|
||||
test.SetSpotFinderParameters(parameters);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.OutputStream().size() == 1);
|
||||
|
||||
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 spot_finder_result = test.GetDeviceOutput(0, 0)->spot_finding_result;
|
||||
REQUIRE (spot_finder_result.strong_pixel_count == 9);
|
||||
REQUIRE (spot_finder_result.snr_threshold == 0);
|
||||
REQUIRE (spot_finder_result.count_threshold == 10);
|
||||
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 0));
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 1));
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 1024));
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, RAW_MODULE_SIZE-1));
|
||||
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 0, 4));
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 0, 6));
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 1, 1));
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 1, 2));
|
||||
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 1024, 3));
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 1024, 4));
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 1024, 5));
|
||||
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 2048, 3));
|
||||
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 100*1024+201, 0));
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 100*1024+201, 1));
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 100*1024+201, 2));
|
||||
CHECK(!spot_finder_output_connectivity(spot_finder_result, 100*1024+201, 3));
|
||||
CHECK(!spot_finder_output_connectivity(spot_finder_result, 100*1024+201, 4));
|
||||
CHECK(!spot_finder_output_connectivity(spot_finder_result, 100*1024+201, 5));
|
||||
CHECK(!spot_finder_output_connectivity(spot_finder_result, 100*1024+201, 6));
|
||||
CHECK(!spot_finder_output_connectivity(spot_finder_result, 100*1024+201, 7));
|
||||
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 99*1024+200, 7));
|
||||
CHECK(spot_finder_output_connectivity(spot_finder_result, 99*1024+200, 4));
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
CHECK(!spot_finder_output_connectivity(spot_finder_result, RAW_MODULE_SIZE-1, i));
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_min_pix_per_spot", "[FPGA][Full]") {
|
||||
const uint16_t nmodules = 4;
|
||||
|
||||
@@ -1636,7 +1543,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_min_pix_per_sp
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 0.0,
|
||||
.photon_count_threshold = 10,
|
||||
.photon_count_threshold = 9,
|
||||
.min_pix_per_spot = 2
|
||||
};
|
||||
test.SetSpotFinderParameters(parameters);
|
||||
@@ -1654,7 +1561,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_min_pix_per_sp
|
||||
auto spot_finder_result = test.GetDeviceOutput(0, 0)->spot_finding_result;
|
||||
REQUIRE (spot_finder_result.strong_pixel_count == 8);
|
||||
REQUIRE (spot_finder_result.snr_threshold == 0);
|
||||
REQUIRE (spot_finder_result.count_threshold == 10);
|
||||
REQUIRE (spot_finder_result.count_threshold == 9);
|
||||
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 0));
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 1));
|
||||
@@ -1692,7 +1599,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_d_min_max", "[
|
||||
|
||||
SpotFindingSettings parameters{
|
||||
.signal_to_noise_threshold = 0.0,
|
||||
.photon_count_threshold = 10,
|
||||
.photon_count_threshold = 9,
|
||||
.min_pix_per_spot = 1,
|
||||
.high_resolution_limit = 1.25,
|
||||
.low_resolution_limit = 3.0
|
||||
@@ -1712,7 +1619,7 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_spot_finder_d_min_max", "[
|
||||
auto spot_finder_result = test.GetDeviceOutput(0, 0)->spot_finding_result;
|
||||
REQUIRE (spot_finder_result.strong_pixel_count == 2);
|
||||
REQUIRE (spot_finder_result.snr_threshold == 0);
|
||||
REQUIRE (spot_finder_result.count_threshold == 10);
|
||||
REQUIRE (spot_finder_result.count_threshold == 9);
|
||||
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 0));
|
||||
CHECK (spot_finder_output_contains(spot_finder_result, 3));
|
||||
|
||||
Reference in New Issue
Block a user