Skip to content

Commit

Permalink
DPL Analysis: fix for iterator not setting the originals correctly (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aalkin authored Dec 5, 2024
1 parent 808730c commit c15014c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
39 changes: 17 additions & 22 deletions Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -1451,12 +1451,7 @@ using PresliceOptional = PresliceBase<T, true, true>;

namespace o2::soa
{
template <typename T>
class FilteredBase;
template <typename T>
class Filtered;

template <typename T>
template <soa::is_table T>
class FilteredBase;
template <typename T>
class Filtered;
Expand Down Expand Up @@ -1728,7 +1723,8 @@ class Table
using columns_t = typename Parent::columns_t;
using external_index_columns_t = typename Parent::external_index_columns_t;
using bindings_pack_t = decltype([]<typename... C>(framework::pack<C...>) -> framework::pack<typename C::binding_t...> {}(external_index_columns_t{}));
static constexpr const std::array<TableRef, sizeof...(T)> originals{T::ref...};
// static constexpr const std::array<TableRef, sizeof...(T)> originals{T::ref...};
static constexpr auto originals = Parent::originals;
using policy_t = IP;
using parent_t = Parent;

Expand All @@ -1741,7 +1737,7 @@ class Table

template <typename P, typename... Os>
TableIteratorBase& operator=(TableIteratorBase<IP, P, Os...> other)
requires(P::ref::signature == Parent::ref::signature)
requires(P::ref.desc_hash == Parent::ref.desc_hash)
{
static_cast<base_iterator<IP>&>(*this) = static_cast<base_iterator<IP>>(other);
return *this;
Expand All @@ -1762,16 +1758,16 @@ class Table
return *this;
}

template <typename P, typename... Os>
TableIteratorBase(TableIteratorBase<IP, P, Os...> const& other)
requires(P::ref::signature == Parent::ref::signature)
template <typename P, typename O1, typename... Os>
TableIteratorBase(TableIteratorBase<IP, P, O1, Os...> const& other)
requires(P::ref.desc_hash == Parent::ref.desc_hash)
{
*this = other;
}

template <typename P, typename... Os>
TableIteratorBase(TableIteratorBase<IP, P, Os...>&& other) noexcept
requires(P::ref::signature == Parent::ref::signature)
template <typename P, typename O1, typename... Os>
TableIteratorBase(TableIteratorBase<IP, P, O1, Os...>&& other) noexcept
requires(P::ref.desc_hash == Parent::ref.desc_hash)
{
*this = other;
}
Expand Down Expand Up @@ -2503,7 +2499,7 @@ consteval auto getIndexTargets()
for (auto const& i : *mColumnIterator) { \
auto pos = mBinding.get<T>()->isInSelectedRows(i); \
if (pos > 0) { \
result.push_back(mBinding.get<T>()->iteratorAt(pos)); \
result.emplace_back(mBinding.get<T>()->iteratorAt(pos)); \
} \
} \
return result; \
Expand Down Expand Up @@ -3061,9 +3057,6 @@ consteval auto getIndexTargets()

namespace o2::soa
{
// template <typename T>
// class FilteredBase;

template <typename D, typename... Ts>
struct JoinFull : Table<o2::aod::Hash<"JOIN"_h>, D, o2::aod::Hash<"JOIN"_h>, Ts...> {
using base = Table<o2::aod::Hash<"JOIN"_h>, D, o2::aod::Hash<"JOIN"_h>, Ts...>;
Expand Down Expand Up @@ -3201,7 +3194,7 @@ constexpr auto concat(Ts const&... t)
return Concat<Ts...>{t...};
}

template <typename T>
template <soa::is_table T>
class FilteredBase : public T
{
public:
Expand Down Expand Up @@ -3473,7 +3466,8 @@ class Filtered : public FilteredBase<T>
public:
using base_t = T;
using self_t = Filtered<T>;
using table_t = typename FilteredBase<T>::table_t;
using table_t = typename T::table_t;
using columns_t = typename T::columns_t;

using iterator = T::template iterator_template_o<FilteredIndexPolicy, self_t>;
using unfiltered_iterator = T::template iterator_template_o<DefaultIndexPolicy, self_t>;
Expand Down Expand Up @@ -3633,9 +3627,10 @@ class Filtered<Filtered<T>> : public FilteredBase<typename T::table_t>
using self_t = Filtered<Filtered<T>>;
using base_t = T;
using table_t = typename FilteredBase<typename T::table_t>::table_t;
using columns_t = typename T::columns_t;

using iterator = FilteredBase<typename T::table_t>::iterator;
using unfiltered_iterator = FilteredBase<typename T::table_t>::unfiltered_iterator;
using iterator = typename T::template iterator_template_o<FilteredIndexPolicy, self_t>;
using unfiltered_iterator = typename T::template iterator_template_o<DefaultIndexPolicy, self_t>;
using const_iterator = iterator;

iterator begin()
Expand Down
9 changes: 9 additions & 0 deletions Framework/Core/test/test_GroupSlicer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
// or submit itself to any jurisdiction.

#include "Framework/ASoA.h"
#include "Framework/AnalysisDataModel.h"
#include "Framework/TableBuilder.h"
#include "Framework/GroupSlicer.h"
#include "Framework/ArrowTableSlicingCache.h"
#include <arrow/util/config.h>
#include <iostream>

#include <catch_amalgamated.hpp>

Expand Down Expand Up @@ -85,6 +87,13 @@ DECLARE_SOA_COLUMN(Lst, lst, std::vector<double>);
DECLARE_SOA_TABLE(EventExtra, "AOD", "EVTSXTRA", test::Arr, test::Boo, test::Lst);

} // namespace o2::aod
TEST_CASE("RelatedByIndex")
{
using Trks = soa::Join<aod::Tracks, aod::TracksExtra>;
CHECK(soa::relatedByIndex<aod::Collision, Trks>() == true);
CHECK(soa::relatedByIndex<aod::Collision, aod::Tracks>() == true);
}

TEST_CASE("GroupSlicerOneAssociated")
{
TableBuilder builderE;
Expand Down

0 comments on commit c15014c

Please sign in to comment.