Getting Average of Voxel in TH3F

Hello experts,
I have create TH3F hist which i am filling with weights
like
hist->SetBinContent(x, y, z, w);
and it may possible then more than one entry goes to each voxel
like
hist->SetBinContent(1, 2, 3, 0.6);
hist->SetBinContent(1, 1, 1, 0.2);
hist->SetBinContent(1, 2, 3, 0.6);

so in this case the bin content for voxel at (1,2,3) will be 1.2 and number of entries in this voxel should be 2.

So is there any function exist that will give me this information about number of entries in a voxel by specifying the bin number in x, y an z.

Now what i want is the average of weight that each voxel has collected. So if get the voxel content and number of entries then average can be computed by dividing the two.

Or is there any function exist that can directly give me this average weight for each voxel.

Regards,
Raman

If you do this:

hist->SetBinContent(1, 2, 3, 0.6);
hist->SetBinContent(1, 1, 1, 0.2);
hist->SetBinContent(1, 2, 3, 0.6);

bin (1,2,3) will contain 0.6… not 1.2 …
You should use Fill not SetBinContent

Thanks couet,
so its cleared now that i have to use Fill, but how to get the number of entries in a voxel because ultimately i want the average of all the entries in a voxel.

Regards,
Raman

A bin does not keep the number of Fill call was done. That’s histogrammed data. You can deduce it from the bin content if all the Fill calls have been done with the same weight.