Basic ROOT Histograpm help

Hi

i am runing ROOT 5.10/00 and am looking to get infromation from a tree onto a histogram,

i am currently using the coding

[code]{
gROOT->Reset();
TCanvas *MyC = new TCanvas(“MyC”,“Example with Formula”,200,10,700,500);
;

MyC->cd(1);
TTree* a=(TTree*) gROOT->FindObject(“100”);
a->Draw(“id”);

MyC->SaveAs(“graphs/id.ps”);

}
[/code]

i know there is a way you can do this by reading in entrys and filling the histogram using a loop. could someone please explain how i might do this.

also using my method is there anyway to set things like the start and end of the axis?

Thanks very much,

Gareth

[quote]also using my method is there anyway to set things like the start and end of the axis?
[/quote]Yes … see the TTree::Draw documentation.

[quote]i know there is a way you can do this by reading in entrys and filling the histogram using a loop. could someone please explain how i might do this. [/quote]Yes … use a TSelector see the documentation for TTree::Selector.

You may also want to re-read the ROOT Users’ Guide. In particular the chapter on TTree analysis.

Cheers,
Philippe.

If you want to specify your own bining, xmin, xmax, you can do
a->Draw(“id>>hid(50,0,500)”);
This will force the output histogram “hid” to have 50 bins with xmin=0 and xmax=500

Rene

thanks you both very much

solved