Hi, is there a way to take the max and the min X value from a Tgraph?
I’ve a TTree and i need the range xmax-xmin of the graph i have from the ttree.
For a tree:
TTree::GetMinimum
TTree::GetMaximum
For a “graph
”:
TMath::MinElement(graph->GetN(), graph->GetX())
TMath::MaxElement(graph->GetN(), graph->GetX())
It might be overall fewer lines with RDataFrame. To just get the min/max of a column, maybe conditional to a cut, these are all the lines you need:
auto selected_df = ROOT::RDataFrame("treename", "filename.root").Filter("x > 0");
auto min = df.Min("x");
auto max = df.Max("y");
To create a TGraph from an RDataFrame:
ROOT::RDataFrame df("treename", "files/*.root");
graph = df.Graph("x", "y");
Cheers,
Enrico
it says error: no member named ‘MaxElement’ in ‘TGraph’
i don’t understand the value i have in output on the terminal.
oh sorry, all is correct! i was wrong with copy/paste…