From ed7a61b91ea12779674dd953fa7fea7c3047078a Mon Sep 17 00:00:00 2001 From: Anton Alkin Date: Fri, 16 Aug 2024 12:31:46 +0200 Subject: [PATCH] DPL Analysis: make table origin a dynamic property in preparation to handle multiple sources (#13358) --- .../AODProducerWorkflow/AODProducerHelpers.h | 2 +- Detectors/AOD/src/AODProducerWorkflowSpec.cxx | 4 +- Framework/Core/include/Framework/ASoA.h | 277 +++++++++++------- .../include/Framework/AnalysisDataModel.h | 2 +- .../Core/include/Framework/AnalysisHelpers.h | 18 +- .../Core/include/Framework/AnalysisManagers.h | 2 +- .../Core/include/Framework/TableBuilder.h | 4 +- Framework/Core/src/AODReaderHelpers.cxx | 2 +- Framework/Core/test/benchmark_ASoA.cxx | 8 +- Framework/Core/test/benchmark_ASoAHelpers.cxx | 20 +- .../Core/test/benchmark_TableBuilder.cxx | 2 +- Framework/Core/test/test_ASoA.cxx | 38 +-- Framework/Core/test/test_ASoAHelpers.cxx | 28 +- .../Core/test/test_AnalysisDataModel.cxx | 2 +- Framework/Core/test/test_AnalysisTask.cxx | 2 +- .../Core/test/test_HistogramRegistry.cxx | 2 +- Framework/Core/test/test_TableBuilder.cxx | 4 +- 17 files changed, 234 insertions(+), 183 deletions(-) diff --git a/Detectors/AOD/include/AODProducerWorkflow/AODProducerHelpers.h b/Detectors/AOD/include/AODProducerWorkflow/AODProducerHelpers.h index dc6f589977cda..9ef05096b2fd2 100644 --- a/Detectors/AOD/include/AODProducerWorkflow/AODProducerHelpers.h +++ b/Detectors/AOD/include/AODProducerWorkflow/AODProducerHelpers.h @@ -50,7 +50,7 @@ struct TripletEqualTo { typedef boost::unordered_map TripletsMap_t; template -framework::Produces createTableCursor(framework::ProcessingContext& pc) +auto createTableCursor(framework::ProcessingContext& pc) { framework::Produces c; c.resetCursor(pc.outputs() diff --git a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx index 5d821fa3a971c..07e54403af472 100644 --- a/Detectors/AOD/src/AODProducerWorkflowSpec.cxx +++ b/Detectors/AOD/src/AODProducerWorkflowSpec.cxx @@ -1814,7 +1814,7 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc) auto tracksCursor = createTableCursor(pc); auto tracksCovCursor = createTableCursor(pc); auto tracksExtraCursor = createTableCursor(pc); - auto tracksQACursor = createTableCursor(pc); + auto tracksQACursor = createTableCursor(pc); auto ambigTracksCursor = createTableCursor(pc); auto ambigMFTTracksCursor = createTableCursor(pc); auto ambigFwdTracksCursor = createTableCursor(pc); @@ -2986,7 +2986,7 @@ DataProcessorSpec getAODProducerWorkflowSpec(GID::mask_t src, bool enableSV, boo OutputForTable::spec(), OutputForTable::spec(), OutputForTable::spec(), - OutputForTable::spec(), + OutputForTable::spec(), OutputSpec{"TFN", "TFNumber"}, OutputSpec{"TFF", "TFFilename"}, OutputSpec{"AMD", "AODMetadataKeys"}, diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 2e80dca06fa36..d51b0516f18e7 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -15,6 +15,7 @@ #include "Framework/Pack.h" #include "Framework/FunctionalHelpers.h" #include "Headers/DataHeader.h" +#include "Headers/DataHeaderHelpers.h" #include "Framework/CompilerBuiltins.h" #include "Framework/Traits.h" #include "Framework/Expressions.h" @@ -37,6 +38,12 @@ using metadata = std::void_t; \ }; +#define DECLARE_SOA_ITERATOR_METADATA() \ + template \ + requires(o2::soa::is_soa_iterator_v) struct MetadataTrait { \ + using metadata = typename MetadataTrait::metadata; \ + }; + namespace o2::aod { DECLARE_SOA_METADATA(); @@ -163,7 +170,7 @@ void call_if_has_not_originals(TLambda&& lambda) } template -constexpr auto make_originals_from_type() +consteval decltype(auto) make_originals_from_type() { using decayed = std::decay_t; if constexpr (sizeof...(T) == 0) { @@ -186,9 +193,15 @@ constexpr auto make_originals_from_type() } template -constexpr auto make_originals_from_type(framework::pack) +consteval decltype(auto) make_originals_from_type(framework::pack p) { - return make_originals_from_type(); + if constexpr (sizeof...(T) == 0) { + return framework::pack<>{}; + } else { + return [](framework::pack) { + return make_originals_from_type(); + }(p); + } } /// Policy class for columns which are chunked. This @@ -770,7 +783,7 @@ struct DefaultIndexPolicy : IndexPolicyBase { int64_t mMaxRow = 0; }; -template +template class Table; /// Similar to a pair but not a pair, to avoid @@ -786,11 +799,11 @@ concept CanBind = requires(T&& t) { { t.B::mColumnIterator }; }; -template +template struct RowViewCore : public IP, C... { public: using policy_t = IP; - using table_t = o2::soa::Table; + using table_t = o2::soa::Table; using all_columns = framework::pack; using persistent_columns_t = framework::selected_pack; using index_columns_t = framework::selected_pack; @@ -813,7 +826,7 @@ struct RowViewCore : public IP, C... { } RowViewCore() = default; - RowViewCore(RowViewCore const& other) + RowViewCore(RowViewCore const& other) : IP{static_cast(other)}, C(static_cast(other))... { @@ -828,7 +841,7 @@ struct RowViewCore : public IP, C... { return *this; } - RowViewCore(RowViewCore const& other) requires std::is_same_v + RowViewCore(RowViewCore const& other) requires std::is_same_v : IP{static_cast(other)}, C(static_cast(other))... { @@ -843,7 +856,7 @@ struct RowViewCore : public IP, C... { RowViewCore operator++(int) { - RowViewCore copy = *this; + RowViewCore copy = *this; this->operator++(); return copy; } @@ -856,7 +869,7 @@ struct RowViewCore : public IP, C... { RowViewCore operator--(int) { - RowViewCore copy = *this; + RowViewCore copy = *this; this->operator--(); return copy; } @@ -958,7 +971,7 @@ struct RowViewCore : public IP, C... { [this](T*) -> void requires is_persistent_v { T::mColumnIterator.mCurrentPos = &this->mRowIndex; }, [this](T*) -> void requires is_dynamic_v { bindDynamicColumn(typename T::bindings_t{});}, [this](T*) -> void {}, - }; +}; (f(static_cast(nullptr)), ...); if constexpr (has_index_v) { this->setIndices(this->getIndices()); @@ -1005,7 +1018,7 @@ struct ArrowHelpers { }; template -using originals_pack_t = decltype(make_originals_from_type()); +using originals_pack_t = decltype(make_originals_from_type(framework::pack{})); template constexpr bool are_bindings_compatible_v(framework::pack&&) @@ -1207,9 +1220,35 @@ using PresliceOptional = PresliceBase; namespace o2::soa { +/// special case for the template with origin +template class Ref> +struct is_specialization_origin : std::false_type { +}; + +template