2 macro Fit

Hi…somebody can help me to write 2 macros to fit 2 distributions please?

  1. First is the macro “distrelelat.c”, the macro fit the distributions using the NKG function that you can see in the eq (1) of this article arxiv.org/pdf/1309.3536v1.pdf, now I want to change the macro to fit using the Linsely function, that you can see in the eq (2) of the same article…I tried to change the line 42 as:
 rho_e_e *= TMath::Power(r,  -a) * TMath::Power(1.0 + r, -eta-a);

but it doesn’t work (bad fit)

  1. Second macro is “netheta.c”, the macro must fit using the equation in the second culomn of page 47 of this article inspirehep.net/record/1371491/files/access.pdf …, I wrote the macro but it doesn’t work too (bad fit)
    Note in this macro you will see TMath::Power(2.71828 18284, -4300/[1]*x)

because when in the program that I use to read CORSIKA files, I defined

x= ((1/(cos(pdata[lp+10] * 57.295779513e0)))-1);

where (pdata[lp+10] * 57.295779513e0) is theta, so I’ve x=sec theta-1

Thanks
netheta.c (2.98 KB)
distrelelat.c (4.75 KB)

Hi,

I understand this is a problem regarding a non-converging fit rather than an issue with ROOT, is this correct?
In general it’s good to explore different initial values of the fitting parameters when a fit of a model does not converge…

D

Hi dpapiro…

About the macro distrelat, it wasn’t written by me…but pepe le pew gave me it in the forum…I tried to change it to fit using the the Linsely functio, but I’m not able to modify it because looking at stat box there are just the parameters of the original macro (parameters of the NKG function)…i add in the attachmente the changed macro…

About the macro netheta, it was written by me but the fit doesn’t converge…I tried to set parameters searching the values on internet…

can you help me to resolve please?
distrelelat.c (4.86 KB)

You can start to play with the attached “distrlat.cxx” macro (which uses the “Linsley” function, instead of [url=https://root-forum.cern.ch/t/fit-nkg-distribution/21743/1

What concerns “netheta.c”, you speak about “the second culomn of page 47 of this article”, but this artcle has only 4 pages (which have no page numbers).
distrlat.cxx (5.61 KB)

Hi pepe, thanks, now I try your macro…

About the netheta macro…you are right…I forgot to write the link of the second article (now I’ve just modified the first topic)…as well this is the article inspirehep.net/record/1371491/files/access.pdf page 47 is the first page of the file (47 is the number page)…

In your “netheta.c” macro, try something like this: // ... Double_t lambda = 106.; Double_t X_0 = 4300.; TF1 *fitspettro = new TF1("fitspettro", "[0] * TMath::Exp(-x * [2] / [1])", 0, 1e3); fitspettro->SetParNames("N_{e}^{}(0)", "#lambda", "X_{0}^{}"); fitspettro->SetParameters(1., lambda, X_0); fitspettro->FixParameter(2, X_0); // fix "X_0" // ... fitspettro->SetParameters(1., lambda, X_0); fitspettro->SetParameter(0, hnethetag->GetBinContent(1)/fitspettro->Eval(hnethetag->GetBinCenter(1))); hnethetag->Fit(fitspettro); // ... fitspettro->SetParameters(1., lambda, X_0); fitspettro->SetParameter(0, hnthetap->GetBinContent(1)/fitspettro->Eval(hnthetap->GetBinCenter(1))); hnthetap->Fit(fitspettro); // ...

Hi pepe, thanks, About the distrlat macro, you gave me it but I modified it to fit just the electrons distributions, because NKG is better for these particles (it is the macro of my first topic)…unfortunatly it looks like a good fit just in the first part of the distribution, but after it doesnt’ converge as you can see in this image:

and the error on age parameter is very big…but yesterday I found this article arxiv.org/pdf/1309.3536v1.pdf where it is written that NKG describes fine just the distribution at low distances by the core but not at bigger distances…so I tried to modified the macro to use the Linsely function but it didn’t work because in the stat box there weren’t the linsely parameters but the NKG parameters…now i’ve just tried your macro but the fits arent’ good

Ps. I’ve changed the macro to just fit electrons distributions (See attachment) but same result of NKG macro…

PS now I try the netheta macro

EDIT I modified the netheta macro using your code (see attachment), but unfortunatly Ne parametere looks like to me very big value, and there isn’t the line of the fit


netheta.c (3.33 KB)
distrlat.cxx (4.65 KB)

If you try: { TF1 *f = new TF1("f", "[0] * TMath::Exp(-x * [2] / [1])", 1, 1e4); f->SetParameters(11111, 11, 1); f->SetMinimum(0.5); f->SetMaximum(5e5); f->Draw(); gPad->SetLogx(); gPad->SetLogy(); gPad->SetGrid(1, 1); } you will clearly see that the “shape” of this function is quite different from the “shapes” of your histograms (used by the “netheta.c” macro).

You really need to talk to people who created these CORSIKA simulations (e.g. about [url=https://root-forum.cern.ch/t/fit-nkg-distribution/21743/1 errors" of all your histograms[/url]) and to your “supervisor” (I’m not an expert in showers).

[quote=“Pepe Le Pew”]If you try: { TF1 *f = new TF1("f", "[0] * TMath::Exp(-x * [2] / [1])", 1, 1e4); f->SetParameters(11111, 11, 1); f->SetMinimum(0.5); f->SetMaximum(5e5); f->Draw(); gPad->SetLogx(); gPad->SetLogy(); gPad->SetGrid(1, 1); } you will clearly see that the “shape” of this function is quite different from your data points (used by the netheta macro).

You really need to talk to people who created this CORSICA simulation (for example about [url=https://root-forum.cern.ch/t/fit-nkg-distribution/21743/1 errors" of all your histograms[/url]) and to your “supervisor” (I’m not an expert in showers).[/quote]

Hi pepe

  1. unfortunatly I wrote to the author about the problem that NKG didn’t converge, but I didn’t have answer…
  2. About the bin error, if you mean the RMS values, I think this is normal because particles are in the range 1GeV-1TeV, so the effects are different…ROOT calculate de mean value, but it is normal having a big RMS if values are so different… or didn’t I understand your observation? For example in the hene histogram…particles have energy from 1GeV to 1TeV, but particles with low values of the energy are more thank particles with high values…so the mean energy is =7 but RMS is 31…

3)Unfortunatly I think that the program has some problems…for example I know (by TH2F plots) that in gamma showers I’ve about 7000 hadrons producted… now look at this histogram (number of secondary particles):

what do you note? histogram of hadrons (blue line) in the bin “1-2” has a molteplicity about 10^7… how is it possible if I’ve just 7000 hadrons? and the code about this is an histogram wasn’t written by me, but by the author of the program…now…same problem with the proton simulations…I know that in proton simulations there are about 1,3*10^6 hadrons…well…look to this plot

from 1 to about 700-800, I’ve a molteplicity 10^5…how is it possible? for example if we just consider the number 600, it means that 60010^5= 6010^6, but I’ve just 1,3*10^6 hadrons…can’t I read the histogram or is it wrong?

You really need to talk to “the author of the program” (or somebody else who knows what’s inside).

Do you think am I right about the plots of the number of secondary particles? are they impossible?

About the netheta.c I see I made an error…I calculated the sec(theta) using theta in degree…I’d to use theta in radians…