Dense per-pixel maps through the panel table (panel layout stage 1)
Every dense map that needs geometry now evaluates each image pixel at its place on the detector plane (DetectorModules), so it is right for a stacked panel layout and picks up refined module placements: - AzimuthalIntegrationMapping: bins, resolution, solid-angle/polarisation corrections built per pixel through the table; a pixel on no panel is left as a masked one. The geometry cache key now includes the panel table, so a mapping built after the stills module placement is rebuilt rather than served from the cache. ResolutionMaskBits follows (it is a lookup). - ROIMap / ExportROIMap: azimuthal ROIs on the plane (box and circle ROIs stay in image pixels). - ROIIntegration CPU+GPU: the weighted sums are taken per ROI and panel in image pixels and placed on the plane at the end (exact; the affine commutes with a weighted mean). - HotPixelFinder: ring/sector keys and the zeta of the persistence rule on the plane. - Background beam-centre walk CPU+GPU: pixels binned at their plane position; host and device share BackgroundPlanePoint so they stay bit-identical. New common/PanelRows.h: ForEachPixelInRows, ForEachPixel cut to a band of rows in index order, for the row-parallel builders. An empty table takes the old arithmetic in the old order: rotation sets and every single-panel input are unchanged. [PanelLayout] AzintMapping and ResolutionMask enabled (+ azimuthal ROI map and ROI centroid on the plane); new BeamCenterFromBackground_BinsOnThePlane and ROIIntegrationGPU_MatchesCPU_Panels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015CeEGgpKdfkCTJb3YNMJcu
This commit is contained in:
1 parent
c8fb472f4d
commit
dcad4104ce
22 files changed
+427
-134
No files matched your search
@@ -11,6 +11,7 @@
|
||||
#include "../../common/CompressedImage.h"
|
||||
#include "../../common/JFJochMath.h"
|
||||
#include "../../common/ParallelFor.h"
|
||||
#include "../../common/PanelRows.h"
|
||||
#ifdef JFJOCH_USE_CUDA
|
||||
#include "../../common/CUDAWrapper.h"
|
||||
#include "BeamCenterBackgroundGPU.h"
|
||||
@@ -181,13 +182,20 @@ FindBeamCenterFromBackground(const DiffractionExperiment &experiment, const Pixe
|
||||
band.tan_lo = tan_lo;
|
||||
band.tan_hi = tan_hi;
|
||||
|
||||
// The pixels are binned at their place on the plane.
|
||||
const DetectorModules &modules = experiment.GetModules();
|
||||
std::vector<BackgroundPanel> panels;
|
||||
for (const auto &m: modules.Get())
|
||||
panels.push_back({static_cast<int>(m.x0), static_cast<int>(m.y0), static_cast<int>(m.width),
|
||||
static_cast<int>(m.height), m.ox, m.oy, m.fx, m.fy, m.sx, m.sy});
|
||||
|
||||
#ifndef JFJOCH_USE_CUDA
|
||||
(void) allow_device;
|
||||
#else
|
||||
// With a GPU the two passes over the pixels run there, and only the cells come back.
|
||||
std::unique_ptr<BeamCenterBackgroundGPU> gpu;
|
||||
if (allow_device && get_gpu_count() > 0)
|
||||
gpu = std::make_unique<BeamCenterBackgroundGPU>(W, H, block_row, usable.data(), mean.data());
|
||||
gpu = std::make_unique<BeamCenterBackgroundGPU>(W, H, block_row, panels, usable.data(), mean.data());
|
||||
#endif
|
||||
|
||||
float step_x = 0.0f, step_y = 0.0f, sigma_x = 0.0f, sigma_y = 0.0f;
|
||||
@@ -209,25 +217,25 @@ FindBeamCenterFromBackground(const DiffractionExperiment &experiment, const Pixe
|
||||
int32_t *cells = band_cell.data() + static_cast<size_t>(block_row[b]) * W;
|
||||
float *values = band_value.data() + static_cast<size_t>(block_row[b]) * W;
|
||||
size_t n_band = 0;
|
||||
for (int y = block_row[b]; y < block_row[b + 1]; y++) {
|
||||
for (int x = 0; x < W; x++) {
|
||||
const size_t i = static_cast<size_t>(y) * W + x;
|
||||
if (!usable[i])
|
||||
continue;
|
||||
float jac_x, jac_y;
|
||||
const int cell = BackgroundBandCell(band, x, y, beam_x, beam_y, jac_x, jac_y);
|
||||
if (cell < 0)
|
||||
continue;
|
||||
cells[n_band] = cell;
|
||||
values[n_band] = mean[i];
|
||||
n_band++;
|
||||
b_count[cell]++;
|
||||
b_sum[cell] += mean[i];
|
||||
b_sum_sq[cell] += static_cast<double>(mean[i]) * mean[i];
|
||||
b_jx[cell] += jac_x;
|
||||
b_jy[cell] += jac_y;
|
||||
}
|
||||
}
|
||||
ForEachPixelInRows(modules, W, block_row[b], block_row[b + 1], [&](int64_t p, size_t i, double px, double py) {
|
||||
if (!usable[i])
|
||||
return;
|
||||
auto x = static_cast<float>(px), y = static_cast<float>(py);
|
||||
if (p >= 0) // as the device has it
|
||||
BackgroundPlanePoint(panels[p], static_cast<int>(i % W), static_cast<int>(i / W), x, y);
|
||||
float jac_x, jac_y;
|
||||
const int cell = BackgroundBandCell(band, x, y, beam_x, beam_y, jac_x, jac_y);
|
||||
if (cell < 0)
|
||||
return;
|
||||
cells[n_band] = cell;
|
||||
values[n_band] = mean[i];
|
||||
n_band++;
|
||||
b_count[cell]++;
|
||||
b_sum[cell] += mean[i];
|
||||
b_sum_sq[cell] += static_cast<double>(mean[i]) * mean[i];
|
||||
b_jx[cell] += jac_x;
|
||||
b_jy[cell] += jac_y;
|
||||
});
|
||||
band_pixels[b] = n_band;
|
||||
});
|
||||
fold(true);
|
||||
|
||||
Reference in new issue
Block a user