JG ROOT Tools libraries
version 5.0 - august 2014
|
#include <RRealSampleFFT.hh>
Public Member Functions | |
RRealSampleFFT (const u_int n=0, const double dt=1.L) | |
RRealSampleFFT (const RRealSampleFFT &original) | |
RRealSampleFFT (const GRealSampleFFT &original) | |
RRealSampleFFT (const u_int n, const double data[]) | |
RRealSampleFFT (const u_int n, const double t_lo, const double t_hi, const double data[], bool ctr=false) | |
RRealSampleFFT (const u_int n, const double t_lo, const double t_hi, double(*fct_ptr)(const double, const double[]), const double fct_par[], bool ctr=false) | |
RRealSampleFFT (const u_int n, const double t_lo, const double t_hi, double(*fct_ptr)(const double[], const double[]), const double fct_par[], bool ctr=false) | |
RRealSampleFFT (const u_int n, const double t_lo, const double t_hi, TF1 *fct, bool ctr=false) | |
RRealSampleFFT (TH1 *hptr) | |
RRealSampleFFT (const u_int n, const double data_re[], const double data_im[]) | |
RRealSampleFFT & | operator= (const RRealSampleFFT &original) |
virtual | ~RRealSampleFFT () |
virtual void | InitFunctionData (const u_int n, const double t_lo, const double t_hi, TF1 *fct, bool ctr=false) |
virtual void | InitFunctionData (TH1 *hptr) |
virtual void | SetFunctionData (TF1 *fct) |
virtual void | FillRandomGaus (double mean, double fwhm, TRandom *rnd=NULL) |
virtual void | FillRandomGaus (double fwhm, TRandom *rnd=NULL) |
virtual int | SetFunctionValues (u_int i1, u_int i2, TF1 *fct) |
void | SetDefaultValues () |
void | SetColor (const Color_t col) |
void | SetFunctionTitles (const char tit[]="", const char tit_x[]="", const char tit_y[]="") |
void | SetTransformTitles (const char tit[]="", const char tit_f[]="", const char tit_amp[]="", const char tit_ph[]="", const char tit_pow[]="") |
void | SetTransformComplexTitles (const char tit_re[]="", const char tit_im[]="") |
TGraph * | CreateFunctionGraph (double scale=1.L) |
TGraph * | CreateTransformGraph (double scale=1.L) |
TGraph * | CreateTrfAmpliGraph (double scale=1.L) |
TGraph * | CreateTrfPhaseGraph (bool deg=false) |
TGraph * | CreatePowerGraph (double scale=1.L) |
TH1D * | CreateFunctionHisto (const string &name, double scale=1.L) |
int | FillFunctionHisto (TH1D *hptr, double scale=1.L, bool reset=true) |
RRealSampleFFT | operator+ (RRealSampleFFT &s) |
RRealSampleFFT | operator- (RRealSampleFFT &s) |
RRealSampleFFT | operator* (RRealSampleFFT &s) |
RRealSampleFFT | operator/ (RRealSampleFFT &s) |
RRealSampleFFT | operator* (double r) |
RRealSampleFFT | operator/ (double r) |
RRealSampleFFT | operator+ (double r) |
RRealSampleFFT | operator- (double r) |
ClassDef (RRealSampleFFT, 0) | |
Public Attributes | |
string | fct_title |
Function title. | |
string | fct_title_x |
Function title (X axis) | |
string | fct_title_y |
Function title (Y axis) | |
string | fft_title |
Fourier transform title. | |
string | fft_title_freq |
Fourier transform frequency axis title. | |
string | fft_title_amp |
Fourier transform amplitude axis title. | |
string | fft_title_phase |
Fourier transform phase axis title. | |
string | fft_title_power |
Fourier transform power axis title. | |
string | fft_title_re |
Fourier transform real axis title. | |
string | fft_title_im |
Fourier transform imaginary axis title. | |
Protected Member Functions | |
void | CopyData (const RRealSampleFFT &original) |
Private Member Functions | |
GObject (RRealSampleFFT) | |
This is a class to manage of a real function samples and the corresponding Fourier transform.
This class is based on GRealSampleFFT general class, with features for ROOT. It defines some information for graphs and histograms to be created for ROOT.
RRealSampleFFT::RRealSampleFFT | ( | const u_int | n = 0 , |
const double | dt = 1.L |
||
) |
Base constructor.
n | number of function samples |
dt | sampling time step |
RRealSampleFFT::RRealSampleFFT | ( | const RRealSampleFFT & | original | ) |
RRealSampleFFT::RRealSampleFFT | ( | const GRealSampleFFT & | original | ) |
RRealSampleFFT::RRealSampleFFT | ( | const u_int | n, |
const double | data[] | ||
) |
Constructor with function data initialisation. The data array must have at least a length n.
n | number of real data |
data | array of input data for real function samples |
References SetDefaultValues().
RRealSampleFFT::RRealSampleFFT | ( | const u_int | n, |
const double | t_lo, | ||
const double | t_hi, | ||
const double | data[], | ||
bool | ctr = false |
||
) |
Constructor with function data initialisation. The data array must have at least a length n.
n | number of real data |
t_lo | lower time limit of the defined sample |
t_hi | upper time limit of the defined sample |
data | array of input data for real function samples |
ctr | indicates how the time limits are defined (see time scale) |
References SetDefaultValues().
RRealSampleFFT::RRealSampleFFT | ( | const u_int | n, |
const double | t_lo, | ||
const double | t_hi, | ||
double(*)(const double, const double[]) | fct_ptr, | ||
const double | fct_par[], | ||
bool | ctr = false |
||
) |
Constructor with function pointer. The function is real with 2 arguments: the first one is the time coordinate, the second one is an array of parameters. The time limits are used to set the proper values of the function argument. The time limits are given with respect to the defined sample (The effective time range will be adjusted if n is not a power of 2).
n | number of real data |
t_lo | lower time limit of the defined sample |
t_hi | upper time limit of the defined sample |
fct_ptr | function pointer |
fct_par | array of parameters for the function |
ctr | indicates how the time limits are defined (see time scale) |
References SetDefaultValues().
RRealSampleFFT::RRealSampleFFT | ( | const u_int | n, |
const double | t_lo, | ||
const double | t_hi, | ||
double(*)(const double[], const double[]) | fct_ptr, | ||
const double | fct_par[], | ||
bool | ctr = false |
||
) |
Constructor with function pointer. The function is real with 2 arguments: the first one is the function variables array (only the first one is defined), the second one is an array of parameters. The time limits are used to set the proper values of the function argument. The time limits are given with respect to the defined sample (The effective time range will be adjusted if n is not a power of 2).
n | number of real data |
t_lo | lower time limit of the defined sample |
t_hi | upper time limit of the defined sample |
fct_ptr | function pointer |
fct_par | array of parameters for the function |
ctr | indicates how the time limits are defined (see time scale) |
References SetDefaultValues().
RRealSampleFFT::RRealSampleFFT | ( | const u_int | n, |
const double | t_lo, | ||
const double | t_hi, | ||
TF1 * | fct, | ||
bool | ctr = false |
||
) |
Constructor with TF1 function pointer argument. The time limits are given with respect to the defined sample (The effective time range will be adjusted if n is not a power of 2).
n | number of real data |
t_lo | lower time limit of the defined sample |
t_hi | upper time limit of the defined sample |
fct | ROOT function pointer |
ctr | indicates how the time limits are defined (see time scale) |
References InitFunctionData(), and SetDefaultValues().
RRealSampleFFT::RRealSampleFFT | ( | TH1 * | hptr | ) |
Constructor from histogram (1D) pointer argument.
hptr | pointer to the histogram |
References InitFunctionData(), and SetDefaultValues().
RRealSampleFFT::RRealSampleFFT | ( | const u_int | n, |
const double | data_re[], | ||
const double | data_im[] | ||
) |
Constructor with transform data initialisation. The corresponding real function has 2*n samples. Since the sampled function is real, Im[0] (that should be 0) must contain Re[n]. The data_re and data_im arrays must have at least a length n.
n | number of complex data |
data_re | real component input (n real data) |
data_im | imaginary component input (n real data) |
References SetDefaultValues().
|
virtual |
Destructor: cleans-up the data.
|
private |
Macro from GCpp library that defines the following functions:
RRealSampleFFT & RRealSampleFFT::operator= | ( | const RRealSampleFFT & | original | ) |
|
virtual |
Set the function samples to be n real data (double) from a TF1 function defined by its pointer (see SetFunctionData). The time limits are given with respect to the defined sample
n | number of real data |
t_lo | lower time limit of the defined sample |
t_hi | upper time limit of the defined sample |
fct | TF1 function pointer |
ctr | indicates how the time limits are defined (see time scale) |
References SetFunctionData().
Referenced by RRealSampleFFT().
|
virtual |
Set the function samples to be n real data from a TH1 histogram defined by its pointer.
hptr | pointer to the histogram |
|
virtual |
Set the function samples from a function defined by its pointer.
After this function call, the functions samples are set and the Fourier transform data are not set.
fct | ROOT function pointer |
Referenced by InitFunctionData().
|
virtual |
Fill the function sample with random noise with Gauss distribution. If a random generator is provided, it is used to generate the valuse (for samples reproductability), else, a local generator is used.
After this function call, the functions samples are set and the Fourier transform data are not set.
mean | mean samples value |
fwhm | FWHM of the samples |
rnd | ROOT random generator |
Referenced by FillRandomGaus().
|
inlinevirtual |
Fill the function sample with random noise with Gauss distribution with a mean value equal to 0. If a random generator is provided, it is used to generate the valuse (for samples reproductability), else, a local generator is used.
After this function call, the functions samples are set and the Fourier transform data are not set.
fwhm | FWHM of the samples |
rnd | ROOT random generator |
References FillRandomGaus().
|
virtual |
Function that sets a part of the sample array values, from index i1 to index i2 (included) with the values computed from the function (time is from currently defined time sampling). The function returns the number of values that have been set.
The use of this function implies that the sample is defined through the function data and that the FFT data have to be recomputed.
i1 | lower index of the sample data |
i2 | upper index of the sample data |
fct | ROOT function pointer |
|
inline |
Set the default titles for graphs and histograms.
References fct_title, fct_title_x, fct_title_y, fft_title, fft_title_amp, fft_title_freq, fft_title_im, fft_title_phase, fft_title_power, and fft_title_re.
Referenced by RRealSampleFFT().
|
inline |
Set the default line and marker colors for graphs.
col | selected ROOT color |
|
inline |
Set titles for the function samples (for graphs and histograms).
tit | function title |
tit_x | function time axis title |
tit_y | function amplitude axis title |
References fct_title, fct_title_x, and fct_title_y.
|
inline |
Set titles for the Fourier transform (for graphs and histograms).
tit | FT title |
tit_f | FT frequency axis title |
tit_amp | FT amplitude axis title |
tit_ph | FT phase axis title |
tit_pow | FT power density axis title |
References fft_title, fft_title_amp, fft_title_freq, fft_title_phase, and fft_title_power.
|
inline |
Set titles for the Fourier transform axis in complex plane (for graphs and histograms).
tit_re | FT real axis title |
tit_im | FT imaginary axis title |
References fft_title_im, and fft_title_re.
TGraph * RRealSampleFFT::CreateFunctionGraph | ( | double | scale = 1.L | ) |
Create a graph from function samples, with signal amplitude as a function of the time coordinate. The graph must be destroyed by the calling program.
scale | scaling factor |
References fct_title, fct_title_x, and fct_title_y.
TGraph * RRealSampleFFT::CreateTransformGraph | ( | double | scale = 1.L | ) |
Create a graph from the Fourier transform, in the complex plane. The graph dimension contains n/2-1 points, where n is the number of samples in the function. The first and last point have a null imaginary part. The graph must be destroyed by the calling program.
scale | scaling factor |
References fft_title, fft_title_im, and fft_title_re.
TGraph * RRealSampleFFT::CreateTrfAmpliGraph | ( | double | scale = 1.L | ) |
Create a graph from the amplitude of the Fourier transform. The graph dimension contains n/2-1 points, where n is the number of samples in the function. The first and last point have a null imaginary part. The graph must be destroyed by the calling program.
scale | scaling factor |
References fft_title, fft_title_amp, and fft_title_freq.
TGraph * RRealSampleFFT::CreateTrfPhaseGraph | ( | bool | deg = false | ) |
Create a graph from the phase of the Fourier transform. The graph dimension contains n/2-1 points, where n is the number of samples in the function. The first and last point have a null imaginary part. The graph must be destroyed by the calling program.
deg | if the phase is expressed in deg. (default is rad.) |
References fft_title, fft_title_freq, and fft_title_phase.
TGraph * RRealSampleFFT::CreatePowerGraph | ( | double | scale = 1.L | ) |
Create a graph from the Power Spectral Density. The graph dimension contains n/2-1 points, where n is the number of samples in the function. The graph must be destroyed by the calling program.
scale | scaling factor |
References fft_title, fft_title_freq, and fft_title_power.
TH1D * RRealSampleFFT::CreateFunctionHisto | ( | const string & | name, |
double | scale = 1.L |
||
) |
Create an histogram from function samples, with signal amplitude as a function of the time coordinate. The histogram must be destroyed by the calling program.
name | histogram identifier |
scale | scaling factor |
References fct_title_x, and fct_title_y.
int RRealSampleFFT::FillFunctionHisto | ( | TH1D * | hptr, |
double | scale = 1.L , |
||
bool | reset = true |
||
) |
Fills an histogram from function samples, with signal amplitude as a function of the time coordinate. The function returns 0 if no error occured. The histogram is filled bin by bin, and no check is performed on the bound values, only on the dimension.
hptr | histogram pointer |
scale | scaling factor |
reset | whether the histogram should be resetted before filling |
|
inline |
Sum of samples. The samples must have the same number of data. WARNING: there is no check of the sampling time is the same !
s | sample to be summed to the current one |
|
inline |
Difference of samples. The samples must have the same number of data. WARNING: there is no check of the sampling time is the same !
s | sample to be summed to the current one |
|
inline |
Product bin by bin of samples. The samples must have the same number of data. WARNING: there is no check of the sampling time is the same !
s | sample to be summed to the current one |
|
inline |
Division bin by bin of samples. The samples must have the same number of data. WARNING: there is no check of the sampling time is the same !
s | sample to be summed to the current one |
|
inline |
Scaling (multiplication factor) of the current sample.
r | scale factor |
|
inline |
Scaling (division factor) of the current sample.
r | scale factor |
|
inline |
Offset addition.
r | offset |
|
inline |
Offset subtraction.
r | offset |
|
protected |
This function copies the data from original to the current object. It is not a virtual function, and it copies only the part corresponding to this stage of the heritance tree.
original | object to be copied |
References fct_title, fct_title_x, fct_title_y, fft_title, fft_title_amp, fft_title_freq, fft_title_im, fft_title_phase, fft_title_power, and fft_title_re.
Referenced by operator=(), and RRealSampleFFT().
RRealSampleFFT::ClassDef | ( | RRealSampleFFT | , |
0 | |||
) |
for use within ROOT.