Hey, This is a too simple question, however, I did not know how to use GetBinWithContent() correctly.
As in root.cern.ch/root/html/TH1#TH1:GetBinWithContent,
Double_t GetBinWithContent(Double_t c, Int_t& binx, Int_t firstx = 0, Int_t lastx = 0, Double_t maxdiff = 0) const,
I do not know how to deal with Int_t& binx.
Can somebody give an example, supposed there is a TH1D *h? Thanks.
Hey, please somebody helps…
I think the documentation is quite clear.
Suppose you have an histogram h1 and you want to know the bin number which has a bin content (the y value) as close as possible to your given value y0. The as close as possible is specified by a maximum difference maxdiff. You want to find to search for this bin number in the bin range [firstx, lastx]. Then you do:
int binx = 0;
h1->GetBinWithContent(y0 , binx, firstx, lastx, maxdiff);
after the call binx will be the bin with h1->GetBinContent(binx) closest to y0.
thank Lorenzo. I was confused by Int_t& binx.