40 std::vector<double> cum_sum(
histo->GetNbinsX() + 2);
49 const double last_value = cum_sum.back();
51 [&last_value](
auto &
c) { return c / last_value; });
61 if (
histo->GetNbinsX() <= 3 ||
histo->Integral() == 0.)
63 return std::make_pair<double>(0, 0);
67 double min_width =
histo->GetBinCenter(
histo->GetNbinsX()) -
histo->GetBinCenter(1);
68 std::pair<int, int> window_bin(0,
histo->GetNbinsX() + 1);
70 for (
int ibin = 0; ibin !=
histo->GetNbinsX() + 1; ++ibin)
72 const double target_prob =
prob + cum_sum[ibin];
76 const auto up_it = std::upper_bound(cum_sum.begin() + ibin, cum_sum.end(), target_prob);
78 const double width =
histo->GetBinCenter(end_bin) -
histo->GetBinCenter(ibin);
80 if (
width < min_width)
83 window_bin.first = ibin;
84 window_bin.second = end_bin;
87 return std::make_pair<double>(
histo->GetBinCenter(window_bin.first),
histo->GetBinCenter(window_bin.second));
94 return 0.5 * (window.second - window.first);
100 template <
typename T>