NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
Threshold.hpp
1 // Threshold.hpp
2 //
3 // Author : Jeromy Tompkins
4 // Date : 8/14/2013
5 
6 #ifndef THRESHOLD_H
7 #define THRESHOLD_H
8 
9 #include "Trace.hpp"
10 #include "AlgoIterator.hpp"
11 
12 namespace TrAnal {
13 
14 
16 
26  template<class T>
27  TrIterator<T> Threshold(const TrIterator<T>& begin,
28  const TrIterator<T>& end,
29  double thresh)
30  {
31  TrIterator<T> it=begin;
32  while ( it<end && *it<thresh ) ++it;
33 
34  return it;
35  }
36 
38 
44  template<class T>
45  TrIterator<T> Threshold(const TrRange<T>& range, double thresh) { return Threshold<T>(range.begin(), range.end(), thresh);}
46 
48 
57  template<class T>
58  TrIterator<T> Threshold(AlgoIterator<T>& begin,
59  const TrIterator<T>& end,
60  double thresh)
61  {
62  // Default return is end
63  TrIterator<T> ret_it = end;
64 
65  // change the name of begin
66  AlgoIterator<T>& it = begin;
67 
68  while ( it<end && *it<thresh ) {
69  ++it;
70  }
71 
72  // Store result if threshold exceeded
73  if ( *it >= thresh) ret_it = it.min_extent();
74 
75  return ret_it;
76  }
77 
78 } // end namespace
79 #endif
Definition: AlgoIterator.hpp:12