Lowpass filter function errors

My code is used to smooth a function which I get as a bunch of discrete data points (1000 points to be exact). To do this I do an FFT and set high frequency components equal to zero, and then do an IFFT to get back the function. LPF.C runs and executes DoLPFilterNewest.C . Can someone help with 3 errors I don’t understand?

1- Error in TPluginHandler::ExecPlugin: nargs (3) not consistent with expected number of arguments ([0–1])
2- Error in TVirtualFFT::FFT: plugin failed to create TVirtualFFT object
3- Error illegal pointer to class object hm 0x0 1350 DoLPFilterNewest.C:76:

To fix #3 I defined the histogram hm globally but that didn’t solve the problem!
For #1 I am at a loss. I send in data arrays of size 1001, yet there is still a problem with number of arguments?! I must not understand what this error is about.
My code came from root.cern.ch/root/html/tutorials/fft/FFT.C.html .
Thanks for your help!
LPF.C (425 Bytes)
DoLPFilterNewest.C (7.54 KB)

Any advice will be appreciated. I am really lost as to what the number of arguments refers to. I think this is because I do not understand the TVirtual stuff.

At least “nppw” and “data” are missing for the one who would possibly like to try your code.

Pepe is right, to test my code you need more. Here is a folder with all the code. Put all the files from this folder into a directory. Go to that directory and start ROOT. Then type these commands, one at a time, into root:

1- .x TimeResolution.C
2- InputData(“A.txt”, 100)
3- .x LPF.C

That will give you the lovely errors, haha.
Oh, and you can open up LPF.C and change the number of times it loops. If it loops for “<=1” then the code works. If it loops for “<=2” or more it will not work. And I only gave you a data file with the first 7 waves (A.txt) so you can’t do “<=8” or higher!
TimeResolution.zip (16 KB)

Try the attached source code.

unzip LPF.zip
cd LPF
root
root [0] .L InputData.C++
root [1] .L DoLPFilterNewest.C++
root [2] .L LPF.C++
root [3] InputData(“A.txt”, 100);
root [4] LPF();

I don’t really know if it works properly, because sometimes, when I try it, I get (Ubuntu 10.04.3 LTS, i686, gcc 4.4.3, recent “v5-28-00-patches”):

(…)
point 4
Warning in TCanvas::Constructor: Deleting canvas with same name: myc
*** glibc detected *** /…/v5-28-00-patches/bin/root.exe: munmap_chunk(): invalid pointer: 0x092cb4b0 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0xb669c591]
/lib/tls/i686/cmov/libc.so.6(+0x6c80e)[0xb669d80e]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb68a5741]
/…/v5-28-00-patches/lib/libCore.so.5.28(_ZN8TStorage13ObjectDeallocEPv+0xa0)[0xb7278ed0]
/…/v5-28-00-patches/lib/libCore.so.5.28(_ZN7TObjectdlEPv+0x38)[0xb72562d8]
/…/v5-28-00-patches/lib/libGui.so(_ZN11TRootCanvasD0Ev+0x329)[0xb53690a9]
/…/v5-28-00-patches/lib/libGpad.so(_ZN7TCanvas5CloseEPKc+0xe3)[0xb5a2ab53]
/…/v5-28-00-patches/lib/libGpad.so(_ZN7TCanvas10DestructorEv+0x8d)[0xb5a29fcd]
/…/v5-28-00-patches/lib/libGpad.so(_ZN7TCanvasD0Ev+0x53)[0xb5a2adc3]
/…/v5-28-00-patches/lib/libGpad.so(_ZN7TCanvas11ConstructorEPKcS1_ii+0x101)[0xb5a2bef1]
/…/v5-28-00-patches/lib/libGpad.so(_ZN7TCanvasC1EPKcS1_ii+0xd0)[0xb5a2c880]
/…/LPF/./DoLPFilterNewest_C.so(_Z16DoLPFilterNewestv+0x6c)[0xb50d8e1c]
/…/LPF/./LPF_C.so(_Z3LPFv+0x141)[0xb5b4ef21]
(…)
LPF.zip (8.6 KB)

I get “*** Break *** segmentation violation” running those five lines. However if I save the C files as C++ files I get lots of errors when I load them! What really doesn’t make sense is if I run root.cern.ch/root/html/tutorials/fft/FFT.C.html (the C code) it works, but if I run it a second time there are errors. Why can I not do FFT multiple times?

I don’t know why there were sometimes problems when the canvas was being automatically deleted (maybe a bug in ROOT?).
I protected the code against it (I explicitly delete the canvas now).
Try the new attached source code (“LPF.zip”).
If you get problems (e.g. “segmentation violations”), you need to send the output here.
Using the new code, I “always” get (see also the attached picture below):

[/.../LPF] > root
  *******************************************
  *                                         *
  *        W E L C O M E  to  R O O T       *
  *                                         *
  *   Version  5.28/00f     4 August 2011   *
  *                                         *
  *  You are welcome to visit our Web site  *
  *          http://root.cern.ch            *
  *                                         *
  *******************************************

ROOT 5.28/00f (branches/v5-28-00-patches@40439, Aug 11 2011, 10:50:00 on linux)

CINT/ROOT C/C++ Interpreter version 5.18.00, July 2, 2010
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .L InputData.C++
Info in <TUnixSystem::ACLiC>: creating shared library /.../LPF/./InputData_C.so
/.../LPF/InputData_C_ACLiC_dict.cxx: In function ‘int G__InputData_C_ACLiC_dict__0_1290(G__value*, const char*, G__param*, int)’:
/.../LPF/InputData_C_ACLiC_dict.cxx:80: warning: deprecated conversion from string constant to ‘char*’
root [1] .L DoLPFilterNewest.C++
Info in <TUnixSystem::ACLiC>: creating shared library /.../LPF/./DoLPFilterNewest_C.so
In file included from /.../LPF/DoLPFilterNewest_C_ACLiC_dict.h:34,
                 from /.../LPF/DoLPFilterNewest_C_ACLiC_dict.cxx:17:
/.../LPF/./DoLPFilterNewest.C: In function ‘void DoLPFilterNewest()’:
/.../LPF/./DoLPFilterNewest.C:65: warning: unused variable ‘fsin’
/.../LPF/./DoLPFilterNewest.C:98: warning: unused variable ‘fft1’
/.../LPF/./DoLPFilterNewest.C:107: warning: unused variable ‘jj’
/.../LPF/./DoLPFilterNewest.C:107: warning: unused variable ‘ll’
/.../LPF/./DoLPFilterNewest.C:112: warning: unused variable ‘cc’
/.../LPF/./DoLPFilterNewest.C:112: warning: unused variable ‘dd’
/.../LPF/./DoLPFilterNewest.C:112: warning: unused variable ‘ee’
/.../LPF/./DoLPFilterNewest.C:112: warning: unused variable ‘ff’
/.../LPF/./DoLPFilterNewest.C:114: warning: unused variable ‘comp’
/.../LPF/./DoLPFilterNewest.C:114: warning: unused variable ‘out’
/.../LPF/./DoLPFilterNewest.C:204: warning: unused variable ‘Z’
/.../LPF/./DoLPFilterNewest.C:205: warning: unused variable ‘re_2’
/.../LPF/./DoLPFilterNewest.C:205: warning: unused variable ‘im_2’
root [2] .L LPF.C++
Info in <TUnixSystem::ACLiC>: creating shared library /.../LPF/./LPF_C.so
root [3] InputData("A.txt", 100);
Using File = A.txt
Number of data points in data set = 7014
Number of data points per waveform = 1001
root [4] LPF();
point 5
point 4
1st transform: DC component: -42.875309
1st transform: Nyquist harmonic: -0.008587
0.0596832 : 0.0994719
point 6
point 5
point 4
1st transform: DC component: -57.437665
1st transform: Nyquist harmonic: -0.064912
0.0596832 : 0.0994719
point 6
point 5
point 4
1st transform: DC component: -77.157095
1st transform: Nyquist harmonic: 0.150035
0.0596832 : 0.0994719
point 6
point 5
point 4
1st transform: DC component: -90.662978
1st transform: Nyquist harmonic: 0.072325
0.0596832 : 0.0994719
point 6
point 5
point 4
1st transform: DC component: -27.619327
1st transform: Nyquist harmonic: 0.002682
0.0596832 : 0.0994719
point 6
point 5
point 4
1st transform: DC component: -41.960543
1st transform: Nyquist harmonic: 0.288005
0.0596832 : 0.0994719
point 6
point 5
point 4
1st transform: DC component: -29.829059
1st transform: Nyquist harmonic: 0.021804
0.0596832 : 0.0994719
point 6
root [5].q
[/.../LPF] > 


LPF.zip (8.67 KB)