12#include <TPolyLine3D.h>
14#include <Math/Vector3D.h>
16using namespace ROOT::Math;
25 LOG(info) <<
"LKFMinuit::Initialize ";
31 fMyFit->ExecuteCommand(
"SET PRINT", arglist, 1);
32 fMyFit->ExecuteCommand(
"SIMPLEX", 0, 0);
41 if (NULL ==
min) LOG(fatal) <<
"DoFit: no TFitter specified!";
43 min->SetObjectFit(
gr);
46 min->SetParameter(0,
"x0", pStart[0], 0.1, -10000., 10000.);
47 min->SetParameter(1,
"Ax", pStart[1], 0.01, -10., 10.);
48 min->SetParameter(2,
"y0", pStart[2], 0.1, -10000.0, 10000.);
49 min->SetParameter(3,
"Ay", pStart[3], 0.01, -10., 10.);
54 min->ExecuteCommand(
"MIGRAD", arglist, 2);
58 min->ExecuteCommand(
"SET NOWarnings", arglist, 3);
61 double amin, edm, errdef;
62 min->GetStats(amin, edm, errdef, nvpar, nparx);
68 for (
int i = 0; i < 4; ++i)
107 XYZVector xp(
x,
y, z);
108 XYZVector x0(p[0], p[2], 0.);
109 XYZVector x1(p[0] + p[1], p[2] + p[3], 1.);
110 XYZVector u = (x1 - x0).Unit();
111 double d2 = ((xp - x0).Cross(u)).Mag2();
120 XYZVector xp(
x,
y, z);
121 XYZVector x0(p[0], p[2], 0.);
122 XYZVector x1(p[0] + p[1], p[2] + p[3], 1.);
123 XYZVector u = (x1 - x0).Unit();
124 XYZVector xr = xp - x0;
125 XYZVector
D = xr.Cross(u);
127 double d2e = TMath::Power(
D.X(), 2) / ex / ex;
128 d2e += TMath::Power(
D.Y(), 2) / ey / ey;
129 d2e += TMath::Power(
D.Z(), 2) / ez / ez;
153 if (NULL ==
fgr) LOG(fatal) <<
"Invalid TGraph2Errors";
154 TGraph2DErrors*
gr =
fgr;
156 double*
x =
gr->GetX();
157 double*
y =
gr->GetY();
158 double* z =
gr->GetZ();
159 double* ex =
gr->GetEX();
160 double* ey =
gr->GetEY();
161 double* ez =
gr->GetEZ();
162 int npoints =
gr->GetN();
164 for (
int i = 0; i < npoints; ++i) {
166 double d =
distance2err(
x[i],
y[i], z[i], ex[i], ey[i], ez[i], par);
171 std::cout <<
" -D- LKFMinuit::SumDistance2: point " << i <<
"\t" <<
x[i] <<
"\t" << ex[i] <<
"\t" <<
y[i]
172 <<
"\t" << ey[i] <<
"\t" << z[i] <<
"\t" << ez[i] <<
"\t" << std::sqrt(d) << std::endl;
176 if (
first) std::cout <<
" -D- LKFMinuit::SumDistance2: Total sum2 = " << sum << std::endl;
185 result =
LKF_obj->SumDistance2(par);
friend fscal min(fscal x, fscal y)
static LKFMinuit * LKF_obj
static TGraph2DErrors * fgr
double myFunction(double)
double distance2err(double x, double y, double z, double ex, double ey, double ez, double *p)
double distance2(double x, double y, double z, double *p)
int DoFit(TGraph2DErrors *gr, double pStart[])
void line(double t, double *p, double &x, double &y, double &z)
static void minuitFunction(int &nDim, double *gout, double &result, double par[], int flg)
double SumDistance2(double par[])
static LKFMinuit * fInstance