Hi Rooters,
I was trying to fit a histogram with a gaussian+landau. My intention was
as follows. The histogram ranges from -20 to 200. I want to fit the range
from -20 to 10 with a gaussian and from 10 to 200 with a landau. Then I
add the two fitting functions (gaus+landau) to fit the overall
distribution. Here comes my problem I want the overall fit (which from now
on we call "total") to follow a gaussian shape between -20 and 10 and then
a landau shape between 10 and 200. But instead what I get is a continuous
fitting shape (with no dip at 10 and no bump at 15, where the MPV of the
landau is). I was following the "How to fit in a sub-range of an
histogram" from the ROOT tutorial.
I would appreciate if someone could kindly point me where I am doing wrong
(or should I try some other procedure as $ROOTSYS/tutorials/FittingDemo.C
where I define my own function).
I am attaching the code I used (which is
really $ROOTSYS/tutorials/multifit.C)
//*************************
TFile *f = new TFile("ADC_final.root");
adc_high_cent4 = (TH1F*)f->Get("adc_high_cent4");
g2 = new TF1("g2","landau",10,200);
g1 = new TF1("g1","gaus",-20,10);
total = new TF1("total","landau(0)+gaus(0)",-20,200);
total->SetLineColor(2);
g1->SetLineColor(4);
adc_high_cent4->Fit("g1","R0");
g1->GetParameters(&par[0]);
adc_high_cent4->Fit("g2","R0+");
g2->GetParameters(&par[3]);
total->SetParameters(par);
adc_high_cent4->Fit("total","R0+");
adc_high_cent4->Draw();
g1->Draw("same");
g2->Draw("same");
total->Draw("same");
//*************************
Best Regards,
-tahsina
-----------------------------------------------------------------------------
Tahsina Ferdousi
------------------------------------------------------------------------------
Graduate Student |email: |Phone:
Department of Physics |tahsina@phyun0.ucr.edu |(909)-787-7301
University of California |tahsina@ucrhi2.ucr.edu |
Riverside, CA 92521 |url: |
USA |www.phenix.bnl.gov/~tahsina|
------------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:11 MET