First part of the tutorial shows how to transform the histograms Second part shows how to transform the data arrays directly
1st transform: DC component: 26.000000
1st transform: Nyquist harmonic: -0.932840
2nd transform: DC component: 29.000000
2nd transform: Nyquist harmonic: -0.000000
void FFT()
{
TCanvas *myc =
new TCanvas(
"myc",
"Fast Fourier Transform", 800, 600);
TPad *c1_1 =
new TPad(
"c1_1",
"c1_1",0.01,0.67,0.49,0.99);
TPad *c1_2 =
new TPad(
"c1_2",
"c1_2",0.51,0.67,0.99,0.99);
TPad *c1_3 =
new TPad(
"c1_3",
"c1_3",0.01,0.34,0.49,0.65);
TPad *c1_4 =
new TPad(
"c1_4",
"c1_4",0.51,0.34,0.99,0.65);
TPad *c1_5 =
new TPad(
"c1_5",
"c1_5",0.01,0.01,0.49,0.32);
TPad *c1_6 =
new TPad(
"c1_6",
"c1_6",0.51,0.01,0.99,0.32);
TF1 *fsin =
new TF1(
"fsin",
"sin(x)+sin(2*x)+sin(0.5*x)+1", 0, 4*
TMath::Pi());
}
hm = hsin->
FFT(hm,
"MAG");
hm->
SetTitle(
"Magnitude of the 1st transform");
hp = hsin->
FFT(hp,
"PH");
hp->
SetTitle(
"Phase of the 1st transform");
printf("1st transform: DC component: %f\n", re);
printf("1st transform: Nyquist harmonic: %f\n", re);
hb->
SetTitle(
"The backward transform result");
delete fft_back;
fft_back=0;
}
if (!fft_own) return;
hr->
SetTitle(
"Real part of the 3rd (array) transform");
him->
SetTitle(
"Im. part of the 3rd (array) transform");
TF1 *fcos =
new TF1(
"fcos",
"cos(x)+cos(0.5*x)+cos(2*x)+1", 0, 4*
TMath::Pi());
}
printf("2nd transform: DC component: %f\n", re_2);
printf("2nd transform: Nyquist harmonic: %f\n", re_2);
delete fft_own;
delete [] in;
delete [] re_full;
delete [] im_full;
}
virtual void SetLabelSize(Float_t size=0.04)
Set size of axis labels.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
void SetFrameFillColor(Color_t color=1)
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
TAxis * GetYaxis() const
Get y axis of the function.
void Draw(Option_t *option="") override
Draw this function with its current attributes.
virtual Double_t Eval(Double_t x, Double_t y=0, Double_t z=0, Double_t t=0) const
Evaluate this function.
TAxis * GetXaxis() const
Get x axis of the function.
1-D histogram with a double per channel (see TH1 documentation)}
TH1 is the base class of all histogram classes in ROOT.
void SetTitle(const char *title) override
Change (i.e.
static TH1 * TransformHisto(TVirtualFFT *fft, TH1 *h_output, Option_t *option)
For a given transform (first parameter), fills the histogram (second parameter) with the transform ou...
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
virtual TH1 * FFT(TH1 *h_output, Option_t *option)
This function allows to do discrete Fourier transforms of TH1 and TH2.
void Draw(Option_t *option="") override
Draw this histogram with options.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
The most important graphics class in the ROOT system.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set Current pad.
void Draw(Option_t *option="") override
Draw Pad in Current pad (re-parent pad if necessary).
TVirtualFFT is an interface class for Fast Fourier Transforms.
static void SetTransform(TVirtualFFT *fft)
static: set the current transfrom to parameter
virtual void GetPoints(Double_t *data, Bool_t fromInput=kFALSE) const =0
static TVirtualFFT * FFT(Int_t ndim, Int_t *n, Option_t *option)
Returns a pointer to the FFT of requested size and type.
static TVirtualFFT * GetCurrentTransform()
static: return current fgFFT
virtual void SetPoints(const Double_t *data)=0
virtual void SetPointsComplex(const Double_t *re, const Double_t *im)=0
virtual void Transform()=0
virtual void GetPointComplex(Int_t ipoint, Double_t &re, Double_t &im, Bool_t fromInput=kFALSE) const =0
virtual void GetPointsComplex(Double_t *re, Double_t *im, Bool_t fromInput=kFALSE) const =0