Skip to content

DetectorField: Fix Floating-Point Rounding Issue

Simon Spannagel requested to merge p-fieldlookup into master

This is a follow-up to !1011 (merged) where a floating point rounding issue was introduced. Background:

For weighting potentials, it is important that if we reach the sensor surface, we do not get a reading of 0 when being slightly outside the volume, because this would induce a strong current of opposite polarity, quite obviously unphysical. Allpix Squared therefore has the possibility to "extrapolate" fields to the outside when required, i.e. taking the last value inside the sensor, no matter where the charge carrier landed. In the code of DetectorField, this is governed by the extrapolate_z parameter.

Before !1011 (merged) this extrapolation was done in the field lookup method by clamping the allowed values for the field bin to [0, nbins - 1].

In !1011 (merged) this was reworked because this information is already used and calculated earlier. So instead of clamping the bins of the field map, the actual z value in local coordinates was clamped to [-d/2, d/2] of the thickness domain. However, for the surface case, the value then is exactly d/2 and a casting and flooring to an integer of the field bins does not result in nbins - 1 but in nbins and hence it is considered outside. The effect was exactly as described above: strong spikes of reverse polarity in induced current pulses.

Now, I have (re-) added the additional clamping on the bins themselves as additional safety measure. Computationally this is negligible, but if anyone has a better idea - chime in!

(cc) @cferrero

Merge request reports