Re: [ROOT] Problem with variable bin histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Sep 09 2002 - 17:51:15 MEST


Hi Natalia,

Sorry, I misread your mail.

The convention in numbering bin numbers is, eg
assuming TH1F("h","h",nbins,xmin,xmax)

  bin 0 is the underflow bin
  bin 1 is the first real bin starting at xmin (xmin included)
  bin nbins is the last real bin ending at xmax (xmax excluded)
  bin nbins+1 is the overflow bin

Rene Brun

On Mon, 9 Sep 2002, Natalia Kuznetsova wrote:

> Hi Rene,
> 
>   Thank you for your comment!
> 
>   As a matter of fact, Lower does have N = 8 values, so I thought
> specifying 7 in the constructor would be correct as the array is then
> of size N+1.  Is that not the case?
> 
>   I did follow your suggestion in any case, however, and it didn't solve
> the problem -- the only thing it did was to remove the outermost bin, so
> the histogram now ends at 10 as opposed to 14.  Is there something else I
> am missing?
> 
>   Regards,
> 
>   Natalia
> 
> ______________________
> Natalia Kuznetsova
> Fermilab/CDF
> P.O. Box 500, MS 318
> Batavia, IL 60510
> (630) 840-5115
> ______________________
> 
> On Mon, 9 Sep 2002, Rene Brun wrote:
> 
> > Hi Natalia,
> > instead of
> >    TH1F* hist = new TH1F("hist","", 7, Lower);
> > do
> >    TH1F* hist = new TH1F("hist","", 6, Lower);
> >
> > see comments in TH1 constructor. In case of variable bins histogram,
> > you must specify an array with N+1 bin values.
> >
> > Rene Brun
> >
> >
> > On Sun, 8 Sep 2002, Natalia Kuznetsova wrote:
> >
> > > Dear ROOTers,
> > >
> > >   I would like to create a variable bin histogram with the following array
> > > of low edges:
> > >
> > >   Float_t Lower[8];
> > >
> > >   Lower[0] = 2;
> > >   Lower[1] = 3;
> > >   Lower[2] = 4;
> > >   Lower[3] = 5;
> > >   Lower[4] = 6;
> > >   Lower[5] = 8;
> > >   Lower[6] = 10;
> > >   Lower[7] = 14;
> > >
> > >   I used TH1F* hist = new TH1F("hist","", 7, Lower);
> > >
> > >   The resulting histogram appears to be skewed by 1 bin.  When I print out
> > > the bin content, it says:
> > >
> > > bin 0 = 0.005
> > > bin 1 = 0.013
> > >
> > >    but the actual histogram's first point sits at 2.5 (the histogram
> > > starts at 2), and it is the entry corresponding to bin 1 (0.013).
> > >
> > >    How do I make sure that bin 0 is plotted, and plotted exactly at 2?
> > >
> > >    Thanks for your help,
> > >
> > >    Natalia
> > >
> > > ______________________
> > > Natalia Kuznetsova
> > > Fermilab/CDF
> > > P.O. Box 500, MS 318
> > > Batavia, IL 60510
> > > (630) 840-5115
> > > ______________________
> > >
> >
> >
> 



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