Skip to content

Commit 69ef405

Browse files
authored
DPL Analysis: Set tables only once for event mixing (#8033)
1 parent bcea6b4 commit 69ef405

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

Framework/Core/include/Framework/AnalysisManagers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct GroupedCombinationManager<GroupedCombinationsGenerator<T1, GroupingPolicy
4646
{
4747
static_assert(sizeof...(T2s) > 0, "There must be associated tables in process() for a correct pair");
4848
static_assert(!soa::is_soa_iterator_t<std::decay_t<H>>::value, "Only full tables can be in process(), no grouping");
49-
if constexpr (std::conjunction_v<std::is_same<G, TG>, std::is_same<H, TH>>) {
49+
if constexpr (std::is_same_v<G, TG> && std::is_same_v<H, TH>) {
5050
// Take respective unique associated tables for grouping
5151
auto associatedTuple = std::tuple<Us...>(std::get<Us>(associated)...);
5252
comb.setTables(hashes, grouping, associatedTuple);

Framework/Core/include/Framework/GroupedCombinations.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,18 @@ struct GroupedCombinationsGenerator<T1, GroupingPolicy, H, G, pack<Us...>, As...
231231
{
232232
setTables(hashes, grouping, associated);
233233
}
234+
GroupedCombinationsGenerator(GroupedCombinationsGenerator const&) = default;
235+
GroupedCombinationsGenerator& operator=(GroupedCombinationsGenerator const&) = default;
234236
~GroupedCombinationsGenerator() = default;
235237

236238
void setTables(H& hashes, G& grouping, std::tuple<Us...>& associated)
237239
{
238-
std::shared_ptr slicer_ptr = std::make_shared<GroupSlicer<G, Us...>>(grouping, associated);
239-
mBegin.setTables(hashes, grouping, slicer_ptr);
240-
mEnd.setTables(hashes, grouping, slicer_ptr);
241-
mEnd.moveToEnd();
240+
if (mSlicer == nullptr) {
241+
mSlicer = std::make_shared<GroupSlicer<G, Us...>>(grouping, associated);
242+
mBegin.setTables(hashes, grouping, mSlicer);
243+
mEnd.setTables(hashes, grouping, mSlicer);
244+
mEnd.moveToEnd();
245+
}
242246
}
243247

244248
private:
@@ -247,20 +251,21 @@ struct GroupedCombinationsGenerator<T1, GroupingPolicy, H, G, pack<Us...>, As...
247251
const char* mCategory;
248252
const int mCatNeighbours;
249253
const T1 mOutsider;
254+
std::shared_ptr<GroupSlicer<G, Us...>> mSlicer = nullptr;
250255
};
251256

252257
// Aliases for 2-particle correlations
253258
// 'Pair' and 'Triple' can be used for same kind pair/triple, too, just specify the same type twice
254259
template <typename H, typename G>
255260
using joinedCollisions = typename soa::Join<H, G>::table_t;
256261
template <typename H, typename G, typename A1, typename A2, typename T1 = int, typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<T1, joinedCollisions<H, G>, joinedCollisions<H, G>>>
257-
using Pair = GroupedCombinationsGenerator<T1, GroupingPolicy, H, G, unique_pack_t<pack<A1, A2>>>;
262+
using Pair = GroupedCombinationsGenerator<T1, GroupingPolicy, H, G, unique_pack_t<pack<A1, A2>>, A1, A2>;
258263
template <typename H, typename G, typename A, typename T1 = int, typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<T1, joinedCollisions<H, G>, joinedCollisions<H, G>>>
259264
using SameKindPair = GroupedCombinationsGenerator<T1, GroupingPolicy, H, G, pack<A>, A, A>;
260265

261266
// Aliases for 3-particle correlations
262267
template <typename H, typename G, typename A1, typename A2, typename A3, typename T1 = int, typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<T1, joinedCollisions<H, G>, joinedCollisions<H, G>, joinedCollisions<H, G>>>
263-
using Triple = GroupedCombinationsGenerator<T1, GroupingPolicy, H, G, unique_pack_t<pack<A1, A2, A3>>>;
268+
using Triple = GroupedCombinationsGenerator<T1, GroupingPolicy, H, G, unique_pack_t<pack<A1, A2, A3>>, A1, A2, A3>;
264269
template <typename H, typename G, typename A, typename T1 = int, typename GroupingPolicy = o2::soa::CombinationsBlockStrictlyUpperSameIndexPolicy<T1, joinedCollisions<H, G>, joinedCollisions<H, G>, joinedCollisions<H, G>>>
265270
using SameKindTriple = GroupedCombinationsGenerator<T1, GroupingPolicy, H, G, pack<A>, A, A, A>;
266271

0 commit comments

Comments
 (0)