Question about entries in projections

Hi

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.

Thanks,

Mark

Mark,

I cannot reproduce this problem. Could you send me your TH3 object
in a ROOT file?

Rene

Hi

Here is some simple code which produces output I don’t understand. I could not upload the file (too large?) so I put it on the web at:

www-pdsf.nersc.gov/~mhorner/test.root

{
 TFile f("test.root");
 TH3D* mainhist =  f.Get("hmassvphi1");
 
 TH1D* xh = mainhist->Project3D("x");
 TH1D* yh = mainhist->Project3D("y");
 TH1D* zh = mainhist->Project3D("z");
 TH1D* zph = mainhist->ProjectionZ("zph");
 TH1D* zph2 = mainhist->ProjectionZ("zph2",0,mainhist->GetNbinsX(),0,mainhist->GetNbinsY(),"");
 
 cout <<"Get Entries\n3D x: "<<xh->GetEntries()<<"\n3D y: "<<yh->GetEntries()<<"\n3D z: "<<zh->GetEntries()<<"\nZ :"<<zph->GetEntries()<<"\nZ with params: "<<zph2->GetEntries() <<endl;
}

Thanks,

Mark

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.

Rene

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”)?)

Please send the shortest possible script reprodicing the problem.
Make sure to use 4.02 or newer.

Rene

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)

Thanks for sending this small script. Thanks to it I have fixed the problem
in the CVS version.

Rene