From d8fd4432064bd1b61ff308d667203c9601ae0aea Mon Sep 17 00:00:00 2001 From: Jan Fiete Date: Thu, 27 Jan 2022 12:12:20 +0100 Subject: [PATCH 1/5] Add DECLARE_EQUIVALENT_FOR_INDEX --- Framework/Core/include/Framework/ASoA.h | 31 +++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index bee91a96c9af0..c6eefbe59f1e6 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1382,11 +1382,28 @@ using JoinBase = decltype(join(std::declval()...)); template using ConcatBase = decltype(concat(std::declval(), std::declval())); -template -constexpr auto is_binding_compatible_v() +template +struct EquivalentIndex { + constexpr static bool value = false; +}; + +template +constexpr bool is_index_equivalent_v = EquivalentIndex::value; + +template +constexpr bool are_bindings_compatible_v(framework::pack&&) +{ + if constexpr (is_type_with_originals_v) { + return (are_bindings_compatible_v(originals_pack_t{}) || ...); + } else { + return ((std::is_same_v || is_index_equivalent_v) || ...); + } +} + +template +constexpr bool is_binding_compatible_v() { - return framework::pack_size( - framework::intersected_pack_t, originals_pack_t>{}) > 0; + return are_bindings_compatible_v(originals_pack_t{}); } } // namespace o2::soa @@ -1397,6 +1414,12 @@ constexpr auto is_binding_compatible_v() using metadata = std::void_t; \ } +#define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \ + template <> \ + struct EquivalentIndex<_Base_, _Equiv_> { \ + constexpr static bool value = true; \ + } + #define DECLARE_SOA_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \ struct _Name_ : o2::soa::Column<_Type_, _Name_> { \ static constexpr const char* mLabel = _Label_; \ From 93ebb36d2c53dc63fec1a7a516b7776566b4a589 Mon Sep 17 00:00:00 2001 From: Jan Fiete Date: Sun, 30 Jan 2022 22:05:45 +0100 Subject: [PATCH 2/5] add _ for slice and array index --- Framework/Core/include/Framework/ASoA.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index c6eefbe59f1e6..2cbc7ed2934d9 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1831,7 +1831,7 @@ constexpr bool is_binding_compatible_v() void const* mBinding = nullptr; \ }; -#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_) +#define DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_) /// SELF ARRAY #define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \ struct _Name_##Ids : o2::soa::Column, _Name_##Ids> { \ @@ -1890,7 +1890,8 @@ constexpr bool is_binding_compatible_v() void const* mBinding = nullptr; \ }; -#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, #_Name_) +#define DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, "_" #_Name_) + /// A dynamic column is a column whose values are derived /// from those of other real columns. These can be used for /// example to provide different coordinate systems (e.g. polar, From c4028bee26ffb0548aba4678265ae91a13640492 Mon Sep 17 00:00:00 2001 From: Jan Fiete Date: Tue, 18 Jan 2022 09:01:25 +0100 Subject: [PATCH 3/5] MCParticle version 001 with slice and array --- .../include/Framework/AnalysisDataModel.h | 28 ++++++++++++++++--- Framework/Core/src/AODReaderHelpers.cxx | 4 ++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index d3b140ead20a8..cd642c0723655 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -795,8 +795,8 @@ DECLARE_SOA_SELF_INDEX_COLUMN_FULL(Mother0, mother0, int, "McParticles_Mother0") DECLARE_SOA_SELF_INDEX_COLUMN_FULL(Mother1, mother1, int, "McParticles_Mother1"); //! Track index of the last mother DECLARE_SOA_SELF_INDEX_COLUMN_FULL(Daughter0, daughter0, int, "McParticles_Daughter0"); //! Track index of the first daugther DECLARE_SOA_SELF_INDEX_COLUMN_FULL(Daughter1, daughter1, int, "McParticles_Daughter1"); //! Track index of the last daugther -DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(Daughters, daughters); //! Daughter tracks (possibly empty) slice -DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(Mothers, mothers); //! Mother tracks (possible empty) array +DECLARE_SOA_SELF_ARRAY_INDEX_COLUMN(Mothers, mothers); //! Mother tracks (possible empty) array. Iterate over mcParticle.mothers_as()) +DECLARE_SOA_SELF_SLICE_INDEX_COLUMN(Daughters, daughters); //! Daughter tracks (possibly empty) slice. Check for non-zero with mcParticle.has_daughters(). Iterate over mcParticle.daughters_as()) DECLARE_SOA_COLUMN(Weight, weight, float); //! MC weight DECLARE_SOA_COLUMN(Px, px, float); //! Momentum in x in GeV/c DECLARE_SOA_COLUMN(Py, py, float); //! Momentum in y in GeV/c @@ -847,7 +847,7 @@ DECLARE_SOA_EXPRESSION_COLUMN(Y, y, float, //! Particle rapidity, conditionally (aod::mcparticle::e - aod::mcparticle::pz)))); } // namespace mcparticle -DECLARE_SOA_TABLE_FULL(StoredMcParticles, "McParticles", "AOD", "MCPARTICLE", //! On disk version of the MC particle table +DECLARE_SOA_TABLE_FULL(StoredMcParticles_000, "McParticles", "AOD", "MCPARTICLE", //! MC particle table, version 000 o2::soa::Index<>, mcparticle::McCollisionId, mcparticle::PdgCode, mcparticle::StatusCode, mcparticle::Flags, mcparticle::Mother0Id, mcparticle::Mother1Id, @@ -860,13 +860,33 @@ DECLARE_SOA_TABLE_FULL(StoredMcParticles, "McParticles", "AOD", "MCPARTICLE", // mcparticle::GetProcess, mcparticle::IsPhysicalPrimary); -DECLARE_SOA_EXTENDED_TABLE(McParticles, StoredMcParticles, "MCPARTICLE", //! Basic MC particle properties +DECLARE_SOA_TABLE_FULL(StoredMcParticles_001, "McParticles_001", "AOD", "MCPARTICLE_001", //! MC particle table, version 001 + o2::soa::Index<>, mcparticle::McCollisionId, + mcparticle::PdgCode, mcparticle::StatusCode, mcparticle::Flags, + mcparticle::MothersIds, mcparticle::DaughtersIdSlice, mcparticle::Weight, + mcparticle::Px, mcparticle::Py, mcparticle::Pz, mcparticle::E, + mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, mcparticle::Vt, + mcparticle::ProducedByGenerator, + mcparticle::FromBackgroundEvent, + mcparticle::GetGenStatusCode, + mcparticle::GetProcess, + mcparticle::IsPhysicalPrimary); + +DECLARE_SOA_EXTENDED_TABLE(McParticles_000, StoredMcParticles_000, "MCPARTICLE", //! Basic MC particle properties + mcparticle::Phi, + mcparticle::Eta, + mcparticle::Pt, + mcparticle::P, + mcparticle::Y); + +DECLARE_SOA_EXTENDED_TABLE(McParticles_001, StoredMcParticles_001, "MCPARTICLE_001", //! Basic MC particle properties mcparticle::Phi, mcparticle::Eta, mcparticle::Pt, mcparticle::P, mcparticle::Y); +using McParticles = McParticles_000; using McParticle = McParticles::iterator; namespace mctracklabel diff --git a/Framework/Core/src/AODReaderHelpers.cxx b/Framework/Core/src/AODReaderHelpers.cxx index a2017e1eab70f..2dbf21f6d0dd5 100644 --- a/Framework/Core/src/AODReaderHelpers.cxx +++ b/Framework/Core/src/AODReaderHelpers.cxx @@ -168,7 +168,9 @@ AlgorithmSpec AODReaderHelpers::aodSpawnerCallback(std::vector& reque } else if (description == header::DataDescription{"FWDTRACKCOV"}) { outputs.adopt(Output{origin, description}, maker(o2::aod::FwdTracksCovExtensionMetadata{})); } else if (description == header::DataDescription{"MCPARTICLE"}) { - outputs.adopt(Output{origin, description}, maker(o2::aod::McParticlesExtensionMetadata{})); + outputs.adopt(Output{origin, description}, maker(o2::aod::McParticles_000ExtensionMetadata{})); + } else if (description == header::DataDescription{"MCPARTICLE_001"}) { + outputs.adopt(Output{origin, description}, maker(o2::aod::McParticles_001ExtensionMetadata{})); } else { throw runtime_error("Not an extended table"); } From 06bfa73fd77c9f318d87cce9b140cf631462d7b2 Mon Sep 17 00:00:00 2001 From: Jan Fiete Date: Sun, 30 Jan 2022 22:08:16 +0100 Subject: [PATCH 4/5] Equivalent for McParticles --- Framework/Core/include/Framework/AnalysisDataModel.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index cd642c0723655..c998222f3fecf 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -888,7 +888,13 @@ DECLARE_SOA_EXTENDED_TABLE(McParticles_001, StoredMcParticles_001, "MCPARTICLE_0 using McParticles = McParticles_000; using McParticle = McParticles::iterator; +} +namespace soa +{ +DECLARE_EQUIVALENT_FOR_INDEX(aod::StoredMcParticles_000, aod::StoredMcParticles_001); +} +namespace aod { namespace mctracklabel { DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle From 406b250322a7c60ff103ce3a083874592daa964c Mon Sep 17 00:00:00 2001 From: Jan Fiete Date: Mon, 31 Jan 2022 08:17:11 +0100 Subject: [PATCH 5/5] clang --- Framework/Core/include/Framework/ASoA.h | 8 ++++---- Framework/Core/include/Framework/AnalysisDataModel.h | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 2cbc7ed2934d9..303d9a477f462 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -1416,7 +1416,7 @@ constexpr bool is_binding_compatible_v() #define DECLARE_EQUIVALENT_FOR_INDEX(_Base_, _Equiv_) \ template <> \ - struct EquivalentIndex<_Base_, _Equiv_> { \ + struct EquivalentIndex<_Base_, _Equiv_> { \ constexpr static bool value = true; \ } @@ -1572,7 +1572,7 @@ constexpr bool is_binding_compatible_v() #define DECLARE_SOA_SLICE_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_SLICE_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "") -///ARRAY +/// ARRAY #define DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) \ struct _Name_##Ids : o2::soa::Column, _Name_##Ids> { \ static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \ @@ -1651,7 +1651,7 @@ constexpr bool is_binding_compatible_v() #define DECLARE_SOA_ARRAY_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_ARRAY_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "") -///NORMAL +/// NORMAL #define DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Table_, _Suffix_) \ struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \ static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \ @@ -1724,7 +1724,7 @@ constexpr bool is_binding_compatible_v() #define DECLARE_SOA_INDEX_COLUMN(_Name_, _Getter_) DECLARE_SOA_INDEX_COLUMN_FULL(_Name_, _Getter_, int32_t, _Name_##s, "") -///SELF +/// SELF #define DECLARE_SOA_SELF_INDEX_COLUMN_FULL(_Name_, _Getter_, _Type_, _Label_) \ struct _Name_##Id : o2::soa::Column<_Type_, _Name_##Id> { \ static_assert(std::is_integral_v<_Type_>, "Index type must be integral"); \ diff --git a/Framework/Core/include/Framework/AnalysisDataModel.h b/Framework/Core/include/Framework/AnalysisDataModel.h index c998222f3fecf..c909006ea54eb 100644 --- a/Framework/Core/include/Framework/AnalysisDataModel.h +++ b/Framework/Core/include/Framework/AnalysisDataModel.h @@ -888,13 +888,14 @@ DECLARE_SOA_EXTENDED_TABLE(McParticles_001, StoredMcParticles_001, "MCPARTICLE_0 using McParticles = McParticles_000; using McParticle = McParticles::iterator; -} +} // namespace aod namespace soa { DECLARE_EQUIVALENT_FOR_INDEX(aod::StoredMcParticles_000, aod::StoredMcParticles_001); } -namespace aod { +namespace aod +{ namespace mctracklabel { DECLARE_SOA_INDEX_COLUMN(McParticle, mcParticle); //! MC particle