Errors in TProfile

Dear ROOT experts,

I have noticed one problem with TProfile when there is a bin with only one entry, or with more than one entry which are all identical. Let me illustrate it with two examples. First, by running this piece of code

{
 
TProfile *testProfile = new TProfile("testProfile","testProfile",6,-3,3);

testProfile->Fill(-2.5,1.3);
testProfile->Fill(-2.5,3.3);
testProfile->Fill(-2.5,3.6);

testProfile->Fill(2.5,2.2);
testProfile->Fill(2.5,4.7);

testProfile->Fill(1.5,2.0);

for(int i=1;i<testProfile->GetNbinsX()+1;i++){

   cout<<"bin "<<i<<" content: "<<testProfile->GetBinContent(i)<<endl;
   cout<<"bin "<<i<<" error: "<<testProfile->GetBinError(i)<<endl;
   cout<<endl;
}

}

you will get the following output

No surprises there. However, if you change it slightly

{
 
TProfile *testProfile = new TProfile("testProfile","testProfile",6,-3,3);

testProfile->Fill(-2.5,1.3);
testProfile->Fill(-2.5,3.3);
testProfile->Fill(-2.5,3.6);

testProfile->Fill(2.5,2.2);
testProfile->Fill(2.5,4.7);

testProfile->Fill(1.5,2.1); // notice the change from 2.0 to 2.1

for(int i=1;i<testProfile->GetNbinsX()+1;i++){

   cout<<"bin "<<i<<" content: "<<testProfile->GetBinContent(i)<<endl;
   cout<<"bin "<<i<<" error: "<<testProfile->GetBinError(i)<<endl;
   cout<<endl;
}

}

and run it again, you will get the following output

,i.e., bin 5 now has some value for its error. Is this the intended behavior of error bars? This is very important when you want to fit data contained in TProfile since you might get an unexpected results.

In short, I would expect all bins with only one entry to have zero spread, regardless of the value that was filled in. I’m using ROOT Version 5.14/00f.

Any input on this issue would be most appreciated.[/quote]

try with:Printf("bin %d content: %g",i, testProfile->GetBinContent(i)); Printf("bin %d error: %g\n",i, testProfile->GetBinError(i));
with ROOT 5.19.02:[quote]bin 1 content: 2.73333
bin 1 error: 0.589413

bin 2 content: 0
bin 2 error: 0

bin 3 content: 0
bin 3 error: 0

bin 4 content: 0
bin 4 error: 0

bin 5 content: 2.1
bin 5 error: 0

bin 6 content: 3.45
bin 6 error: 0.883883[/quote]Jan

Thanks, musinsky. In v5.19.02 I get the same output as you, i.e., the one that I first expected.