Re: extracting bin contents (fwd)

Laurent Mirabito (mirabito@in2p3.fr)
Thu, 27 Mar 1997 12:10:48 +0100 (MET)


Hello,

I found a strange behaviour with the functions Fill, GetBinContent and
SetBinContent.
Using the following macro
{
gROOT.Reset();
UShort_t cnt[3];
cnt[0]= 1001;
cnt[1]= 1002;
cnt[2]= 1003;
TH1S toto("t","Test",3,-0.1,2.9);
TH1S toto1("t1","Test",3,-0.1,2.9);
for (Int_t j=0;j<3;j++)
{ toto.SetBinContent(j,cnt[j]);
printf("toto: channel %d content %d \n",j,toto.GetBinContent(j));
toto1.Fill(j,cnt[j]);
printf("toto1: channel %d content %d \n",j,toto1.GetBinContent(j));
printf("toto1+: channel %d content %d \n",j,toto1.GetBinContent(j+1));}

}

I obtain:

toto: channel 0 content 1001
toto1: channel 0 content 0
toto1+: channel 0 content 1001
toto: channel 1 content 1002
toto1: channel 1 content 1001
toto1+: channel 1 content 1002
toto: channel 2 content 1003
toto1: channel 2 content 1002
toto1+: channel 2 content 1003

Is the bin range running between 0,nbins-1 or 1,nbins?
Why in this particular case Fill and SetBinContent does not give
identical results?

Many thanks in advance for the answer
Best regards
Laurent