Reading root files and make one graph

Hi,

It is simple question, but I don’t know how to do that.
I created two root files and they have “c2” canvas graphs.
I want to merge two graphs in the root files into one graph (and make one root file).
I have to adjust the x and y axis range for that.
I think it is simple, but I cannot find the code for the way.
Would you tell me how to do for that?
I attached example two root file and I want to merge one graph and the root file.
brahms_auau200_y0_10_20_err_contour.root (15.6 KB)
brahms_auau200_y0_0_10_err_contour.root (15.6 KB)

Hi,

I am not sure how far you got. There is no automatic tool to merge graphs stored in canvas stored in 2 different file.
Also I am not sure what you mean by “merge”. Do you intent to plot both on the same canvas (in which case review the documentation of TGraph::Draw) or do you want to combine them both into a single TGraph object?

Cheers,
Philippe.

Hi,

Yes, I want to plot both into a single TGraph.
So, I will see two contours (or total four contours since each one has two contours) in one graph if I can do it.

Do you have any idea for that?
Thank you!

Use a TMultiGraph

[code]TMultiGraph *mg = new TMultiGraph();

//loop on your files reading each TGraph and add it to the TMultiGraph
for (file=…) {
TGraph g = (TGraph)file->Get(“graphname”);
mg->Add(g);
}
mg->Draw();[/code]
Rene