Re: [ROOT] Problem with variable bin histograms

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Sep 09 2002 - 07:27:36 MEST


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:08 MET