12#ifndef FRAMEWORK_BINNINGPOLICY_H
13#define FRAMEWORK_BINNINGPOLICY_H
21namespace binning_helpers
26 int nBins =
static_cast<int>(
bins[0]);
28 expanded.resize(nBins + 2);
30 for (
int i = 0;
i <= nBins;
i++) {
37template <std::
size_t N>
41 static_assert(N <= 3,
"No default binning for more than 3 columns, you need to implement a binning class yourself");
42 for (
int i = 0;
i < N;
i++) {
47 template <
typename...
Ts>
50 static_assert(
sizeof...(Ts) == N,
"There must be the same number of binning axes and data values/columns");
52 unsigned int i = 2,
j = 2, k = 2;
55 if (std::get<0>(
data) < this->
mBins[0][1]) {
58 if constexpr (N > 1) {
59 if (std::get<1>(
data) < this->
mBins[1][1]) {
63 if constexpr (N > 2) {
64 if (std::get<2>(
data) < this->
mBins[2][1]) {
74 for (;
i < this->
mBins[0].size(); i++) {
77 if constexpr (N > 1) {
78 for (;
j < this->
mBins[1].size();
j++) {
81 if constexpr (N > 2) {
82 for (; k < this->
mBins[2].size(); k++) {
83 if (std::get<2>(
data) < this->
mBins[2][k]) {
84 return getBinAt(
i,
j, k);
93 return getBinAt(
i,
j, k);
102 if constexpr (N > 2) {
103 for (k = 2; k < this->
mBins[2].size(); k++) {
104 if (std::get<2>(
data) < this->
mBins[2][k]) {
105 return getBinAt(
i,
j, k);
112 return getBinAt(
i,
j, k);
122 if constexpr (N > 1) {
123 for (
j = 2;
j < this->
mBins[1].size();
j++) {
126 if constexpr (N > 2) {
127 for (k = 2; k < this->
mBins[2].size(); k++) {
128 if (std::get<2>(
data) < this->
mBins[2][k]) {
129 return getBinAt(
i,
j, k);
135 return getBinAt(
i,
j, k);
141 if constexpr (N > 2) {
142 for (k = 2; k < this->
mBins[2].size(); k++) {
143 if (std::get<2>(
data) < this->
mBins[2][k]) {
144 return getBinAt(
i,
j, k);
150 return getBinAt(
i,
j, k);
156 return getBinsCount(
mBins[0]);
162 if constexpr (N == 1) {
165 return getBinsCount(
mBins[1]);
171 if constexpr (N < 3) {
174 return getBinsCount(
mBins[2]);
180 if constexpr (N == 1) {
183 if constexpr (N == 2) {
186 if constexpr (N == 2) {
192 std::array<std::vector<double>, N>
mBins;
199 int getBinAt(
unsigned int iRaw,
unsigned int jRaw,
unsigned int kRaw)
const
201 int shiftBinsWithoutOverflow = getOverflowShift();
202 unsigned int i = iRaw - 1 - shiftBinsWithoutOverflow;
203 unsigned int j = jRaw - 1 - shiftBinsWithoutOverflow;
204 unsigned int k = kRaw - 1 - shiftBinsWithoutOverflow;
206 if constexpr (N == 1) {
208 }
else if constexpr (N == 2) {
209 return i +
j * xBinsCount;
210 }
else if constexpr (N == 3) {
217 int getOverflowShift()
const
223 int getBinsCount(std::vector<double>
const&
bins)
const
225 return bins.size() - 1 - getOverflowShift();
229template <
typename,
typename...>
232template <
typename...
Ts,
typename... Ls>
238 template <
typename T,
typename T2>
239 auto getBinningValue(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1)
const
242 if (globalIndex != -1) {
243 rowIterator.setCursor(globalIndex);
245 return std::get<T2>(mBinningFunctions)(rowIterator);
247 return soa::row_helpers::getSingleRowData<T, T2>(table, rowIterator, ci, ai, globalIndex);
251 template <
typename T>
252 auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1)
const
254 return std::make_tuple(getBinningValue<T, Ts>(rowIterator, table, ci, ai, globalIndex)...);
257 template <
typename T>
258 auto getBinningValues(
typename T::iterator rowIterator, T& table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1)
const
260 return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
263 template <
typename... T2s>
272 std::tuple<Ls...> mBinningFunctions;
275template <
typename...
Ts>
281 template <
typename T>
282 auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1)
const
284 return std::make_tuple(soa::row_helpers::getSingleRowData<T, Ts>(table, rowIterator, ci, ai, globalIndex)...);
287 template <
typename T>
288 auto getBinningValues(
typename T::iterator rowIterator, T& table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1)
const
290 return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
293 int getBin(std::tuple<typename Ts::type...>
const&
data)
const
306 template <
typename T>
307 auto getBinningValues(T& rowIterator, arrow::Table* table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1)
const
309 return std::make_tuple(soa::row_helpers::getSingleRowData<T, C>(table, rowIterator, ci, ai, globalIndex));
312 template <
typename T>
313 auto getBinningValues(
typename T::iterator rowIterator, T& table, uint64_t ci = -1, uint64_t ai = -1, uint64_t globalIndex = -1)
const
315 return getBinningValues(rowIterator, table.asArrowTable().get(), ci, ai, globalIndex);
320 return std::get<0>(
data);
void expandConstantBinning(std::vector< double > const &bins, std::vector< double > &expanded)
Defining PrimaryVertex explicitly as messageable.
std::decay_t< decltype(prune_voids_pack(pack<>{}, with_condition_pack< Condition, Types... >{}))> selected_pack
constexpr double VARIABLE_WIDTH
std::conditional_t< is_persistent_column< C >, std::true_type, std::false_type > is_persistent_column_t
Defining DataPointCompositeObject explicitly as copiable.
int getXBinsCount() const
int getBin(std::tuple< Ts... > const &data) const
int getYBinsCount() const
int getZBinsCount() const
BinningPolicyBase(std::array< std::vector< double >, N > bins, bool ignoreOverflows=true)
int getAllBinsCount() const
std::array< std::vector< double >, N > mBins
auto getBinningValues(T &rowIterator, arrow::Table *table, uint64_t ci=-1, uint64_t ai=-1, uint64_t globalIndex=-1) const
auto getBinningValues(typename T::iterator rowIterator, T &table, uint64_t ci=-1, uint64_t ai=-1, uint64_t globalIndex=-1) const
framework::selected_pack< o2::soa::is_persistent_column_t, Ts... > persistent_columns_t
ColumnBinningPolicy(std::array< std::vector< double >, sizeof...(Ts)> bins, bool ignoreOverflows=true)
int getBin(std::tuple< typename Ts::type... > const &data) const
auto getBinningValues(typename T::iterator rowIterator, T &table, uint64_t ci=-1, uint64_t ai=-1, uint64_t globalIndex=-1) const
framework::selected_pack< o2::soa::is_persistent_column_t, Ts... > persistent_columns_t
auto getBinningValue(T &rowIterator, arrow::Table *table, uint64_t ci=-1, uint64_t ai=-1, uint64_t globalIndex=-1) const
FlexibleBinningPolicy(std::tuple< Ls... > const &lambdaPtrs, std::array< std::vector< double >, sizeof...(Ts)> bins, bool ignoreOverflows=true)
int getBin(std::tuple< T2s... > const &data) const
auto getBinningValues(T &rowIterator, arrow::Table *table, uint64_t ci=-1, uint64_t ai=-1, uint64_t globalIndex=-1) const
framework::selected_pack< o2::soa::is_persistent_column_t, C > persistent_columns_t
NoBinningPolicy()=default
auto getBinningValues(typename T::iterator rowIterator, T &table, uint64_t ci=-1, uint64_t ai=-1, uint64_t globalIndex=-1) const
auto getBinningValues(T &rowIterator, arrow::Table *table, uint64_t ci=-1, uint64_t ai=-1, uint64_t globalIndex=-1) const
int getBin(std::tuple< typename C::type > const &data) const