FFT histogram is same as original histogram

Hey guys
I’m trying to plot the FFT for a waveform which basically has three plots:
the first plot has waveforms for the same wire plotted on top of each other
the second plot has the difference between the two waveforms
the third plot should be the FFT of the first plot, so it should have the FFT of the waveforms plotted on top of each other.
I have attached the plots and also my code.
Just to save you some time, here’s how i define my histograms:

TH1F *WaveformHistCV_Chan1500 = new TH1F(“WaveformHistCV_Chan1500”,“Channel 1500 Waveform;Time Tick;ADC Value”,maxTicks,-0.5,maxTicks-0.5);

WaveformHistCV_Chan1500->GetYaxis()->SetTitleOffset(1.2);

TH1F *WaveformHistWhitenoise_Chan1500 = new TH1F(“WaveformHistWhitenoise_Chan1500”,“Channel 1500 Waveform;Time Tick;ADC Value”,maxTicks,-0.5,maxTicks-0.5);

WaveformHistWhitenoise_Chan1500->GetYaxis()->SetTitleOffset(1.2);

TH1* fftHistCV=0;
TVirtualFFT::SetTransform(0);
fftHistCV=WaveformHistCV_Chan1500->FFT(WaveformHistCV_Chan1500,"MAG");
TH1* fftHistWhitenoise=0;
TVirtualFFT::SetTransform(0);
fftHistWhitenoise=WaveformHistWhitenoise_Chan1500->FFT(WaveformHistWhitenoise_Chan1500,"MAG");

Ar39Study.cpp (7.6 KB)

For some reason instead of getting the third plot as FFT it’s the same as the first plot, which i don’t want. I simply want the FFT.

Any help is appreciated.

Thanks !

Try:

TH1 *fftHistCV = WaveformHistCV_Chan1500->FFT(0, "MAG");
TH1 *fftHistWhitenoise = WaveformHistWhitenoise_Chan1500->FFT(0, "MAG");

It looks like the FFT and the first plot is decoupled now, but the fft histogram is not populated correctly or at all. It’s weird:

Any clue?

It seems to me that for both histograms (WaveformHistCV_Chan1500 and WaveformHistWhitenoise_Chan1500), you try to run FFT right after you create them but before you fill (SetBinContent) them.

So is that not how it should be? Can you elaborate more on that?

Thanks

What Wile meant is that you might have run FFT on empty histograms.

Thanks for your help. It seems that we were getting the correct FFT histogram as seen in the out_MAG histogram above. It was filled with a very large value for the first bin and when I got rid of it the histogram simply rescaled correctly as expected:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.