NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes 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