Dear corooters,
there is a simple way to plot data of a TNtuple into a TGraphErrors?
I’ve found different solution for create and plot a TGraph, but nothing for TGraphErrors.
The code below return a blank canvas:
TNtuple *nt = new TNtuple("nt", "nt", "pre:e_pre:r1:er1:r2:er2:r3:er3");
nt->ReadFile("range.txt");
nt->Draw("pre:r1");
TGraphErrors *un = new TGraphErrors(nt->GetSelectedRows(), nt->GetVal(0), nt->GetVal(2), nt->GetVal(1), nt->GetVal(3));
un->Draw("ap");
Thanks for your attention.
_ROOT Version:6-26
_Platform:Manjaro Linux Compiler: Not Provided
In fact it seems that it is the only way to create a TGraphErrors starting from a TNtuple. But it doesn’t seem to work.
I’m just looking for a way to figure out creating a TGraphErrors from a TNtuple
Yes, you abuse this feature (see “How to obtain more info from TTree::Draw” in the TTree::Draw class reference).
But you can then create your desired TGraphErrors out of it.
Thank you very much for your attention, I had already viewed the link you sent me and starting from that I tried to write the code linked above. In particular I found this example: https://root.cern/doc/master/treegetval_8C.html
But the latter only works for TGraphs and not for TGraphErrors
I can’t understand why this command makes the code work.
In the documentation i found that The “goff” option only suppresses generating the graphics!
Thanks again.