Hi Every Body,
I have two .root files including histograms. I got them from pythia8. For opening these files I need root.
I need to open these two files in one canvas in order to be able to compare them.
I am wondering should I write a c++ code for that or can I do it easily from the browser?
Really thank for your help.
couet
June 3, 2022, 7:49am
2
Welcome to the ROOT forum.
At the ROOT prompt, you can do.:
auto c = new TCanvas();
c->Divide(2,1);
TFile *f1 = TFile::Open("first.root");
c->cd(1); h1->Draw();
TFile *f2 = TFile::Open("second.root");
c->cd(2); h2->Draw();
hey,
actually, I have two root files and i want to compare the histogram in one graph.
couet
June 3, 2022, 8:54am
4
Yes, the example I showed has two root files also.
It depends what you mean by “compare”?
I want to compare the results as shown in the attached image.
couet
June 3, 2022, 12:45pm
6
auto c = new TCanvas();
TFile *f1 = TFile::Open("first.root");
h1->Draw();
TFile *f2 = TFile::Open("second.root");
h2->Draw("SAME");
Thank you. It’s working.
how to add legend, xtitle, y title ?
couet
June 3, 2022, 4:37pm
8
Titles:
h1->SetTitle("global title; X title; Y title");
Legend, see the doc:
https://root.cern/doc/master/classTLegend.html
okay. I got it.
Thank you.
why is it showing the information of the first root file? how to remove this?
Before drawing, execute: gStyle->SetOptStat(0);
Hey,
If I have two root files and the plots are in the Tree format, then how to compare them?
and also how to normalize y axis?
system
Closed
June 26, 2022, 6:57am
13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.