Setting bins for TTree.Draw

Pasha Murat (murat@cdfsga.fnal.gov)
Tue, 19 May 1998 15:14:35 -0500 (CDT)


William Love writes:
> I plot a histogram from a TTree (made with h2root) of
> an integer variable and ROOT picks bad bins. I tried to do
> TH1 *hrows = new TH1("hrows","TPC rows",45,0.5, 45.5);
> to set good bins and then
> h10.Draw("row>>+hrows");
> but I got
> Warning in <TTree::Draw>: Deleting old histogram with different dimensions
> and the same wrong-headed histogram. There seems to be no
> TTree.SetBins method. You used to could do graph/hplot/null in
> PAW and then draw on the premade plot. Must be able to do it
> in ROOT?

Bill:

TTree::Draw acts like nt/plot, so it does binning automatically.

You can book your histogram with TH1* constructor and then use TTree::Project
which projects ntuple contents into a histogram:

tree->Project("hist","parameter","cuts")

see TTree.h (or ROOT docs) for more detail (also consider asking Valery,
who is supposed to sit in one of the nearby offices).

Regards, Pasha.