Creating TGraphObject manually from TNuple


I want to create Graphs easily from ASCII-Files like in Gnuplot. Luckily, there is the class TNtuple with the convinient ReadFile() method, so i don’t have to code the reading procedure myself. However, the Draw() method from NTuple is too simple for my case. It does not support error bars, for instance.

What I want to do is to create my own TGraph oder TGraphErrors or whatever object from the entries of my TNtuple. However, I have no idea how to acess these entries (the whole TBranch and TLeaf stuff is rather confusing and does not give any information as which kind of objects the fields in my ntuple are implemented…).

I would be grateful if someone has a quick way to fill a Graph from the ntuple. Thank!

You can also create directly a TGraph from an ascii file. See the doc:

Oh, that’s great! Thanks for your quick response! But I see that this constructor uses C format strings in contrast to the TTree::ReadFromFile syntax. (Btw: something that annoys me of ROOT. The syntax and method design is rather inconsistent.)

Is there a convenient way to plot expressions like, for instance, sqrt(2nd column) or is the only way to do this to modify the TGraph entries point per point?

(EDIT: And what about things like plotting e.g. the product of 1st and 3rd column like $1*$3 in gnuplot?)

If you want to plot expression of variable versus each then you need an Ntuple. You can retrive the graph as explain in the doc;