LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArFFTW.cxx
Go to the documentation of this file.
2 
3 using std::string;
4 
5 util::LArFFTW::LArFFTW(int transformSize, const void* fplan, const void* rplan, int fitbins)
6  : fSize(transformSize), fPlan(fplan), rPlan(rplan), fFitBins(fitbins)
7 {
8 
9  fFreqSize = fSize / 2 + 1;
10 
11  // ... Real-Complex
12  fIn = fftw_malloc(sizeof(double) * fSize);
13  fOut = fftw_malloc(sizeof(fftw_complex) * fFreqSize);
14 
15  // ... Complex-Real
16  rIn = fftw_malloc(sizeof(fftw_complex) * fFreqSize);
17  rOut = fftw_malloc(sizeof(double) * fSize);
18 
19  // ... allocate other data vectors
20  fCompTemp.resize(fFreqSize);
21  fKern.resize(fFreqSize);
22  fConvHist.resize(fFitBins);
23 }
24 
26 {
27  fPlan = 0;
28  fftw_free(fIn);
29  fIn = 0;
30  fftw_free((fftw_complex*)fOut);
31  fOut = 0;
32 
33  rPlan = 0;
34  fftw_free((fftw_complex*)rIn);
35  rIn = 0;
36  fftw_free(rOut);
37  rOut = 0;
38 }
39 
40 // According to the Fourier transform identity
41 // f(x-a) = Inverse Transform(exp(-2*Pi*i*a*w)F(w))
42 // -----------------------------------------------------------------------------
43 void util::LArFFTW::ShiftData(ComplexVector& input, double shift)
44 {
45  double factor = -2.0 * std::acos(-1) * shift / (double)fSize;
46 
47  for (int i = 0; i < fFreqSize; i++) {
48  input[i] *= std::exp(std::complex<double>(0, factor * (double)i));
49  }
50 
51  return;
52 }
ComplexVector fKern
Definition: LArFFTW.h:65
void * fIn
Definition: LArFFTW.h:70
int fFreqSize
Definition: LArFFTW.h:69
const void * fPlan
Definition: LArFFTW.h:72
std::vector< std::complex< double >> ComplexVector
Definition: LArFFTW.h:23
LArFFTW(int transformSize, const void *fplan, const void *rplan, int fitbins)
Definition: LArFFTW.cxx:5
void * rOut
Definition: LArFFTW.h:74
std::vector< float > fConvHist
Definition: LArFFTW.h:67
int fFitBins
Definition: LArFFTW.h:76
void * rIn
Definition: LArFFTW.h:73
void ShiftData(ComplexVector &input, double shift)
Definition: LArFFTW.cxx:43
const void * rPlan
Definition: LArFFTW.h:75
void * fOut
Definition: LArFFTW.h:71
ComplexVector fCompTemp
Definition: LArFFTW.h:66