NSCL DDAS  1.0
Support for XIA DDAS at the NSCL
 All Classes Namespaces Files Functions Variables Macros Pages
RiseTimeProcessor.hpp
1 // RiseTimeProcessor.hpp
2 //
3 // Author : Jeromy Tompkins
4 // Date : 8/14/2013
5 
6 #ifndef RISETIMEPROCESSOR_H
7 #define RISETIMEPROCESSOR_H
8 #include <iostream>
9 #include <TObject.h>
10 #include "Trace.hpp"
11 #include "AmplitudeProcessor.hpp"
12 #include "Threshold.hpp"
13 
14 namespace TrAnal
15 {
16 
18 template<class T>
20 {
21 
22  public:
23  double baseline;
24  double amp;
25 
28 
29  double t10_amp;
30  double t90_amp;
31 
32  // ROOT dictionary generation
34  ClassDef(RiseTimeProcResult,0);
36 };
37 
38 
40 
45 template<class T>
46  RiseTimeProcResult<T> ComputeRiseTime(const TrRange<T>& bline_range, const TrRange<T>& pfind_range)
47  {
48  // Process the amplitude to get the baseline and the peak height
49 
50  // Use smart pointer to make this exception safe... we don't want
51  // to have one of the results for the primitive processors to persist
52  // if an exception is thrown.
53 
54  AmplitudeProcResult amp_res = ComputeAmplitude(bline_range,pfind_range);
55 
56  // find the t10 point
57  double amp10 = amp_res.baseline + 0.10*amp_res.amp;
58  TrIterator<T> thr10_res = Threshold(pfind_range,amp10);
59 
60  // find the t90 point
61  double amp90 = amp_res.baseline + 0.90*amp_res.amp;
62  TrIterator<T> thr90_res = Threshold(TrRange<T>(thr10_res,pfind_range.end()),amp90);
63 
64  // if order of the t10 and t90 indices is not
65  // first t10 then t90, then something bizarre happened
66  // This is not a valid result.
67  if (thr10_res >= thr90_res) {
68  throw InvalidResultException("t10 comes after t90...nonsensical result");
69  }
70 
71  if (*thr10_res >= *thr90_res) {
72  throw InvalidResultException("t10_amp > t90_amp ... nonsensical result");
73  }
74 
75  // if we made it here, then there were no exceptions...
76  // create the result and fill it with data.
77  // Note that this will not be deleted when it goes out of scope... the
78  // ownership of the result will be passed to the caller
79  RiseTimeProcResult<T> res;
80 
81  res.baseline = amp_res.baseline;
82  res.amp = amp_res.amp;
83 
84  res.t10_index = thr10_res;
85  res.t90_index = thr90_res;
86 
87  res.t10_amp = *(res.t10_index);
88  res.t90_amp = *(res.t90_index);
89 
90  return res;
91 
92 }
93 
95 
108 template<class T>
109 RiseTimeProcResult<T> ComputeRiseTime(const TrIterator<T>& begin, int bline_range, int pfind_range)
110 {
111  return ComputeRiseTime(TrRange<T>(begin,bline_range), TrRange<T>(begin+bline_range, pfind_range));
112 }
113 
114 } // end TrAnal namespace
115 
116 #endif
double t10_amp
value pointed to by t10_index
Definition: RiseTimeProcessor.hpp:29
TrIterator template class.
Definition: TrIterator.hpp:24
TrIterator< T > end() const
Get value of end iterator.
Definition: TrIterator.hpp:224
double amp
amplitude (i.e. peak - baseline)
Definition: AmplitudeProcessor.hpp:23
double baseline
computed value of baseline
Definition: RiseTimeProcessor.hpp:23
TrRange class.
Definition: TrIterator.hpp:173
double t90_amp
value pointed to by t90_index
Definition: RiseTimeProcessor.hpp:30
Result for ComputeAmplitude algorithm.
Definition: AmplitudeProcessor.hpp:20
Definition: AlgoIterator.hpp:12
double baseline
mean value of trace within baseline search range
Definition: AmplitudeProcessor.hpp:26
Result of ComputeRiseTime.
Definition: RiseTimeProcessor.hpp:19
TrIterator< T > t10_index
points to first value equal to or exceeding 10% of the amplitude
Definition: RiseTimeProcessor.hpp:26
double amp
computed amplitude
Definition: RiseTimeProcessor.hpp:24
TrIterator< T > t90_index
points to first value equal to or exceeding 90% of the amplitude
Definition: RiseTimeProcessor.hpp:27
Definition: Exceptions.h:51