Hi Kirti, After the fit, ou can do something like TF1 *func = h->GetFunction("pol1"); for (int bin=1, bin<=nbins;bin++) { double x = h->GetXaxis()->GetBinCenter(bin); double fval = func->Eval(x); h1->SetBinContent(bin,h->GetBinContent(bin)-fval); } or even simpler TH1F *h1 = (TH1F*)h->Clone("h1"); h1->Add(h->GetFunction("pol1"),-1); Rene Brun kirti@fnal.gov wrote: > > Hi again! > I have one more query: > > I am plotting one dim. histogram and then fit it with linear(po1) fit in > some specified range. > > >TH1D *h = (TH1D*) h_ave->ProjectionY("", 29, 29); > > //where h_ave is 2D histogram. There are 50 bins and the maximum value > in this plot goes up to 20000. > > >TF1 *pol1 = new TF1("pol1","pol1",0,2000); > h->Fit("pol1","R"); > > I would now like to take the difference between the two i.e., Fit and > original Histogram, and plot it. > > For histogram I can find the Bin Content by using: > >for(bin=0; bin<50;bin++) > h1->SetBinContent(1+bin,h->GetBinContent(1+bin)); > > But I do not understand how to find the bin content for Fit and then > take the differnce. > Please suggest. > Kirti > > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET