4 #include "NDimensionalExecutor.h"
22 : fMinBounds(minBounds), fMaxBounds(maxBounds)
29 throw std::invalid_argument(
"Min and max bounds vectors must have the same size.");
32 throw std::invalid_argument(
"Bounds vectors cannot be empty.");
39 throw std::invalid_argument(
"Min bound (" + std::to_string(
fMinBounds[i]) +
40 ") cannot be greater than max bound (" + std::to_string(
fMaxBounds[i]) +
41 ") for dimension " + std::to_string(i));
54 if (hist ==
nullptr) {
55 throw std::invalid_argument(
"THnSparse pointer cannot be null.");
60 if (hist->GetNbins() <= 0) {
61 throw std::invalid_argument(
"THnSparse histogram is empty.");
69 for (
int i = 0; i < hist->GetNdimensions(); ++i) {
71 fMaxBounds.push_back(hist->GetAxis(i)->GetNbins());
std::vector< int > fMinBounds
Minimum bounds for each dimension.
std::vector< int > fMaxBounds
Maximum bounds for each dimension.
std::vector< int > fCurrentCoords
Current coordinates during iteration.
bool Increment()
Increment the current coordinates to the next point in the N-dimensional space.
NDimensionalExecutor(const std::vector< int > &minBounds, const std::vector< int > &maxBounds)
Constructor from min/max bounds for each dimension.
size_t fNumDimensions
Number of dimensions.
void Execute(const std::function< void(const std::vector< int > &coords)> &func)
Execute a function over all coordinates in the N-dimensional space.