1 #ifndef larana_OPTICALDETECTOR_UTILFUNC_CXX 2 #define larana_OPTICALDETECTOR_UTILFUNC_CXX 15 double mean(
const std::vector<short>& wf,
size_t start,
size_t nsample)
17 if(!nsample) nsample = wf.size();
18 if(start > wf.size() || (start+nsample) > wf.size())
21 double sum = std::accumulate(wf.begin()+start,wf.begin()+start+nsample,0.0) / ((double)nsample);
30 auto n_t =
unsigned{0};
32 for(
int k = start; k <
end; ++k) {
33 if (k < 0 or k > (
int)(wf.size()) - 1)
continue;
38 if( n_t > 0 ) m /= n_t;
44 double std(
const std::vector<short>& wf,
const double ped_mean,
size_t start,
size_t nsample)
46 if(!nsample) nsample = wf.size();
47 if(start > wf.size() || (start+nsample) > wf.size())
52 for(
size_t index=start; index < (start+nsample); ++index)
54 sigma += pow( (wf[index] - ped_mean), 2 );
56 sigma = sqrt(sigma/((
double)(nsample)));
67 double bin_width = ((*res.second) - (*res.first)) / ((
double)nbins);
69 if(nbins==1 || bin_width == 0)
return ((*res.first) + bin_width /2.);
74 static std::vector<size_t> ctr_v(nbins,0);
75 for(
auto& v : ctr_v) v=0;
76 for(
auto const& v : mean_v) {
78 size_t index = int((v - (*res.first))/bin_width);
90 double mean_max_occurrence = 0;
91 double num_occurrence = 0;
92 for(
size_t bin=0;
bin<ctr_v.size(); ++
bin) {
94 if(ctr_v[
bin] != (*max_it))
continue;
96 mean_max_occurrence += ((*res.first) + bin_width / 2. + bin_width *
bin);
98 num_occurrence += 1.0;
101 return (mean_max_occurrence / num_occurrence);
108 if (val > 0)
return 1;
109 if (val < 0)
return -1;
119 TH1D th(
"th",
";;",bins,*min_it,*max_it);
121 for (
const auto & m : v) th.Fill(m);
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)
std::vector< evd::details::RawDigitInfo_t >::const_iterator begin(RawDigitCacheDataClass const &cache)
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
std::vector< double > PedestalMean_t
double BinnedMaxTH1D(const std::vector< double > &v, int bins)