diff --git a/Detectors/AOD/include/AODProducerWorkflow/AODProducerHelpers.h b/Detectors/AOD/include/AODProducerWorkflow/AODProducerHelpers.h index 9ef05096b2fd2..5351504443269 100644 --- a/Detectors/AOD/include/AODProducerWorkflow/AODProducerHelpers.h +++ b/Detectors/AOD/include/AODProducerWorkflow/AODProducerHelpers.h @@ -18,8 +18,6 @@ #include #include #include -#include -#include #include namespace o2::aodhelpers @@ -55,7 +53,7 @@ auto createTableCursor(framework::ProcessingContext& pc) framework::Produces c; c.resetCursor(pc.outputs() .make(framework::OutputForTable::ref())); - c.setLabel(o2::aod::MetadataTrait::metadata::tableLabel()); + c.setLabel(aod::label()); return c; } } // namespace o2::aodhelpers diff --git a/Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h b/Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h index d9481917f9a05..eaaf2d9eaedd9 100644 --- a/Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h +++ b/Detectors/AOD/include/AODProducerWorkflow/AODProducerWorkflowSpec.h @@ -21,7 +21,6 @@ #include "DataFormatsTRD/TrackTRD.h" #include "DetectorsBase/GRPGeomHelper.h" #include "DetectorsBase/Propagator.h" -#include "Framework/AnalysisHelpers.h" #include "Framework/DataProcessorSpec.h" #include "Framework/Task.h" #include "ReconstructionDataFormats/GlobalTrackID.h" @@ -36,7 +35,6 @@ #include #include #include -#include #include #include using namespace o2::framework; diff --git a/Detectors/AOD/src/StandaloneAODProducer.cxx b/Detectors/AOD/src/StandaloneAODProducer.cxx index a9f5a09141d8c..7ac59a556ac08 100644 --- a/Detectors/AOD/src/StandaloneAODProducer.cxx +++ b/Detectors/AOD/src/StandaloneAODProducer.cxx @@ -94,7 +94,7 @@ void fillMCollisionTable(o2::steer::MCKinematicsReader const& mcreader) TFile outfile("aod.root", "UPDATE"); { - TableToTree t2t(mccoltable, &outfile, aod::MetadataTrait::metadata::tableLabel()); + TableToTree t2t(mccoltable, &outfile, aod::description_str(aod::signature()).data()); t2t.addAllBranches(); t2t.process(); } @@ -200,12 +200,12 @@ void fillCollisionAndTrackTable() f.Close(); TFile outfile("aod.root", "RECREATE"); { - TableToTree t2t(colltable, &outfile, aod::MetadataTrait::metadata::tableLabel()); + TableToTree t2t(colltable, &outfile, aod::description_str(aod::signature()).data()); t2t.addAllBranches(); t2t.process(); } { - TableToTree t2t(tracktable, &outfile, "Tracks" /* aod::MetadataTrait::metadata::tableLabel() */); + TableToTree t2t(tracktable, &outfile, aod::description_str(aod::signature()).data()); t2t.addAllBranches(); t2t.process(); } diff --git a/Framework/Core/CMakeLists.txt b/Framework/Core/CMakeLists.txt index 02367afdcc556..5cdd1241ecfb0 100644 --- a/Framework/Core/CMakeLists.txt +++ b/Framework/Core/CMakeLists.txt @@ -236,6 +236,7 @@ add_executable(o2-test-framework-core test/test_Services.cxx test/test_StringHelpers.cxx test/test_StaticFor.cxx + test/test_TableSpawner.cxx test/test_TMessageSerializer.cxx test/test_TableBuilder.cxx test/test_TimeParallelPipelining.cxx diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index 34d18476e483d..25e64daefeba7 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" @@ -26,152 +27,362 @@ #include #include #include +#include #include #include #include #include -#define DECLARE_SOA_METADATA() \ - template \ - struct MetadataTrait { \ - using metadata = std::void_t; \ - }; - -#define DECLARE_SOA_ITERATOR_METADATA() \ - template \ - requires(o2::soa::is_iterator) \ - struct MetadataTrait { \ - using metadata = typename MetadataTrait::metadata; \ - }; - namespace o2::framework { using ListVector = std::vector>; std::string cutString(std::string&& str); +std::string strToUpper(std::string&& str); +} // namespace o2::framework -struct OriginEnc { - static constexpr size_t size = 4; - uint32_t value; - consteval OriginEnc(uint32_t v) : value{v} - { - } - consteval OriginEnc(std::string_view in) : value{0} +namespace o2::soa +{ +void accessingInvalidIndexFor(const char* getter); +void dereferenceWithWrongType(); +void missingFilterDeclaration(int hash, int ai); +void notBoundTable(const char* tableName); +} // namespace o2::soa + +namespace o2::soa +{ +/// Generic identifier for a table type +struct TableRef { + consteval TableRef() + : label_hash{0}, + desc_hash{0}, + origin_hash{0}, + version{0} { - for (auto i = 0U; i < (size < in.size() ? size : in.size()); ++i) { - value |= ((uint8_t)in[i]) << (8 * i); - } } - operator const char*() const + consteval TableRef(uint32_t _label, uint32_t _desc, uint32_t _origin, uint32_t _version) + : label_hash{_label}, + desc_hash{_desc}, + origin_hash{_origin}, + version{_version} { - return (const char*)(&value); } + uint32_t label_hash; + uint32_t desc_hash; + uint32_t origin_hash; + uint32_t version; - consteval operator o2::header::DataOrigin() + constexpr bool operator==(TableRef const& other) const noexcept { - return o2::header::DataOrigin{value}; + return (this->label_hash == other.label_hash) && + (this->desc_hash == other.desc_hash) && + (this->origin_hash == other.origin_hash) && + (this->version == other.version); } - consteval OriginEnc(OriginEnc const& other) = default; - consteval OriginEnc(OriginEnc&& other) noexcept = default; - consteval OriginEnc& operator=(OriginEnc const& other) = default; - consteval OriginEnc& operator=(OriginEnc&& other) noexcept = default; -}; -} // namespace o2::framework - -template <> -struct fmt::formatter { - char presentation = 's'; - constexpr auto parse(format_parse_context& ctx) + constexpr bool descriptionCompatible(TableRef const& other) const noexcept { - auto it = ctx.begin(), end = ctx.end(); - if (it != end && (*it == 's')) { - presentation = *it++; - } - - // Check if reached the end of the range: - if (it != end && *it != '}') { - throw format_error("invalid pick format"); - } - - // Return an iterator past the end of the parsed range: - return it; + return this->desc_hash == other.desc_hash; } - template - auto format(o2::framework::OriginEnc const& origin, FormatContext& ctx) + constexpr bool descriptionCompatible(uint32_t _desc_hash) const noexcept { - return fmt::format_to(ctx.out(), "{}", (std::string_view)origin); + return this->desc_hash == _desc_hash; } + + constexpr TableRef(TableRef const&) = default; + constexpr TableRef& operator=(TableRef const&) = default; + constexpr TableRef(TableRef&&) = default; + constexpr TableRef& operator=(TableRef&&) = default; }; -namespace o2::aod +/// Helpers to manipulate TableRef arrays +template ar1, std::array ar2> +consteval auto merge() { -DECLARE_SOA_METADATA(); + constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](TableRef const& a) { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); }); + std::array out; + + auto pos = std::copy(ar1.begin(), ar1.end(), out.begin()); + std::copy_if(ar2.begin(), ar2.end(), pos, [&](TableRef const& a) { return std::none_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }); }); + return out; } -namespace o2::soa +template ar1, std::array ar2, typename L> +consteval auto merge_if(L l) { -/// special case for the template with origin -template class Ref> -struct is_specialization_origin : std::false_type { -}; + constexpr const int to_remove = std::ranges::count_if(ar1.begin(), ar1.end(), [&](TableRef const& a) { return !l(a); }); + constexpr const int duplicates = std::ranges::count_if(ar2.begin(), ar2.end(), [&](TableRef const& a) { return std::any_of(ar1.begin(), ar1.end(), [&](TableRef const& e) { return e == a; }) || !l(a); }); + std::array out; -template