GetBinContent vs. GetArray in TProfile

Dear Roottalk people,

I have a TH2D histogram from which I get a TProfile by doing ProfileX(), from the TProfile I want to get the results in an array (numpy array) which I do by doing:

np.frombuffer(prf.GetArray(),‘d’, prf.GetNbinsX(), 0)

I also get the results in a python list by looping over all the bins and using GetBinContent. And I am not getting the same results…by the values I can guess the difference, but could you tell me what it is just to be sure? and is there a way to do what I want? i.e. instead of looping over all the bins and using GetBinContent and GetBinError, just dump all the values and errors in an array?

Thanks a lot in advance!!


yes, for a TProfile (unlike a TH1D, where it simply indexes fArray), the GetBinContent method looks like:[code] if (fBuffer) ((TProfile*)this)->BufferEmpty();

if (bin < 0 || bin >= fNcells) return 0;
if (fBinEntries.fArray[bin] == 0) return 0;
if (!fArray) return 0;
return fArray[bin]/fBinEntries.fArray[bin];[/code]
whereas GetArray just returns fArray. I’d figure that’s also the difference you guessed.