13 double mean(
const std::vector<short>& wf,
size_t start,
size_t nsample)
15 if (!nsample) nsample = wf.size();
16 if (start > wf.size() || (start + nsample) > wf.size())
20 std::accumulate(wf.begin() + start, wf.begin() + start + nsample, 0.0) / ((double)nsample);
29 auto n_t =
unsigned{0};
31 for (
int k = start; k <
end; ++k) {
32 if (k < 0 or k > (
int)(wf.size()) - 1)
continue;
37 if (n_t > 0) m /= n_t;
43 double std(
const std::vector<short>& wf,
const double ped_mean,
size_t start,
size_t nsample)
45 if (!nsample) nsample = wf.size();
46 if (start > wf.size() || (start + nsample) > wf.size())
51 for (
size_t index = start; index < (start + nsample); ++index)
53 sigma += pow((wf[index] - ped_mean), 2);
55 sigma = sqrt(sigma / ((
double)(nsample)));
66 double bin_width = ((*res.second) - (*res.first)) / ((
double)nbins);
68 if (nbins == 1 || bin_width == 0)
return ((*res.first) + bin_width / 2.);
73 static std::vector<size_t> ctr_v(nbins, 0);
76 for (
auto const& v : mean_v) {
78 size_t index = int((v - (*res.first)) / bin_width);
89 double mean_max_occurrence = 0;
90 double num_occurrence = 0;
91 for (
size_t bin = 0;
bin < ctr_v.size(); ++
bin) {
93 if (ctr_v[
bin] != (*max_it))
continue;
95 mean_max_occurrence += ((*res.first) + bin_width / 2. + bin_width *
bin);
97 num_occurrence += 1.0;
100 return (mean_max_occurrence / num_occurrence);
107 if (val > 0)
return 1;
108 if (val < 0)
return -1;
118 TH1D th(
"th",
";;", bins, *min_it, *max_it);
120 for (
const auto& m : v)
123 return th.GetXaxis()->GetBinCenter(th.GetMaximumBin());
Class def header for exception classes in OpticalDetector package.
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
double BinnedMaxOccurrence(const PedestalMean_t &mean_v, const size_t nbins)
double edge_aware_mean(const std::vector< short > &wf, int start, int end)
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
std::vector< double > PedestalMean_t
double BinnedMaxTH1D(const std::vector< double > &v, int bins)