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) {
61 XYZVector x1(p[0] + p[1], p[2] + p[3], 1. );
63 double d2 = ((xp-x0).Cross(u)).Mag2();
69 assert(fGraph !=
nullptr);
70 double *
x = fGraph->
GetX();
71 double *
y = fGraph->
GetY();
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;
143 result.
Print(std::cout);
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;
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
TRObject operator()(const T1 &t1) const
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,...
const double * GetParams() const
parameter values (return const pointer)
void Print(std::ostream &os, bool covmat=false) const
print the result and optionally covariance matrix and correlations
double MinFcnValue() const
Return value of the objective function (chi2 or likelihood) used in the fit.
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.
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
void Draw(Option_t *option="") override
Default Draw method for all objects.
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)