2 #include "FairLogger.h"
3 #include <Math/Vector3D.h>
7 #include <TPolyLine3D.h>
9 using namespace ROOT::Math;
17 LOG(info) <<
"LKFMinuit::Initialize ";
18 fMyFit =
new TFitter(2);
23 fMyFit->ExecuteCommand(
"SET PRINT", arglist, 1);
24 fMyFit->ExecuteCommand(
"SIMPLEX", 0, 0);
31 TFitter*
min = fMyFit;
32 if (NULL ==
min) LOG(fatal) <<
"DoFit: no TFitter specified!";
34 min->SetObjectFit(
gr);
37 min->SetParameter(0,
"x0", pStart[0], 0.1, -10000., 10000.);
38 min->SetParameter(1,
"Ax", pStart[1], 0.01, -10., 10.);
39 min->SetParameter(2,
"y0", pStart[2], 0.1, -10000.0, 10000.);
40 min->SetParameter(3,
"Ay", pStart[3], 0.01, -10., 10.);
45 min->ExecuteCommand(
"MIGRAD", arglist, 2);
50 "SET NOWarnings", arglist, 3);
53 double amin, edm, errdef;
54 min->GetStats(amin, edm, errdef, nvpar, nparx);
56 fChi2DoF = amin / (double) nvpar;
60 for (
int i = 0;
i < 4; ++
i)
61 fparFit[
i] =
min->GetParameter(
i);
96 XYZVector xp(
x,
y, z);
97 XYZVector x0(p[0], p[2], 0.);
98 XYZVector x1(p[0] + p[1], p[2] + p[3], 1.);
99 XYZVector u = (x1 - x0).Unit();
100 double d2 = ((xp - x0).Cross(u)).Mag2();
114 XYZVector xp(
x,
y, z);
115 XYZVector x0(p[0], p[2], 0.);
116 XYZVector x1(p[0] + p[1], p[2] + p[3], 1.);
117 XYZVector u = (x1 - x0).Unit();
118 XYZVector xr = xp - x0;
119 XYZVector D = xr.Cross(u);
121 double d2e = TMath::Power(D.X(), 2) / ex / ex;
122 d2e += TMath::Power(D.Y(), 2) / ey / ey;
123 d2e += TMath::Power(D.Z(), 2) / ez / ez;
146 if (NULL == fgr) LOG(fatal) <<
"Invalid TGraph2Errors";
150 double*
x =
gr->GetX();
151 double*
y =
gr->GetY();
152 double* z =
gr->GetZ();
153 double* ex =
gr->GetEX();
154 double* ey =
gr->GetEY();
155 double* ez =
gr->GetEZ();
156 int npoints =
gr->GetN();
158 for (
int i = 0;
i < npoints; ++
i) {
160 double d = distance2err(
x[
i],
y[
i], z[
i], ex[
i], ey[
i], ez[
i], par);
165 std::cout <<
" -D- LKFMinuit::SumDistance2: point " <<
i <<
"\t" <<
x[
i]
166 <<
"\t" << ex[
i] <<
"\t" <<
y[
i] <<
"\t" << ey[
i] <<
"\t"
167 << z[
i] <<
"\t" << ez[
i] <<
"\t" <<
std::sqrt(
d) << std::endl;
172 std::cout <<
" -D- LKFMinuit::SumDistance2: Total sum2 = " << sum