Skip to content

kernels: read pixel response bins at (k + 1/2) * bin - #3

Open
kvtsang wants to merge 1 commit into
DeepLearnPhysics:mainfrom
kvtsang:pr/pixel-half-bin-offset
Open

kvtsang wants to merge 1 commit into
DeepLearnPhysics:mainfrom
kvtsang:pr/pixel-half-bin-offset

Conversation

@kvtsang

@kvtsang kvtsang commented Nov 11, 2026

Copy link
Copy Markdown

Pixel response NPZ tables (larnd-sim's, and config/pixel_response.npz) sample the quadrant at bin centres, x_k = (k + 1/2) * bin from the pixel centre. interpolate_pixel_response_kernel read bin k at x = k * bin, so every lookup was half a bin too far out. Charge on pixel edges was lost. With 10 bins per pitch and diffusion off, the total charge collected by all output pixels averaged 0.81 of the pad-sum (0.9 per axis), and fell to 0.016 near a pixel corner.

  • Read distance d (in bins) at max(d - 1/2, 0). Within half a bin of the centre the mirror neighbour of bin 0 is bin 0, so the clip is exact.
  • Pad the 3-D diffusion table with mode='symmetric' instead of 'reflect'. 'reflect' assumes a sample at the centre; the bin-centre grid has none.

The table format and output shapes are unchanged. Gradients with respect to the sub-pixel offset still match finite differences away from the interpolation kinks.

Adds tests/test_pixel_kernel_grid.py: total charge equals the pad-sum within 1e-3 at 20x20 offsets, with and without transverse diffusion. It fails before this change.

Pixel response NPZ tables (larnd-sim's, and config/pixel_response.npz)
sample the quadrant at bin centres, x_k = (k + 1/2) * bin from the pixel
centre. interpolate_pixel_response_kernel read bin k at x = k * bin, so
every lookup was half a bin too far out. Charge on pixel edges was lost.
With 10 bins per pitch and diffusion off, the total charge collected by
all output pixels averaged 0.81 of the pad-sum (0.9 per axis), and fell
to 0.016 near a pixel corner.

- Read distance d (in bins) at max(d - 1/2, 0). Within half a bin of
  the centre the mirror neighbour of bin 0 is bin 0, so the clip is
  exact.
- Pad the 3-D diffusion table with mode='symmetric' instead of
  'reflect'. 'reflect' assumes a sample at the centre; the bin-centre
  grid has none.

The table format and output shapes are unchanged. Gradients with respect
to the sub-pixel offset still match finite differences away from the
interpolation kinks.

Adds tests/test_pixel_kernel_grid.py: total charge equals the pad-sum
within 1e-3 at 20x20 offsets, with and without transverse diffusion.
It fails before this change.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant