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.
This adds the field
amplitude_bit_shift
to records, as introduced by @zhut19 in XENONnT/straxen#38. This will help make desaturation corrections possible, e.g. based on pulse shape as in XENON1T or using the attenuated / high-energy channels (@ariannarocchetti @petergaemers).Setting this field means the amplitude the data should be multiplied by
2**amplitude_bit_shift
before it is used. Currently, desaturation corrections cannot store amplitudes above2**15 -1
, since strax uses signed 16-bit integers (np.int16) to represent waveforms. After this, a correction function could set amplitude_bit_shift = 1 (or 2, 3, etc) and divide the whole waveform by 2 (or 4, 8, etc), so it can store higher amplitudes while staying within the allowed integer range. Of course this loses some precision, but for a giant waveform that seems acceptable.I went through the pulse processing / integration routines to change them were needed, but it would be great if someone could check if I did it correctly or missed some function. Even better would be to test this of course.
The baseline field is assumed to be left unaffected by the multiplier. Thus, we do not use the multiplier when correcting integrals for the non-integer part of the baseline (see #2).
This also implements Tianyu's proposed fix in #256 for the saturated channel counting. The saturation check takes into account the multiplier, so a channel will still be flagged as saturated even after a desaturation correction is run on it.