Files
Jungfraujoch/tools/SpotFindingPerformanceTest.cpp

59 lines
2.0 KiB
C++

// Copyright (2019-2023) Paul Scherrer Institute
#include <random>
#include "../image_analysis/StrongPixelSet.h"
int main() {
Logger logger("SpotFindingPerformanceTest");
DeviceOutput dev_output;
size_t nstrong_pixel = 2048;
dev_output.spot_finding_result.strong_pixel_count = nstrong_pixel;
for (auto &i: dev_output.spot_finding_result.strong_pixel)
i = 0;
std::mt19937 g1(67678);
std::uniform_int_distribution<size_t> distribution(0, RAW_MODULE_SIZE - 1);
int pixels_set = 0;
while (pixels_set < nstrong_pixel) {
size_t pixel = distribution(g1);
size_t location = pixel / 8;
size_t bit = (1 << (pixel % 8));
if ((dev_output.spot_finding_result.strong_pixel[location] & bit) == 0) {
dev_output.spot_finding_result.strong_pixel[location] |= (1LU << bit);
pixels_set++;
}
}
DiffractionExperiment experiment(DetectorGeometry(18, 3, 8, 36));
experiment.DetectorDistance_mm(50.0).BeamX_pxl(1200).BeamY_pxl(1200);
SpotFindingSettings settings{
.min_pix_per_spot = 1,
.max_pix_per_spot = 250,
.high_resolution_limit = 0.3,
.low_resolution_limit = 100.0
};
int iterations = 100;
{
int tmp = 0;
auto start_time = std::chrono::system_clock::now();
for (int i = 0; i < iterations; i++) {
std::vector<DiffractionSpot> spots, spots_out;
for (int m = 0; m < experiment.GetModulesNum(); m++) {
StrongPixelSet strong_pixel_set(experiment);
strong_pixel_set.ReadFPGAOutput(dev_output);
strong_pixel_set.FindSpots(experiment, settings, spots, m);
}
FilterSpotsByResolution(experiment, spots, spots_out);
tmp += spots_out.size();
}
auto end_time = std::chrono::system_clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
logger.Info("Performance {:.2f} us", elapsed.count() / static_cast<double>(iterations));
}
}