12#ifndef FRAMEWORK_GROUPEDCOMBINATIONS_H
13#define FRAMEWORK_GROUPEDCOMBINATIONS_H
25template <
typename... T1s,
typename... T2s, std::size_t... Is>
28 return std::tuple_cat(std::make_tuple(std::get<Is>(
t1), std::get<Is>(t2))...);
31template <
typename... T1s,
typename... T2s>
37template <
typename T,
typename G>
38using is_index_to_g_t =
typename std::conditional<o2::soa::is_binding_compatible_v<G, typename T::binding_t>(), std::true_type, std::false_type>
::type;
40template <
typename G,
typename A>
43 using external_index_columns_pack =
typename A::external_index_columns_t;
45 static_assert(
pack_size(selected_indices_t{}) == 1,
"No matching index column from associated to grouping");
47 return expressions::BindingNode{index_column_t::mLabel, o2::framework::TypeIdHelpers::uniqueId<typename index_column_t::column_t>(), expressions::selectArrowType<typename index_column_t::type>()};
50template <
typename T1,
typename GroupingPolicy,
typename BP,
typename G,
typename... As>
51 requires(
sizeof...(As) > 0)
70 template <
typename... T2s>
73 mGrouping{
std::make_shared<G>(
std::vector{grouping.asArrowTable()})},
74 mAssociated{
std::make_shared<
std::tuple<As...>>(
std::make_tuple(
std::get<has_type_at<As>(
pack<T2s...>{})>(associated)...))},
75 mIndexColumns{getMatchingIndexNode<G, As>()...},
78 if constexpr (soa::is_filtered_table<std::decay_t<G>>) {
79 mGrouping = std::make_shared<G>(std::vector{grouping.asArrowTable()}, grouping.getSelectedRows());
81 mGrouping = std::make_shared<G>(std::vector{grouping.asArrowTable()});
83 setMultipleGroupingTables<
sizeof...(As)>(grouping);
85 setCurrentGroupedCombination();
93 template <
typename... T2s>
94 void setTables(
const G& grouping,
const std::tuple<T2s...>& associated)
97 mGrouping = std::make_shared<G>(std::vector{grouping.asArrowTable()}, grouping.getSelectedRows());
99 mGrouping = std::make_shared<G>(std::vector{grouping.asArrowTable()});
101 mAssociated = std::make_shared<std::tuple<As...>>(std::make_tuple(std::get<has_type_at_v<As>(
pack<T2s...>{})>(associated)...));
102 setMultipleGroupingTables<
sizeof...(As)>(grouping);
104 setCurrentGroupedCombination();
108 template <std::size_t N,
typename T,
typename... Args>
111 if constexpr (N == 1) {
112 GroupingPolicy::setTables(
param, args...);
114 setMultipleGroupingTables<N - 1>(
param,
param, args...);
120 GroupingPolicy::moveToEnd();
128 setCurrentGroupedCombination();
142 return *mCurrentGrouped;
146 return (this->mIsEnd && rh.mIsEnd) || (this->mCurrent == rh.mCurrent);
150 return !(*
this == rh);
154 std::tuple<As...> getAssociatedTables()
156 return doGetAssociatedTables(std::make_index_sequence<
sizeof...(As)>());
159 template <std::size_t... Is>
160 std::tuple<As...> doGetAssociatedTables(std::index_sequence<Is...>)
162 return std::make_tuple(getAssociatedTable<Is>()...);
165 template <std::
size_t I>
166 auto getAssociatedTable()
168 uint64_t ind = *std::get<0>(std::get<I>(this->mCurrent).getIndices());
169 if (std::get<I>(*mAssociated).size() == 0) {
170 return std::get<I>(*mAssociated);
172 return std::get<I>(*mAssociated).sliceByCached(mIndexColumns[I], ind, *cache);
175 void setCurrentGroupedCombination()
178 auto& currentGrouping = GroupingPolicy::mCurrent;
179 mSlices.emplace(getAssociatedTables());
184 std::array<expressions::BindingNode,
sizeof...(As)> mIndexColumns;
185 std::shared_ptr<G> mGrouping;
186 std::shared_ptr<std::tuple<As...>> mAssociated;
187 std::optional<std::tuple<As...>> mSlices;
188 std::optional<GroupedIteratorType> mCurrentGrouped;
189 SliceCache* cache =
nullptr;
213 : mBegin(
GroupingPolicy(binningPolicy, catNeighbours, outsider), cache),
214 mEnd(
GroupingPolicy(binningPolicy, catNeighbours, outsider), cache) {}
215 template <
typename... T2s>
219 setTables(grouping, associated);
225 template <
typename... T2s>
226 void setTables(
const G& grouping,
const std::tuple<T2s...>& associated)
228 mBegin.setTables(grouping, associated);
229 mEnd.setTables(grouping, associated);
240 typename T::GroupedIterator;
242 { t.begin() } -> std::same_as<typename T::iterator>;
243 { t.end() } -> std::same_as<typename T::iterator>;
248template <
typename G,
typename A1,
typename A2,
typename BP,
typename T1 =
int,
typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<BP, T1, G, G>>
250template <
typename G,
typename A,
typename BP,
typename T1 =
int,
typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<BP, T1, G, G>>
254template <
typename G,
typename A1,
typename A2,
typename A3,
typename BP,
typename T1 =
int,
typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<BP, T1, G, G, G>>
256template <
typename G,
typename A,
typename BP,
typename T1 =
int,
typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<BP, T1, G, G, G>>
GLint GLint GLsizei GLint GLenum GLenum type
GLboolean GLboolean GLboolean GLboolean a
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Defining PrimaryVertex explicitly as messageable.
auto interleaveTuplesImpl(std::tuple< T1s... > &t1, std::tuple< T2s... > &t2, std::index_sequence< Is... >)
decltype(interleave_pack(P1{}, P2{})) interleaved_pack_t
decltype(sequence_to_pack< T >(std::make_index_sequence< N >())) repeated_type_pack_t
typename std::conditional< o2::soa::is_binding_compatible_v< G, typename T::binding_t >(), std::true_type, std::false_type >::type is_index_to_g_t
std::decay_t< decltype(select_pack< Condition >(pack<>{}, Pack{}, CondPack{}))> selected_pack_multicondition
expressions::BindingNode getMatchingIndexNode()
auto interleaveTuples(std::tuple< T1s... > &t1, std::tuple< T2s... > &t2)
constexpr std::size_t pack_size(pack< Ts... > const &)
template function to determine number of types in a pack
typename pack_element< 0, T >::type pack_head_t
decltype(pack_to_tuple(P{})) pack_to_tuple_t
Defining DataPointCompositeObject explicitly as copiable.
~GroupedIterator()=default
GroupedIterator(const GroupingPolicy &groupingPolicy, SliceCache *cache_)
GroupedIteratorType * pointer
void setTables(const G &grouping, const std::tuple< T2s... > &associated)
GroupedIteratorType & reference
void setMultipleGroupingTables(const T ¶m, const Args &... args)
bool operator==(const GroupedIterator &rh) const
GroupedIterator & operator=(GroupedIterator const &)=default
bool operator!=(const GroupedIterator &rh) const
GroupedIterator(GroupedIterator const &)=default
GroupedIterator operator++(int)
GroupedIterator(const GroupingPolicy &groupingPolicy, const G &grouping, const std::tuple< T2s... > &associated, SliceCache *cache_)
std::forward_iterator_tag iterator_category
GroupedIteratorType value_type
GroupedIterator & operator++()
const_iterator end() const
const_iterator begin() const
GroupedCombinationsGenerator(const BP &binningPolicy, int catNeighbours, const T1 &outsider, const G &grouping, const std::tuple< T2s... > &associated, SliceCache *cache)
GroupedCombinationsGenerator(GroupedCombinationsGenerator const &)=default
~GroupedCombinationsGenerator()=default
GroupedCombinationsGenerator & operator=(GroupedCombinationsGenerator const &)=default
GroupedCombinationsGenerator(const BP &binningPolicy, int catNeighbours, const T1 &outsider, SliceCache *cache)
void setTables(const G &grouping, const std::tuple< T2s... > &associated)
pack_to_tuple_t< interleaved_pack_t< repeated_type_pack_t< typename G::iterator, sizeof...(As)>, pack< As... > > > GroupedIteratorType
An expression tree node corresponding to a column binding.