LArFFTWPlan.cxx
Go to the documentation of this file.
2 
3 using std::string;
5 
6 util::LArFFTWPlan::LArFFTWPlan(int transformSize, const std::string &option)
7  : fSize (transformSize)
8  , fOption (option){
9 
10  std::lock_guard<std::mutex> lock(mutex_);
11 
12  fFreqSize = fSize/2+1;
13  fN = new int[1];
14  fN[0] = fSize;
15 
16  fIn = fftw_malloc(sizeof(double)*fSize);
17  fOut= fftw_malloc(sizeof(fftw_complex)*fFreqSize);
18  fPlan = (void*)fftw_plan_dft_r2c(1, fN, (double*)fIn, (fftw_complex*)fOut, MapFFTWOption());
19 
20  rIn = fftw_malloc(sizeof(fftw_complex)*fFreqSize);
21  rOut= fftw_malloc(sizeof(double)*fSize);
22  rPlan = (void*)fftw_plan_dft_c2r(1, fN, (fftw_complex*)rIn, (double*)rOut, MapFFTWOption());
23 }
24 
26 {
27  fftw_destroy_plan((fftw_plan)fPlan);
28  fPlan = 0;
29  fftw_free(fIn);
30  fIn = 0;
31  fftw_free((fftw_complex*)fOut);
32  fOut = 0;
33 
34  fftw_destroy_plan((fftw_plan)rPlan);
35  rPlan = 0;
36  fftw_free((fftw_complex*)rIn);
37  rIn = 0;
38  fftw_free(rOut);
39  rOut = 0;
40 
41  delete [] fN;
42  fN = 0;
43 }
44 
46 {
47  std::transform(fOption.begin(), fOption.end(),fOption.begin(), ::toupper);
48  if (fOption.find("ES")!=string::npos)
49  return FFTW_ESTIMATE;
50  if (fOption.find("M")!=string::npos)
51  return FFTW_MEASURE;
52  if (fOption.find("P")!=string::npos)
53  return FFTW_PATIENT;
54  if (fOption.find("EX")!=string::npos)
55  return FFTW_EXHAUSTIVE;
56  return FFTW_ESTIMATE;
57 }
std::string string
Definition: nybbler.cc:12
std::string fOption
Definition: LArFFTWPlan.h:30
static std::mutex mutex_
Definition: LArFFTWPlan.h:26
LArFFTWPlan(int transformSize, const std::string &option)
Definition: LArFFTWPlan.cxx:6
unsigned int MapFFTWOption()
Definition: LArFFTWPlan.cxx:45