TH1F *myHist = new TH1F("myHist", "Example Histogram", 100, 0, 10); int numBins = myHist->GetNbinsX();
TH1F *myHist = (TH1F*)file->Get("myHist"); int numBins = myHist->GetNbinsX();This example retrieves an existing histogram from a ROOT file and stores it in the pointer variable myHist. The GetNbinsX function is then called on the histogram to retrieve the number of bins along the x-axis. Package/Library: ROOT.