Here I want to fit the exponential and Gaussian together, but I don’t get a desired outline of the histogram.
Can you please point out the mistake ?
void f1()
{
TH1F *h4 = new TH1F("h4","Exponential+Gaussian",100,-1.,6.);
TF1 *f1 = new TF1("f1", "expo");
f1->SetParameter(0, 3);
f1->SetParameter(1, -0.3);
h4->FillRandom("f1",100000);
TF1 *f2 = new TF1("f2", "gaus");
f2->SetParameters(1, 2.1, 0.67);
h4->FillRandom("f2",15000);
TCanvas *c4 = new TCanvas("c4","Fit-1",800,600);
h4->Draw();
TF1 *fit1 = new TF1("fit1","f1",-1.,1.3);
TF1 *fit2 = new TF1("fit2","f2",1.3,3.);
TF1 *fit3 = new TF1("fit3","f1",3.,6.);
h4->Fit(fit1,"R");
h4->Fit(fit2,"R");
h4->Fit(fit3,"R");
c4->Print("H4.jpg");
}
ROOT Version: 6.27/01
Platform: Linux
Compiler: C++17