DUNE-DAQ / fdreadoutlibs

fdreadoutlibs
0 stars 3 forks source link

TPG "avx" vs "naive" algorithm discrepancy #152

Closed hristovaivana closed 7 months ago

hristovaivana commented 7 months ago

During TPG algorithm validation, in particular using more complex test pattern with hits on more than one channel, I found difference in the number of hits extracted by the NAIVE and AVX implementations of the TPG hit finder algorithms (currently SimpleThreshold used). As an example, the parameters of the hits found for the same input, are respectively:

NAIVE

8,106333538989559595,0,106333538989559595,66,66
44,106333538989559435,32,106333538989559467,134,68
50,106333538989559403,0,106333538989559403,65,65
44,106333538989561771,32,106333538989561803,142,72

AVX:

8,106333538989559595,0,106333538989559595,66,66
44,106333538989559435,32,106333538989559467,134,68
50,106333538989559403,0,106333538989559403,65,65
39,106333538989561739,64,106333538989561771,205,70
44,106333538989561771,32,106333538989561803,142,72

In summary, the number of TP hits extracted, when running the AVX algorithm implementation is, in the general case of hits created across many channels, higher compared to the NAIVE implementation. I've confirmed that the NAIVE implementation identified the correct number of hits, while the AVX implementation produced additional (incomplete) hits, i.e more hits than expected.

hristovaivana commented 7 months ago

The discrepancy is found to be to due to the fact that AVX processes 16 channels at a time. When a hit is complete on one (out of the 16 channels) a flag is set to signal the WIBEth frame processor that a TP is found. However, any hits that have been started on the other 15 channels but have not been completed (i.e. their ADC waveform did not fall below threshold yet) will be still counted as TPs, along with the complete TP. This leads to an excessive number of found TPs ranging between 0% and 1500%. typically > 100-500%. The exact number would depend/vary with the running conditions and detector type (HD vs VD, due to their different channel mapping/adjacency).

A proposed fix is implemented in the current development branch, https://github.com/DUNE-DAQ/fdreadoutlibs/tree/hristova/tpg_validation

Changes are in: WIBEthFrameProcessor.hpp ProcessAVX2.hpp