Dear all,
I am wondering how to find the maximum bin whose content is bigger than 0. I can find it like this :
#include <iostream>
void testMax()
{
TH1F *h1 = new TH1F("_EventSize", "Event size distribution;Bytes", 1000, 0, 1);
h1->SetBit(TH1::kCanRebin);
h1->Fill(144);
h1->Fill(146);
Int_t firstBinX = h1->GetXaxis()->GetFirst();
Int_t lastBinX = h1->GetXaxis()->GetLast();
int maxBin = 0;
for (binx = firstBinX; binx <= lastBinX; binx++) {
if(h1->GetBinContent(binx) >= 1) {
maxBin = binx;
}
}
float maxValue = h1->GetXaxis()->GetBinCenter(maxBin);
cout << "maxValue : " << maxValue << endl;
cout << "maxBin : " << maxBin << endl;
}
Is there a method in TH1 that does the same ?
I tried numerous GetMaximum* methods but none seemed to do what I wished.
Thanks in advance,
Barth