@@ -69,15 +69,6 @@ concept is_enumeration = is_enumeration_v<std::decay_t<T>>;
6969template <typename T>
7070concept is_table_iterator_or_enumeration = soa::is_table_or_iterator<T> || is_enumeration<T>;
7171
72- // / Structure to contain mapping between matchers and process functions.
73- // / Process function is identified by hash, each matcher has associated
74- // / argument position for that process function; single argument can have
75- // / many matchers associated due to complicated joins
76- struct InputInfo {
77- uint32_t hash;
78- std::vector<std::pair<int , ConcreteDataMatcher>> matchers;
79- };
80-
8172// Helper struct which builds a DataProcessorSpec from
8273// the contents of an AnalysisTask...
8374namespace
@@ -268,38 +259,37 @@ struct AnalysisDataProcessorBuilder {
268259 }
269260 }
270261
271- template <is_enumeration T, int AI>
272- static auto extract (InputRecord&, std::vector<InputInfo> , std::vector<ExpressionInfo>&, size_t )
262+ template <is_enumeration T, int AI, std::ranges::input_range R >
263+ static auto extract (InputRecord&, R , std::vector<ExpressionInfo>&, size_t )
273264 {
274265 return T{};
275266 }
276267
277- template <soa::is_table_or_iterator T, int AI>
278- static auto extract (InputRecord& record, std::vector<InputInfo> iInfos , std::vector<ExpressionInfo>& infos, size_t phash)
268+ template <soa::is_table_or_iterator T, int AI, std::ranges::input_range R >
269+ static auto extract (InputRecord& record, R matchers , std::vector<ExpressionInfo>& infos, size_t phash)
279270 {
280- auto matchers = std::ranges::find_if (iInfos, [&phash](auto const & info) { return info.hash == phash; })->matchers | std::views::filter ([](auto const & pair) { return pair.first == AI; });
271+ // auto matchers = std::ranges::find_if(iInfos, [&phash](auto const& info) { return info.hash == phash; })->matchers | std::views::filter([](auto const& pair) { return pair.first == AI; });
281272 if constexpr (soa::is_filtered<T>) {
282273 return extractFilteredFromRecord<T>(record, matchers, *std::ranges::find_if (infos, [&phash](ExpressionInfo const & i) { return (i.processHash == phash && i.argumentIndex == AI); }));
283274 } else {
284275 return extractFromRecord<T>(record, matchers);
285276 }
286277 }
287278
288- template <typename C, is_table_iterator_or_enumeration Grouping, soa::is_table... Args>
289- static auto bindGroupingTable (InputRecord& record, std::vector<InputInfo> iInfos , void (C::*)(Grouping, Args...), std::vector<ExpressionInfo>& infos)
279+ template <std::ranges::input_range R, typename C, is_table_iterator_or_enumeration Grouping, soa::is_table... Args>
280+ static auto bindGroupingTable (InputRecord& record, R matchers , void (C::*)(Grouping, Args...), std::vector<ExpressionInfo>& infos)
290281 requires(!std::same_as<Grouping, void >)
291282 {
292283 constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId<void (C::*)(Grouping, Args...)>();
293- return extract<std::decay_t <Grouping>, 0 >(record, iInfos , infos, hash);
284+ return extract<std::decay_t <Grouping>, 0 >(record, matchers | std::views::filter ([]( auto const & pair) { return pair. first == 0 ; }) , infos, hash);
294285 }
295286
296- template <typename C, is_table_iterator_or_enumeration Grouping, soa::is_table... Args>
297- static auto bindAssociatedTables (InputRecord& record, std::vector<InputInfo> iInfos , void (C::*)(Grouping, Args...), std::vector<ExpressionInfo>& infos)
287+ template <std::ranges::input_range R, typename C, is_table_iterator_or_enumeration Grouping, soa::is_table... Args>
288+ static auto bindAssociatedTables (InputRecord& record, R matchers , void (C::*)(Grouping, Args...), std::vector<ExpressionInfo>& infos)
298289 requires(!std::same_as<Grouping, void > && sizeof ...(Args) > 0)
299290 {
300- constexpr auto p = pack<Args...>{};
301291 constexpr auto hash = o2::framework::TypeIdHelpers::uniqueId<void (C::*)(Grouping, Args...)>();
302- return std::make_tuple (extract<std::decay_t <Args>, has_type_at_v<Args>(p ) + 1 >(record, iInfos , infos, hash)...);
292+ 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)...);
303293 }
304294
305295 template <soa::is_table... As>
@@ -308,11 +298,11 @@ struct AnalysisDataProcessorBuilder {
308298 (std::get<As>(dest).bindInternalIndicesTo (&std::get<As>(src)), ...);
309299 }
310300
311- template <typename Task, is_table_iterator_or_enumeration Grouping, soa::is_table... Associated>
312- static void invokeProcess (Task& task, InputRecord& inputs, std::vector<InputInfo> iInfos , void (Task::*processingFunction)(Grouping, Associated...), std::vector<ExpressionInfo>& infos, ArrowTableSlicingCache& slices, header::DataOrigin newOrigin = header::DataOrigin{" AOD" })
301+ template <typename Task, is_table_iterator_or_enumeration Grouping, std::ranges::input_range R, soa::is_table... Associated>
302+ static void invokeProcess (Task& task, InputRecord& inputs, R matchers , void (Task::*processingFunction)(Grouping, Associated...), std::vector<ExpressionInfo>& infos, ArrowTableSlicingCache& slices, header::DataOrigin newOrigin = header::DataOrigin{" AOD" })
313303 {
314304 using G = std::decay_t <Grouping>;
315- auto groupingTable = AnalysisDataProcessorBuilder::bindGroupingTable (inputs, iInfos , processingFunction, infos);
305+ auto groupingTable = AnalysisDataProcessorBuilder::bindGroupingTable (inputs, matchers , processingFunction, infos);
316306
317307 constexpr const int numElements = nested_brace_constructible_size<false , std::decay_t <Task>>() / 10 ;
318308
@@ -341,7 +331,7 @@ struct AnalysisDataProcessorBuilder {
341331 }
342332 } else {
343333 // multiple arguments to process
344- auto associatedTables = AnalysisDataProcessorBuilder::bindAssociatedTables (inputs, iInfos , processingFunction, infos);
334+ auto associatedTables = AnalysisDataProcessorBuilder::bindAssociatedTables (inputs, matchers , processingFunction, infos);
345335 // pre-bind self indices
346336 std::apply (
347337 [&task](auto &... t) mutable {
@@ -381,7 +371,7 @@ struct AnalysisDataProcessorBuilder {
381371 task);
382372 overwriteInternalIndices (associatedTables, associatedTables);
383373 if constexpr (soa::is_iterator<G>) {
384- auto slicer = GroupSlicer (groupingTable, associatedTables, slices, newOrigin);
374+ auto slicer = GroupSlicer (groupingTable, associatedTables, slices, matchers, newOrigin);
385375 for (auto & slice : slicer) {
386376 auto associatedSlices = slice.associatedTables ();
387377 overwriteInternalIndices (associatedSlices, associatedTables);
@@ -674,14 +664,18 @@ DataProcessorSpec adaptAnalysisTask(ConfigContext const& ctx, Args&&... args)
674664 }
675665 // execute process()
676666 if constexpr (requires { &T::process; }) {
677- AnalysisDataProcessorBuilder::invokeProcess (*(task.get ()), pc.inputs (), inputInfos, &T::process, expressionInfos, slices, newOrigin);
667+ constexpr auto phash = o2::framework::TypeIdHelpers::uniqueId<decltype (&T::process)>();
668+ auto matchers = std::ranges::find_if (inputInfos, [&phash](auto const & info) { return info.hash == phash; })->matchers ;
669+ AnalysisDataProcessorBuilder::invokeProcess (*(task.get ()), pc.inputs (), matchers, &T::process, expressionInfos, slices, newOrigin);
678670 }
679671 // execute optional process()
680672 homogeneous_apply_refs_sized<numElements>(
681673 [&pc, &expressionInfos, &task, &slices, &inputInfos, &newOrigin](auto & x) {
682674 if constexpr (is_process_configurable<decltype (x)>) {
683675 if (x.value == true ) {
684- AnalysisDataProcessorBuilder::invokeProcess (*task.get (), pc.inputs (), inputInfos, x.process , expressionInfos, slices, newOrigin);
676+ constexpr auto phash = o2::framework::TypeIdHelpers::uniqueId<decltype (x.process )>();
677+ auto matchers = std::ranges::find_if (inputInfos, [&phash](auto const & info) { return info.hash == phash; })->matchers ;
678+ AnalysisDataProcessorBuilder::invokeProcess (*task.get (), pc.inputs (), matchers, x.process , expressionInfos, slices, newOrigin);
685679 return true ;
686680 }
687681 return false ;
0 commit comments