Fitting and Minimizing 5 parameter function

Hello,

I am currently an undergraduate student and for the past few days I have been trying to fit a single variable function with 5 parameters.

This is for Muon Life Time and we’re using Scintilators. The model we were told to use was:

f(t)= Background + N1exp(-t/tau1) +N2exp(-t/tau2)
I wrote:
Fitter=new TF1(“Chi-it”,"[0]+ [1] * TMath::Exp(-(x/[2])) + [3] * TMath::Exp(-(x/[4]))",leftbound,rightbound);

I wrote a Monte Carlo Simulation to check how I would do this fit.

Here’s what I’ve tried:

  1. Use my “Fitter” as:
    myhist->Fit(“Chi-it”);

So far, the resulting value is highly dependent on initially set parameters of my Fitter.
The “Perfect Fit” is when my tau1=tau2 and N1=N2, so I am really fitting one exponential function.
Ratio between N1 and N2 is supposed to be close to 1:9.
Also, often the chi-squared minimization fails to converge

2)As I am generating a uniform random Background,
N1 type events and N2 type events.
I keep them in individual arrays and have three separate histograms then set 3 different TF1 and get their parameters and insert them(FixParameter) in my Fitter.
Minimization of chi-squared value fails to converge if I generate over 10,000,000 events.

FitBack=new TF1(“Background”,"[0]",leftbound,rightbound);
Fitone=new TF1(“India”,"[0]*TMath::Exp(-x/[1])",leftbound,rightbound);
Fitone1=new TF1(“India1”,"[0]*TMath::Exp(-x/[1])",leftbound,rightbound);

//Puc=Ionization Count, Test2=Background Count, Test3=muon
Puc.Draw();
Puc.Fit(“India”);
Can3.cd(2);
Test2.Draw();
Test2.Fit(“Background”);
Can3.cd(3);
Test3.Draw();
Test3.Fit(“India1”);

  1. if I use the parameters successfully found from 2), the resulting Guided Fitter with Fixed Parameters make a great fit and N1:N2 is comparable to 1:9.

Guided.FixParameter(0,Test2.GetFunction(“Background”).GetParameter(0) );
Guided.FixParameter(1,Puc.GetFunction(“India”).GetParameter(0));
Guided.FixParameter(2,Puc.GetFunction(“India”).GetParameter(1));
Guided.FixParameter(3,Test3.GetFunction(“India1”).GetParameter(0));
Guided.FixParameter(4,Test3.GetFunction(“India1”).GetParameter(1));

When I am analyzing the real data, I won’t have the separate “background”, “signal from ionization” or “signal from muon” data. I am going to use the parameters found from 2) as a guidance (SetParameter) to fit my real data.

A slight problem: If I do exactly what I stated in 3) on another set of simulated data, once again either minimization fails to converge or Single exponential function is fitted.

I could use an advice on how to proceed.

Thank you for your time
-SJL

Hi,

I suspect that your fit fails because the initial parameter you are giving ar maybe too far away from the minimum. Try maybe with closer values of initial parameter.
Otherwise, in order to help you, I would need the simplest runnable macro with your data histogram, so I can reproduce and investigate your problem.

Best Regards

Lorenzo

If required, I can post my entire MC+analysis code but I can’t post a sample with data simply because we are still collecting it.

Is there a way to stop ROOT from duplicating the exponential functions?

I don’t understand what you are referring to ? Please explain

Lorenzo

The Initial fit using my “FITTER” returns:

Background=15.8523 counts
N1=9115.68 counts Tau1=0.200215 MicroSec
N2=9115.68 counts Tau2=0.200215 MicroSec

meaning
N1=N2, Tau1=Tau2, so the first exponential term is the same as the second exponential term.

What I should be expecting is:
N1=18060, Tau1=0.1997
N2=192, Tau2= 0.2084
Background=16
(This comes from individually fitting components)