From a69a37f1b9ef211ef6470b43c8dc8a5db0edbde2 Mon Sep 17 00:00:00 2001 From: Danilo Piparo <danilo.piparo@cern.ch> Date: Tue, 26 Mar 2019 15:56:11 +0100 Subject: [PATCH] [Tutorials] Use in RDF/Multicore tutorials the new TFile::Get<T> method in order to make of this code the most up-to-date set of examples possible. --- tutorials/dataframe/df007_snapshot.C | 5 ++--- tutorials/multicore/imt001_parBranchProcessing.C | 3 +-- tutorials/multicore/mp103_processSelector.C | 3 +-- tutorials/multicore/mt102_readNtuplesFillHistosAndFit.C | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tutorials/dataframe/df007_snapshot.C b/tutorials/dataframe/df007_snapshot.C index e66e1d3a85f..f4729c92f4b 100644 --- a/tutorials/dataframe/df007_snapshot.C +++ b/tutorials/dataframe/df007_snapshot.C @@ -60,8 +60,7 @@ int df007_snapshot() // Open the new file and list the columns of the tree TFile f1(outFileName); - TTree *t; - f1.GetObject(treeName, t); + auto t = f1.Get<TTree>(treeName); std::cout << "These are the columns b1, b1_square and b2_vector:" << std::endl; for (auto branch : *t->GetListOfBranches()) { std::cout << "Branch: " << branch->GetName() << std::endl; @@ -75,7 +74,7 @@ int df007_snapshot() // Open the new file and list the columns of the tree TFile f2(outFileNameAllColumns); - f2.GetObject(treeName, t); + t = f2.Get<TTree>(treeName); std::cout << "These are all the columns available to this tdf:" << std::endl; for (auto branch : *t->GetListOfBranches()) { std::cout << "Branch: " << branch->GetName() << std::endl; diff --git a/tutorials/multicore/imt001_parBranchProcessing.C b/tutorials/multicore/imt001_parBranchProcessing.C index 312d9307bc9..8f87ac425c7 100644 --- a/tutorials/multicore/imt001_parBranchProcessing.C +++ b/tutorials/multicore/imt001_parBranchProcessing.C @@ -23,8 +23,7 @@ int imt001_parBranchProcessing() auto file = TFile::Open("http://root.cern.ch/files/h1/dstarmb.root"); // Get the tree - TTree *tree = nullptr; - file->GetObject<TTree>("h42", tree); + auto tree = file->Get<TTree>("h42"); const auto nEntries = tree->GetEntries(); diff --git a/tutorials/multicore/mp103_processSelector.C b/tutorials/multicore/mp103_processSelector.C index 525dc1f08d9..97e51b59be2 100644 --- a/tutorials/multicore/mp103_processSelector.C +++ b/tutorials/multicore/mp103_processSelector.C @@ -42,8 +42,7 @@ int mp103_processSelector() // #define __reproduce_davix #if defined(__reproduce_davix) auto fp = std::make_unique<TTree>(TFile::Open(file0)); - TTree *tree; - fp->GetObject("h42", tree); + auto tree = fp->Get<TTree>("h42"); #endif ROOT::TTreeProcessorMP pool(3); diff --git a/tutorials/multicore/mt102_readNtuplesFillHistosAndFit.C b/tutorials/multicore/mt102_readNtuplesFillHistosAndFit.C index 14781f9a2f4..043a3f51973 100644 --- a/tutorials/multicore/mt102_readNtuplesFillHistosAndFit.C +++ b/tutorials/multicore/mt102_readNtuplesFillHistosAndFit.C @@ -46,8 +46,7 @@ Int_t mt102_readNtuplesFillHistosAndFit() // We define our work item auto workItem = [&histograms](UInt_t workerID) { TFile f(Form("mt101_multiCore_%u.root", workerID)); - TNtuple *ntuple = nullptr; - f.GetObject("multiCore", ntuple); + auto ntuple = f.Get<TNtuple>("multiCore"); auto &histo = histograms.at(workerID); for (auto index : ROOT::TSeqL(ntuple->GetEntriesFast())) { ntuple->GetEntry(index); -- GitLab