From: federico <>
Date: Tue, 15 Feb 2005 19:40:45 +0100

Dear Rooters,

I read in the reference manual about the binning of 2D historgrams,

"In case of 2-D or 3-D histograms, a "global bin" number is defined. For example, assuming a 3-D histogram with binx,biny,binz, the function Int_t <ListOfTypes.html#Int_t> gbin = h->GetBin <#TH1:GetBin>(binx,biny,binz); returns a global/linearized gbin number. This global gbin is useful to access the bin content/error information independently of the dimension. "

but I've a problem to understand what's happening with TProfile2D..

I want to fill the TProfile2D, plot it and then print out what is contained in each bin.

Please find attached a simple script intending to do that.

Why "i", the bin number, does not go from 1 to 4 (=nbinsx*nbinsy) ? Why only one bin results with a content > 0 while 2 are plotted?

Maybe I'm giving wrong arguments to:

Is it possible to:
-retrieve the total number of bins
-scan with some index over all the bins and get bincenter (in 2D), bins
contents, bin entries etc...

Thanks a lot,





	 Double_t nbinsx=2;
	 Double_t xmin=-4;
	 Double_t xmax=4;

	 Double_t nbinsy=2;
	 Double_t ymin=-4;
	 Double_t ymax=4;

	 Double_t bwidthx=(xmax-xmin)/nbinsx;
	 Double_t bwidthy=(ymax-ymin)/nbinsy;

	 TCanvas *c1 = new TCanvas("c1","Profile histogram example",200,10,700,500);
	 h2  = new TProfile2D("h2","h2",nbinsx,xmin,xmax,nbinsy,ymin,ymax,0,20);
	 Int_t i=0;
	 for (i=0; i<5; i++) 

	 Double_t x,y,z;
	 while(x<xmax) {
		  while(y<ymax) {
			   cout << i << "\t" << x << "\t" << y << "\t" << z << endl;


} Received on Tue Feb 15 2005 - 19:40:56 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET