CFEL - ASG Software Suite  2.5.0
CASS
waveform.h
Go to the documentation of this file.
1 // Copyright (C) 2010 Lutz Foucar
2 
3 /**
4  * @file waveform.h file contains acqiris data retrieval processor
5  * declaration
6  *
7  * @author Lutz Foucar
8  */
9 
10 #ifndef _WAVEFORM__H_
11 #define _WAVEFORM__H_
12 
13 #include "processor.h"
14 
15 namespace cass
16 {
17 //forward declarations
18 class CASSEvent;
19 class Histogram1DFloat;
20 
21 /** acqiris channel waveform.
22  *
23  * @PPList "110": retrieve wavefrom of a channel
24  *
25  * @see Processor for a list of all commonly available cass.ini
26  * settings.
27  *
28  * @cassttng Processor/\%name\%/{InstrumentId} \n
29  * The instrument id of the acqiris instrument that contains the
30  * channel. Default is 8. Options are:
31  * - 8: Camp Acqiris
32  * - 4: AMO ITof Acqiris
33  * - 2: AMO GD Acqiris
34  * - 5: AMO Mbes Acqiris
35  * - 22: XPP Acqiris
36  * @cassttng Processor/\%name\%/{ChannelNbr} \n
37  * The channel number of the acqiris instrument. Default is 0.
38  * @cassttng Processor/\%name\%/{NbrSamples} \n
39  * Number of samples in the waveform. Default is 40000
40  * @cassttng Processor/\%name\%/{SampleInterval} \n
41  * Sample Interval (Time between to samples in s. Default is 1e-9
42  *
43  * @author Lutz Foucar
44  */
45 class pp110 : public Processor
46 {
47 public:
48  /** constructor */
49  pp110(const name_t &name);
50 
51  /** copy the last waveform from the channel*/
52  virtual void process(const CASSEvent&, result_t&);
53 
54  /** load the settings of this pp */
55  virtual void loadSettings(size_t);
56 
57 protected:
58  /** the instrument that contains the channel this processor will work on */
59  uint32_t _instrument;
60 
61  /** the Acqiris channel number of this processor */
62  size_t _channel;
63 
64  /** the sample interval */
66 };
67 
68 
69 
70 /** cfd trace from waveform
71  *
72  * @PPList "111": convert wavefrom to cfd trace
73  *
74  * @see Processor for a list of all commonly available cass.ini
75  * settings.
76  *
77  * @cassttng Processor/\%name\%/{Waveform} \n
78  * The name of the Processor containing the waveform that should
79  * be converted. Default is 'Unknown'
80  * @cassttng Processor/\%name\%/{Delay_ns}\n
81  * Delay in ns used. Default is 5.
82  * @cassttng Processor/\%name\%/{Fraction}\n
83  * Fraction used. Default is 0.6
84  * @cassttng Processor/\%name\%/{Walk_V}\n
85  * walk in V used. Default is 0.
86  *
87  * @author Lutz Foucar
88  */
89 class pp111 : public Processor
90 {
91 public:
92  /** constructor */
93  pp111(const name_t &name);
94 
95  /** copy the last waveform from the channel*/
96  virtual void process(const CASSEvent&, result_t&);
97 
98  /** load the settings of this pp */
99  virtual void loadSettings(size_t);
100 
101 protected:
102  /** the Processor that contains the waveform to convert */
104 
105  /** the delay in bins */
106  size_t _delay;
107 
108  /** the fraction */
109  float _fraction;
110 
111  /** the walk in volts */
112  float _walk;
113 };
114 
115 
116 
117 /** cfd analysis of waveform
118  *
119  * @PPList "112": cfd analysis of waveform
120  *
121  * @see Processor for a list of all commonly available cass.ini
122  * settings.
123  *
124  * @cassttng Processor/\%name\%/{Waveform} \n
125  * The name of the Processor containing the waveform that should
126  * be converted. Default is 'Unknown'
127  * @cassttng Processor/\%name\%/{Delay}\n
128  * Delay in units of the input x-axis is used. Default is 5.
129  * @cassttng Processor/\%name\%/{Fraction}\n
130  * Fraction used. Default is 0.6
131  * @cassttng Processor/\%name\%/{Threshold}\n
132  * threshold in units of the y-axis. Default is 0.1
133  * @cassttng Processor/\%name\%/{Walk}\n
134  * walk in units of the y-axis. Default is 0.
135  *
136  * @author Lutz Foucar
137  */
138 class pp112 : public Processor
139 {
140 public:
141  /** constructor */
142  pp112(const name_t &name);
143 
144  /** copy the last waveform from the channel*/
145  virtual void process(const CASSEvent&, result_t&);
146 
147  /** load the settings of this pp */
148  virtual void loadSettings(size_t);
149 
150 protected:
151  /** definition of the table */
153 
154  /** enum describing the contents of the resulting table */
156  {
157  position = 0,
158  height = 1,
159  maxpos = 2,
160  fwhm = 3,
161  startpos = 4,
162  endpos = 5,
163  integral = 6,
164  width = 7,
165  polarity = 8,
166  CoM = 9,
168  };
169 
170 protected:
171  /** define the fitparameters */
172  typedef std::pair<float,float> fitparam_t;
173 
174  /** define a point */
175  typedef std::pair<float,float> point_t;
176 
177  /** define points */
178  typedef std::vector<point_t> points_t;
179 
180  /** make a linear regression through points
181  *
182  * @return the constant and the slope
183  * @param points vector containing the x,y coordintas of the points
184  */
185  fitparam_t linearRegression(points_t::const_iterator first, points_t::const_iterator last);
186 
187  /** create Newton Polynomial
188  *
189  * This function creates the coefficients for Newton interpolating Polynomials.
190  * Newton Polynomials are created from n Points and have the form
191  * \f$p(x) = c_0 + c_1(x-x_0) + c_2(x-x_0)(x-x_1)+...+c_{n-1}(x-x_0)(x-x_1)...(x-x_{n-2})\f$
192  * given that you have n Points
193  * \f$(x_0,y_0), (x_1,y_1), ..., (x_{n-1},y_{n-1})\f$
194  * Here we do it for 4 Points.
195  *
196  * @param[in] x the x-values of the points
197  * @param[in] y the y-values of the points
198  * @param[out] coeff the coefficients of the newton polynomial
199  */
200  void createNewtonPolynomial(const float * x, const float * y, float * coeff);
201 
202  /** evaluate Newton Polynomial
203  *
204  * this function evaluates the Newton Polynomial that was created from n Points
205  * \f$(x_0,y_0),..., (x_{n-1},y_{n-1}) with coefficients (c_0,...,c_{n-1})\f$
206  * using Horner's Rule. This is done for an polynomial with 4 entries
207  *
208  * @return the newton polynomial
209  * @param[in] x array of x values
210  * @param[in] coeff array of coefficients
211  * @param[in] X
212  */
213  float evalNewtonPolynomial(const float * x, const float * coeff, float X);
214 
215  /** Achims Numerical Approximation
216  *
217  * this function should find x value corrosponding to a given y value
218  * in a newton polynomial. It does it the following way:
219  * -# create a lower and upper boundary point
220  * -# create an interating x-value and initialize it with the Start value
221  * -# evaluate the y-value at the x-value
222  * -# if the y value is bigger than the requested value the start point
223  * is defines the new upper or lower boundary depending on the slope.
224  * -# the new x-point is defined by the arithmetic mean between the tow
225  * boundary points.
226  * -# do points 3-5 until the new x-value does not differ more than 0.005
227  * from the old one.
228  *
229  *@param[in] x two points describing upper and lower boundaries
230  *@param[in] coeff the newton polynomial coefficents
231  *@param[in] Y the requested y-values to find the x-value for
232  *@param[in] Start the x-value we start the search with
233  */
234  float findXForGivenY(const float * x, const float * coeff, const float Y, const float Start);
235 
236 protected:
237  /** the Processor that contains the waveform to convert */
239 
240  /** the delay in bins */
241  size_t _delay;
242 
243  /** the fraction */
244  float _fraction;
245 
246  /** the walk in volts */
247  float _walk;
248 
249  /** the threshold */
250  float _threshold;
251 
252  /** the baseline */
253  float _baseline;
254 };
255 }
256 
257 #endif
float _baseline
the baseline
Definition: waveform.h:253
float _fraction
the fraction
Definition: waveform.h:109
size_t _channel
the Acqiris channel number of this processor
Definition: waveform.h:62
Event to store all LCLS Data.
Definition: cass_event.h:32
float _threshold
the threshold
Definition: waveform.h:250
float _fraction
the fraction
Definition: waveform.h:244
uint32_t _instrument
the instrument that contains the channel this processor will work on
Definition: waveform.h:59
std::vector< value_t > storage_t
the storage of this container
Definition: result.hpp:332
cfd trace from waveform
Definition: waveform.h:89
float findXForGivenY(const float *x, const float *coeff, const float Y, const float Start)
Achims Numerical Approximation.
Definition: waveform.cpp:284
virtual void loadSettings(size_t)
load the settings of this pp
Definition: waveform.cpp:48
const name_t name() const
retrieve the name of this processor
Definition: processor.h:167
virtual void process(const CASSEvent &, result_t &)
copy the last waveform from the channel
Definition: waveform.cpp:69
ColumnNames
enum describing the contents of the resulting table
Definition: waveform.h:155
size_t _delay
the delay in bins
Definition: waveform.h:241
cfd analysis of waveform
Definition: waveform.h:138
virtual void loadSettings(size_t)
load the settings of this pp
Definition: waveform.cpp:143
shared_pointer _waveform
the Processor that contains the waveform to convert
Definition: waveform.h:103
fitparam_t linearRegression(points_t::const_iterator first, points_t::const_iterator last)
make a linear regression through points
Definition: waveform.cpp:238
std::vector< point_t > points_t
define points
Definition: waveform.h:178
size_t _delay
the delay in bins
Definition: waveform.h:106
base class for processors.
Definition: processor.h:39
std::pair< float, float > point_t
define a point
Definition: waveform.h:175
void createNewtonPolynomial(const float *x, const float *y, float *coeff)
create Newton Polynomial
Definition: waveform.cpp:257
pp112(const name_t &name)
constructor
Definition: waveform.cpp:198
virtual void process(const CASSEvent &, result_t &)
copy the last waveform from the channel
Definition: waveform.cpp:172
std::pair< float, float > fitparam_t
define the fitparameters
Definition: waveform.h:172
result_t::storage_t table_t
definition of the table
Definition: waveform.h:152
float _walk
the walk in volts
Definition: waveform.h:247
file contains processors baseclass declaration
float _walk
the walk in volts
Definition: waveform.h:112
shared_pointer _waveform
the Processor that contains the waveform to convert
Definition: waveform.h:238
pp111(const name_t &name)
constructor
Definition: waveform.cpp:137
acqiris channel waveform.
Definition: waveform.h:45
virtual void loadSettings(size_t)
load the settings of this pp
Definition: waveform.cpp:204
float evalNewtonPolynomial(const float *x, const float *coeff, float X)
evaluate Newton Polynomial
Definition: waveform.cpp:274
pp110(const name_t &name)
constructor
Definition: waveform.cpp:42
double _sampleInterval
the sample interval
Definition: waveform.h:65
virtual void process(const CASSEvent &, result_t &)
copy the last waveform from the channel
Definition: waveform.cpp:374
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