49 iterator(
size_t begin1,
size_t end1,
size_t begin2)
86 std::vector<size_t> result;
87 result.reserve(this->
size());
88 for (
size_t idx : *
this) {
89 result.push_back(idx);
102 template <AxisBoundaryType bdt>
116 m_width((xmax - xmin) / nBins),
142 return neighborHoodIndices(idx, std::make_pair(-
size,
size));
156 std::enable_if_t<T == AxisBoundaryType::Open, int> = 0>
158 std::pair<int, int> sizes = {
160 constexpr
int min = 0;
161 const int max = getNBins() + 1;
162 const int itmin = std::clamp(static_cast<int>(idx + sizes.first), min, max);
164 std::clamp(static_cast<int>(idx + sizes.second), min, max);
178 std::enable_if_t<T == AxisBoundaryType::Bound, int> = 0>
180 std::pair<int, int> sizes = {
182 if (idx <= 0 || idx >= (getNBins() + 1)) {
185 constexpr
int min = 1;
186 const int max = getNBins();
187 const int itmin = std::clamp(static_cast<int>(idx) + sizes.first, min, max);
189 std::clamp(static_cast<int>(idx) + sizes.second, min, max);
203 std::enable_if_t<T == AxisBoundaryType::Closed, int> = 0>
205 std::pair<int, int> sizes = {
208 if (idx <= 0 || idx >= (getNBins() + 1)) {
215 const int max = getNBins();
216 sizes.first = std::clamp(sizes.first, -max, max);
217 sizes.second = std::clamp(sizes.second, -max, max);
218 if (std::abs(sizes.first - sizes.second) >= max) {
219 sizes.first = 1 -
idx;
220 sizes.second = max -
idx;
230 const int itmin = idx + sizes.first;
231 const int itmax = idx + sizes.second;
232 const size_t itfirst = wrapBin(itmin);
233 const size_t itlast = wrapBin(itmax);
234 if (itfirst <= itlast) {
235 return NeighborHoodIndices(itfirst, itlast + 1);
237 return NeighborHoodIndices(itfirst, max + 1, 1, itlast + 1);
248 std::enable_if_t<T == AxisBoundaryType::Open, int> = 0>
250 return std::max(
std::min(bin, static_cast<int>(getNBins()) + 1), 0);
260 std::enable_if_t<T == AxisBoundaryType::Bound, int> = 0>
262 return std::max(
std::min(bin, static_cast<int>(getNBins())), 1);
272 std::enable_if_t<T == AxisBoundaryType::Closed, int> = 0>
274 const int w = getNBins();
275 return 1 + (w + ((bin - 1) % w)) % w;
291 static_cast<int>(std::floor((x - getMin()) / getBinWidth()) + 1));
310 return getMin() + (bin - 1) * getBinWidth();
324 return getMin() + bin * getBinWidth();
335 return getMin() + (bin - 0.5) * getBinWidth();
351 size_t getNBins()
const override {
return m_bins; }
365 std::vector<ActsScalar> binEdges;
366 for (
size_t i = 1;
i <= m_bins;
i++) {
367 binEdges.push_back(getBinLowerBound(
i));
369 binEdges.push_back(getBinUpperBound(m_bins));
388 template <AxisBoundaryType bdt>
400 Axis(std::vector<ActsScalar> binEdges) : m_binEdges(std::
move(binEdges)) {}
425 return neighborHoodIndices(idx, std::make_pair(-
size,
size));
439 std::enable_if_t<T == AxisBoundaryType::Open, int> = 0>
441 std::pair<int, int> sizes = {
443 constexpr
int min = 0;
444 const int max = getNBins() + 1;
445 const int itmin = std::max(min, static_cast<int>(idx) + sizes.first);
446 const int itmax =
std::min(max, static_cast<int>(idx) + sizes.second);
460 std::enable_if_t<T == AxisBoundaryType::Bound, int> = 0>
462 std::pair<int, int> sizes = {
464 if (idx <= 0 || idx >= (getNBins() + 1)) {
467 constexpr
int min = 1;
468 const int max = getNBins();
469 const int itmin = std::max(min, static_cast<int>(idx) + sizes.first);
470 const int itmax =
std::min(max, static_cast<int>(idx) + sizes.second);
484 std::enable_if_t<T == AxisBoundaryType::Closed, int> = 0>
486 std::pair<int, int> sizes = {
489 if (idx <= 0 || idx >= (getNBins() + 1)) {
496 const int max = getNBins();
497 sizes.first = std::clamp(sizes.first, -max, max);
498 sizes.second = std::clamp(sizes.second, -max, max);
499 if (std::abs(sizes.first - sizes.second) >= max) {
500 sizes.first = 1 -
idx;
501 sizes.second = max -
idx;
511 const int itmin = idx + sizes.first;
512 const int itmax = idx + sizes.second;
513 const size_t itfirst = wrapBin(itmin);
514 const size_t itlast = wrapBin(itmax);
515 if (itfirst <= itlast) {
516 return NeighborHoodIndices(itfirst, itlast + 1);
518 return NeighborHoodIndices(itfirst, max + 1, 1, itlast + 1);
529 std::enable_if_t<T == AxisBoundaryType::Open, int> = 0>
531 return std::max(
std::min(bin, static_cast<int>(getNBins()) + 1), 0);
541 std::enable_if_t<T == AxisBoundaryType::Bound, int> = 0>
543 return std::max(
std::min(bin, static_cast<int>(getNBins())), 1);
553 std::enable_if_t<T == AxisBoundaryType::Closed, int> = 0>
555 const int w = getNBins();
556 return 1 + (w + ((bin - 1) % w)) % w;
584 return m_binEdges.at(bin) - m_binEdges.at(bin - 1);
598 return m_binEdges.at(bin - 1);
621 return 0.5 * (getBinLowerBound(bin) + getBinUpperBound(bin));
637 size_t getNBins()
const override {
return m_binEdges.size() - 1; }
647 return (m_binEdges.front() <=
x) && (x < m_binEdges.back());
652 std::vector<ActsScalar>
getBinEdges()
const override {
return m_binEdges; }