Hi Rene,
Thanks for the response. I realise I didn't quite express exactly what I'm
looking for: specifically, I'd like the same code to work for both 1D and 2D
histograms, so that in the 1D case, the loop is over all bins in x, while in
the 2D case, the loop is over all bins in x and y. I was hoping the
underlying 1D binning scheme in the histogram classes could help me here.
Anyway, on second glance, I see that GetNbinsY() returns 1 for 1D histograms, so I can just use a double loop, or a loop from 0 to GetNbinsX()*GetNbinsY() (plus something to account for underflow and overflow). I guess this would work.
Regards,
Philip
On Monday 25 August 2008 09:18:15 Rene Brun wrote:
> Assuming a TH1* h
>
> int nbinsx = h->GetXaxis()->GetNbins();
>
> Rene Brun
>
> Philip Rodrigues wrote:
> > Hi roottalk,
> > Given a pointer to a TH1 (which may point to a 1D or 2D histogram), how
> > can I loop over all the bins? It looks like I want a function that
> > returns fNCells, which I could use along with the 1D version of
> > GetBinContent(), but I can't see one.
> >
> > Thanks,
> > Philip
Received on Mon Aug 25 2008 - 21:00:50 CEST
This archive was generated by hypermail 2.2.0 : Tue Aug 26 2008 - 11:50:01 CEST