TKDTreeBinning in 4D and issue with FindBin()

Dear experts,

I’m trying out the TKDTreeBinning class aiming to create an even-statistics binning in four dimensions for following observables: MT, MW, RBQ, MLBR.

When I observe the computed binning, it seems that the TKDTreeBinning only splits the first two dimensions and has always same edges for the last two dimensions. Below are bin edges for seven bins (same is true for higher number of bins):

Bin 0 edges: 177.554 - 202.686 63.3668 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 
Bin 1 edges: 202.686 - 1547.81 63.3668 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 
Bin 2 edges: 96.3453 - 156.315 63.3668 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 
Bin 3 edges: 156.315 - 167.387 63.3668 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 
Bin 4 edges: 167.387 - 177.554 63.3668 - 111.429 0.158435 - 15.7238 0.110401 - 1.21322 
Bin 5 edges: 167.387 - 177.554 111.429 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 
Bin 6 edges: 213.55 - 1547.81 63.3668 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 

Is there a way to force it to also split other dimensions?


Another issue I’m facing is that if I get the bin index using FindBin() such as

Double_t kdPoint[4] = {MT, MW, RBQ, MLBR};
int binIdx = kdBins_->FindBin(kdPoint);

the bin edges corresponding to that bin index do not always match. Here are the lines of code I
use to print this information:

int numBins =  kdBins_->GetNBins();
int numDimensions = kdBins_->GetDim();

// Print 4D coordinates
cout << MT << " " << MW << " " << RBQ << " " << MLBR;

// Index corresponding to the point
cout << " belongs to bin: " << binIdx << endl;

// Print all bin edges
for (int bin = 0; bin < numBins; ++bin) {
    cout << "Bin " << bin << " edges: ";
    for (int dim = 0; dim < numDimensions; ++dim) {
        cout << kdBins_->GetBinMinEdges(bin)[dim] << " - " << kdBins_->GetBinMaxEdges(bin)[dim] << " ";
    }
    cout << endl;
}

Below is an example where the point should go to bin 3 but is assigned to bin 2

161.601 88.4317 1.34017 0.631215 belongs to bin: 2
...
Bin 2 edges: 96.3453 - 156.315 63.3668 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 
Bin 3 edges: 156.315 - 167.387 63.3668 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 
...

and here it should go to 3 but goes to 4:

165.602 90.2592 2.13917 0.840461 belongs to bin: 4
...
Bin 3 edges: 156.315 - 167.387 63.3668 - 138.264 0.158435 - 15.7238 0.110401 - 1.21322 
Bin 4 edges: 167.387 - 177.554 63.3668 - 111.429 0.158435 - 15.7238 0.110401 - 1.21322 
...

Have I completely misunderstood how the GetBinMaxEdges() works or is there something else wrong with my approach, I cannot seem to find it myself.

Thank you very much in advance,
Mikael


ROOT Version: 6.14/09
Platform: cmssw-el7
Compiler: gcc

Welcome to the ROOT Forum!
Maybe @moneta or @jonas can help