I have a problem that I can only seem to get 6 bits of precision. If I try to bin with 128 bins my histogram has precision artifacts as seen in the picture attached. When I use 64 bins, I get a proper histogram with no precision artifacts but of course have lost resolution.
The waveform is a pulse-height spectrum from a nuclear detector. It should be a two gaussians next to each other. You can see in the incorrect picture that the counts in each channel go high/medium/high/medium/high/medium and it is not smooth. In the correct picture, you can see the two gaussians with the single channel in the middle being a proper 'valley' in between the two peaks.
Below the pictures I discuss my code used (3 lines).
Correct with actual waveform overlaid
The whopping 3 lines of code that touch my data are listed below. I believe I should be getting 7 bits of precision because my waveform lies between 0 and 1 volt so I am sampling between -1 and 1 volt and losing one bit not having negative values. (the waveform really lies between 0 and ~550mV)
- Code: Select all
//initialize bin divisor
m_binDivider = std::numeric_limits<short>::max() / static_cast<float>(m_bins-1);
// m_binDivider is a float
// (m_bins-1) is used because 0 is used as a bin
// copy from the picoscope
memcpy(Picoscope::m_buffer + Picoscope::m_bufferSize * sizeof(short), *overviewBuffers, nValues * sizeof(short));
for each peak in peaks_seen_in_sampleInterval
m_events.push_back((peak / m_binDivider)); // yes, the cast causes truncation
// m_events is a std::vector of ints
// peak is a short which holds maximum value of each peak of each gaussian seen coming down the line
// push m_events entries into histogram vector before painting where the histogram vector bin-values are ints
// paint histogram
Am I going about this incorrectly?
Thanks so much for any help.
PS - is it possible to ask the picoscope to sample with +-500mV at some DC offset? I didn't see this in the documentation.