Exponential Decay Fit

I am trying to fit this exponential decay histogram.
I used TF1* f1 = new TF1(“f1”,“[0]*exp(-[1]*x)”,0,150);
f1->SetParameters(0, 2000);
f1->SetParameters(1, 5000);


Why this fitting not working?

Your function is very far from your histogram. Its range is more [0,0.001] than [0,150] . Try:

root [0] TF1* f1 = new TF1("f1","2000*exp(-5000*x)",0,0.001);
root [1] f1->Draw()

@couet Now I am getting ,

can you sent the code you are using ?

@couet And I want to fit like simple single exponential A*exp(-t/tau). So that I get tau which will be the mean valuie .

 TF1* f1 = new TF1("f1","2000*exp(-5000*x)",0,0.001);
 Edep_histogram->Fit(f1, "QRN0");
 f1->Draw("same");

You should set the parameters as you did before and keep the same range for the function. What I meant is that the initial parameters’ values ( 2000 and 5000) are very far away from the real distribution and that may explain why your fit did not converge. @moneta can confirm.

You are performing a non-linear fit, so starting values are critical for convergence.

Try

f1->SetParameters(0, 1000);
f1->SetParameters(1, 0.5);

In general please submit a working example in order to solve “Why this fitting not working”

2 Likes

@Eddy_Offermann Thank you sir! It worked.
What function I must use If I want to include the Gaussian part on the left of this exponential decaying part.


Simply giving the range starting from zero won’t work.

The left side shape is cause by effects of the experimental setup. If you’re interested in that you can model that in your function, otherwise I would define the function from 6 to 150.

1 Like

fyi: Detector Dead Time Determination and Optimal Counting Rate for a Detector Near a Spallation Source or a Subcritical Multiplying System