[ROOT] how to access Taxis from TH1F histo

From: Stanley Forrester (sforrest@lifshitz.ucdavis.edu)
Date: Wed Feb 06 2002 - 23:58:39 MET


Given a preexisting histogram how can one determine the min and max bin 
number in the histogram?   I'm producing effiecncy plots, but need 
to change the x axis limits on histos to exclude high ranges with no data.
Right now I am just assuming that the max bin number is 200, but would 
like to be able to access the Taxis inline function GetXmax() to make this 
a more general function.  I'd also like to add a empty low range exclusion 
as well.

Currently I am resizing histograms with the following code

  TFile *f = new TFile("MyRootFile.root");
  TH1F* myHisto = SomeHisto;
  Int_t maxBin;   
  for(int i = 200; myHisto->GetBinContent(i) == 0 ; i-- ){     
      maxBin = i;}
  Int_t minBin = 0;
  Int_t numberOfBins = maxBin - minBin +1;
  myHisto->SetBins(numberOfBins, minBin, maxBin);



-- 
Stanley S. Forrester
sforrest@lifshitz.ucdavis.edu

[The movement] seeks no victory over anyone. It seeks 
to liberate American society and to share in the 
self-liberation of all the people. 

		Martin Luther King Jr.
		Nobel Lecture, December 11, 1964 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:41 MET