Repository navigation
Wire response: cubic sub-tick placement (N2) and collection-plane tiling (N4) - #8
Merged
Merged
Conversation
The 2-tap linear blend in interpolate_diffusion_kernel is not a pure fractional shift -- it is a shift CONVOLVED WITH A TRIANGLE, so it injects t_alpha*(1-t_alpha) ticks^2 of extra pulse width. That depends only on where the deposit happens to land inside its tick, not on any physics: identical deposits at different sub-tick phases come out with longitudinal widths differing by up to 0.25 tick^2 (0.39 mm). Cubic Lagrange matches the first three moments, so it places the pulse without inflating its width. Measured against physics truth -- the continuous convolution (gaussian arrival density) * (band-limited response), POINT-SAMPLED at ticks, which is what the ADC does -- worst-case waveform error over sub-tick phase: plane drift linear (before) Lagrange-4 (after) Y 2 cm 2.088% 0.313% Y 32 cm 1.888% 0.241% Y 200 cm 1.725% 0.135% U 2 cm 4.646% 0.661% U 32 cm 3.995% 0.505% U 200 cm 3.229% 0.330% Registration is deliberately identical to the blend it replaces (t_alpha=1 -> v[i], t_alpha=0 -> v[i+1], both exact), so the output length stays kernel_height-1 and time_zero_bin_out = time_zero_bin - 1 remains correct. B2, the electronics/noise FFT sizes and every profiled max_keys/max_buckets are unchanged. Verified against an independent numpy implementation to 3.5e-7 (float32), with the two endpoints bit-exact. Lagrange-6/8 were also measured: better at the extremes but WORSE at mid drift (0.566%/0.599% vs 0.505% on U at 32 cm), so 4 points is the robust choice. Deliberately NOT changed: - The build-time blur stays point-sampled. Its discrete variance does collapse for sigma_L below ~0.6 ticks, but the physical sigma_L^2 there (0.067 tick^2 at 8 cm) sits inside a pulse of variance ~25 tick^2 that is dominated by the 2.2 us shaping, so correcting it changes the waveform by ~0.1% -- and measured end-to-end it is neutral-to-slightly-worse (2.088% -> 2.209% at 2 cm). - The pixel path keeps its 2-tap blend: it interpolates on the FINE 0.1 us grid and then averages over the coarse tick, so its residual triangle variance is ~25x smaller. Tests: 195 passed, 23 skipped (fast suite, CPU).
Wires tile the pitch, so every drift electron is collected by exactly one of them:
S(x) = sum_n R(x - n) must be CONSTANT in x
A collection response is R = C * 1[|Delta| < 1/2] + induction, and that boxcar's edge
falls EXACTLY on a grid sample. A step landing on a sample must carry HALF weight, so
the two half-contributions from the wires either side sum to one; linear interpolation
in Delta then tiles exactly (home wire C(1-a)+(C/2)a, neighbour 0(1-a)+(C/2)a, sum = C
for every a).
The shipped default Y kernel stores the NON-COLLECTING branch there instead (column
integral 7e-6 against 0.060 one sample inside), so the collection boxcar is 0.9 pitch
wide and the tiling has a hole. Measured on the Y kernel:
residue-class tiling spread 112.15% -> 0.93%
mean tiling sum 0.053929 -> 0.059963 (on-wire column 0.060318)
which is a UNIFORM 10.6% under-collection at every drift -- independently confirmed in
the full simulator, absolute ratio 0.8412 at mid-drift / 0.935 attenuation = 0.900 --
plus an offset-dependent loss, worst case over sub-pitch offset per sigma_T (pitch):
0.05: 20.9% -> 99.5% 0.15: 73.3% -> 99.7%
0.30: 92.7% -> 99.9% 0.45: 99.2% -> 100.0%
Applied at load time because the default kernels have no builder in the repo. It is
IDEMPOTENT -- a kernel that already tiles (the SBND kernels store the mean, which is
exactly the half weight) is returned unchanged.
Collection planes only, and that scope is measured rather than assumed: on Y the
separatrix step is 81.6% of peak, 3.3x the largest step anywhere else, and the stored
value sits 25.4% from the outside branch but 87.9% from the inside one. On U/V the
separatrix step (9.1%, 20.0%) is SMALLER than the largest step elsewhere (32.9%, 27.3%)
and the stored value is within ~2%/~15% of the inside branch, outside branch and their
mean alike, so nothing there is identifiable as a mishandled discontinuity -- and the
induction tiling invariant is only approximate (sum_n psi_n = psi_plane, which is not
transversally uniform near a wire grid), so it could not derive a correction anyway.
Settling U/V would need the garfield source.
Cost: none. Two columns, at load. No memory or runtime change.
Documents the pitch/time asymmetry that gives each axis exactly one failure mode, the tiling invariant behind _enforce_wire_tiling (and why it is collection-plane only, from the garfield branch data), the band-limited fractional delay on the time axis, and the list of things deliberately NOT done with the measurement that ruled each out.
…ched rtol=1e-3 was tight enough to nudge kernels that already tile: the SBND Y kernel tiles to 1.25% and stores the mean at the separatrix (which IS the half weight), yet still picked up a -0.4% 'correction' -- fitting noise. The defect being targeted is a MISSING BRANCH, which shows up as a ~100% deficit (default Y: +100.5%). rtol=0.05 sits far from both, so only a genuine hole is corrected and already-correct kernels are returned unchanged.
Every existing kernel test is structural (shape, finiteness, batch == sequential,
JIT-compat) or self-referential -- they compare the code to itself. 195 of them passed
while the collection response was losing 10.6% of its charge, while the sub-tick shift
was injecting phase-dependent pulse width, and while the dense and bucketed paths
disagreed on the time index. These assert what the PHYSICS requires instead.
Each test was checked to FAIL on the unfixed code, which is the only thing that makes a
regression test worth having:
width swing across sub-tick phase unfixed 0.2500 ticks^2 -> fixed 0.0000
(0.25 is exactly max a(1-a), as predicted)
charge variation vs sub-pitch offset unfixed 25.9% -> fixed 0.0%
Covered:
- the wire-tiling invariant sum_n R(x-n) = const, plus a companion test asserting the
DEFECT is detectable (so the invariant test cannot silently become vacuous)
- _enforce_wire_tiling repairs, is idempotent, leaves correct kernels untouched, and
skips induction planes
- collected charge independent of the sub-pitch offset, driven from a BROKEN kernel
through the load-time repair so it guards the whole chain (using an already-correct
kernel would test nothing -- it passes with or without the fix)
- pulse width independent of the sub-tick phase
- the dense/bucketed time-index convention, which test_dense_equals_bucketed
structurally cannot catch because it passes the SAME time_indices array to both
accumulators, making them equal by construction
Tests: 205 passed, 23 skipped (was 195; +10).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
docs/physics/response_representation.md.Changes output: Y-plane sensor amplitude rises by about 11%, so thresholds and calorimetric calibration need re-deriving.