From 970bcded2f9b54a0fff1832ffaf00c597257ac8e Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Wed, 18 Jun 2025 13:08:57 +0200 Subject: [PATCH 1/2] DPL Analysis: add PresliceGroup --- Framework/Core/include/Framework/ASoA.h | 18 ++++++++++++++++++ .../Core/include/Framework/AnalysisManagers.h | 18 ++++++++++++++++-- Framework/Core/test/test_AnalysisTask.cxx | 15 +++++++++++++++ Framework/Core/test/test_Concepts.cxx | 9 +++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 592864528244c..2d7bfebb71526 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1465,6 +1465,24 @@ using PresliceOptional = PresliceBase; template concept is_preslice = std::derived_from; +/// Can be user to group together a number of Preslice declaration +/// to avoid the limit of 100 data members per task +/// +/// struct MyTask +/// struct : public PresliceGroup { +/// Preslice perCol = aod::track::collisonId; +/// Preslice perMcCol = aod::mcparticle::mcCollisionId; +/// } preslices; +/// +/// individual components can be access with +/// +/// preslices.perCol; +struct PresliceGroup { +}; + +template +concept is_preslice_group = std::derived_from; + } // namespace o2::framework namespace o2::soa diff --git a/Framework/Core/include/Framework/AnalysisManagers.h b/Framework/Core/include/Framework/AnalysisManagers.h index 2a052c0b07218..44c0346bec800 100644 --- a/Framework/Core/include/Framework/AnalysisManagers.h +++ b/Framework/Core/include/Framework/AnalysisManagers.h @@ -543,7 +543,7 @@ static void setGroupedCombination(C& comb, TG& grouping, std::tuple& asso /// Preslice handling template - requires(!is_preslice) + requires(!is_preslice && !is_preslice_group) bool registerCache(T&, Cache&, Cache&) { return false; @@ -585,8 +585,15 @@ bool registerCache(T& preslice, Cache&, Cache& bsksU) return true; } +template +bool registerCache(T& presliceGroup, Cache& bsks, Cache& bsksU) +{ + homogeneous_apply_refs([&bsks, &bsksU](auto& preslice){ return registerCache(preslice, bsks, bsksU); }, presliceGroup); + return true; +} + template - requires(!is_preslice) + requires(!is_preslice && !is_preslice_group) bool updateSliceInfo(T&, ArrowTableSlicingCache&) { return false; @@ -618,6 +625,13 @@ static bool updateSliceInfo(T& preslice, ArrowTableSlicingCache& cache) return true; } +template +static bool updateSliceInfo(T& presliceGroup, ArrowTableSlicingCache& cache) +{ + homogeneous_apply_refs([&cache](auto& preslice){ return updateSliceInfo(preslice, cache); }, presliceGroup); + return true; +} + /// Process switches handling template static bool setProcessSwitch(std::pair, T&) diff --git a/Framework/Core/test/test_AnalysisTask.cxx b/Framework/Core/test/test_AnalysisTask.cxx index ff0f7da1acaab..f5d8c4c43bc38 100644 --- a/Framework/Core/test/test_AnalysisTask.cxx +++ b/Framework/Core/test/test_AnalysisTask.cxx @@ -13,6 +13,7 @@ #include "TestClasses.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" +#include #include @@ -185,6 +186,17 @@ struct LTask { void process(aod::McCollision const&, soa::SmallGroups> const&) {} }; +struct MTask { + SliceCache cache; + struct : public PresliceGroup { + Preslice perCol = aod::track::collisionId; + PresliceOptional perPart = aod::mctracklabel::mcParticleId; + PresliceUnsorted perMcCol = aod::mccollisionlabel::mcCollisionId; + PresliceUnsortedOptional perMcColopt = aod::mccollisionlabel::mcCollisionId; + } foo; + void process(aod::McCollision const&, soa::SmallGroups> const&) {} +}; + TEST_CASE("AdaptorCompilation") { auto cfgc = makeEmptyConfigContext(); @@ -258,6 +270,9 @@ TEST_CASE("AdaptorCompilation") auto task12 = adaptAnalysisTask(*cfgc, TaskName{"test12"}); REQUIRE(task12.inputs.size() == 3); + + auto task13 = adaptAnalysisTask(*cfgc, TaskName{"test13"}); + REQUIRE(task13.inputs.size() == 3); } TEST_CASE("TestPartitionIteration") diff --git a/Framework/Core/test/test_Concepts.cxx b/Framework/Core/test/test_Concepts.cxx index 4bf4f977ec3a8..3ceba91bf1da2 100644 --- a/Framework/Core/test/test_Concepts.cxx +++ b/Framework/Core/test/test_Concepts.cxx @@ -87,6 +87,14 @@ TEST_CASE("IdentificationConcepts") Preslice ps = o2::aod::track::collisionId; REQUIRE(is_preslice); + struct : PresliceGroup { + Preslice pc = o2::aod::track::collisionId; + Preslice pmcc = o2::aod::mcparticle::mcCollisionId; + } preslices; + REQUIRE(is_preslice_group); + REQUIRE(is_preslice); + REQUIRE(is_preslice); + REQUIRE(has_filtered_policy::iterator>); REQUIRE(is_filtered_iterator::iterator>); @@ -162,6 +170,7 @@ TEST_CASE("IdentificationConcepts") expressions::Filter f = o2::aod::track::pt > 1.0f; REQUIRE(expressions::is_filter); + // Combinations using C = SameKindPair>; REQUIRE(is_combinations_generator); } From 1ddd2ced26faa47783202ab7a251d403b6852fcb Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Wed, 18 Jun 2025 11:12:17 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- Framework/Core/include/Framework/AnalysisManagers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisManagers.h b/Framework/Core/include/Framework/AnalysisManagers.h index 44c0346bec800..3d963d54643d5 100644 --- a/Framework/Core/include/Framework/AnalysisManagers.h +++ b/Framework/Core/include/Framework/AnalysisManagers.h @@ -588,7 +588,7 @@ bool registerCache(T& preslice, Cache&, Cache& bsksU) template bool registerCache(T& presliceGroup, Cache& bsks, Cache& bsksU) { - homogeneous_apply_refs([&bsks, &bsksU](auto& preslice){ return registerCache(preslice, bsks, bsksU); }, presliceGroup); + homogeneous_apply_refs([&bsks, &bsksU](auto& preslice) { return registerCache(preslice, bsks, bsksU); }, presliceGroup); return true; } @@ -628,7 +628,7 @@ static bool updateSliceInfo(T& preslice, ArrowTableSlicingCache& cache) template static bool updateSliceInfo(T& presliceGroup, ArrowTableSlicingCache& cache) { - homogeneous_apply_refs([&cache](auto& preslice){ return updateSliceInfo(preslice, cache); }, presliceGroup); + homogeneous_apply_refs([&cache](auto& preslice) { return updateSliceInfo(preslice, cache); }, presliceGroup); return true; }