Making a TGraph from an ntuple


I know that TNtuple::Draw will produce a TGraph when it uses two dimensions, but if I do something like
an object called graph is created but it will be a TH2F, which seems a bit inconsistent (to me).

Since I wanted to have a TGraph I tried things like gPad->GetPrimitive, but that doesn’t seem to work if I ploted more than one graph in the same pad, using “same”.

I would even love something like ntuple.GetLeaf(“x”).GetArray(), so I can get an array to give as an argument for the TGraph constructor. In the end what I do is to traverse the ntuple, creating two arrays and giving them to the TGraph constructor.

Is it there a shorter way to do that?

Read documentation of TTree::Draw, in particular the section
"How to obtain more info from TTree::Draw"