25 {
26 if (argc !=3) {
27 cout <<
"Usage: " <<
argv[0] <<
" input.root output.root" << endl;
28 return 1;
29 }
30
31 auto fin = make_unique<TFile>(argv[1],
"READ");
32 auto fout = make_unique<TFile>(argv[2],
"RECREATE");
33
34
35 auto etaLegFunc = [](
double*
x,
double*
par){
36 double tanhEtaSq = std::tanh(
x[0]);
37 tanhEtaSq = tanhEtaSq*tanhEtaSq;
38
39
40 double lp2 = 1.5*tanhEtaSq - 0.5;
41 double lp4 = 0.125*(35.*tanhEtaSq*tanhEtaSq - 30.*tanhEtaSq + 3.);
42 double lp6 = 0.0625*(231*tanhEtaSq*tanhEtaSq*tanhEtaSq - 315*tanhEtaSq*tanhEtaSq + 105*tanhEtaSq - 5);
43 return par[0]*(1. +
par[2]*(lp2-1) +
par[4]*(lp4-1) +
par[6]*(lp6-1)) +
44 par[1]*(1. + par[3]*(lp2-1) + par[5]*(lp4-1) + par[7]*(lp6-1))/
x[1];
45 };
46
47
48 TIter
next(
fin->GetListOfKeys());
49 while (TObject* obj =
next()) {
50 string objName =
obj->GetName();
51 cout << "Fitting " << objName << endl;
52 TGraph2DErrors*
gr =
nullptr;
55 cerr <<
"Could not retrieve " <<
obj->GetName()
56 << " as a TGraph2DErrors." << endl;
57 continue;
58 }
59 TF2* func = new TF2(objName.data(), etaLegFunc, -2.5, 2.5, 0.1, 100.0, 8);
60
61 func->SetNpy(200);
62 func->SetParameters(0.02, 0.1, 0.1, 0.1, 0., 0., 0., 0.);
63 func->SetParLimits(0, 0., 5.);
64 func->SetParLimits(1, 0., 5.);
66 func->SetParLimits(2, -ext, ext);
67 func->SetParLimits(3, -ext, ext);
68 func->SetParLimits(4, -ext, ext);
69 func->SetParLimits(5, -ext, ext);
70 func->SetParLimits(6, -ext, ext);
71 func->SetParLimits(7, -ext, ext);
72
73
74
75 func->FixParameter(6, 0.);
76 func->FixParameter(7, 0.);
78 cout <<
"ndf, g.N = " <<
result->Ndf() <<
", " <<
gr->GetN() << endl;
79 func->Write();
80 }
81
82
83 return 0;
84}