Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions Framework/Core/include/Framework/AnalysisTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ concept is_table_iterator_or_enumeration = soa::is_table_or_iterator<T> || is_en
// the contents of an AnalysisTask...
namespace
{
// One closure type for every argument index. Written inline inside the pack
// expansion in bindAssociatedTables() below, the predicate lambda would get a
// fresh closure type per Args, and with it its own std::ranges::filter_view,
// __bind_back and __perfect_forward_impl instantiation -- paid once per
// associated table per process function. Taking the index as a runtime capture
// instead lets every call site share a single filter_view specialisation.
inline auto matchersForArgument(int argumentIndex)
{
return std::views::filter([argumentIndex](auto const& pair) { return pair.first == argumentIndex; });
}

struct AnalysisDataProcessorBuilder {
template <soa::is_iterator G, soa::is_table... Args>
static void addGroupingCandidates(Cache& bk, Cache& bku, bool enabled)
Expand Down Expand Up @@ -286,15 +297,15 @@ struct AnalysisDataProcessorBuilder {
requires(!std::same_as<Grouping, void>)
{
constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId<void (C::*)(Grouping, Args...)>();
return extract<std::decay_t<Grouping>, 0>(record, matchers | std::views::filter([](auto const& pair) { return pair.first == 0; }), infos, hash);
return extract<std::decay_t<Grouping>, 0>(record, matchers | matchersForArgument(0), infos, hash);
}

template <std::ranges::input_range R, typename C, is_table_iterator_or_enumeration Grouping, soa::is_table... Args>
static auto bindAssociatedTables(InputRecord& record, R matchers, void (C::*)(Grouping, Args...), std::vector<ExpressionInfo>& infos)
requires(!std::same_as<Grouping, void> && sizeof...(Args) > 0)
{
constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId<void (C::*)(Grouping, Args...)>();
return std::make_tuple(extract<std::decay_t<Args>, has_type_at_v<Args>(pack<Args...>{}) + 1>(record, matchers | std::views::filter([](auto const& pair) { return pair.first == has_type_at_v<Args>(pack<Args...>{}) + 1; }), infos, hash)...);
return std::make_tuple(extract<std::decay_t<Args>, has_type_at_v<Args>(pack<Args...>{}) + 1>(record, matchers | matchersForArgument(has_type_at_v<Args>(pack<Args...>{}) + 1), infos, hash)...);
}

template <soa::is_table... As>
Expand Down Expand Up @@ -595,8 +606,7 @@ DataProcessorSpec adaptAnalysisTask(ConfigContext const& ctx, Args&&... args)
// replace origins in Preslice declarations
homogeneous_apply_refs_sized<numElements>([&newOrigin](auto& element) { return analysis_task_parsers::replaceOrigin(element, newOrigin); }, *task.get());

auto algo = AlgorithmSpec::InitCallback
{
auto algo = AlgorithmSpec::InitCallback{
[task = task, expressionInfos, inputInfos, newOrigin, newOriginStr](InitContext& ic) mutable {
Cache bindingsKeys;
Cache bindingsKeysUnsorted;
Expand Down Expand Up @@ -715,8 +725,7 @@ DataProcessorSpec adaptAnalysisTask(ConfigContext const& ctx, Args&&... args)
// finalize outputs
homogeneous_apply_refs_sized<numElements>([&pc](auto& element) { return analysis_task_parsers::finalizeOutput(pc, element); }, *task.get());
};
}
};
}};

return {
name,
Expand Down
Loading