Reading and organizing data from text file

I’m quite new to ROOT and would like some advice on how to think about reading data from a file into a TTree, including some computations in the process. I have say 40 text files each with 16 columns of numbers. From the numbers in each column I want to calculate 3 quantities. This makes a 3*16-variable space, in which each of the 40 files will generate one data point. In the end I thus want a TTree with 48 leaves for each of the variables, with 40 entries. (Finally, I want to make a statistical analysis on these, a Principal Component Analysis, but that’s for later).

How would you go about to do this? I would just like to hear how someone experienced would reason on a problem like this.

At the moment I’m first reading in the data to a tree to calculate the three quantities, and then once they’re calculated written to a new tree. I’m not sure this is a very clever way though.


if I understand correctly, your problem is splittable in two components: parsing of files and storing content in ROOT.
For the parsing, you can for sure use C++ or use a language more suited for this operations, like Python (all ROOT classes are accessible via PyROOT in Python).
Now, about making your data available in ROOT. If I understand correctly, you need to save only numbers and not complex objects. So I would propose to use the TNtuple class: