Re: titling histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Oct 04 1999 - 09:12:04 MEST


Hi Stephen,
The default histogram generated by TTree::Draw is named "htemp"
In an interactive session you can do, eg:
 Root > tree->Draw("var");
 Root > htemp->Fit("gaus");

If you want to generate an histogram with a different name, you do not
need to create this histogram before invoking TTree::Draw. Just do:
  Root > tree->Draw("var>>myHist")
  Root > myhist->xxxx

You only need to create the histogram before TTree::Draw when you want
to
specify your own histogram limits, number of channels.

Rene Brun


Stephen Markacs wrote:
> 
> > >From the root prompt it works like this:
> >
> > root [0] f=new TFile("hsimple.root")
> > (class TFile*)0x0
> > root [1] f->ls()
> > TFile**         hsimple.root
> >  TFile*         hsimple.root
> >   KEY: TH1F     hpx;1   This is the px distribution
> >   KEY: TH2F     hpxpy;1 py vs px
> >   KEY: TProfile hprof;1 Profile of pz versus px
> >   KEY: TNtuple  ntuple;1        Demo ntuple
> > root [2] hpx->Draw()
> > Warning in <MakeDefCanvas>: creating a default canvas with name c1
> > root [3] hpx->SetTitle("new title")
> > root [4]
> 
> This works if you have a histogram.  I knew about SetTitle.  My deal
> though is that I am using TNtuple.Draw() to draw histograms.  When done
> like this, the histogram is not named and so I can't just call it's
> SetTitle unless I can get to it through it's pad.  For instance, I could
> imagine a syntax like:
> 
> c = new TCanvas("c","c")
> c.Divide(2,2)
> c.cd(1)
> SomeNtuple.Draw("somefield")
> c.GetSubPad(1).GetHisto().SetTitle("some new title")
> 
> or somesuch.
> 
> As I said before, I don't want to use the Draw("somefield>>h") drawing to
> histogram technique because then I have to manually range and bin every
> histogram, which is extrememly inconvenient.  I was just thinking there
> should be a way to descend the container heirarchy to get to a histogram
> from the main canvas.
> 
>    S t e p h e n   M a r k a c s
>    stephen@phys.columbia.edu
>    http://phys.columbia.edu/~stephen/



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:40 MET