Skip to content

Commit 6f78cf3

Browse files
authored
DPL Analysis: add PresliceGroup (#14418)
1 parent 50d26e3 commit 6f78cf3

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

Framework/Core/include/Framework/ASoA.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,24 @@ using PresliceOptional = PresliceBase<T, PreslicePolicySorted, true>;
14681468
template <typename T>
14691469
concept is_preslice = std::derived_from<T, PreslicePolicyBase>;
14701470

1471+
/// Can be user to group together a number of Preslice declaration
1472+
/// to avoid the limit of 100 data members per task
1473+
///
1474+
/// struct MyTask
1475+
/// struct : public PresliceGroup {
1476+
/// Preslice<aod::Tracks> perCol = aod::track::collisonId;
1477+
/// Preslice<aod::McParticles> perMcCol = aod::mcparticle::mcCollisionId;
1478+
/// } preslices;
1479+
///
1480+
/// individual components can be access with
1481+
///
1482+
/// preslices.perCol;
1483+
struct PresliceGroup {
1484+
};
1485+
1486+
template <typename T>
1487+
concept is_preslice_group = std::derived_from<T, PresliceGroup>;
1488+
14711489
} // namespace o2::framework
14721490

14731491
namespace o2::soa

Framework/Core/include/Framework/AnalysisManagers.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ static void setGroupedCombination(C& comb, TG& grouping, std::tuple<Ts...>& asso
580580

581581
/// Preslice handling
582582
template <typename T>
583-
requires(!is_preslice<T>)
583+
requires(!is_preslice<T> && !is_preslice_group<T>)
584584
bool registerCache(T&, Cache&, Cache&)
585585
{
586586
return false;
@@ -622,8 +622,15 @@ bool registerCache(T& preslice, Cache&, Cache& bsksU)
622622
return true;
623623
}
624624

625+
template <is_preslice_group T>
626+
bool registerCache(T& presliceGroup, Cache& bsks, Cache& bsksU)
627+
{
628+
homogeneous_apply_refs<true>([&bsks, &bsksU](auto& preslice) { return registerCache(preslice, bsks, bsksU); }, presliceGroup);
629+
return true;
630+
}
631+
625632
template <typename T>
626-
requires(!is_preslice<T>)
633+
requires(!is_preslice<T> && !is_preslice_group<T>)
627634
bool updateSliceInfo(T&, ArrowTableSlicingCache&)
628635
{
629636
return false;
@@ -655,6 +662,13 @@ static bool updateSliceInfo(T& preslice, ArrowTableSlicingCache& cache)
655662
return true;
656663
}
657664

665+
template <is_preslice_group T>
666+
static bool updateSliceInfo(T& presliceGroup, ArrowTableSlicingCache& cache)
667+
{
668+
homogeneous_apply_refs<true>([&cache](auto& preslice) { return updateSliceInfo(preslice, cache); }, presliceGroup);
669+
return true;
670+
}
671+
658672
/// Process switches handling
659673
template <typename T>
660674
static bool setProcessSwitch(std::pair<std::string, bool>, T&)

Framework/Core/test/test_AnalysisTask.cxx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "TestClasses.h"
1414
#include "Framework/AnalysisTask.h"
1515
#include "Framework/AnalysisDataModel.h"
16+
#include <iostream>
1617

1718
#include <catch_amalgamated.hpp>
1819

@@ -185,6 +186,17 @@ struct LTask {
185186
void process(aod::McCollision const&, soa::SmallGroups<soa::Join<aod::Collisions, aod::McCollisionLabels>> const&) {}
186187
};
187188

189+
struct MTask {
190+
SliceCache cache;
191+
struct : public PresliceGroup {
192+
Preslice<aod::Tracks> perCol = aod::track::collisionId;
193+
PresliceOptional<aod::Tracks> perPart = aod::mctracklabel::mcParticleId;
194+
PresliceUnsorted<aod::McCollisionLabels> perMcCol = aod::mccollisionlabel::mcCollisionId;
195+
PresliceUnsortedOptional<aod::Collisions> perMcColopt = aod::mccollisionlabel::mcCollisionId;
196+
} foo;
197+
void process(aod::McCollision const&, soa::SmallGroups<soa::Join<aod::Collisions, aod::McCollisionLabels>> const&) {}
198+
};
199+
188200
TEST_CASE("AdaptorCompilation")
189201
{
190202
auto cfgc = makeEmptyConfigContext();
@@ -258,6 +270,9 @@ TEST_CASE("AdaptorCompilation")
258270

259271
auto task12 = adaptAnalysisTask<LTask>(*cfgc, TaskName{"test12"});
260272
REQUIRE(task12.inputs.size() == 3);
273+
274+
auto task13 = adaptAnalysisTask<MTask>(*cfgc, TaskName{"test13"});
275+
REQUIRE(task13.inputs.size() == 3);
261276
}
262277

263278
TEST_CASE("TestPartitionIteration")

Framework/Core/test/test_Concepts.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ TEST_CASE("IdentificationConcepts")
9696
Preslice<o2::aod::Tracks> ps = o2::aod::track::collisionId;
9797
REQUIRE(is_preslice<decltype(ps)>);
9898

99+
struct : PresliceGroup {
100+
Preslice<o2::aod::Tracks> pc = o2::aod::track::collisionId;
101+
Preslice<o2::aod::McParticles> pmcc = o2::aod::mcparticle::mcCollisionId;
102+
} preslices;
103+
REQUIRE(is_preslice_group<decltype(preslices)>);
104+
REQUIRE(is_preslice<decltype(preslices.pc)>);
105+
REQUIRE(is_preslice<decltype(preslices.pmcc)>);
106+
99107
REQUIRE(has_filtered_policy<soa::Filtered<o2::aod::Tracks>::iterator>);
100108

101109
REQUIRE(is_filtered_iterator<soa::Filtered<o2::aod::Tracks>::iterator>);
@@ -176,6 +184,7 @@ TEST_CASE("IdentificationConcepts")
176184
expressions::Filter f = o2::aod::track::pt > 1.0f;
177185
REQUIRE(expressions::is_filter<decltype(f)>);
178186

187+
// Combinations
179188
using C = SameKindPair<aod::Collisions, aod::Tracks, ColumnBinningPolicy<aod::collision::PosZ>>;
180189
REQUIRE(is_combinations_generator<C>);
181190
}

0 commit comments

Comments
 (0)