Exchange form Lorentzian to gaus

Hi Dears
I have this macro which fit by lorentzian and I want it as gaus fit
could you please exhange it to fit as gaus
My Regards
NewFittingDemo.c (4.45 KB)

Well, you can try to cheat a bit like this: // Gaussian Peak function Double_t lorentzianPeak(Double_t *x, Double_t *par) { return ( par[0] * TMath::Gaus(x[0], par[2], par[1], kTRUE) ); } or like that: // Gaussian Peak function Double_t lorentzianPeak(Double_t *x, Double_t *par) { return ( par[0] / par[1] / TMath::Sqrt(2.0 * TMath::Pi()) / TMath::Exp( (x[0] - par[2]) / par[1] * (x[0] - par[2]) / par[1] / 2.0 ) ); }

Thanks very much dear Wile for comment
But dear I tried to apply this code in the obove macro but it still not work with respect to this type of data.
Could you please applied it and tell me where the worng is?
I’m grateful to you for help
output.txt (584 KB)

You need to fit to a sub range of your histogram:
ROOT User’s Guide -> Fitting Histograms -> Fitting Multiple Sub Ranges
${ROOTSYS}/tutorials/fit/multifit.C
${ROOTSYS}/tutorials/fit/fitExclude.C
ROOT User’s Guide -> Fitting Histograms -> Combining Functions

A brutal fix for your current macro could be:

  1. comment out (remove) the line: histo->Fit(“fitFcn”,“0”);
  2. modify the line: histo->Fit(“fitFcn”,“V+”,“ep”);
    into: histo->Fit(“fitFcn”, “V”, “ep”, 1450, 1850);

Thanks a lot dear Wile

Now it works

I will be always grateful to you dear