TH1F *histogram = new TH1F("exampleHist", "Example Histogram", 100, 0, 100); histogram->GetXaxis()->SetTitle("x-axis title");
TH1F *histogram = new TH1F("exampleHist", "Example Histogram", 100, 0, 100); int numBins = histogram->GetXaxis()->GetNbins();This code creates a new TH1F object with 100 bins ranging from 0 to 100, and retrieves the number of bins in the x-axis using the GetNbins() method of the TH1Axis class, which is returned by the GetXaxis() method. Package library: ROOT.