24 using namespace ROOT::Math;
28 void line(
double t,
const double *p,
double &
x,
double &
y,
double &
z) {
62 double *
x = fGraph->GetX();
63 double *
y = fGraph->GetY();
64 double *
z = fGraph->GetZ();
65 int npoints = fGraph->GetN();
67 for (
int i = 0; i < npoints; ++i) {
71 if (
first) std::cout <<
"point " << i <<
"\t"
79 std::cout <<
"Total Initial distance square = " << sum << std::endl;
102 double p0[4] = {10,20,1,2};
124 SumDistance2 sdist(gr);
131 double pStart[4] = {1,1,1,1};
132 fitter.
SetFCN(fcn,pStart);
136 bool ok = fitter.
FitFCN();
138 Error(
"line3Dfit",
"Line3D Fit failed");
144 std::cout <<
"Total final distance square " << result.
MinFcnValue() << std::endl;
145 result.
Print(std::cout);
151 const double * parFit = result.
GetParams();
159 for (
int i = 0; i <
n;++i) {
160 double t = t0+ dt*i/
n;
162 line(t,parFit,x,y,z);
170 for (
int i = 0; i <
n;++i) {
171 double t = t0+ dt*i/
n;
const FitConfig & Config() const
access to the fit configuration (const method)
void line(double t, const double *p, double &x, double &y, double &z)
void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
virtual void Draw(Option_t *option="")
Specific drawing options can be used to paint a TGraph2D:
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Documentation for class Functor class.
R__EXTERN TStyle * gStyle
bool FitFCN(unsigned int npar, Function &fcn, const double *params=0, unsigned int dataSize=0, bool chi2fit=false)
Fit using the a generic FCN function as a C++ callable object implementing double () (const double *)...
A 3-dimensional polyline.
const FitResult & Result() const
get fit result
double distance2(double x, double y, double z, const double *p)
virtual void SetLineColor(Color_t lcolor)
void SetStepSize(double err)
set the step size
const double * GetParams() const
parameter values (return const pointer)
Fitter class, entry point for performing all type of fits.
const ParameterSettings & ParSettings(unsigned int i) const
get the parameter settings for the i-th parameter (const method)
void SetOptFit(Int_t fit=1)
The type of information about fit parameters printed in the histogram statistics box can be selected ...
T Mag2(const SVector< T, D > &rhs)
Vector magnitude square Template to compute .
R__EXTERN TRandom * gRandom
virtual void Draw(Option_t *option="")
Draw this 3-D polyline with its current attributes.
SVector< T, 3 > Cross(const SVector< T, 3 > &lhs, const SVector< T, 3 > &rhs)
Vector Cross Product (only for 3-dim vectors) .
class containg the result of the fit and all the related information (fitted parameter values...
TRObject operator()(const T1 &t1) const
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Set point n to x, y, z.
static const double x1[5]
virtual void SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
Sets point number n.
void Print(std::ostream &os, bool covmat=false) const
print the result and optionaly covariance matrix and correlations
virtual Double_t Uniform(Double_t x1=1)
Returns a uniform deviate on the interval (0, x1).
double MinFcnValue() const
Return value of the objective function (chi2 or likelihood) used in the fit.
bool SetFCN(unsigned int npar, Function &fcn, const double *params=0, unsigned int dataSize=0, bool chi2fit=false)
Set a generic FCN function as a C++ callable object implementing double () (const double *) Note that...
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
SVector< T, D > Unit(const SVector< T, D > &rhs)
Unit.
Graphics object made of three arrays X, Y and Z with the same number of points each.
void Error(ErrorHandler_t func, int code, const char *va_(fmt),...)
Write error message and call a handler, if required.