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)
7  , fPlan (fplan)
8  , rPlan (rplan)
9  , fFitBins (fitbins)
10 {
11 
12  fFreqSize = fSize/2+1;
13 
14  // ... Real-Complex
15  fIn = fftw_malloc(sizeof(double)*fSize);
16  fOut= fftw_malloc(sizeof(fftw_complex)*fFreqSize);
17 
18  // ... Complex-Real
19  rIn = fftw_malloc(sizeof(fftw_complex)*fFreqSize);
20  rOut= fftw_malloc(sizeof(double)*fSize);
21 
22  // ... allocate other data vectors
23  fCompTemp.resize(fFreqSize);
24  fKern.resize(fFreqSize);
25  fConvHist.resize(fFitBins);
26 }
27 
29 {
30  fPlan = 0;
31  fftw_free(fIn);
32  fIn = 0;
33  fftw_free((fftw_complex*)fOut);
34  fOut = 0;
35 
36  rPlan = 0;
37  fftw_free((fftw_complex*)rIn);
38  rIn = 0;
39  fftw_free(rOut);
40  rOut = 0;
41 }
42 
43 // According to the Fourier transform identity
44 // f(x-a) = Inverse Transform(exp(-2*Pi*i*a*w)F(w))
45 // -----------------------------------------------------------------------------
47 {
48  double factor = -2.0*std::acos(-1)*shift/(double)fSize;
49 
50  for(int i = 0; i < fFreqSize; i++){
51  input[i] *= std::exp(std::complex<double>(0,factor*(double)i));
52  }
53 
54  return;
55 }
ComplexVector fKern
Definition: LArFFTW.h:55
void * fIn
Definition: LArFFTW.h:60
int fFreqSize
Definition: LArFFTW.h:59
const void * fPlan
Definition: LArFFTW.h:62
std::string string
Definition: nybbler.cc:12
std::vector< std::complex< double >> ComplexVector
Definition: LArFFTW.h:24
LArFFTW(int transformSize, const void *fplan, const void *rplan, int fitbins)
Definition: LArFFTW.cxx:5
void * rOut
Definition: LArFFTW.h:64
std::vector< float > fConvHist
Definition: LArFFTW.h:57
int fFitBins
Definition: LArFFTW.h:66
static int input(void)
Definition: code.cpp:15695
void * rIn
Definition: LArFFTW.h:63
void ShiftData(ComplexVector &input, double shift)
Definition: LArFFTW.cxx:46
const void * rPlan
Definition: LArFFTW.h:65
void * fOut
Definition: LArFFTW.h:61
ComplexVector fCompTemp
Definition: LArFFTW.h:56