784 class RCustomColumnBase;
788 using ColumnNames_t = ROOT::Detail::RDF::ColumnNames_t;
789 using ColumnNamesPtr_t = std::shared_ptr<const ColumnNames_t>;
791 namespace RDFInternal = ROOT::Internal::RDF;
802 RDataFrame::RDataFrame(std::string_view treeName, TDirectory *dirPtr,
const ColumnNames_t &defaultBranches)
803 : RInterface(std::make_shared<RDFDetail::RLoopManager>(nullptr, defaultBranches))
806 auto msg =
"Invalid TDirectory!";
807 throw std::runtime_error(msg);
809 const std::string treeNameInt(treeName);
810 auto tree =
static_cast<TTree *
>(dirPtr->Get(treeNameInt.c_str()));
812 auto msg =
"Tree \"" + treeNameInt +
"\" cannot be found!";
813 throw std::runtime_error(msg);
815 GetProxiedPtr()->SetTree(std::shared_ptr<TTree>(tree, [](TTree *) {}));
828 RDataFrame::RDataFrame(std::string_view treeName, std::string_view filenameglob,
const ColumnNames_t &defaultBranches)
829 : RInterface(std::make_shared<RDFDetail::RLoopManager>(nullptr, defaultBranches))
831 const std::string treeNameInt(treeName);
832 const std::string filenameglobInt(filenameglob);
833 auto chain = std::make_shared<TChain>(treeNameInt.c_str());
834 chain->Add(filenameglobInt.c_str());
835 GetProxiedPtr()->SetTree(chain);
847 RDataFrame::RDataFrame(std::string_view treeName,
const std::vector<std::string> &fileglobs,
848 const ColumnNames_t &defaultBranches)
849 : RInterface(std::make_shared<RDFDetail::RLoopManager>(nullptr, defaultBranches))
851 std::string treeNameInt(treeName);
852 auto chain = std::make_shared<TChain>(treeNameInt.c_str());
853 for (
auto &f : fileglobs)
854 chain->Add(f.c_str());
855 GetProxiedPtr()->SetTree(chain);
866 RDataFrame::RDataFrame(TTree &tree,
const ColumnNames_t &defaultBranches)
867 : RInterface(std::make_shared<RDFDetail::RLoopManager>(&tree, defaultBranches))
879 RDataFrame::RDataFrame(ULong64_t numEntries)
880 : RInterface(std::make_shared<RDFDetail::RLoopManager>(numEntries))
892 RDataFrame::RDataFrame(std::unique_ptr<ROOT::RDF::RDataSource> ds,
const ColumnNames_t &defaultBranches)
893 : RInterface(std::make_shared<RDFDetail::RLoopManager>(std::move(ds), defaultBranches))
902 std::string printValue(ROOT::RDataFrame *tdf)
904 auto &df = *tdf->GetLoopManager();
905 auto *tree = df.GetTree();
906 auto defBranches = df.GetDefaultColumnNames();
908 std::ostringstream ret;
910 ret <<
"A data frame built on top of the " << tree->GetName() <<
" dataset.";
911 if (!defBranches.empty()) {
912 if (defBranches.size() == 1)
913 ret <<
"\nDefault branch: " << defBranches[0];
915 ret <<
"\nDefault branches:\n";
916 for (
auto &&branch : defBranches) {
917 ret <<
" - " << branch <<
"\n";
921 }
else if (
auto ds = tdf->fDataSource) {
922 ret <<
"A data frame associated to the data source \"" << cling::printValue(ds) <<
"\"";
924 ret <<
"An empty data frame that will create " << df.GetNEmptyEntries() <<
" entries\n";