// Author: Danilo Piparo, Enrico Guiraud, Stefan Wunsch CERN 04/2018 /************************************************************************* * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers. * * All rights reserved. * * * * For the licensing terms see $ROOTSYS/LICENSE. * * For the list of contributors see $ROOTSYS/README/CREDITS. * *************************************************************************/ #ifndef ROOT_PyROOTHelpers #define ROOT_PyROOTHelpers #include "ROOT/RDataFrame.hxx" #include #include #include namespace ROOT { namespace Internal { namespace RDF { template ULong64_t GetVectorAddress(std::vector &p) { return reinterpret_cast(&p); } inline ULong64_t GetAddress(std::vector &p) { return reinterpret_cast(&p); } inline ULong64_t GetAddress(TTree &p) { return reinterpret_cast(&p); } template void TTreeAsFlatMatrix(std::index_sequence, TTree &tree, std::vector &matrix, std::vector &columns) { auto buffer = matrix.data(); auto fillMatrix = [buffer](ColTypes... cols, ULong64_t entry) { int expander[] = {(buffer[entry * sizeof...(Idx) + Idx] = cols, 0)...}; (void)expander; }; auto columnsWithEntry = columns; columnsWithEntry.emplace_back("tdfentry_"); ROOT::RDataFrame dataframe(tree, columns); dataframe.Foreach(fillMatrix, columnsWithEntry); } template void TTreeAsFlatMatrixHelper(TTree &tree, std::vector &matrix, std::vector &columns) { TTreeAsFlatMatrix(std::index_sequence_for(), tree, matrix, columns); } // RDataFrame.AsNumpy helpers // NOTE: This is a workaround for the missing Take action in the PyROOT interface template ROOT::RDF::RResultPtr> RDataFrameTake(ROOT::RDF::RNode df, std::string_view column) { return df.Take(column); } } // namespace RDF } // namespace Internal } // namespace ROOT #endif