From 61b1fc61021ff04f51961b48dbdabfa8bf14688d Mon Sep 17 00:00:00 2001 From: Giulio Eulisse Date: Thu, 12 Dec 2019 10:26:15 +0100 Subject: [PATCH] Align Converter to latest incarnation of Peter's AODs (#18) --- Converter/src/Framework/ASoA.h | 12 +- Converter/src/Framework/AnalysisDataModel.h | 126 +++++++++++++----- Converter/src/Framework/BasicOps.h | 4 +- Converter/src/Framework/CompilerBuiltins.h | 12 +- Converter/src/Framework/Expressions.h | 119 ++++++++++++++++- .../src/Framework/RootTableBuilderHelpers.h | 23 +++- Converter/src/Framework/Traits.h | 11 ++ Converter/src/Run3AODConverter.cxx | 4 +- 8 files changed, 262 insertions(+), 49 deletions(-) diff --git a/Converter/src/Framework/ASoA.h b/Converter/src/Framework/ASoA.h index db5faa2..b038c7d 100644 --- a/Converter/src/Framework/ASoA.h +++ b/Converter/src/Framework/ASoA.h @@ -628,6 +628,7 @@ class Table using filtered_const_iterator = RowViewFiltered; using table_t = Table; using columns = framework::pack; + using persistent_columns_t = framework::selected_pack; Table(std::shared_ptr table) : mTable(table), @@ -691,7 +692,9 @@ class Table arrow::Column* lookupColumn() { if constexpr (T::persistent::value) { - return mTable->column(mTable->schema()->GetFieldIndex(T::label())).get(); + auto label = T::label(); + auto index = mTable->schema()->GetFieldIndex(label); + return mTable->column(index).get(); } else { return nullptr; } @@ -766,7 +769,8 @@ class TableMetadata return *mColumnIterator; \ } \ }; \ - static const o2::framework::expressions::BindingNode _Getter_ { _Label_ } + static const o2::framework::expressions::BindingNode _Getter_ { _Label_, \ + o2::framework::expressions::selectArrowType<_Type_>() } /// A dynamic column is a column whose values are derived /// from those of other real columns. These can be used for @@ -884,6 +888,8 @@ template struct Join : JoinBase { Join(std::shared_ptr t1, std::shared_ptr t2) : JoinBase{ArrowHelpers::joinTables({t1, t2})} {} + Join(std::vector> tables) + : JoinBase{ArrowHelpers::joinTables(std::move(tables))} {} using left_t = T1; using right_t = T2; @@ -894,6 +900,8 @@ template struct Concat : ConcatBase { Concat(std::shared_ptr t1, std::shared_ptr t2) : ConcatBase{ArrowHelpers::concatTables({t1, t2})} {} + Concat(std::vector> tables) + : ConcatBase{ArrowHelpers::concatTables(std::move(tables))} {} using left_t = T1; using right_t = T2; diff --git a/Converter/src/Framework/AnalysisDataModel.h b/Converter/src/Framework/AnalysisDataModel.h index 7f90b17..e426f66 100644 --- a/Converter/src/Framework/AnalysisDataModel.h +++ b/Converter/src/Framework/AnalysisDataModel.h @@ -24,7 +24,7 @@ DECLARE_SOA_STORE(); namespace track { // TRACKPAR TABLE definition -DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fID4Collisions"); +DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fCollisionsID"); DECLARE_SOA_COLUMN(X, x, float, "fX"); DECLARE_SOA_COLUMN(Alpha, alpha, float, "fAlpha"); DECLARE_SOA_COLUMN(Y, y, float, "fY"); @@ -94,7 +94,7 @@ using TrackExtra = TracksExtra::iterator; namespace calo { -DECLARE_SOA_COLUMN(CollisionId, collisionId, int32_t, "fID4Collisions"); +DECLARE_SOA_COLUMN(CollisionId, collisionId, int32_t, "fCollisionsID"); DECLARE_SOA_COLUMN(CellNumber, cellNumber, int64_t, "fCellNumber"); DECLARE_SOA_COLUMN(Amplitude, amplitude, float, "fAmplitude"); DECLARE_SOA_COLUMN(Time, time, float, "fTime"); @@ -108,9 +108,10 @@ using Calo = Calos::iterator; namespace calotrigger { -DECLARE_SOA_COLUMN(CollisionId, collisionId, int32_t, "fID4Collision"); -DECLARE_SOA_COLUMN(FastorAbsId, fastorAbsId, int32_t, "fFastOrAbsID"); +DECLARE_SOA_COLUMN(CollisionId, collisionId, int32_t, "fCollisionsID"); +DECLARE_SOA_COLUMN(FastorAbsId, fastorAbsId, int32_t, "fFastorAbsID"); DECLARE_SOA_COLUMN(L0Amplitude, l0Amplitude, float, "fL0Amplitude"); +DECLARE_SOA_COLUMN(L0Time, l0Time, float, "fL0Time"); DECLARE_SOA_COLUMN(L1Timesum, l1Timesum, int32_t, "fL1TimeSum"); DECLARE_SOA_COLUMN(NL0Times, nl0Times, int8_t, "fNL0Times"); DECLARE_SOA_COLUMN(Triggerbits, triggerbits, int32_t, "fTriggerBits"); @@ -118,16 +119,16 @@ DECLARE_SOA_COLUMN(CaloType, caloType, int8_t, "fType"); } // namespace calotrigger DECLARE_SOA_TABLE(CaloTriggers, "AOD", "CALOTRIGGER", - calotrigger::CollisionId, calotrigger::FastorAbsId, calotrigger::L0Amplitude, calotrigger::L1Timesum, calotrigger::NL0Times, calotrigger::Triggerbits, calotrigger::CaloType); + calotrigger::CollisionId, calotrigger::FastorAbsId, calotrigger::L0Amplitude, calotrigger::L0Time, calotrigger::L1Timesum, calotrigger::NL0Times, calotrigger::Triggerbits, calotrigger::CaloType); using CaloTrigger = CaloTriggers::iterator; namespace muon { -DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fID4Collisions"); +DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fCollisionsID"); DECLARE_SOA_COLUMN(InverseBendingMomentum, inverseBendingMomentum, float, "fInverseBendingMomentum"); DECLARE_SOA_COLUMN(ThetaX, thetaX, float, "fThetaX"); DECLARE_SOA_COLUMN(ThetaY, thetaY, float, "fThetaY"); -DECLARE_SOA_COLUMN(ZMu, zMu, float, "fZmu"); +DECLARE_SOA_COLUMN(ZMu, zMu, float, "fZ"); DECLARE_SOA_COLUMN(BendingCoor, bendingCoor, float, "fBendingCoor"); DECLARE_SOA_COLUMN(NonBendingCoor, nonBendingCoor, float, "fNonBendingCoor"); // FIXME: need to implement array columns... @@ -143,45 +144,100 @@ DECLARE_SOA_TABLE(Muons, "AOD", "MUON", muon::Chi2, muon::Chi2MatchTrigger); using Muon = Muons::iterator; +namespace muoncluster +{ +DECLARE_SOA_COLUMN(TrackId, trackId, int, "fMuTrackID"); +DECLARE_SOA_COLUMN(X, x, float, "fX"); +DECLARE_SOA_COLUMN(Y, y, float, "fY"); +DECLARE_SOA_COLUMN(Z, z, float, "fZ"); +DECLARE_SOA_COLUMN(ErrX, errX, float, "fErrX"); +DECLARE_SOA_COLUMN(ErrY, errY, float, "fErrY"); +DECLARE_SOA_COLUMN(Charge, charge, float, "fCharge"); +DECLARE_SOA_COLUMN(Chi2, chi2, float, "fChi2"); +} // namespace muoncluster + +DECLARE_SOA_TABLE(MuonClusters, "AOD", "MUONCLUSTER", + muoncluster::TrackId, + muoncluster::X, muoncluster::Y, muoncluster::Z, + muoncluster::ErrX, muoncluster::ErrY, + muoncluster::Charge, muoncluster::Chi2); + +using MuonCluster = MuonClusters::iterator; + +namespace zdc +{ +DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fCollisionsID"); +DECLARE_SOA_COLUMN(ZEM1Energy, zem1Energy, float, "fZEM1Energy"); +DECLARE_SOA_COLUMN(ZEM2Energy, zem2Energy, float, "fZEM2Energy"); +// FIXME: arrays... +// DECLARE_SOA_COLUMN(ZNCTowerEnergy, zncTowerEnergy, float[5], "fZNCTowerEnergy"); +// DECLARE_SOA_COLUMN(ZNATowerEnergy, znaTowerEnergy, float[5], "fZNATowerEnergy"); +// DECLARE_SOA_COLUMN(ZPCTowerEnergy, zpcTowerEnergy, float[5], "fZPCTowerEnergy"); +// DECLARE_SOA_COLUMN(ZPATowerEnergy, zpaTowerEnergy, float[5], "fZPATowerEnergy"); +// DECLARE_SOA_COLUMN(ZNCTowerEnergyLR, zncTowerEnergyLR, float[5], "fZNCTowerEnergyLR"); +// DECLARE_SOA_COLUMN(ZNATowerEnergyLR, znaTowerEnergyLR, float[5], "fZNATowerEnergyLR"); +// DECLARE_SOA_COLUMN(ZPCTowerEnergyLR, zpcTowerEnergyLR, float[5], "fZPCTowerEnergyLR"); +// DECLARE_SOA_COLUMN(ZPATowerEnergyLR, zpaTowerEnergyLR, float[5], "fZPATowerEnergyLR"); +// DECLARE_SOA_COLUMN(fZDCTDCCorrected, fZDCTDCCorrected, float[32][4], "fZDCTDCCorrected"); +DECLARE_SOA_COLUMN(Fired, fired, uint8_t, "fFired"); +} // namespace zdc + +DECLARE_SOA_TABLE(Zdcs, "AOD", "ZDC", zdc::CollisionId, zdc::ZEM1Energy, zdc::ZEM2Energy, zdc::Fired); +using Zdc = Zdcs::iterator; + namespace vzero { -DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fIDvz"); +DECLARE_SOA_COLUMN(CollisionId, collisionId, int, "fCollisionsID"); // FIXME: add missing arrays... +// DECLARE_SOA_COLUMN(Adc, adc, float[64], "fAdc"); +// DECLARE_SOA_COLUMN(Time, time, float[64], "fTime"); +// DECLARE_SOA_COLUMN(Width, width, float[64], "fWidth"); +DECLARE_SOA_COLUMN(BBFlag, bbFlag, uint64_t, "fBBFlag"); +DECLARE_SOA_COLUMN(BGFlag, bgFlag, uint64_t, "fBGFlag"); } // namespace vzero -DECLARE_SOA_TABLE(VZeros, "AOD", "VZERO", vzero::CollisionId); +DECLARE_SOA_TABLE(VZeros, "AOD", "VZERO", vzero::CollisionId, vzero::BBFlag, vzero::BGFlag); using VZero = VZeros::iterator; +namespace v0 +{ +DECLARE_SOA_COLUMN(PosTrackId, posTrackId, int, "fPosTrackID"); +DECLARE_SOA_COLUMN(NegTrackId, negTrackId, int, "fNegTrackID"); +} // namespace v0 + +DECLARE_SOA_TABLE(V0s, "AOD", "V0", v0::PosTrackId, v0::NegTrackId); +using V0 = V0s::iterator; + +namespace cascade +{ +DECLARE_SOA_COLUMN(V0Id, v0Id, int, "fV0ID"); +DECLARE_SOA_COLUMN(BachelorId, bachelorId, int, "fBachelorID"); +} // namespace cascade + +DECLARE_SOA_TABLE(Cascades, "AOD", "CASCADE", cascade::V0Id, cascade::BachelorId); +using Casecade = Cascades::iterator; + namespace collision { -DECLARE_SOA_COLUMN(TimeframeID, timeframeID, uint64_t, "timeframeID"); -DECLARE_SOA_COLUMN(NumTracks, numtracks, uint32_t, "numtracks"); -DECLARE_SOA_COLUMN(VtxID, vtxID, int, "vtxID"); // index of the vertex inside the timeframe, AliESDVertex, ushort_t -DECLARE_SOA_COLUMN(PosX, posX, double, "posX"); // vertex x position, AliVertex.h, Double32_t -DECLARE_SOA_COLUMN(PosY, posY, double, "posY"); // vertex y position, AliVertex.h, Double32_t -DECLARE_SOA_COLUMN(PosZ, posZ, double, "posZ"); // vertex z position, AliVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovXX, covXX, double, "covXX"); // vertex covariance matrix element: XX, AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovXY, covXY, double, "covXY"); // vertex covariance matrix element: XY, AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovXZ, covXZ, double, "covXZ"); // vertex covariance matrix element: XZ, AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovYX, covYX, double, "covYX"); // vertex covariance matrix element: YX (same as XY), AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovYY, covYY, double, "covYY"); // vertex covariance matrix element: YY, AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovYZ, covYZ, double, "covYZ"); // vertex covariance matrix element: YZ, AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovZX, covZX, double, "covZX"); // vertex covariance matrix element: ZX (same as XZ), AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovZY, covZY, double, "covZY"); // vertex covariance matrix element: ZY (same as YZ), AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(CovZZ, covZZ, double, "covZZ"); // vertex covariance matrix element: ZZ, AliESDVertex.h, Double32_t -DECLARE_SOA_COLUMN(Chi2, chi2, double, "chi2"); // chi2 of vertex fit, AliESDVertex.h, Double32_t -//DECLARE_SOA_COLUMN(Indices, indices, int*, "indices"); // contributing track IDs to the vertex reconstruction, AliVertex.h, UShort_t* -DECLARE_SOA_COLUMN(BCNum, bcnum, int, "bcnum"); // LHC bunch crossing number, AliESDHeader.h, UShort_t -DECLARE_SOA_COLUMN(OrbitNum, orbitnum, int, "orbitnum"); // LHC orbit number, AliESDHeader, UInt_t -//DECLARE_SOA_COLUMN(PeriodNumber, periodNumber, int, "periodNumber"); // period number (No period number in run 3. Will be included in orbit number.), AliESDHeader, UInt_t -//DECLARE_SOA_COLUMN(V0mult, v0mult, int, "v0mult"); // V0 multiplicity (redundant as it is also in the detector table) -//DECLARE_SOA_COLUMN(T0multA, t0multA, int, "t0multA"); // T0 A multiplicity (redundant as it is also in the detector table) -//DECLARE_SOA_COLUMN(T0multC, t0multc, int, "t0multC"); // T0 C multiplicity (redundant as it is also in the detector table) -//DECLARE_SOA_COLUMN(FITmult, fitmult, int, "fitmult"); // FIT multiplicity (redundant as it is also in the detector table) -DECLARE_SOA_COLUMN(TriggerMask, triggermask, int, "triggermask"); // Trigger mask, AliESDHeader.h, ULong64_t +// DECLARE_SOA_COLUMN(TimeframeId, timeframeId, uint64_t, "timeframeID"); +DECLARE_SOA_COLUMN(VtxId, vtxId, int, "fEventId"); +DECLARE_SOA_COLUMN(PosX, posX, double, "fX"); +DECLARE_SOA_COLUMN(PosY, posY, double, "fY"); +DECLARE_SOA_COLUMN(PosZ, posZ, double, "fZ"); +DECLARE_SOA_COLUMN(CovXX, covXX, double, "fCovXX"); +DECLARE_SOA_COLUMN(CovXY, covXY, double, "fcovXY"); +DECLARE_SOA_COLUMN(CovXZ, covXZ, double, "fCovXZ"); +DECLARE_SOA_COLUMN(CovYY, covYY, double, "fCovYY"); +DECLARE_SOA_COLUMN(CovYZ, covYZ, double, "fCovYZ"); +DECLARE_SOA_COLUMN(CovZZ, covZZ, double, "fCovZZ"); +DECLARE_SOA_COLUMN(Chi2, chi2, double, "fChi2"); +DECLARE_SOA_COLUMN(NumContrib, numContrib, uint32_t, "fN"); +DECLARE_SOA_COLUMN(EventTime, eventTime, double, "fEventTime"); +DECLARE_SOA_COLUMN(EventTimeRes, eventTimeRes, double, "fEventTimeRes"); +DECLARE_SOA_COLUMN(EventTimeMask, eventTimeMask, uint8_t, "fEventTimeMask"); } // namespace collision -DECLARE_SOA_TABLE(Collisions, "AOD", "COLLISION", collision::TimeframeID, collision::NumTracks, collision::VtxID, collision::PosX, collision::PosY, collision::PosZ, collision::CovXX, collision::CovXY, collision::CovXZ, collision::CovYX, collision::CovYY, collision::CovYZ, collision::CovZX, collision::CovZY, collision::CovZZ, collision::Chi2, collision::BCNum, collision::OrbitNum, collision::TriggerMask); +DECLARE_SOA_TABLE(Collisions, "AOD", "COLLISION", collision::VtxId, collision::PosX, collision::PosY, collision::PosZ, collision::CovXX, collision::CovXY, collision::CovXZ, collision::CovYY, collision::CovYZ, collision::CovZZ, collision::Chi2, collision::NumContrib, collision::EventTime, collision::EventTimeRes, collision::EventTimeMask); using Collision = Collisions::iterator; diff --git a/Converter/src/Framework/BasicOps.h b/Converter/src/Framework/BasicOps.h index 119444b..3e48162 100644 --- a/Converter/src/Framework/BasicOps.h +++ b/Converter/src/Framework/BasicOps.h @@ -18,11 +18,13 @@ enum BasicOp : unsigned int { Addition, Subtraction, Division, + Multiplication, LessThan, LessThanOrEqual, GreaterThan, GreaterThanOrEqual, - Equal + Equal, + NotEqual }; } // namespace o2::framework diff --git a/Converter/src/Framework/CompilerBuiltins.h b/Converter/src/Framework/CompilerBuiltins.h index 9288def..93d0215 100644 --- a/Converter/src/Framework/CompilerBuiltins.h +++ b/Converter/src/Framework/CompilerBuiltins.h @@ -33,11 +33,19 @@ #endif #if __GNUC__ -#define O2_BUILTIN_PREFETCH(x, ...) __builtin_prefetch(x, __VA_ARGS__) +#define O2_BUILTIN_PREFETCH(x, ...) __builtin_prefetch((x), __VA_ARGS__) #elif __clang__ -#define O2_BUILTIN_PREFETCH(x, ...) __builtin_prefetch(x, __VA_ARGS__) +#define O2_BUILTIN_PREFETCH(x, ...) __builtin_prefetch((x), __VA_ARGS__) #else #define O2_BUILTIN_PREFETCH(x, ...) #endif +#if __GNUC__ +#define O2_VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) +#elif __clang__ +#define O2_VISIBILITY_HIDDEN __attribute__((visibility("hidden"))) +#else +#define O2_VISIBILITY_HIDDEN +#endif + #endif // O2_FRAMEWORK_COMPILER_BUILTINS_H_ diff --git a/Converter/src/Framework/Expressions.h b/Converter/src/Framework/Expressions.h index 9d1d0ba..8e4b0f1 100644 --- a/Converter/src/Framework/Expressions.h +++ b/Converter/src/Framework/Expressions.h @@ -11,33 +11,65 @@ #define O2_FRAMEWORK_EXPRESSIONS_H_ #include "Framework/BasicOps.h" - +#include "Framework/CompilerBuiltins.h" +#include "Framework/FunctionalHelpers.h" +#include #include #include - +#include +#include "gandiva/filter.h" #include #include #include +using atype = arrow::Type; + namespace o2::framework::expressions { +template +struct LiteralStorage { + using stored_type = std::variant; + using stored_pack = framework::pack; +}; + +using LiteralValue = LiteralStorage; + +template +constexpr auto selectArrowType() +{ + if constexpr (std::is_same_v) { + return atype::INT32; + } else if constexpr (std::is_same_v) { + return atype::BOOL; + } else if constexpr (std::is_same_v) { + return atype::FLOAT; + } else if constexpr (std::is_same_v) { + return atype::DOUBLE; + } else { + return atype::NA; + } + O2_BUILTIN_UNREACHABLE(); +} + /// An expression tree node corresponding to a literal value struct LiteralNode { template - LiteralNode(T v) : value{v} + LiteralNode(T v) : value{v}, type{selectArrowType()} { } - using var_t = std::variant; + using var_t = LiteralValue::stored_type; var_t value; + atype::type type = atype::NA; }; /// An expression tree node corresponding to a column binding struct BindingNode { BindingNode(BindingNode const&) = default; BindingNode(BindingNode&&) = delete; - BindingNode(std::string const& name_) : name{name_} {} + BindingNode(std::string const& name_, atype::type type_) : name{name_}, type{type_} {} std::string name; + atype::type type; }; /// An expression tree node corresponding to binary operation @@ -74,6 +106,8 @@ struct Node { }; /// overloaded operators to build the tree from an expression + +/// literal comparisons template inline Node operator>(Node left, T rightValue) { @@ -104,6 +138,44 @@ inline Node operator==(Node left, T rightValue) return Node{BinaryOpNode{BasicOp::Equal}, std::move(left), LiteralNode{rightValue}}; } +template +inline Node operator!=(Node left, T rightValue) +{ + return Node{BinaryOpNode{BasicOp::NotEqual}, std::move(left), LiteralNode{rightValue}}; +} + +/// node comparisons +inline Node operator>(Node left, Node right) +{ + return Node{BinaryOpNode{BasicOp::GreaterThan}, std::move(left), std::move(right)}; +} + +inline Node operator<(Node left, Node right) +{ + return Node{BinaryOpNode{BasicOp::LessThan}, std::move(left), std::move(right)}; +} + +inline Node operator>=(Node left, Node right) +{ + return Node{BinaryOpNode{BasicOp::GreaterThanOrEqual}, std::move(left), std::move(right)}; +} + +inline Node operator<=(Node left, Node right) +{ + return Node{BinaryOpNode{BasicOp::LessThanOrEqual}, std::move(left), std::move(right)}; +} + +inline Node operator==(Node left, Node right) +{ + return Node{BinaryOpNode{BasicOp::Equal}, std::move(left), std::move(right)}; +} + +inline Node operator!=(Node left, Node right) +{ + return Node{BinaryOpNode{BasicOp::NotEqual}, std::move(left), std::move(right)}; +} + +/// logical operations inline Node operator&&(Node left, Node right) { return Node{BinaryOpNode{BasicOp::LogicalAnd}, std::move(left), std::move(right)}; @@ -114,6 +186,31 @@ inline Node operator||(Node left, Node right) return Node{BinaryOpNode{BasicOp::LogicalOr}, std::move(left), std::move(right)}; } +/// arithmetical operations between node and literal +template +inline Node operator*(Node left, T right) +{ + return Node{BinaryOpNode{BasicOp::Multiplication}, std::move(left), LiteralNode{right}}; +} + +template +inline Node operator/(Node left, T right) +{ + return Node{BinaryOpNode{BasicOp::Division}, std::move(left), LiteralNode{right}}; +} + +template +inline Node operator+(Node left, T right) +{ + return Node{BinaryOpNode{BasicOp::Addition}, std::move(left), LiteralNode{right}}; +} + +template +inline Node operator-(Node left, T right) +{ + return Node{BinaryOpNode{BasicOp::Subtraction}, std::move(left), LiteralNode{right}}; +} + /// A struct, containing the root of the expression tree struct Filter { Filter(Node&& node_) : node{std::make_unique(std::move(node_))} {} @@ -122,7 +219,17 @@ struct Filter { }; using Selection = std::shared_ptr; -Selection createSelection(std::shared_ptr table, Filter const& filter); +Selection createSelection(std::shared_ptr table, Filter const& expression); + +struct ColumnOperationSpec; +using Operations = std::vector; + +Operations createOperations(Filter const& expression); +bool isSchemaCompatible(gandiva::SchemaPtr const& Schema, Operations const& opSpecs); +gandiva::NodePtr createExpressionTree(Operations const& opSpecs, + gandiva::SchemaPtr const& Schema); +std::shared_ptr createFilter(gandiva::SchemaPtr const& Schema, + gandiva::ConditionPtr condition); } // namespace o2::framework::expressions diff --git a/Converter/src/Framework/RootTableBuilderHelpers.h b/Converter/src/Framework/RootTableBuilderHelpers.h index 70bb8bc..dd2f5d4 100644 --- a/Converter/src/Framework/RootTableBuilderHelpers.h +++ b/Converter/src/Framework/RootTableBuilderHelpers.h @@ -66,6 +66,15 @@ struct ValueExtractor { } }; +template +struct ColumnReaderTrait { + using Reader = TTreeReaderValue; + static std::unique_ptr createReader(TTreeReader& reader) + { + return std::make_unique(reader, C::base::label()); + }; +}; + struct RootTableBuilderHelpers { template static void convertTTree(TableBuilder& builder, @@ -73,12 +82,24 @@ struct RootTableBuilderHelpers { TTREEREADERVALUE&... values) { std::vector branchNames = {values.GetBranchName()...}; - auto filler = builder.preallocatedPersist::Type...>(branchNames, reader.GetEntries(true)); + auto filler = builder.preallocatedPersist>::Type...>(branchNames, reader.GetEntries(true)); reader.Restart(); while (reader.Next()) { filler(0, ValueExtractor::deref(values)...); } } + + template + static void convertASoAColumns(TableBuilder& builder, TTreeReader& reader, pack) + { + return convertTTree(builder, reader, *ColumnReaderTrait::createReader(reader)...); + } + + template + static void convertASoA(TableBuilder& builder, TTreeReader& reader) + { + return convertASoAColumns(builder, reader, typename T::persistent_columns_t{}); + } }; } // namespace framework diff --git a/Converter/src/Framework/Traits.h b/Converter/src/Framework/Traits.h index ac4bd52..4fa561f 100644 --- a/Converter/src/Framework/Traits.h +++ b/Converter/src/Framework/Traits.h @@ -37,6 +37,17 @@ struct always_static_assert : std::false_type { template inline constexpr bool always_static_assert_v = always_static_assert::value; +template