Getting actual bin content


Im having some difficulty with some rather silly questions. Im new to root, so forgive the very basic questions. I have a TH2I histogram that contains data of Time Of Flight(TOF) vs Energy data. I need to do some manipulations on this data, but im unsure as to how to obtain correct data. I’ve gone thru the forum as much as I can trying to find someone which had a similar problem, but it seems Im still stuck.

Here is my problem. When I do:

 double value = h->GetBinContent(j,i);

is that the contents, i.e. the number of entries in the bin, or some other value. If it is just the number of entries in the bin, then how can I get the actual values, and what would be an acceptable of storing these values, for example a 2d-array. I need to perform some clustering on the data, using an adaption of the k-means algorithm.


Also, when I do this:

        TH2I *h = (TH2I*)f->Get("TOFVE");
     	TAxis *xaxis = h->GetXaxis();
	const TArrayD *array = xaxis->GetXbins();

it returns a zero value.

What do you mean by “actual values”? Is the bin content not what you want?
Please be more specific in your questions.

   const TArrayD *array = xaxis->GetXbins(); 

This array exists only in case of variable size bins. For fixed size bins, there is no need to store the bin limits as they cam be computed from the global axis limits and retrieved with, eg



Thank you for the quick response. Sorry about the questions being so general.