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())
19 double sum = std::accumulate(wf.begin()+start,wf.begin()+start+nsample,0.0) / ((double)nsample);
28 auto n_t =
unsigned{0};
30 for(
int k = start;
k <
end; ++
k) {
31 if (k < 0 or k > (
int)(wf.size()) - 1)
continue;
36 if( n_t > 0 )
m /= n_t;
42 double std(
const std::vector<short>& wf,
const double ped_mean,
size_t start,
size_t nsample)
44 if(!nsample) nsample = wf.size();
45 if(start > wf.size() || (start+nsample) > wf.size())
50 for(
size_t index=start; index < (start+nsample); ++index)
52 sigma += pow( (wf[index] - ped_mean), 2 );
54 sigma = sqrt(sigma/((
double)(nsample)));
65 double bin_width = ((*res.second) - (*res.first)) / ((
double)nbins);
67 if(nbins==1 || bin_width == 0)
return ((*res.first) + bin_width /2.);
72 static std::vector<size_t> ctr_v(nbins,0);
73 for(
auto& v : ctr_v) v=0;
74 for(
auto const& v : mean_v) {
76 size_t index = int((v - (*res.first))/bin_width);
88 double mean_max_occurrence = 0;
89 double num_occurrence = 0;
90 for(
size_t bin=0;
bin<ctr_v.size(); ++
bin) {
92 if(ctr_v[
bin] != (*max_it))
continue;
94 mean_max_occurrence += ((*res.first) + bin_width / 2. + bin_width *
bin);
96 num_occurrence += 1.0;
99 return (mean_max_occurrence / num_occurrence);
106 if (val > 0)
return 1;
107 if (val < 0)
return -1;
117 TH1D th(
"th",
";;",bins,*min_it,*max_it);
119 for (
const auto &
m : v) th.Fill(
m);
121 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)
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
auto end(FixedBins< T, C > const &) noexcept
auto begin(FixedBins< T, C > const &) noexcept
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
std::vector< double > PedestalMean_t
double BinnedMaxTH1D(const std::vector< double > &v, int bins)