For “METHOD1” and “METHOD2” you should use:
TFile *f = TFile::Open("cub_his3D.root");
TH3 *his3D; f->GetObject("his3D", his3D);
For “METHOD3” and “METHOD4” you should use:
TFile *f = TFile::Open("cub_sparse.root");
THnSparse *his3D; f->GetObject("his3D", his3D);
I’m not sure if the “number of entries” is what you want. I guess you’d better try with the TH1::Integral method.
Note also that, in any operations, entire bins are always taken into account so, if you want to compare numbers, you need to make sure that e.g. zaxis->GetBinLowEdge(zaxis->FindFixBin( zmin ))
and zaxis->GetBinUpEdge(zaxis->FindFixBin( zmax ))
(and so on) are equal for all histograms that you want to compare (btw. following the standard convention for numbering bins, the low-edge is included but the upper-edge is excluded).
Please compare input parameters of the TAxis::SetRange, the TAxis::SetRangeUser and the TH1::SetAxisRange methods.