Fitting 2d data points with 1d function

Dear rooters,
I need to fit this peak and more like it.

I was trying with predefined gaus but always getting Minimizer is Minuit / Migrad and Abnormal termination of minimization.

This is my code:

ntuple->Draw("x:y>>htemp","","",1,1);
htemp->Draw();
htemp->Fit("gaus","","",40,60);

I also tried:

ntuple->Draw("x:y>>htemp","","",1,1);
TProfile *prof = htemp->ProfileX();
prof->Draw();
prof->Fit("gaus","","",40,60);

and

ntuple->Draw("x:y","","",1,1);
TGraph *graph = (TGraph*)gPad->GetPrimitive("Graph");
graph->Draw();
graph->Fit("gaus","","",40,60);

and nothing works :confused:
I would greatly appreciate any help you can provide
data.root (1.92 MB)

ROOT has problems with negative bin contents (and “negative” peaks).
The simplest way for you is to negate “x” (i.e. take “-ch1” and/or “-ch2”), e.g.: data->Draw("-ch1:t>>htmp","","",1,1); Also, do not use the name “htemp” (ROOT uses this name “internally” on different occasions).

Works perfect :smiley:
Thank you so much.