I have a TH3D with 1.1x10^10 entries and when I consider ProjectionZ() I find the number of entries is the same, however, if I make a Project3D(“z”) the entries decrease to 8.9x10^9.
I don’t understand this behaviour. Are the two not supposed to return the same thing? Perhaps its a bug fixed in a later version - I use v4-00-04.
Problem now understood and fixed in CVS.
I have added the following note to ProjectionZ and Project3D
// NOTE 2: The number of entries in the projected histogram is set to the
// number of entries of the parent histogram if all bins are selected,
// otherwise it is set to the sum of the bin contents.
I have just run across this problem as well. When I do a Project3D(“xy”), I get fewer entries than the original TH3D.
I know for certain that the original 3D hist has overflows in the z-axis. I was looking at the source code, and when projecting (xy) it ignores the z-axis underflow and overflow bins.
[size=75] Int_t izmin = fZaxis.GetFirst();
Int_t izmax = fZaxis.GetLast();
…
case 4:
// "xy"
if (izbin < izmin || izbin > izmax) continue;[/size]
This will be true whether or not I have “SetRange”.
Is this a correct observation? (I would like to include the z underflow and overflow bins, unless I have used SetRange on the z-axis. Will I have to write a function to add them, after using Project3D(“xy”)?)
I’ve run this test script on 4.02 (MacOSX), with the same results on 4.00 (Linux).
The script output is:
[color=darkblue]Entries for small3 = 800
Entries for sma2 = 800
Entries for medium3 = 1000
Entries for med2 = 800
Entries for large3 = 1200
Entries for lar2 = 800[/color]
The difference between the small, medium, and large TH3D histograms, are entries made in the z-axis overflow and underflow bins. I use Project3D(“xy”) to make the TH2D histograms. The 2D hists all have the same number of entries, so the xy-projection ignores the z-axis overflow and underflow bins. The code snipet I listed in the previous post is from TH3::Project3D source code, and shows the limitation (even when SetRange is not being used). test_file.txt (1.97 KB)