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>
56 template <
typename...
Ts>
59 return (framework::has_type<As>(p) && ...);
75 template <
typename... T2s>
78 mGrouping{
std::make_shared<G>(
std::vector{grouping.asArrowTable()})},
79 mAssociated{
std::make_shared<
std::tuple<As...>>(
std::make_tuple(
std::get<has_type_at<As>(
pack<T2s...>{})>(associated)...))},
80 mIndexColumns{getMatchingIndexNode<G, As>()...},
83 if constexpr (soa::is_filtered_table<std::decay_t<G>>) {
84 mGrouping = std::make_shared<G>(std::vector{grouping.asArrowTable()}, grouping.getSelectedRows());
86 mGrouping = std::make_shared<G>(std::vector{grouping.asArrowTable()});
88 setMultipleGroupingTables<
sizeof...(As)>(grouping);
90 setCurrentGroupedCombination();
98 template <
typename... T2s>
99 void setTables(
const G& grouping,
const std::tuple<T2s...>& associated)
102 mGrouping = std::make_shared<G>(std::vector{grouping.asArrowTable()}, grouping.getSelectedRows());
104 mGrouping = std::make_shared<G>(std::vector{grouping.asArrowTable()});
106 mAssociated = std::make_shared<std::tuple<As...>>(std::make_tuple(std::get<has_type_at_v<As>(
pack<T2s...>{})>(associated)...));
107 setMultipleGroupingTables<
sizeof...(As)>(grouping);
109 setCurrentGroupedCombination();
113 template <std::size_t N,
typename T,
typename... Args>
116 if constexpr (N == 1) {
117 GroupingPolicy::setTables(
param, args...);
119 setMultipleGroupingTables<N - 1>(
param,
param, args...);
125 GroupingPolicy::moveToEnd();
133 setCurrentGroupedCombination();
147 return *mCurrentGrouped;
151 return (this->mIsEnd && rh.mIsEnd) || (this->mCurrent == rh.mCurrent);
155 return !(*
this == rh);
159 std::tuple<As...> getAssociatedTables()
161 return doGetAssociatedTables(std::make_index_sequence<
sizeof...(As)>());
164 template <std::size_t... Is>
165 std::tuple<As...> doGetAssociatedTables(std::index_sequence<Is...>)
167 return std::make_tuple(getAssociatedTable<Is>()...);
170 template <std::
size_t I>
171 auto getAssociatedTable()
173 uint64_t ind = *std::get<0>(std::get<I>(this->mCurrent).getIndices());
174 if (std::get<I>(*mAssociated).size() == 0) {
175 return std::get<I>(*mAssociated);
177 return std::get<I>(*mAssociated).sliceByCached(mIndexColumns[I], ind, *cache);
180 void setCurrentGroupedCombination()
183 auto& currentGrouping = GroupingPolicy::mCurrent;
184 mSlices.emplace(getAssociatedTables());
189 std::array<expressions::BindingNode,
sizeof...(As)> mIndexColumns;
190 std::shared_ptr<G> mGrouping;
191 std::shared_ptr<std::tuple<As...>> mAssociated;
192 std::optional<std::tuple<As...>> mSlices;
193 std::optional<GroupedIteratorType> mCurrentGrouped;
194 SliceCache* cache =
nullptr;
218 : mBegin(
GroupingPolicy(binningPolicy, catNeighbours, outsider), cache),
219 mEnd(
GroupingPolicy(binningPolicy, catNeighbours, outsider), cache) {}
220 template <
typename... T2s>
224 setTables(grouping, associated);
230 template <
typename... T2s>
231 void setTables(
const G& grouping,
const std::tuple<T2s...>& associated)
233 mBegin.setTables(grouping, associated);
234 mEnd.setTables(grouping, associated);
245 typename T::GroupedIterator;
252template <
typename G,
typename A1,
typename A2,
typename BP,
typename T1 =
int,
typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<BP, T1, G, G>>
254template <
typename G,
typename A,
typename BP,
typename T1 =
int,
typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<BP, T1, G, G>>
258template <
typename G,
typename A1,
typename A2,
typename A3,
typename BP,
typename T1 =
int,
typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<BP, T1, G, G, G>>
260template <
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
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
static consteval bool compatible(framework::pack< Ts... > p)
An expression tree node corresponding to a column binding.