Diana Software
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QFFT Class Referenceabstract

Interface for ffts in Diana analysis. More...

Inheritance diagram for QFFT:
QRealComplexFFT QRealComplexFFTGSL QRealComplexFFTW3

Public Types

enum  WindowType {
  WT_None = 0 , WT_Welch = 1 , WT_Rect = 2 , WT_Hann = 3 ,
  WT_Hamming = 4 , WT_Cosinus = 5 , WT_BlackmanHarris = 6 , WT_Kaiser3 = 7
}
 window type More...
 
enum  ZeroPadSide { kMiddle = 0 , kSymmetric = 1 , kLeft = 2 , kRight = 3 }
 
enum  FFTDirection { kForward = 1 , kBackward = 0 }
 

Public Member Functions

 QFFT (const size_t size)
 constructor with its size More...
 
 QFFT ()
 empty constructor with its size More...
 
virtual ~QFFT ()
 destructor More...
 
virtual int Transform (const QVector &data, QVector &result)=0
 virtual method. Must be implemented by daughter classes. More...
 
virtual bool Resize (size_t s)=0
 virtual method. Must be implemented by daughter classes More...
 
virtual void SetWindowType (WindowType wt, int coherent=false)=0
 virtual method. Must be implemented by daughter classes set the window type. More...
 
int GetWindowType () const
 Return the window type. More...
 
void SetForward (bool isForward)
 virtual method. Must be implemented by daughter classes set the direction of the transform. More...
 
void SetNormalized (bool isNormalized)
 virtual method. Must be implemented by daughter classes set the normalization of the transform. More...
 

Static Public Member Functions

static QVector FFTAntiSym (const QVector &input)
 antisimmetrize time domain vector More...
 
static QVector FFTSym (const QVector &input)
 simmetrize time domain vector More...
 
static QVector ZeroPad (const QVector &input, size_t n_zeros, int Side=kMiddle, double zeroVal=0.)
 Add zeros to the input. More...
 
static QVectorC ZeroPad (const QVectorC &input, size_t n_zeros, int Side=kMiddle, Diana::QComplex zeroVal=Diana::QComplex(0, 0))
 Add zeros to the input. More...
 
static WindowType StrToWindowType (const std::string &winName)
 Convert string to window type. More...
 
static QVector GetWindow (WindowType wt, size_t size, size_t zeros=0, int coherent=0, int param=0)
 create window and add zeros/2 to the left and zeros/2 to the right More...
 
static QVector CutSides (const QVector &input, size_t ncut, bool isSym)
 cut left and right sides by ncut/2 More...
 
static bool IsPowerOf2 (UInt_t Value)
 Is the input a power of 2. More...
 
static bool IsPowerOf2 (UInt_t Value, UInt_t &Power, UInt_t &Remainder)
 Is the input a power of 2? More...
 

Protected Member Functions

void IsPowerOf2 ()
 
 ClassDef (QFFT, 0)
 

Protected Attributes

size_t fSize
 
FFTDirection fDirection
 
bool fNormalized
 
bool fIsPowerOf2
 
double * fData
 
double * fWindow
 
size_t fWindowSize
 
WindowType fWindowType
 

Detailed Description

Interface for ffts in Diana analysis.

Every fft class written within the DIANA framework should inherit from this class

Definition at line 26 of file QFFT.hh.

Member Enumeration Documentation

◆ FFTDirection

Enumerator
kForward 
kBackward 

Definition at line 46 of file QFFT.hh.

◆ WindowType

window type

Enumerator
WT_None 
WT_Welch 
WT_Rect 
WT_Hann 
WT_Hamming 
WT_Cosinus 
WT_BlackmanHarris 
WT_Kaiser3 

Definition at line 30 of file QFFT.hh.

◆ ZeroPadSide

Enumerator
kMiddle 
kSymmetric 
kLeft 
kRight 

Definition at line 40 of file QFFT.hh.

Constructor & Destructor Documentation

◆ QFFT() [1/2]

Q_BEGIN_NAMESPACE QFFT::QFFT ( const size_t  size)

constructor with its size

Parameters
sizeis the number of entries of the vector to be transformed

Definition at line 14 of file QFFT.cc.

References fData, fDirection, fNormalized, fWindow, fWindowSize, fWindowType, IsPowerOf2(), kForward, and WT_None.

◆ QFFT() [2/2]

QFFT::QFFT ( )

empty constructor with its size

Definition at line 24 of file QFFT.cc.

References fData, fDirection, fIsPowerOf2, fNormalized, fSize, fWindow, fWindowSize, fWindowType, kForward, and WT_None.

◆ ~QFFT()

QFFT::~QFFT ( )
virtual

destructor

Definition at line 35 of file QFFT.cc.

References fData, and fWindow.

Member Function Documentation

◆ ClassDef()

QFFT::ClassDef ( QFFT  ,
 
)
protected

◆ CutSides()

QVector QFFT::CutSides ( const QVector input,
size_t  ncut,
bool  isSym 
)
static

cut left and right sides by ncut/2

Definition at line 290 of file QFFT.cc.

References FFTAntiSym(), FFTSym(), QVectorConstView::GetVector(), and QVector::Size().

◆ FFTAntiSym()

QVector QFFT::FFTAntiSym ( const QVector input)
static

antisimmetrize time domain vector

Definition at line 201 of file QFFT.cc.

Referenced by CutSides().

◆ FFTSym()

QVector QFFT::FFTSym ( const QVector input)
static

simmetrize time domain vector

Definition at line 208 of file QFFT.cc.

Referenced by CutSides().

◆ GetWindow()

QVector QFFT::GetWindow ( WindowType  wt,
size_t  size,
size_t  zeros = 0,
int  coherent = 0,
int  param = 0 
)
static

create window and add zeros/2 to the left and zeros/2 to the right

Definition at line 82 of file QFFT.cc.

References cos(), pow(), QVector::Resize(), QVector::Size(), WT_BlackmanHarris, WT_Cosinus, WT_Hamming, WT_Hann, WT_Kaiser3, WT_None, WT_Rect, and WT_Welch.

Referenced by QOptimumFilter::BuildFilter(), QRealComplexFFTGSL::SetWindowType(), and QRealComplexFFTW3::SetWindowType().

◆ GetWindowType()

int QFFT::GetWindowType ( ) const
inline

Return the window type.

Returns
the type of the window set

Definition at line 135 of file QFFT.hh.

References fWindowType.

◆ IsPowerOf2() [1/3]

void QFFT::IsPowerOf2 ( )
protected

Definition at line 61 of file QFFT.cc.

References fIsPowerOf2, and fSize.

Referenced by IsPowerOf2(), QFFT(), QRealComplexFFTGSL::QRealComplexFFTGSL(), and QRealComplexFFTGSL::Resize().

◆ IsPowerOf2() [2/3]

bool QFFT::IsPowerOf2 ( UInt_t  Value)
static

Is the input a power of 2.

Static method to determine if a value is a power of 2.

Definition at line 57 of file QFFT.cc.

References IsPowerOf2().

◆ IsPowerOf2() [3/3]

bool QFFT::IsPowerOf2 ( UInt_t  Value,
UInt_t &  Power,
UInt_t &  Remainder 
)
static

Is the input a power of 2?

Static method to returns true if a value is a power of 2

Parameters
PowerStore the largest power of 2 smaller than Value.
ReimainderWhere to store the difference between Value and the next smaller power of 2.

Definition at line 45 of file QFFT.cc.

◆ Resize()

virtual bool QFFT::Resize ( size_t  s)
pure virtual

virtual method. Must be implemented by daughter classes

Parameters
sis the size of the vector to be transformed

Implemented in QRealComplexFFTW3, QRealComplexFFTGSL, and QRealComplexFFT.

◆ SetForward()

void QFFT::SetForward ( bool  isForward)
inline

virtual method. Must be implemented by daughter classes set the direction of the transform.

Parameters
isForwardis true when the direction is forward

Definition at line 142 of file QFFT.hh.

References fDirection, kBackward, and kForward.

Referenced by QRealComplexFFTGSL::TransformFromFreq(), QRealComplexFFTW3::TransformFromFreq(), QRealComplexFFTGSL::TransformToFreq(), and QRealComplexFFTW3::TransformToFreq().

◆ SetNormalized()

void QFFT::SetNormalized ( bool  isNormalized)
inline

virtual method. Must be implemented by daughter classes set the normalization of the transform.

Parameters
isNormalizedis true when the fft is normalized

Definition at line 149 of file QFFT.hh.

References fNormalized.

Referenced by QRealComplexFFTGSL::TransformFromFreq(), and QRealComplexFFTGSL::TransformToFreq().

◆ SetWindowType()

virtual void QFFT::SetWindowType ( WindowType  wt,
int  coherent = false 
)
pure virtual

virtual method. Must be implemented by daughter classes set the window type.

Parameters
tis the type of window applied

Implemented in QRealComplexFFTW3, QRealComplexFFTGSL, and QRealComplexFFT.

◆ StrToWindowType()

QFFT::WindowType QFFT::StrToWindowType ( const std::string &  winName)
static

◆ Transform()

virtual int QFFT::Transform ( const QVector data,
QVector result 
)
pure virtual

virtual method. Must be implemented by daughter classes.

Parameters
datareferences the vector of data to be transformed
resultreferences the vector holding the result

Implemented in QRealComplexFFTW3, QRealComplexFFTGSL, and QRealComplexFFT.

◆ ZeroPad() [1/2]

QVector QFFT::ZeroPad ( const QVector input,
size_t  n_zeros,
int  Side = kMiddle,
double  zeroVal = 0. 
)
static

Add zeros to the input.

This method can handle odd size arrays and odd size zero padding just fine. Though things wont be 100% symmetric (obviously).If zero padding the center, there will be an extra non-zero element on the left. If zero padding the sides symmetrically, there will be an extra zero on the left.

Parameters
inputThe input array to be padded.
n_zerosThe total number of zeros to be added.
SizeWhere the zeros should be added. Can be kMiddle, kSymmetric, kLeft or kRight.
zeroValThe value to pad with. (Defaults to 0).
Returns
The new zero padded array.

Definition at line 216 of file QFFT.cc.

References kMiddle, kRight, kSymmetric, QVector::Shift(), and QVector::Size().

Referenced by QOptimumFilter::BuildFilter().

◆ ZeroPad() [2/2]

QVectorC QFFT::ZeroPad ( const QVectorC input,
size_t  n_zeros,
int  Side = kMiddle,
Diana::QComplex  zeroVal = Diana::QComplex(0,0) 
)
static

Add zeros to the input.

This method can handle odd size arrays and odd size zero padding just fine. Though things wont be 100% symmetric (obviously).If zero padding the center, there will be an extra non-zero element on the left. If zero padding the sides symmetrically, there will be an extra zero on the left.

Parameters
inputThe input array to be padded.
n_zerosThe total number of zeros to be added.
SizeWhere the zeros should be added. Can be kMiddle, kSymmetric, kLeft or kRight.
zeroValThe value to pad with. (Defaults to 0).
Returns
The new zero padded array.

Definition at line 253 of file QFFT.cc.

References kMiddle, kRight, kSymmetric, QVectorC::Shift(), and QVectorC::Size().

Member Data Documentation

◆ fData

double* QFFT::fData
protected

◆ fDirection

FFTDirection QFFT::fDirection
protected

◆ fIsPowerOf2

bool QFFT::fIsPowerOf2
protected

Definition at line 175 of file QFFT.hh.

Referenced by IsPowerOf2(), QFFT(), and QRealComplexFFTGSL::Transform().

◆ fNormalized

bool QFFT::fNormalized
protected

◆ fSize

size_t QFFT::fSize
protected

◆ fWindow

double* QFFT::fWindow
protected

◆ fWindowSize

size_t QFFT::fWindowSize
protected

◆ fWindowType

WindowType QFFT::fWindowType
protected

The documentation for this class was generated from the following files: