Hi,
I’m trying to fit multiple sub ranges, but I just don’t succeed… I"m trying to stick to the example given in the ROOT user guide, but I guess I don’t understand how it’s supposed to work…
The histogram which I’d like to fit is defined in the following way:
TH1F *to_all = new TH1F(“to_all”,“turn on EM_HI all”,80,0.,80.);
Then I’m basically doing the followin (compare to the user guide, page 65/66):
TF1 *t1 = new TF1(“t1”,turnon_func,0,20);
t1->SetParameters(12.0,1.0,0.2); //halfpoint,slope,plateau
TF1 *t2 = new TF1(“t2”,turnon_func,20,40);
t2->SetParameters(25.0,1.0,1.0); //halfpoint,slope,plateau
TF1 *total = new TF1(“total”,turnon_func+turnon_func,5,40,6); <-THIS LINE IS THE PROBLEM
Double_t par[6];
to_all->Fit(“t1”,“R”);
to_all->Fit(“t2”,“R+”);
t1->GetParameters(&par[0]);
t2->GetParameters(&par[3]);
total->SetParameters(par);
to_all->Fit(total,“R+”);
The function I’d like to fit (“turnon_func”) is defined in the following way:
Double_t turnon_func(Double_t *x, Double_t *par)
{
double halfpoint = par[0];
double slope = par[1];
double plateau = par[2];
double offset = 0;
double pt = TMath::Max(x[0],0.000001);
double arg = 0;
arg = (pt - halfpoint)/(TMath::Sqrt(pt)slope);
double fitval = offset+0.5plateau*(1+TMath::Erf(arg));
return fitval;
}
Above I’ve marked the line where I’m running into trouble. I can compile the program, but when running I get the error message that “total” cannot be compiled. Any ideas what I have to change to make it work?
Cheers,
Carsten