Skip to content

Commit 970bcde

Browse files
committed
DPL Analysis: add PresliceGroup
1 parent c978bd4 commit 970bcde

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
@@ -1465,6 +1465,24 @@ using PresliceOptional = PresliceBase<T, PreslicePolicySorted, true>;
14651465
template <typename T>
14661466
concept is_preslice = std::derived_from<T, PreslicePolicyBase>;
14671467

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

14701488
namespace o2::soa

Framework/Core/include/Framework/AnalysisManagers.h

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

544544
/// Preslice handling
545545
template <typename T>
546-
requires(!is_preslice<T>)
546+
requires(!is_preslice<T> && !is_preslice_group<T>)
547547
bool registerCache(T&, Cache&, Cache&)
548548
{
549549
return false;
@@ -585,8 +585,15 @@ bool registerCache(T& preslice, Cache&, Cache& bsksU)
585585
return true;
586586
}
587587

588+
template <is_preslice_group T>
589+
bool registerCache(T& presliceGroup, Cache& bsks, Cache& bsksU)
590+
{
591+
homogeneous_apply_refs<true>([&bsks, &bsksU](auto& preslice){ return registerCache(preslice, bsks, bsksU); }, presliceGroup);
592+
return true;
593+
}
594+
588595
template <typename T>
589-
requires(!is_preslice<T>)
596+
requires(!is_preslice<T> && !is_preslice_group<T>)
590597
bool updateSliceInfo(T&, ArrowTableSlicingCache&)
591598
{
592599
return false;
@@ -618,6 +625,13 @@ static bool updateSliceInfo(T& preslice, ArrowTableSlicingCache& cache)
618625
return true;
619626
}
620627

628+
template <is_preslice_group T>
629+
static bool updateSliceInfo(T& presliceGroup, ArrowTableSlicingCache& cache)
630+
{
631+
homogeneous_apply_refs<true>([&cache](auto& preslice){ return updateSliceInfo(preslice, cache); }, presliceGroup);
632+
return true;
633+
}
634+
621635
/// Process switches handling
622636
template <typename T>
623637
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
@@ -87,6 +87,14 @@ TEST_CASE("IdentificationConcepts")
8787
Preslice<o2::aod::Tracks> ps = o2::aod::track::collisionId;
8888
REQUIRE(is_preslice<decltype(ps)>);
8989

90+
struct : PresliceGroup {
91+
Preslice<o2::aod::Tracks> pc = o2::aod::track::collisionId;
92+
Preslice<o2::aod::McParticles> pmcc = o2::aod::mcparticle::mcCollisionId;
93+
} preslices;
94+
REQUIRE(is_preslice_group<decltype(preslices)>);
95+
REQUIRE(is_preslice<decltype(preslices.pc)>);
96+
REQUIRE(is_preslice<decltype(preslices.pmcc)>);
97+
9098
REQUIRE(has_filtered_policy<soa::Filtered<o2::aod::Tracks>::iterator>);
9199

92100
REQUIRE(is_filtered_iterator<soa::Filtered<o2::aod::Tracks>::iterator>);
@@ -162,6 +170,7 @@ TEST_CASE("IdentificationConcepts")
162170
expressions::Filter f = o2::aod::track::pt > 1.0f;
163171
REQUIRE(expressions::is_filter<decltype(f)>);
164172

173+
// Combinations
165174
using C = SameKindPair<aod::Collisions, aod::Tracks, ColumnBinningPolicy<aod::collision::PosZ>>;
166175
REQUIRE(is_combinations_generator<C>);
167176
}

0 commit comments

Comments
 (0)