TH1D* hist = new TH1D("hist", "Example histogram", 10, 0., 1.); for (int i = 1; i <= hist->GetNbinsX(); i++) { double lowEdge = hist->GetBinLowEdge(i); cout << "Bin " << i << " has lower edge at " << lowEdge << endl; }
double getMean(const TH1D& hist, int binStart, int binEnd) { double sum = 0., n = 0.; for(int i = binStart; i <= binEnd; i++) { double lowEdge = hist.GetBinLowEdge(i); double binContent = hist.GetBinContent(i); sum += lowEdge * binContent; n += binContent; } return sum / n; }In this example, we define a function that takes a reference to a one-dimensional histogram and two integers representing the starting and ending bin numbers. The function calculates the weighted mean of the bin edges in the specified range, where the weight of each edge is given by its bin content. The GetBinLowEdge() function is used to retrieve the lower edge of each bin. In summary, the GetBinLowEdge() function is a useful tool for accessing the properties of one-dimensional histograms in the ROOT framework, and can be found in the TH1D class.