NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
PeakFindProcessor.hpp
1 // PeakFindProcessor.h
2 //
3 // Author : Jeromy Tompkins
4 // Date : 8/14/2013
5 
6 
7 #ifndef PEAKFINDPROCESSOR_H
8 #define PEAKFINDPROCESSOR_H
9 
10 #include "Trace.hpp"
11 #include "AlgoIterator.hpp"
12 #include "TObject.h"
13 
14 namespace TrAnal
15 {
16 
18 template<class T>
20 {
21  public:
22  double max;
23  double umax;
24 
26 
27  // ROOT dictionary generation
29  ClassDef(PeakFindProcResult,1);
31 
32 }; // end of PeakFindProcResult class
33 
35 
40 template<class T>
41 PeakFindProcResult<T> FindPeak(const TrIterator<T>& begin, const TrIterator<T>& end)
42 {
43 
44  double max=0;
45  double current=0;
46  TrIterator<T> index=begin;
47 
48  TrIterator<T> it=begin;
49  while ( it<end ) {
50  current = *it;
51  if (current>max) {
52  max = current;
53  index = it;
54  }
55  ++it;
56  }
57 
58  // We successfully completed the algorithm...store the result
59  // and pass it to the caller
60  PeakFindProcResult<T> res;
61  res.max = max;
62  res.umax = 0;
63  res.index = index;
64 
65  return res;
66 } // end of FindPeak
67 
69 
74 template<class T>
75 PeakFindProcResult<T> FindPeak(AlgoIterator<T>& begin, const TrIterator<T>& end)
76 {
77 
78  double max=0;
79  double current=0;
80  TrIterator<T> index=begin.min_extent();
81 
82  AlgoIterator<T>& it=begin;
83  while ( it<end ) {
84  current = *it;
85  if (current>max) {
86  max = current;
87  index = it.min_extent();
88  }
89  ++it;
90  }
91 
92  // We successfully completed the algorithm...store the result
93  // and pass it to the caller
94  PeakFindProcResult<T> res;
95  res.max = max;
96  res.umax = 0;
97  res.index = index;
98 
99  return res;
100 } // end of FindPeak
101 
102 } // end namespace
103 #endif
double umax
the uncertainty
Definition: PeakFindProcessor.hpp:23
TrIterator template class.
Definition: TrIterator.hpp:24
double max
the value of the maximum found
Definition: PeakFindProcessor.hpp:22
Result of FindPeak algorithm.
Definition: PeakFindProcessor.hpp:19
Definition: AlgoIterator.hpp:12
TrIterator< T > index
points to the peak value
Definition: PeakFindProcessor.hpp:25