Global bin number to binx, biny, binz converter

It would be nice if there were a function (in the TH2,TH3 classes) that gave you the binx, biny, and binz that corresponds to the global number that you pass it. Something like the following:

GetAxisBins(Int_t globalBin, Int_t* binx, Int_t* biny, Int_t* binz)

This would be complimentary to the FindBin() function, which returns the global bin number, but not the 2D or 3D bin numbers. I find that the 2D/3D bin numbers are used for some functions while the global bin number is used in others.

I hope I have not overlooked a function that already describes what I am requesting.

In the meantime, it won’t be hard to make the transformation myself, but this would be a nice easy function to have built in.

Thanks,
Taylor Childers
Heidelberg University

see: root.cern.ch/phpBB2/viewtopic.php?p=23955#23955
and root.cern.ch/root/html/TH1.html#TH1:GetBinXYZ

Rene

Hello!
I have trouble using the function GetBinXYZ. My code is like this:

TH2F *htT_2 = new TH2F("name", "title", 840, 0, 8, 1024, 0, 8); int coord_x, coord_y, coord_z; int globalnumber = 100; htT_2->GetBinXYZ(globalnumber, &coord_x, &coord_y, &coord_z);

and I get a response

Can you help with this?
Viesturs

The problem persists, I still get the same message.

If it’s a compiled code … did you … #include <TH2.h>

All libraries are included. GetBinXYZ is an inherited function of TH2F from TH1:
virtual void TH1::GetBinXYZ(Int_t binglobal, Int_t& binx, Int_t& biny, Int_t& binz) const

I expected that I could use GetBinXYZ with TH2F, but something is not right here.

root [0] TH2F *htT_2 = new TH2F("name", "title", 840, 0, 8, 1024, 0, 8); root [1] int coord_x, coord_y, coord_z; root [2] int globalnumber = 100; root [3] htT_2->GetBinXYZ(globalnumber, coord_x, coord_y, coord_z); root [4] std::cout << coord_x << " " << coord_y << " " << coord_z << std::endl; 100 0 0 root [5] .q

I cannot call GetBinXYZ from my Root. I will need to talk with our Root administrator

[quote]root [0] TH2F *htT_2 = new TH2F(“name”, “title”, 840, 0, 8, 1024, 0, 8);
root [1] int coord_x, coord_y, coord_z;
root [2] int globalnumber = 100;
root [3] htT_2->GetBinXYZ(globalnumber, coord_x, coord_y, coord_z);
Error: Can’t call TH2F::GetBinXYZ(globalnumber,coord_x,coord_y,coord_z) in current scope (tmpfile):1:
Possible candidates are…
(in TH2F)
(in TH2)
(in TH1)
*** Interpreter error recovered ***[/quote]
Thanks.
Viesturs

Which ROOT version are you using ? I think GetBinXYZ is available only from ROOT 5.18 (released 6 years ago)
Lorenzo