FFT root package

FFT in root

While FFT is adopted in ROOT, it is sometimes tedious to interpret the results of the transformation. To faciliate the procedure I invested some time in creating an independent FFTdata_ROOT class which handles the data and transformation of a real valued function given as histogram.

The package is freely downloadable. To install it, simply unpack the tar.gz directory and start root from the unpacked directory. If it doesn't work, leave comment on my email.

Once in the root environment, the calls are:

# initialize the FFT transform
root[] FFTdata_ROOT f
# transform a TH1D histogram (supplied by the user
root[] f.Transform(&h)
# check the transform; real part
root[] f.GetKspaceReal()->Draw()
# check the transform: imaginary part
root[] f.GetKspaceImaginary()->Draw()
# check the transform: power spectrum
root[] TH1D hp;
root[] f.GetPowerSpectrum(&hp);
# do the inverse transform
root[] TH1D hInverse;
root[] f.InverseTransform(&hInverse);

Applying filters

To the transformed function, filters can be applied. Most were developed for filtered back projection with impulse response H(f)=f, but others are also available. After application, Fourier transform in f equals to GF if G is the transform of the user supplied histogram and F is the filter

root[] Filter *gf=0;
#linear filter, F(f)=f
root[] gf=new linearFilter;
#Wiener filter for F(f)=f/(g+pow(f/f0,2)), cuttof frequency f0
root[] double g=1,f0=0.5;
root[] gf=new WienerfFilter(f0,g);
#hanning filter, F(f)=f*(alpha+(1-alpha)*cos(TMath::Pi()*f))
root[] double alpha=0.5;
root[] gf=new hanningFilter(alpha);
#cut-off filter (simply zero G(f) for f>f0)
root[] gf=new cutoffFilter(f0);
#histogram filter where F(f) is tabulated in a supplied histogram
root[] TH1D hf;
root[] gf=new histoFilter(&hf);

After the filter gf is defined, one can transform and filter and inverse transform:

root[] f.Transform(&hOriginal);
root[] f.ApplyFilter(gf);
root[] TH1D hFiltered(hOriginal);
root[] f.InverseTransform(&hFiltered);

Enjoy!

links

social