NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
AmplitudeProcessor.hpp
1 // AmplitudeProcessor.h
2 //
3 // Author : Jeromy Tompkins
4 // Date : 8/14/2013
5 
6 
7 
8 #ifndef AMPLITUDEPROCESSOR_H
9 #define AMPLITUDEPROCESSOR_H
10 
11 #include "BaseLineProcessor.hpp"
12 #include "PeakFindProcessor.hpp"
13 #include "Exceptions.h"
14 
15 #include <TObject.h>
16 namespace TrAnal
17 {
18 
21 {
22  public:
23  double amp;
24  double uamp;
25 
26  double baseline;
27  double ubaseline;
28 
29  // ROOT dictionary generation
31  ClassDef(AmplitudeProcResult,1);
33 };
34 
36 
47 template<class T>
48 AmplitudeProcResult ComputeAmplitude( const TrRange<T>& bline_range, const TrRange<T>& pf_range)
49 {
50  // Call the primitive processors
51  // There results will be deleted automatically when they go out of scope
52  BaseLineProcResult bl_res
53  = ComputeBaseLine(bline_range.begin(), bline_range.end());
54 
56  = FindPeak(pf_range.begin(), pf_range.end());
57 
58  if (pf_res.max < bl_res.mean) {
59  throw InvalidResultException("amplitude less than baseline");
60  }
61 
62  // No exceptions were thrown, create the result and fill it with values
63  AmplitudeProcResult res;
64  res.amp = pf_res.max - bl_res.mean;
65  res.uamp = ::sqrt(::pow(bl_res.stdev,2.0) );
66 
67  res.baseline = bl_res.mean;
68  res.ubaseline = bl_res.stdev;
69 
70  return res;
71 }
72 
73 } // end namespace
74 #endif
TrIterator< T > end() const
Get value of end iterator.
Definition: TrIterator.hpp:224
double amp
amplitude (i.e. peak - baseline)
Definition: AmplitudeProcessor.hpp:23
TrRange class.
Definition: TrIterator.hpp:173
double stdev
std. dev. of values within range
Definition: BaseLineProcessor.hpp:22
Result of the ComputeBaseline function.
Definition: BaseLineProcessor.hpp:18
double uamp
uncertainty in amplitude
Definition: AmplitudeProcessor.hpp:24
Result of FindPeak algorithm.
Definition: PeakFindProcessor.hpp:19
Result for ComputeAmplitude algorithm.
Definition: AmplitudeProcessor.hpp:20
TrIterator< T > begin() const
Get value of begin iterator.
Definition: TrIterator.hpp:222
Definition: AlgoIterator.hpp:12
double mean
mean of values within range
Definition: BaseLineProcessor.hpp:21
double baseline
mean value of trace within baseline search range
Definition: AmplitudeProcessor.hpp:26
double ubaseline
std. dev. of trace within baseline search range
Definition: AmplitudeProcessor.hpp:27
Definition: Exceptions.h:51