Re: [ROOT] loosing histogram resolution in 2D TTree->Draw()

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Mar 05 2002 - 04:34:33 MET


Hi Vuko,

With version 3.02/07 (or newer 3.03) you can specify the number of bins
in the generated histogram (eg: t1->Draw("temp:time >>
temphist(500,0,500,600,-300,300)","");

I would suggest to use a TProfile histogram instead of a 2-d histogram for
this kind of plot

t1->Draw("temp:time >> temphist","","profs");


On your last point, the function is GetNbinsX (not GetNBinsX

Rene Brun

On Mon, 4 Mar
2002, Vuko Brigljevic wrote:

> Hi Rene,
> 
> Sorry for the delay in my reaction, I had to turn to something
> else urgently to finish Moriond results.
> 
> Rene Brun wrote:
> > 
> > Hi Vuko,
> > 
> > The Hist.Binning.nD.x variables were only introduced in version 3.02/07 !
> 
> Ah, ok. Well, I eventually realized that we got that version
> installed at SLAC, even if the official BABAR software still
> uses 2.*, but I can use 3.02/07 for my work so that solves
> that problem :)
> 
> > I do not understand what you mean by a "binning too raw".
> > Could you tell me the min/max/binwidth of the produced histogram
> > and the values you were expecting instead ?
> 
> Well, what I mean is that the histogram  "temphist" coming out
> of the lines:
> 
>   t1->Draw("temp:time >> temphist","");
>   temphist->GetXaxis()->SetTimeDisplay(1);
>   temphist->Draw();
> 
> has very few bins, ~40, in each dimension, and that is not enough
> for the plot I want to make. But since 2 pictures explain better
> than 1000 words, here you see:
> 
> 1) output of the t1->Draw():
> 
> http://www.slac.stanford.edu/~vuko/pictures/Tree-draw.gif
> 
> 2) output of the temphist->Draw():
> 
> http://www.slac.stanford.edu/~vuko/pictures/TH2F-draw.gif
> 
> (WARNING  for the archive: these links will probably removed after March
> 2002!)
> 
> BTW, I tried to call GetNBinsX() for the histogram and got 
> an error (see below), but that must just be my beginner ignorance
> in basic ROOT concepts.
> 
> I repeat: version 3.02/07 solves my problem.
> 
> Thanks,
> 
> Vuko
> 
> 
> root [1] temphist->GetNBinsX()
> Error: Can't call TH2F::GetNBinsX() in current scope
> FILE:/var/tmp/baaTUaOvf_cint LINE:1
> Possible candidates are...
> filename       line:size busy function type and name  (in TH2F)
> filename       line:size busy function type and name  (in TH1F)
> filename       line:size busy function type and name  (in TH1)
> filename       line:size busy function type and name  (in TNamed)
> filename       line:size busy function type and name  (in TObject)
> filename       line:size busy function type and name  (in TAttLine)
> filename       line:size busy function type and name  (in TAttFill)
> filename       line:size busy function type and name  (in TAttMarker)
> filename       line:size busy function type and name  (in TArrayF)
> filename       line:size busy function type and name  (in TArray)
> filename       line:size busy function type and name  (in TH2)
> *** Interpreter error recovered ***
> root [2]                                        
> 
> 
> ========================================================================
>  Vuko Brigljevic                        | Mail : SLAC, Mail Stop 41
>  Lawrence Livermore National Laboratory |        P.O. Box 4349, Stanford
>  Nuclear and Particle Physics Division  |        CA 94309, USA
>                                         | SLAC-Office : B280- room 143
>  Member of the BaBar Collaboration      | Phone : +1-650-926 8512
>  <vuko@slac.stanford.edu>          <http://www.slac.stanford.edu/~vuko>  
> ========================================================================
> 
> 
> 
> 
> > Rene Brun
> > 
> > Vuko Brigljevic wrote:
> > >
> > > Hi root friends,
> > >
> > > still the first steps of a new rooter...
> > >
> > > What I am trying to do: fill a 2D histogram
> > > (some variable vs time) from a tree, change the
> > > X-axis to represent time, and redraw:
> > >
> > >   t1->Draw("temp:time >> temphist","");
> > >   temphist->GetXaxis()->SetTimeDisplay(1);
> > >   temphist->Draw();
> > >
> > > Problem:
> > > I am loosing completely the precision of the first
> > > plot  (from the TTree::Draw()) in the histogram.
> > > The binning must be too raw and the binning and
> > > the entries must be drawn randomly
> > > second histogram is so raw that the structure
> > > of the plot completely disappears.
> > >
> > > What I tried:
> > > 1) I read in the root manual about the environment
> > >    variables:
> > >
> > > Hist.Binning.2D.x: 500
> > > Hist.Binning.2D.y: 500
> > > Hist.Binning.2D.Prof: 10000
> > >
> > > I added these lines to my ~/.rootrc (the values
> > > are mine, not the default), and checked that
> > > they have been correctly read:
> > >
> > > root [0] gEnv->Print()
> > > Hist.Binning.2D.x:        500                            [User]
> > > Hist.Binning.2D.y:        500                            [User]
> > > Hist.Binning.2D.Prof:     10000                          [User]
> > >
> > > Still I have the same problem
> > >
> > > 2) I tried to predefine the histogram with a
> > >    higher binning:
> > >   TH2F * temphist=new TH2F("h2", "test", 1500,
> > > initTime,                        endTime, 500, 10., 20.);
> > >   t1->Draw("temp:time >> temphist","");
> > >   temphist->GetXaxis()->SetTimeDisplay(1);
> > >   temphist->Draw();
> > >
> > >   but this time the plot from the 2nd Draw() is empty.
> > >
> > > Any idea?
> > >
> > > In case it matters, I am running Root Version 2.23,
> > > a bit old I know, but it's still the BABAR standard
> > >
> > > Thanks,
> > >
> > > Vuko
> > >
> > > ========================================================================
> > >  Vuko Brigljevic                        | Mail : SLAC, Mail Stop 41
> > >  Lawrence Livermore National Laboratory |        P.O. Box 4349, Stanford
> > >  Nuclear and Particle Physics Division  |        CA 94309, USA
> > >                                         | SLAC-Office : B280- room 143
> > >  Member of the BaBar Collaboration      | Phone : +1-650-926 8512
> > >  <vuko@slac.stanford.edu>          <http://www.slac.stanford.edu/~vuko>
> > > ========================================================================
> 
> --
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:44 MET