Problem with error bars and logarithmic axis in variable bin histos


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.20/05
Platform: Mac OS X Catalina
Compiler: Apple clang version 11.0.3 (clang-1103.0.32.59)


I think there is definitely a problem with error bars in variable bin histograms with log axis. See the following script

#include <TCanvas.h>
#include <TH1F.h>

int testLOGfca() {`

    double dbl_min = 1e-9;
    double dbl_max = 1e+8;
    int int_nbinsLog = 1000;
    double min_log = TMath::Log10(dbl_min);
    double max_log = TMath::Log10(dbl_max);
    double bin_width = ( max_log - min_log) / (int_nbinsLog+1);
    double logbins[int_nbinsLog + 1];
    for(int k = 0; k <= int_nbinsLog; ++k)
        logbins[k] = TMath::Power(10., min_log + k * bin_width);
    
    TCanvas* canvas = new TCanvas();
    canvas->SetLogx();
    canvas->SetLogy();
    
    TH1D* histo = new TH1D();
    histo->SetBins(int_nbinsLog, logbins); // Logarithmic binning
    
    for(int j=1; j < histo->GetNbinsX(); ++j)
          histo->SetBinContent(j,TMath::Power(10., j*17./1000.));
    
      histo->Draw("hist e");
    
    return 0;
}        

What “problem”?

If you run the script you get “absurd” error bars. Try and see :wink: Best

Federico Carminati
Chief Innovation Officer
CERN openlab
1211 Geneva 23
Switzerland
Tel: +41 22 76 74959
Fax: +41 22 76 68505
Mobile: +41 75 411 4843

I see nothing “absurd”. Try: histo->Sumw2(kTRUE); histo->Print("all");

@couet This is what I obtain. there is a set of point that appears only when the “e” option is present. Best,

Federico Carminati
Chief Innovation Officer
CERN openlab
1211 Geneva 23
Switzerland
Tel: +41 22 76 74959
Fax: +41 22 76 68505
Mobile: +41 75 411 4843

bugroot.pdf (211 KB)

@fca this is what I get with your macro with the master version of ROOT. I do not see that set of point visible in your plot. Can you try with a more recent ROOT version ?

Tu as raison Olivier,
avec a toute dernière version ça marche. Merci!

Federico Carminati
Chief Innovation Officer
CERN openlab
1211 Geneva 23
Switzerland
Tel: +41 22 76 74959
Fax: +41 22 76 68505
Mobile: +41 75 411 4843

Salut Fed,
Oui il y a eu une correction.
Olivier

Merci Olivier,
Amitiés,

Federico Carminati
Chief Innovation Officer
CERN openlab
1211 Geneva 23
Switzerland
Tel: +41 22 76 74959
Fax: +41 22 76 68505
Mobile: +41 75 411 4843

I still encounter the same problem.
Using the macro given above, I have “crazy” error bars.

I have install ROOT with the command line > yum install root
The available package is root-6.20.04-2
My OS is fedora 30.

I am wondering if this version is really the master version of ROOT or if there is another problem ??

with 6.20/05 it is ok.

This seems to be a bug in the ROOT 6.20/04 “tag” which has been fixed in the “patches” branch.

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