Hello Root Users,

I am using ROOT 5.34/09. I want to fit a plot in the attached root file with the macro attached. I have tried with a 12 parameter multi function and I want to know the sigma after fitting. Also, how to calculate FWHM from this function. Could anyone help me in this ?

Thanks in advance,

Anterpreet Kaur

fit.C (2.01 KB)

plot.root (48.8 KB)

Try:

h1->GetListOfFunctions()->Print();

h1->GetFunction(“g1”)->Print();

h1->GetFunction(“g1”)->GetParameter(2)

h1->GetFunction(“g1”)->GetParameter(“Sigma”)

h1->GetFunction(“total”)->Print();

h1->GetFunction(“total”)->GetParameter(…)

[quote=“Wile E. Coyote”]Try:

h1->GetListOfFunctions()->Print();

h1->GetFunction(“g1”)->Print();

h1->GetFunction(“g1”)->GetParameter(2)

h1->GetFunction(“g1”)->GetParameter(“Sigma”)

h1->GetFunction(“total”)->Print();

h1->GetFunction(“total”)->GetParameter(…)[/quote]

Thanks, for the reply.

Output of [color=#0000FF]h1->GetFunction(“total”)->Print();[/color]

##################################################

total : gaus(0)+gaus(3)+gaus(6)+gaus(9) Ndim= 1, Npar= 12, Noper= 7

fExpr[0] = gaus(0) action = 110 action param = 0

fExpr[1] = gaus(3) action = 110 action param = 3

fExpr[2] = + action = 1 action param = 0

fExpr[3] = gaus(6) action = 110 action param = 6

fExpr[4] = + action = 1 action param = 0

fExpr[5] = gaus(9) action = 110 action param = 9

fExpr[6] = + action = 1 action param = 0

Optimized expression

fExpr[0] = gaus(0) action = 110 action param = 0

fExpr[1] = gaus(3) action = 110 action param = 3

fExpr[2] = + action = 1 action param = 0

fExpr[3] = gaus(6) action = 110 action param = 6

fExpr[4] = + action = 1 action param = 0

fExpr[5] = gaus(9) action = 110 action param = 9

fExpr[6] = + action = 1 action param = 0

Par 0 p0 = 8.2099

Par 1 p1 = 0.740543

Par 2 p2 = 0.0620684

Par 3 p3 = 697.201

Par 4 p4 = 1.00438

Par 5 p5 = 0.0547297

Par 6 p6 = 309.264

Par 7 p7 = 1.02128

Par 8 p8 = 0.0800667

Par 9 p9 = 5.29382

Par 10 p10 = 1.3149

Par 11 p11 = 0.137412

##################################################

But [color=#0000FF]h1->GetFunction(“total”)->GetParameter(Sigma)[/color] gives :

Error in TF1::TFormula: Parameter Sigma not found

So out of 12 parameters, which will give sigma for total function ?

Your “total” is a sum of four gaussian functions. Each gaussian has it’s own three parameters. There is no “common” sigma.

You can try to play with: TF1::Moment, TF1::CentralMoment, TF1::Mean, TF1::Variance

[quote=“Wile E. Coyote”]Your “total” is a sum of four gaussian functions. Each gaussian has it’s own three parameters. There is no “common” sigma.

You can try to play with: TF1::Moment, TF1::CentralMoment, [url=https://root.cern.ch/root/html534/TF1.html#TF1:Mean]TF1::Mean[/url, TF1::Variance[/quote]

I have to fit the distribution with a gaussian function and to use its sigma in some calculation. As it is not possible in the case with four gaussian functions, is there any other way to fit with one gaussian and find sigma ?