CFEL - ASG Software Suite  2.5.0
CASS
fft.h
Go to the documentation of this file.
1 // Copyright (C) 2013 Lutz Foucar
2 // Copyright (C) 2013 Stephan Kassemeyer
3 
4 /**
5  * @file fft.h containing the class to calculate the fast fourier transform
6  *
7  * @author Lutz Foucar
8  */
9 
10 #ifndef _FFTW_H_
11 #define _FFTW_H_
12 
13 #include <fftw3.h>
14 #include <tr1/functional>
15 
16 #include "processor.h"
17 #include "result.hpp"
18 
19 namespace cass
20 {
21 
22 /* general traits case not implemented: */
23 template <typename T> struct pp312Traits;
24 
25 /* float traits case specialization: */
26 template <>
27 struct pp312Traits<float>
28 {
29  typedef fftwf_complex fftw_complex_type;
30  typedef float fftw_real_type;
31 };
32 
33 /* double traits case specialization: */
34 template <>
35 struct pp312Traits<double>
36 {
37  typedef fftw_complex fftw_complex_type;
38  typedef double fftw_real_type;
39 };
40 
41 
42 
43 
44 
45 /** calculate the absolute squared fft of an histogram
46  *
47  * details
48  *
49  * @PPList "312": calculate the absolute square fft of an histogram
50  *
51  * @cassttng Processor/\%name\%/{InputName} \n
52  * processor name containing the histogram whos fft
53  * should be calculated.
54  *
55  * @author Stephan Kassemeyer
56  * @author Lutz Foucar
57  */
58 class pp312 : public Processor
59 {
60 public:
61  /** constructor
62  *
63  * @param name the name of this Processor
64  */
65  pp312(const name_t &name);
66 
67  /** process the event
68  *
69  * @param evt the event that contains the id
70  * @param result the histogram that will contain the result of the process
71  */
72  virtual void process(const CASSEvent &evt, result_t &result);
73 
74  /** load the settings of this pp */
75  virtual void loadSettings(size_t);
76 
77 protected:
78  /** define the shape */
79  typedef std::pair<int,int> shape_t;
80 
81 protected:
82  /** calculate the absolute square fft for 1d data
83  *
84  * @param in the incomming data
85  * @param out where the fft will be written to
86  */
88 
89  /** calculate the absolute square fft for 2d data
90  *
91  * @param in the incomming data
92  * @param out where the fft will be written to
93  */
95 
96 protected:
97  /** pp containing histogram to calculate the autocorrelation for */
99 
100  /** the shape of the incomming histogram */
101  size_t _Nx;
102  size_t _Ny;
103 
104  /** fftw plan - stores fftw optimization data for
105  * given data type+size */
106  fftw_plan _fftw_plan;
107 
108  /** info about temporary memory for the fftw calculation */
110 
111  /** function to call for processing */
112  std::tr1::function<void(result_t::const_iterator, result_t::iterator)> _func;
113 };
114 
115 
116 } //end namespace cass
117 #endif
storage_t::const_iterator const_iterator
a const iterator on the storage
Definition: result.hpp:338
Event to store all LCLS Data.
Definition: cass_event.h:32
fftw_plan _fftw_plan
fftw plan - stores fftw optimization data for given data type+size
Definition: fft.h:106
size_t _Ny
Definition: fft.h:102
fftwf_complex fftw_complex_type
Definition: fft.h:29
const name_t name() const
retrieve the name of this processor
Definition: processor.h:167
virtual void process(const CASSEvent &evt, result_t &result)
process the event
Definition: fft.cpp:182
result classes
calculate the absolute squared fft of an histogram
Definition: fft.h:58
int _fft_tmp_padding
info about temporary memory for the fftw calculation
Definition: fft.h:109
shared_pointer _hist
pp containing histogram to calculate the autocorrelation for
Definition: fft.h:98
base class for processors.
Definition: processor.h:39
void fft2d(result_t::const_iterator in, result_t::iterator out)
calculate the absolute square fft for 2d data
Definition: fft.cpp:115
pp312(const name_t &name)
constructor
Definition: fft.cpp:28
std::tr1::function< void(result_t::const_iterator, result_t::iterator)> _func
function to call for processing
Definition: fft.h:112
virtual void loadSettings(size_t)
load the settings of this pp
Definition: fft.cpp:37
file contains processors baseclass declaration
storage_t::iterator iterator
a iterator on the storage
Definition: result.hpp:335
void fft1d(result_t::const_iterator in, result_t::iterator out)
calculate the absolute square fft for 1d data
Definition: fft.cpp:82
std::string name_t
define the name type
Definition: processor.h:46
std::tr1::shared_ptr< Processor > shared_pointer
a shared pointer of this
Definition: processor.h:43
std::pair< int, int > shape_t
define the shape
Definition: fft.h:79
size_t _Nx
the shape of the incomming histogram
Definition: fft.h:101
virtual const result_t & result(const CASSEvent::id_t eventid=0)
retrieve a result for a given id.
Definition: processor.cpp:54
fftw_complex fftw_complex_type
Definition: fft.h:37