Evaluation value from a function

I have a function eff = exp[c0+c1log(x)+c2(log(x))**2]

The input is like this :

x y ey

450 16770 515
1600 10924 634
2453 8538 1043
2904 6438 604
4083 4719 828
5691 2676 456
6124 2275 318
6575 2115 353

Now I fit this data using abobe function and get value of c0 , c1 , c2 .

Now I want to fix value of c0, c1 , c2 and want to get value of eff for a given x ?

Please tell me how to do it ?

regards
saradindu

{
  TF1 *eff = new TF1("eff",
    "TMath::Exp([c0]) + [c1] / TMath::Log(x) + [c2] * TMath::Sq(TMath::Log(x))",
    100., 10000.);
  // eff->Print();
  eff->SetNpx(1000);
  eff->SetParameters(1., 1., 1.);
  // eff->Draw();
  Double_t x[]  = {  450.,  1600., 2453., 2904., 4083., 5691., 6124., 6575.};
  Double_t y[]  = {16770., 10924., 8538., 6438., 4719., 2676., 2275., 2115.};
  Double_t ey[] = {  515.,   634., 1043.,  604.,  828.,  456.,  318.,  353.};
  UInt_t n = sizeof(x) / sizeof(Double_t);
  TGraphErrors *g = new TGraphErrors(n, x, y, 0, ey);
  g->SetTitle("Efficiency;x;eff");
  g->Draw("A*");
  eff->SetParameters(10., -1300., -380.); // set "reasonable" initial values
  g->Fit(eff, "R"); // use the range specified in the function range
  std::cout << "c0 = " << eff->GetParameter(0) << " +- " << eff->GetParError(0) << std::endl;
  std::cout << "c1 = " << eff->GetParameter(1) << " +- " << eff->GetParError(1) << std::endl;
  std::cout << "c2 = " << eff->GetParameter(2) << " +- " << eff->GetParError(2) << std::endl;
  std::cout << "eff(1000.) = " << eff->Eval(1000.) << std::endl;
  std::cout << "eff(5000.) = " << eff->Eval(5000.) << std::endl;
}

Thank you very much .

Could you please tell me how do I can get errors of efficiency ? Here there is no way to evaluate errors ?

regards
saradindu

I don’t have any simple solution. Maybe @moneta knows some trick.

I have another problem . I fit the data points using the above functions . Now I want to fix c1 , c2 and keep c0 as free variable.

How do I can fit another set of data points using this function where c1 , c2 are fixed ?

Thanks
saradindu

eff->FixParameter(1, some_c1_value); eff->FixParameter(2, some_c2_value); g->Fit(eff, "R");

Thanks !

regards
saradindu