Bug #11631
raw.cxx Uncompress gives wrong results for ZeroSuppression and Huffman together
100%
Description
The utility lardata/RawData gives wrong results for the case that both zero suppression and Huffman encoding are requested. It seems the problem is this code in Uncompress:
else if(compress == raw::kZeroHuffman){
UncompressHuffman(adc, uncompressed);
ZeroUnsuppression(adc, uncompressed);
i.e. the uncompressed vector from the Huffman decoding is not but should be used as the input to the zero unsuppression.
When I change to this:
std::vector<short> tmp(2*adc[0]);
UncompressHuffman(adc, tmp);
ZeroUnsuppression(tmp, uncompressed, pedestal);
the problem goes away.
Note my guess for the size allocation of the tmp vector. UncompressHuffman requires the caller to preallocate enough space. I have already reported that in https://cdcvs.fnal.gov/redmine/issues/11572. In my case, it was not enough to use adc0 because the zero suppression increases the size of the vector.
My test showing the problem can be found here:
https://github.com/dladams/art_extensions/blob/master/test/utilities/test_Compress.cxx
History
#1 Updated by Thomas Junk almost 5 years ago
- Assignee changed from Gianluca Petrillo to Jonathan Insler
#2 Updated by Jonathan Insler almost 5 years ago
- Assignee changed from Jonathan Insler to Gianluca Petrillo
- % Done changed from 0 to 100
David Adams wrote:
The utility lardata/RawData gives wrong results for the case that both zero suppression and Huffman encoding are requested. It seems the problem is this code in Uncompress:
else if(compress == raw::kZeroHuffman){
UncompressHuffman(adc, uncompressed);
ZeroUnsuppression(adc, uncompressed);i.e. the uncompressed vector from the Huffman decoding is not but should be used as the input to the zero unsuppression.
When I change to this:
std::vector<short> tmp(2*adc0);
UncompressHuffman(adc, tmp);
ZeroUnsuppression(tmp, uncompressed, pedestal);the problem goes away.
Note my guess for the size allocation of the tmp vector. UncompressHuffman requires the caller to preallocate enough space. I have already reported that in https://cdcvs.fnal.gov/redmine/issues/11572. In my case, it was not enough to use adc0 because the zero suppression increases the size of the vector.
My test showing the problem can be found here:
https://github.com/dladams/art_extensions/blob/master/test/utilities/test_Compress.cxx
Thanks to David for finding this! I have implemented his fix. This functionality was never properly tested.
#3 Updated by Jonathan Insler almost 5 years ago
- Assignee changed from Gianluca Petrillo to Jonathan Insler
#4 Updated by Gianluca Petrillo over 4 years ago
- Status changed from New to Assigned