LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
RegionAboveThresholdFinder.cxx
Go to the documentation of this file.
1 
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();
21  end_ticks.clear();
22 
23  bool in_RAT = false;
24  for (unsigned int i_tick = 0; i_tick < signal.size(); i_tick++) {
25 
26  if (!in_RAT && signal[i_tick] >= fThreshold) {
27  start_ticks.push_back(i_tick);
28  in_RAT = true;
29  }
30  else if (in_RAT && signal[i_tick] < fThreshold) {
31  end_ticks.push_back(i_tick);
32  in_RAT = false;
33  }
34  }
35 
36  if (in_RAT) end_ticks.push_back(signal.size());
37 
38  if (end_ticks.size() != start_ticks.size())
39  throw std::runtime_error(
40  "ERROR in RegionAboveThresholdFinder: start and end tick vectors not equal.");
41 }
void FillStartAndEndTicks(const std::vector< float > &signal, std::vector< unsigned int > &start_ticks, std::vector< unsigned int > &end_ticks)