223 std::vector<float> locWaveform = waveform;
226 std::sort(locWaveform.begin(), locWaveform.end(),[](
const auto&
left,
const auto&
right){
return std::fabs(
left) < std::fabs(
right);});
229 float sumWaveform = std::accumulate(locWaveform.begin(),locWaveform.begin() + locWaveform.size()/2, 0.);
230 float meanWaveform = sumWaveform / float(locWaveform.size()/2);
232 std::vector<float> locWaveformDiff(locWaveform.size()/2);
234 std::transform(locWaveform.begin(),locWaveform.begin() + locWaveform.size()/2,locWaveformDiff.begin(), std::bind(std::minus<float>(),std::placeholders::_1,meanWaveform));
236 float localRMS = std::inner_product(locWaveformDiff.begin(), locWaveformDiff.end(), locWaveformDiff.begin(), 0.);
238 localRMS = std::sqrt(std::max(
float(0.),localRMS /
float(locWaveformDiff.size())));
240 float threshold = 6. * localRMS;
242 std::vector<float>::iterator threshItr = std::find_if(locWaveform.begin(),locWaveform.end(),[threshold](
const auto& val){
return std::fabs(val) > threshold;});
245 int minNumBins = std::max(
int(0.8 * locWaveform.size()),
int(
std::distance(locWaveform.begin(),threshItr)));
248 float aveSum = std::accumulate(locWaveform.begin(), locWaveform.begin() + minNumBins, 0.);
249 float newPedestal = aveSum / minNumBins;
252 locWaveformDiff.resize(minNumBins);
254 std::transform(locWaveform.begin(),locWaveform.begin() + minNumBins,locWaveformDiff.begin(), std::bind(std::minus<float>(),std::placeholders::_1,newPedestal));
256 localRMS = std::inner_product(locWaveform.begin(), locWaveform.begin() + minNumBins, locWaveform.begin(), 0.);
257 localRMS = std::sqrt(std::max(
float(0.),localRMS /
float(minNumBins)));
260 std::transform(waveform.begin(), waveform.end(), fixedWaveform.begin(), [newPedestal](
const auto& val){
return val - newPedestal;});
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.