How to read histograms from root file & fill in single p

Hi,

I hav a root files that contents no. of histograms (say h1, h2, h3, etc.).
Now, i want to fill selected histograms in a canvas so that
i can compair my results.

please, Suggest me ?

Regards,

Hi,

interactive, at the ROOT prompt (i.e. not compiled):

TFile* f=new TFile("myfile.root"); TCanvas* c=new TCanvas(); c->Divide(1,3); c->cd(1); h1->Draw(); c2->cd(2); h2->Draw(); ...

In compiled code you need to use f->GetObject(); see the doc for TDirectoryFile::GetObject(). All of that is explained both in the users guide and in the tutorials.

Cheers, Axel.

Hi,

Axel.
Thanks for ur quick reply.

How can i fill selected histograms in a single pad, not separate pad in a canvas, to compare histograms ?

please, suggest .

regards,

plot the first one directly with:

h1->Draw();

and the 2nd one on the 1st one using option “same” :

h2->Draw(“same”);

You can also group them in a THStack in order to have a global scale fiting both.

Thanks,

I can do it now, the way i wanted to Fill, by your suggestion.

Cheers,