RegionAboveThresholdFinder.cxx
Go to the documentation of this file.
1 /*!
2  * Title: RegionAboveThresholdFinder Class
3  * Author: Wes Ketchum (wketchum@lanl.gov)
4  *
5  * Description: Class that finds a region above threshold in which to do
6  * hit-finding.
7  *
8  * Input: Vector of floats (like a recob::Wire vector)
9  * Output: Vector of begin times, and vector of end times.
10 */
11 
13 #include <stdexcept>
14 
15 void hit::RegionAboveThresholdFinder::FillStartAndEndTicks(const std::vector<float>& signal,
16  std::vector<unsigned int>& start_ticks,
17  std::vector<unsigned int>& end_ticks)
18 {
19 
20  start_ticks.clear(); end_ticks.clear();
21 
22  bool in_RAT = false;
23  for(unsigned int i_tick=0; i_tick<signal.size(); i_tick++){
24 
25  if(!in_RAT && signal[i_tick]>=fThreshold){
26  start_ticks.push_back(i_tick);
27  in_RAT = true;
28  }
29  else if(in_RAT && signal[i_tick]<fThreshold){
30  end_ticks.push_back(i_tick);
31  in_RAT = false;
32  }
33 
34  }
35 
36  if(in_RAT)
37  end_ticks.push_back(signal.size());
38 
39  if(end_ticks.size()!=start_ticks.size())
40  throw std::runtime_error("ERROR in RegionAboveThresholdFinder: start and end tick vectors not equal.");
41 
42 }
void FillStartAndEndTicks(const std::vector< float > &signal, std::vector< unsigned int > &start_ticks, std::vector< unsigned int > &end_ticks)