36void line(
double t,
const double *p,
double &
x,
double &
y,
double &z) {
53 SumDistance2(TGraph2D *
g) : fGraph(
g) {}
56 double distance2(
double x,
double y,
double z,
const double *p) {
63 double d2 = ((xp-x0).Cross(u)).Mag2();
69 assert(fGraph !=
nullptr);
70 double *
x = fGraph->
GetX();
71 double *
y = fGraph->
GetY();
72 double * z = fGraph->
GetZ();
73 int npoints = fGraph->
GetN();
75 for (
int i = 0;
i < npoints; ++
i) {
76 double d = distance2(
x[
i],
y[
i],z[
i],par);
80 std::cout <<
"Total Initial distance square = " <<
sum << std::endl;
104 double p0[4] = {10,20,1,2};
107 for (
int N=0;
N<nd;
N++) {
110 double t =
gRandom->Uniform(0,10);
117 gr->SetPoint(
N,
x,
y,z);
126 SumDistance2 sdist(
gr);
129 double pStart[4] = {1,1,1,1};
130 fitter.
SetFCN(fcn,pStart);
134 bool ok = fitter.
FitFCN();
136 Error(
"line3Dfit",
"Line3D Fit failed");
142 std::cout <<
"Total final distance square " <<
result.MinFcnValue() << std::endl;
149 const double * parFit =
result.GetParams();
156 for (
int i = 0;
i <
n;++
i) {
157 double t = t0+ dt*
i/
n;
160 l->SetPoint(
i,
x,
y,z);
162 l->SetLineColor(
kRed);
167 for (
int i = 0;
i <
n;++
i) {
168 double t = t0+ dt*
i/
n;
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char x1
TRObject operator()(const T1 &t1) const
R__EXTERN TRandom * gRandom
R__EXTERN TStyle * gStyle
const ParameterSettings & ParSettings(unsigned int i) const
get the parameter settings for the i-th parameter (const method)
class containing the result of the fit and all the related information (fitted parameter values,...
Fitter class, entry point for performing all type of fits.
const FitResult & Result() const
get fit result
bool FitFCN(unsigned int npar, Function &fcn, const double *params=nullptr, unsigned int dataSize=0, int fitType=0)
Fit using the a generic FCN function as a C++ callable object implementing double () (const double *)...
const FitConfig & Config() const
access to the fit configuration (const method)
bool SetFCN(unsigned int npar, Function &fcn, const double *params=nullptr, unsigned int dataSize=0, int fitType=0)
Set a generic FCN function as a C++ callable object implementing double () (const double *) Note that...
void SetStepSize(double err)
set the step size
Documentation for class Functor class.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Graphics object made of three arrays X, Y and Z with the same number of points each.
A 3-dimensional polyline.
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
void Draw(Option_t *option="") override
Draw this 3-D polyline with its current attributes.
SVector< T, D > Unit(const SVector< T, D > &rhs)
Unit.
DisplacementVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > XYZVector
3D Vector based on the cartesian coordinates x,y,z in double precision
static uint64_t sum(uint64_t i)