If you are reading as TTree (not RDataFrame), see the read function in this tutorial: https://root.cern/doc/master/hvector_8C.html
In short: create vector pointer(s), use SetBranchAddress, loop over the tree to get each event, and within each event, loop over the elements of the vector(s).
In general, I would recommend going through the manual to get a better understanding of the TTree interface.
For your specific question: the recommended way to process and/or visualize the data inside a TTree is through RDataFrame.
For example, a simple way to visualize the data inside your TTree’s branches is:
ROOT::RDataFrame d("B5", "your_file.root");
auto myHisto = d.Histo1D("Etot"); // replace with whichever branch you want
myHisto->Draw();
RDataFrame also offers a number of other operations that you may want to perform on your data: refer to the documentation linked above if needed.
Thank you very much!! I’ll defintely look a bit into RDataFrame…
May I ask another question? I tried to follow the same method you told me about in order to plot a 2D histogram; this is what I did:
XV and YV are the names of two branches containing vectors.
However, after the “Draw” instruction, root just crashes (there are no errors apparently, it just makes me go back to my directory and I have to start over)
I don’t know if I’m doing something wrong or if maybe it’s just a lot of data to process…
I imagine you’re filling your TTree branches from n.Loop() and then reading them back with RDataFrame right after it. If that’s the case, there might be some resource management error in the Loop() function which causes errors when reading back the data (e.g. maybe the file doesn’t get closed properly before invoking RDataFrame::Draw).
Unfortunately it’s hard to tell what the problem is without knowing what Loop() does exactly. If you want a more thorough answer, you can send me at least the code for the readNtuple class and a small sample of the data you’re processing (you can do it via private message if you prefer).