suppose i want the power fit of the form: y=Ax^c,where i want to know c from the fit,i.e how its varying with x.
here in my case,its dev=A*(rigidity)^c. my command is written as:
{TNtuple calls("calls","calls","dev:rigidity");
calls.ReadFile("ev7.dat");
TCanvas *alpha1 = new TCanvas("alpha1","canvas");
calls.Draw("dev:rigidity");
alpha1->SetFillColor(42);
auto z1 = new TF1("dev", "[A]*rigidity^[c]");
alpha1->Fit(z1);
}
now,what’s wrong in this,can you correct that pls? since i din’t find it.
you do not fit a TCanvas but rather a TGraph or a histogram.
What is needed here is a loop over the TNtuple and the fill of a graph and the fit I think.
maybe although i don’t get that fully,but one thing i need to know is that,what’s the command to be given for doing the power fitting as of the above form for the given data file? i mean could you describe that commands ? so that i can get some idea.
I tried it but its showing abnormal termination of minimization maybe due to the initial values which we put here, i don’t wanna put initial values,its just i want to see how’s my y axis value varies with the power of rigidity(i.e. x axis value) with best fit.any suggestions?
In ROOT, you are expected to provide reasonable initial values of all fit parameters (except for some “built-in” functions, like “gaus”, for which the standard fit procedure can automatically “guess” them). Get used to it.
Note: if you need to swap “X” and “Y” columns, you can try:
TGraph *gYX = new TGraph("ev7.dat");
TGraph *g = new TGraph(gYX->GetN(), gYX->GetY(), gYX->GetX());
delete gYX; // no longer needed