5 #include "Math/ChebyshevPol.h"
12 Double_t pol5pol1(Double_t* x, Double_t* par)
18 f = par[0] + par[1] * xx + par[2] * xx * xx + par[3] * xx * xx * xx + par[4] * xx * xx * xx * xx + par[5] * xx * xx * xx * xx * xx;
22 ctp = par[0] + par[1] * x6 + par[2] * x6 * x6 + par[3] * x6 * x6 * x6 + par[4] * x6 * x6 * x6 * x6 + par[5] * x6 * x6 * x6 * x6 *
24 f = par[7] * x2 + ctp;
33 Double_t Cheb5pol1(Double_t* x, Double_t* par)
40 f = ROOT::Math::Chebyshev5(xx, par[0], par[1], par[2], par[3], par[4], par[5]);
44 ctp = ROOT::Math::Chebyshev5(x6, par[0], par[1], par[2], par[3], par[4], par[5]);
45 f = par[7] * x2 + ctp;
58 explicit XT(TProfile* h1)
60 m_h1 = (TProfile*)h1->Clone();
61 m_h1->SetDirectory(0);
66 XT(TProfile* h1,
int mode)
68 m_h1 = (TProfile*)h1->Clone();
69 m_h1->SetDirectory(0);
76 XT(TH1D* h1,
int mode)
78 m_h1 = (TProfile*)h1->Clone();
79 m_h1->SetDirectory(0);
110 for (
int i = 0; i < 8; ++i) {
m_XTParam[i] = p[i];}
117 double p4,
double p5,
double p6,
double p7)
174 if (mode == 0)
return xtpol5;
218 TF1*
xtpol5 =
new TF1(
"xtpol5", pol5pol1, 0.0, 700, 8);
219 TF1*
xtCheb5 =
new TF1(
"xtCheb5", Cheb5pol1, 0.0, 700, 8);
245 double max_dif = 0.12;
246 double max_dif2 = 0.05;
249 TF1* f1 = (TF1*)
m_h1->GetFunction(
"pol1");
250 double p0 = f1->GetParameter(0);
251 double p1 = f1->GetParameter(1);
252 double f10 = f1->Eval(10);
258 xtpol5->SetParLimits(7, 0.0, 0.001);
259 xtpol5->SetParLimits(1, 0.0, 0.01);
261 xtpol5->SetParLimits(7, 0.0, 0.01);
262 xtpol5->SetParLimits(1, 0.0, 0.01);
265 for (
int i = 0; i < 10; ++i) {
267 std::cout <<
"Fitting" << std::endl;
269 xtpol5->GetParameters(par);
272 double fp6 =
xtpol5->Eval(par[6]);
273 double fbehindp6 =
xtpol5->Eval(par[6] - 12) - 0.01;
274 if (fp6 < fbehindp6 || fp6 > 1) {
277 xtpol5->SetParameters(p0, p1, 0, 0, 0, 0, p6default, 0);
278 xtpol5->SetParLimits(6, p6default - 10, p6default + 10 - out / 2);
280 if (
m_tmax < p6default + 30) {
286 if (fabs(par[0] - p0) > max_dif || fabs(f10 -
xtpol5->Eval(10)) > max_dif2) {
288 if (i == 9) std::cout <<
"ERROR XT FIT inner part" << std::endl;
289 xtpol5->SetParameters(p0, p1, 0, 0, 0, 0, p6default, 0);
290 xtpol5->SetParLimits(1, 0, 0.08);
294 m_tmin = 14; std::cout <<
"ERROR: tmin so small, fit iter: " << std::endl;
300 if (
m_debug) {std::cout <<
"FIT Failure; Layer: " << std::endl;}
303 if (
m_debug) {printf(
"P6default= %3.2f, p6 fit = %3.2f", p6default, par[6]);}
306 if (
m_debug) std::cout <<
"Fit success" << std::endl;
314 TString hname =
m_h1->GetName();
315 TString name = hname +
".pdf";
316 TCanvas* c1 =
new TCanvas(
"c1",
"", 800, 600);
318 xtpol5->SetLineColor(kBlack);
319 xtpol5->DrawF1(0, 400,
"same");
335 xtCheb5->SetParLimits(7, 0., 0.001);
337 m_h1->GetFunction(
"chebyshev5")->GetParameters(p);
338 xtCheb5->SetParameters(p[0], p[1], p[2], p[3], p[4], p[5],
m_XTParam[6], 0.000);
341 for (
int i = 0; i < 10; ++i) {
344 xtCheb5->SetParameters(p[0], p[1], p[2], p[3], p[4], p[5],
m_XTParam[6] - 20, 0.000);
350 double fp6 =
xtCheb5->Eval(par[6]);
351 double fbehindp6 =
xtCheb5->Eval(par[6] - 10) - 0.005;
352 if (fp6 < fbehindp6 || fp6 > 1) {
355 xtCheb5->SetParameters(p[0], p[1], p[2], p[3], p[4], p[5], par[6] - 20, 0.000);
356 xtCheb5->SetParLimits(6, par[6] - 50, par[6] - 10);
375 TString hname =
m_h1->GetName();
376 TString name = hname +
".pdf";
377 TCanvas* c1 =
new TCanvas(
"c1",
"", 800, 600);
380 xtCheb5->DrawF1(0, 400,
"same");