Looping over multiple root files, merging them and plotting a particular tree

Hi @thegame ,

if I understand correctly you have a dataset (split across multiple files) that consists of 10 columns, and column values are arrays of size 3.
Assuming that what’s time consuming is looping over the data 30 times instead of just 1, you can use RDataFrame to speed that up:

ROOT::RDataFrame df(treename, "path/to/data/*.root")
// now we book 30 histograms
auto h00 = df.Define("value00", "column0[0]").Histo1D("value00");
auto h01 = df.Define("value01", "column0[1]").Histo1D("value01");
// ...
// and the event loop is run lazily, the first time you access one of the results, e.g. here:
h00->Draw();

Of course we can use a loop to book all histograms rather than manually writing one line per histogram:

ROOT::RDataFrame df(treename, "path/to/data/*.root")
// now we book 30 histograms
std::vector<ROOT::RDF::RResultPtr<TH1D>> histos;
for (int col_idx = 0; col_idx < 10; ++col_idx) {
  for (int arr_idx = 0; arr_idx < 3; ++arr_idx) {
    const std::string col = std::to_string(col_idx);
    const std::string val = std::to_string(arr_idx);
    df.Define("tmp", "column" + col + '[' + val + ']')
      .Histo1D("tmp");
    histos.push_back();
  }
}

(I plotted the data as histograms but RDF can also produce TGraphs or any other custom data aggregation).

I hope this helps,
Enrico