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

Thank you! Pinging @moneta and @jonas again if you have any insight on this.

Hi,
Can you please post the full running code showing the problem, so I can investigate it?
Thank you

Lorenzo

Dear Lorenzo,

Thank you for the answer, couldn’t upload the input binning file Muo18_Run2018.root since it’s too big but you can download that and an example script kdTreeExample.C from my cernbox:
https://cernbox.cern.ch/s/tJRcZwfK566X2E6

With these you can directly test the two examples I provided in the original post.

Cheers,
Mikael

Hi,
Thank you for sending the link to an example. I will investigate it and let you know, sorry for the delay.

Lorenzo

1 Like

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