@moneta I think I previously misunderstood the difference between the two methods, FindBin() and FindFixBin().
As a test I have done the following:
I generated a histogram:
TH2F *h_p = new TH2F("h_p", "Element array", 20, -100, 100, 20, -100, 100);
Which represents a grid over an area which I would like to fit sets of (x, y) points on and obtain which box/bin a given point is in. For instance, I will have an event at some point within the grid, within the range of (-100, 100) along both axes, and I would like to use:
element = h_p->FindBin(x, y, 0);
to determine the bin that contains the point. For my check I have done the following to make sure I return the same points:
x_test = h_p->GetXaxis()->GetBinCenter(element);
y_test = h_p->GetYaxis()->GetBinCenter(element);
cout << "test position = (" << x_test << " ," << y_test << ")" << endl;
cout << "seeded position = (" << x << " ," << y << ")" << endl;
upon compilation I obtain the following:
test position = (1905 ,1905)
seeded position = (-72.269 ,-10.6774)
test position = (1025 ,1025)
seeded position = (-77.7099 ,-53.9449)
test position = (835 ,835)
seeded position = (-44.8618 ,-66.9224)
test position = (2575 ,2575)
seeded position = (-61.6721 ,11.6775)
test position = (1375 ,1375)
seeded position = (53.6068 ,-41.5784)
test position = (3565 ,3565)
seeded position = (49.3616 ,56.9929)
test position = (2275 ,2275)
seeded position = (74.2571 ,-3.31977)
test position = (1505 ,1505)
seeded position = (-39.6788 ,-32.3741)
test position = (2765 ,2765)
seeded position = (-90.0729 ,24.7655)
test position = (2045 ,2045)
seeded position = (62.5263 ,-13.7962)
While I understand that the bin center and the seeded point used to determine the bin, will not exactly match, I expected them to be within a range of at maximum 5 units of each other.
I assume my understanding is still flawed. Any and all help is greatly appreciated.