Get Data by TChain

Hi Rooters,

I tried to get data from many root files by using TChain but I failed and can’t figure out how to do.

First I write :

Chain ch("T");

Then should I use TFile::Open? By a loop?
And how should I use GetEntry?


you have to pass ch to the TTreeReader constructor:

TTreeReader r(&ch);
TTreeReaderValue<int> x(r, "x"); // proxy to the `x` column
  std::cout << *x  << std::endl; // print all values of x

If you have access to ROOT v6.10, you might want to also take a look at TDataFrame for a higher level interface to read and manipulate ROOT data.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.