root
root copied to clipboard
TKDTreeBinning missing bins
- [x] Checked for duplicates
Describe the bug
I created a 5D binning from some data. The FindBin
function returns seemingly non-existent bins. What is
In [5]: binning.GetNBins()
Out [5]: 1001
In [6]: binning.FindBin(array.array("d", (1.2, 0.5, 0.5, 0.5, 0.5)))
Out [6]: 1004
In [7]: binning.GetBinContent(1004)
TKDTreeBinning::GetBinContent:0: RuntimeWarning: No such bin. Returning 0.
Info in <TKDTreeBinning::GetBinContent>: 'bin' is between 0 and 1001.
Out [7]: 0
The specified coordinates should be well within the binning range - if I understand the method correctly, the binning range is a hyper-rectangle that envelops all the data points, correct?
In [15]: for i in range(5):
...: print(f"Dim {i} - min:{binning.GetDataMin(i)}, max: {binning.GetDataMax(i)}")
...:
Dim 0 - min:0.9872230887413025, max: 1.5643738508224487
Dim 1 - min:0.279508501291275, max: 0.8602268695831299
Dim 2 - min:-0.9999595284461975, max: 0.9999838471412659
Dim 3 - min:-0.9999908804893494, max: 0.9998750686645508
Dim 4 - min:-1.0, max: 1.0000001192092896
Expected behavior
FindBin()
should return a value within [0, binning.GetNBins()
- 1]
To Reproduce
- Download the ROOT file with the binning from CERNBox
- Run the following in Python
import array
import ROOT
file = ROOT.TFile("binning.root")
binning = file.Get("TKDTreeBinning")
binning.FindBin(array.array("d", (1.2, 0.5, 0.5, 0.5, 0.5)))
binning.GetBinContent(1004)
Setup
ROOT 6.26/02 macOS 12.3.1 Homebrew install
Additional context
Hi ROOT team, any update on this? Let me know if you need any more information.
Has there been any progress on this issue?