Precision in automatic binning

Hello all,
If I use the automatic binning option while filling a histogram
(described in the documentation as applying the command h->SetCanExtend(kAllAxes)
is the resulting granularity optimal? In other words: if I have a tree with a measured data set, and I use autofill, do the resulting histogram bins reflect the precision of the data set, or is the binning either coarser or finer?

If the binning is not optimal, is there a way of finding the native granularity/precision present in a tree?

Many thanks!


the criteria used to determine the binning are rather good and proven to satisfy the vast majority of cases.
The “granularity” of the information in the tree cannot be recovered by definition as the very operation of histogramming implies a data reduction.


My understanding was that you could choose the bin size to be the smallest difference in a given observable, and no smaller. That this would be optimal binning. I will rethink it. In the meantime, when I use automatic bins and write to file I get some errors. For example, the code below compiles and runs, and gives a readable output file.

int main(){
    TFile *fIN  = TFile::Open("meas90000.root");
    TTree *bush=(TTree*)fIN->Get("bush");
    TH1F *h1;
    h1 = new TH1F;
    float lowLim=0.0;
    float highLim=0.0;
    float X=0;
    Long64_t nentries = bush->GetEntries();
    Long64_t nbytes = 0, nb = 0;
    for (Long64_t jentry=0; jentry<nentries; jentry++) {
       nb = bush->GetEntry(jentry);   nbytes += nb;
    TFile *fOUT = new TFile("testing.root","RECREATE");
return 0;

But when I click on the histogram to view it, I get the following error
Error in TCanvas::Range: illegal world coordinates range: x1=0.000000, y1=-0.131250, x2=0.000000, y2=1.181250
Error in TCanvas::RangeAxis: illegal axis coordinates range: xmin=0.000000, ymin=0.000000, xmax=0.000000, ymax=1.050000

The file and tree are known goods. If I set the axis limits by hand, then the histogram is viewable without error.

// ...
h1 = new TH1F("testing", "testing", 50, 0, 0);
h1->SetDirectory(0); // 0 or gROOT
// ...

That’s got it. Many thanks.