Reading a large amount of data from TTree at once

I have a root file whose size is smaller than 1GB. This file contains only one TTree that has 11 million entries with 12 variables. Using the data I tried to draw histograms with various settings. For this work, it is desired that the computer holds all data in memory and performs calculations as fast as possible. However, my ROOT macro is even slower than a Python script written for the same task, and the memory consumption by ROOT during the execution of the macro is only about 100 MB. How could I increase the memory usage to enhance the performance?

Hi,

two solutions I’m thinking of:

  • compile your macro. This will accelerate a bit your program.
  • use LoadBaskets() with a meaningful value as parameter. This will force the tree to load a certain amount of data in memory. You can also use it per branch by calling TBranch::LoadBaskets() if it fits your case.
  • compile your macro. This will accelerate a bit your program.
  • use LoadBaskets() with a meaningful value as parameter. This will force the tree to load a certain amount of data in memory. You can also use it per branch by calling TBranch::LoadBaskets() if it fits your case.

Compiling the macros didn’t boost the processing and didn’t increase the memory usage. I tried tree->LoadBaskets() with a large parameter, but it also didn’t help.

When using TBranch::LoadBaskets(), would I have to do this for all branches in the tree?

What is the difference between the (fast) python script and the C++ code?

Are you plotting all the branches, all the times or just a subset?

When using TBranch::LoadBaskets(), would I have to do this for all branches in the tree?

Yes … but that is exactly what TTree::LoadBaskets do …

One advantage of calling TBranch::LoadBaskets() is that you could call it on only the branches you use.

Happy holidays.
Philippe.