14 #include "Math/ChebyshevPol.h"
29 Double_t
pol5pol1(Double_t* x, Double_t* par)
35 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;
39 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 *
41 f = par[7] * x2 + ctp;
50 Double_t
cheby5pol1(Double_t* x, Double_t* par)
57 f = ROOT::Math::Chebyshev5(xx, par[0], par[1], par[2], par[3], par[4], par[5]);
61 ctp = ROOT::Math::Chebyshev5(x6, par[0], par[1], par[2], par[3], par[4], par[5]);
62 f = par[7] * x2 + ctp;
78 m_h1 = (TProfile*)h1->Clone();
80 if (
m_mode == c_Chebyshev) {
91 m_h1 = (TProfile*)h1->Clone();
92 m_h1->SetDirectory(0);
94 if (
m_mode == c_Chebyshev) {
107 m_h1 = (TProfile*)h1->Clone();
108 m_h1->SetDirectory(0);
110 if (
m_mode == c_Chebyshev) {
133 for (
int i = 0; i < 8; ++i) {
157 for (
int i = 0; i < 8; ++i) {
169 void setP6(
double p6)
205 for (
int i = 0; i < 8; ++i) {
m_XTParam[i] = p[i];}
212 double p4,
double p5,
double p6,
double p7)
281 if (
m_mode == c_Polynomial) {
283 }
else if (
m_mode == c_Chebyshev) {
286 B2ERROR(
"Undefined fitting function");
336 B2ERROR(
"Fitting function is wrong");
338 double max_dif = 0.12;
339 double max_dif2 = 0.05;
342 TF1* f1 = (TF1*)
m_h1->GetFunction(
"pol1");
343 double p0 = f1->GetParameter(0);
344 double p1 = f1->GetParameter(1);
345 double f10 = f1->Eval(10);
359 for (
int i = 0; i < 10; ++i) {
361 std::cout <<
"Fitting" << std::endl;
367 double fbehindp6 =
m_fitFunc->Eval(par[6] - 12) - 0.01;
368 if (fp6 < fbehindp6 || fp6 > 1) {
371 m_fitFunc->SetParameters(p0, p1, 0, 0, 0, 0, p6default, 0);
372 m_fitFunc->SetParLimits(6, p6default - 10, p6default + 10 - out / 2);
374 if (
m_tmax < p6default + 30) {
380 if (fabs(par[0] - p0) > max_dif || fabs(f10 -
m_fitFunc->Eval(10)) > max_dif2) {
382 if (i == 9) std::cout <<
"ERROR XT FIT inner part" << std::endl;
384 m_fitFunc->SetParameters(p0, p1, 0, 0, 0, 0, p6default, 0);
389 m_tmin = 14; std::cout <<
"ERROR: tmin so small, fit iter: " << std::endl;
395 if (
m_debug) {std::cout <<
"FIT Failure; Layer: " << std::endl;}
398 if (
m_debug) {printf(
"P6default= %3.2f, p6 fit = %3.2f", p6default, par[6]);}
401 if (
m_debug) std::cout <<
"Fit success" << std::endl;
409 TString hname =
m_h1->GetName();
410 TString name = hname +
".pdf";
411 TCanvas* c1 =
new TCanvas(
"c1",
"", 800, 600);
422 const double p6 =
m_fitFunc->GetParameter(6);
424 B2WARNING(
"Bad xt function");
427 }
else if (p6 < 100.0) {
428 B2WARNING(
"Unrealistic p6");
438 if (
m_mode != c_Chebyshev) {
439 B2ERROR(
"Fitting function is wrong");
451 if (fitresult >= 0) {
452 m_h1->GetFunction(
"chebyshev5")->GetParameters(par);
453 m_fitFunc->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5],
m_XTParam[6], 0.000);
456 for (
int i = 0; i < 10; ++i) {
459 m_fitFunc->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5],
m_XTParam[6] - 20, 0.000);
474 double fbehindp6 =
m_fitFunc->Eval(par[6] - 10) - 0.005;
475 if (fp6 < fbehindp6 || fp6 > 1) {
478 m_fitFunc->SetParameters(par[0], par[1], par[2], par[3], par[4], par[5], par[6] - 20, 0.000);
479 m_fitFunc->SetParLimits(6, par[6] - 50, par[6] - 10);
500 TString hname =
m_h1->GetName();
501 TString name = hname +
".pdf";
502 TCanvas* c1 =
new TCanvas(
"c1",
"", 800, 600);