Bug in h2root

I am working with fedora 43, using ROOT 6.38.00.

The conversion of the histograms has problems I guess with the definition of error bars.

I am attaching one example with an histogram from paw and converted from h2root

I am still doing analyses using fortran/paw and root.

Thanks for your help.

Try: h61->Draw("HIST");
Maybe you also want: h61->Sumw2(kFALSE);

1 Like

The histogram from ROOT is obtained just using TBrowser. I am using h2root since many years and this is a new issue.

It might be you were using an old version of ROOT.
In ROOT, by default, an histogram contaning errors is drawn with error bars if you do
not specify any drawing option. The solutions @Wile_E_Coyote suggested are the right ones.

Problem solved. Thanks.

@couet The interesting question is why the “bin errors” are equal to the “bin content”.

No idea…

Just a random guess:

On the C++ side there is:

if (hcbits[8]) h1->SetBinError(i,hie(id,i));

In the Fortran code there is:

      IF(JBIT(IQ(LCID+KBITS),9).NE.0)THEN
         HIE=HCX(I,2)
      ELSE
         RES=ABS(HCX(I,1))
         HIE=SQRT(RES)
      ENDIF

and then in HCX we have the one path shared for 1 and 2 if LW=0:

IF(IOPT.EQ.1.OR.(IOPT.EQ.2.AND.LW.EQ.0)) THEN

Anyway, h2root has many issues (h2root fragilities · Issue #19329 · root-project/root · GitHub).

The fortran code has not been change since a long time.

I found another bug, still related to the errors.

Including the line

h445->Sumw2(kFALSE);

I obtain the correct error bars for normal histograms. However, if I am going to plot histograms with weighted entries, (i.e. produced with the hbarx option) I obtain incorrect results (probably it is still using the sqrt(entries) error)

I am including the two paw and root versions.

What a bout is you do not include h445->Sumw2(kFALSE); and use h61->Draw("HIST"); ?

For these histograms h445->Draw(“PEX0”) gives the correct errors.

In conclusion the h445->Sumw2(kFALSE) should be included only for standard histograms.

Thanks.

If you used “HBARX”, and/or “HBARY”, and were filling histograms with weights not always equal to 1, and/or used “HOPERA”, then you should not use “Sumw2(kFALSE)”.