Fitting a TProfile with a TF1 of type ax^b

___Hi,
I am trying to fit a tprofile with a user defined function of type ax^b, but by fit is not fitting or failing. Can anybody help me.
Below I have attached by profile histogram and my fitting code.

Thank you
Madhusudhan
Please read tips for efficient and successful posting and posting code

ROOT Version: 6.18/02
_Platform:_Mac_OS
h_prof.root (6.1 KB)
fit_profile.cc (549 Bytes)

Compiler: Not Provided


    // ...
    Double_t x1 = 0.046, x2 = 0.1995;
    Int_t i1 = h_prof->FindFixBin(x1); i1 = std::max(i1, 1);
    Int_t i2 = h_prof->FindFixBin(x2); i2 = std::min(i2, h_prof->GetNbinsX());
    x1 = h_prof->GetBinCenter(i1);
    x2 = h_prof->GetBinCenter(i2);
    Double_t y1 = h_prof->GetBinContent(i1);
    Double_t y2 = h_prof->GetBinContent(i2);
    Double_t p1 = std::log(y1 / y2) / std::log(x1 / x2);
    Double_t p0 = y1 / std::pow(x1, p1);
    // std::cout << "at start: p0 = " << p0 << " , p1 = " << p1 << std::endl;
    TF1 *func = new TF1("func", fitf, x1, x2, 2);
    func->SetParameters(p0, p1);
    h_prof->Fit(func, "R");
    // ...

@Wile_E_Coyote

Thank you very much. It worked.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.