#ifndef MARS_MFFT
#define MARS_MFFT

#ifndef MARS_MAGIC
#include "MAGIC.h"
#endif

#ifndef ROOT_TArrayF
#include "TArrayF.h"
#endif

#ifndef ROOT_TArrayD
#include "TArrayD.h"
#endif

#ifndef ROOT_TH1F
#include "TH1F.h"
#endif

#ifndef ROOT_TH1D
#include "TH1D.h"
#endif

class MFFT : public TObject
{
private:

  void Swap(Float_t &a,  Float_t &b)    { Float_t  c = a;  a = b;  b = c;  }
  void Swap(Double_t &a, Double_t &b)   { Double_t c = a;  a = b;  b = c;  }

  void TransformF(const Int_t isign);
  void TransformD(const Int_t isign);  
  void RealFTF(const Int_t isign);
  void RealFTD(const Int_t isign);

  void CheckDim(Int_t a);
  TH1 *CheckHist(const TH1 *hist, const Int_t flag);
  
  Int_t   fDim;
  TArrayF fDataF;
  TArrayD fDataD;  

public:

  MFFT();
  ~MFFT();

  TArrayF*  RealFunctionFFT( const TArrayF *data);
  TArrayF*  RealFunctionIFFT(const TArrayF *data);  
  
  TArrayD*  RealFunctionFFT( const TArrayD *data);
  TArrayD*  RealFunctionIFFT(const TArrayD *data);  
  
  Float_t*  RealFunctionFFT( const Int_t n, const Float_t *data);
  Float_t*  RealFunctionIFFT(const Int_t n, const Float_t *data);  
  
  Double_t* RealFunctionFFT( const Int_t n, const Double_t *data);
  Double_t* RealFunctionIFFT(const Int_t n, const Double_t *data);  
  
  TH1F* PowerSpectrumDensity(const TH1F *hist);
  TH1D* PowerSpectrumDensity(const TH1D *hist);
  
  ClassDef(MFFT,0)  // Class to perform a Fast Fourier Transform
};
    
#endif
