The "content" argument of TH1::SetBinContent()

Hi all,

It may be silly to ask this, but does it make sense to make all the “content” arguments of SetBinContent() Double_t, even for TH1C which is for one-byte INTEGER data?


What is wrong with that? In C++ you have the automatic type promotion when calling by value. You do not need a long list of function prototypes with one function per type that would be a complete non sense.


Hi Rene,

Thanks for your followup.

Today I wrote a simple Python script which reads lines of data from ascii files and make TH1S spectra using SetBinContent(), but it didn’t work; it complained like the following:[code]TypeError: none of the 3 overloaded methods succeeded. Full details:
void TH1S::SetBinContent(Int_t bin, Double_t content) =>
could not convert argument 1 (Objects/longobject.c:223: bad argument to internal function)
void TH1S::SetBinContent(Int_t bin, Int_t, Double_t content) =>
takes at least 3 arguments (2 given)
void TH1S::SetBinContent(Int_t bin, Int_t, Int_t, Double_t content) =>
takes at least 4 arguments (2 given)


Silly enough, I thought it was due to the Double_t content, but by writing a simpler test code I now found it actually was my fault not to convert values for Int_t bin stored as CHARACTER STRINGS to integer. :frowning: (for the contents, I did, using float()… Sigh…)

Sorry for the trouble…