Errors in an empty histogram

Consider this example:

int emptyhisto()
{
  TH1F h = TH1F("h", "h", 3, 0.0, 3.0);
  h.Print("all");
  h.Fill(1.1, 0.4);
  printf("****\n");
  h.Print("all");
  return 0;
}

The output is:

TH1.Print Name  = h, Entries= 0, Total sum= 0
 fSumw[0]=0, x=-0.5
 fSumw[1]=0, x=0.5
 fSumw[2]=0, x=1.5
 fSumw[3]=0, x=2.5
 fSumw[4]=0, x=3.5
****
TH1.Print Name  = h, Entries= 1, Total sum= 0.4
 fSumw[0]=0, x=-0.5, error=0
 fSumw[1]=0, x=0.5, error=0
 fSumw[2]=0.4, x=1.5, error=0.4
 fSumw[3]=0, x=2.5, error=0
 fSumw[4]=0, x=3.5, error=0
(int) 0

How can I have the histogram before filling (empty histogram) treated as having errors equal to 0.0 in each bin?


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Add

  h.Sumw2();

Read about “Associated errors” here.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.