From 91614c7a0c7a945c495cf8ea8195c90e08cb229a Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Wed, 5 Feb 2025 10:27:27 +0100 Subject: [PATCH 1/2] DPL Analysis: make Attach preserve the filtered status of the table --- Framework/Core/include/Framework/ASoA.h | 4 ++++ .../Core/include/Framework/AnalysisHelpers.h | 15 +++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index be6329b48b7eb..453569cc45c6a 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -2283,6 +2283,10 @@ O2ORIGIN("CONC"); O2HASH("CONC/0"); O2ORIGIN("TEST"); O2HASH("TEST/0"); +O2HASH("ATT/0"); +O2ORIGIN("ATT"); +O2HASH("EXT/0"); +O2ORIGIN("EXT"); } // namespace o2::aod #define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \ diff --git a/Framework/Core/include/Framework/AnalysisHelpers.h b/Framework/Core/include/Framework/AnalysisHelpers.h index d84c9714b2f30..b673e651a3815 100644 --- a/Framework/Core/include/Framework/AnalysisHelpers.h +++ b/Framework/Core/include/Framework/AnalysisHelpers.h @@ -698,18 +698,29 @@ namespace o2::soa template auto Extend(T const& table) { - using output_t = Join, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Cs...>>; + using output_t = Join, o2::aod::Hash<"EXT/0"_h>, o2::aod::Hash<"EXT"_h>, Cs...>>; return output_t{{o2::framework::spawner(framework::pack{}, {table.asArrowTable()}, "dynamicExtension"), table.asArrowTable()}, 0}; } /// Template function to attach dynamic columns on-the-fly (e.g. inside /// process() function). Dynamic columns need to be compatible with the table. template + requires(!soa::is_filtered_table) auto Attach(T const& table) { - using output_t = Join, o2::aod::Hash<"JOIN/0"_h>, o2::aod::Hash<"JOIN"_h>, Cs...>>; + using output_t = Join, o2::aod::Hash<"ATT/0"_h>, o2::aod::Hash<"ATT"_h>, Cs...>>; return output_t{{table.asArrowTable()}, table.offset()}; } + +template +auto Attach(T const& table) +{ + using output_t = soa::Filtered, o2::aod::Hash<"ATT/0"_h>, o2::aod::Hash<"ATT"_h>, Cs...>>>; + SelectionVector selection; + selection.reserve(table->getSelectedRows().size()); + std::copy(table->getSelectedRows().begin(), table->getSelectedRows().end(), std::back_inserter(selection)); + return output_t{{table.asArrowTable()}, std::move(selection), table.offset()}; +} } // namespace o2::soa #endif // o2_framework_AnalysisHelpers_H_DEFINED From e421f95d3763cd70929c068e67a64d3ab2708907 Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Thu, 13 Mar 2025 17:41:44 +0100 Subject: [PATCH 2/2] Update AnalysisHelpers.h --- Framework/Core/include/Framework/AnalysisHelpers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisHelpers.h b/Framework/Core/include/Framework/AnalysisHelpers.h index b673e651a3815..bcad75454d713 100644 --- a/Framework/Core/include/Framework/AnalysisHelpers.h +++ b/Framework/Core/include/Framework/AnalysisHelpers.h @@ -717,8 +717,8 @@ auto Attach(T const& table) { using output_t = soa::Filtered, o2::aod::Hash<"ATT/0"_h>, o2::aod::Hash<"ATT"_h>, Cs...>>>; SelectionVector selection; - selection.reserve(table->getSelectedRows().size()); - std::copy(table->getSelectedRows().begin(), table->getSelectedRows().end(), std::back_inserter(selection)); + selection.reserve(table.getSelectedRows().size()); + std::copy(table.getSelectedRows().begin(), table.getSelectedRows().end(), std::back_inserter(selection)); return output_t{{table.asArrowTable()}, std::move(selection), table.offset()}; } } // namespace o2::soa