46 if ((
a == 0.0) || (
b == 0.0))
return v;
53 x =
x * std::cos(theta) +
y * std::sin(theta);
54 y =
y * std::cos(theta) -
v * std::sin(theta);
114 if (!
g)
return nullptr;
115 if (
g->GetN() < 6)
return nullptr;
136 m->SetMaxFunctionCalls(1000000);
137 m->SetMaxIterations(100000);
138 m->SetTolerance(0.001);
153 double x0, y0,
a,
b, theta;
159 theta = ((std::abs(
b) > 9999.9 * std::abs(
a)) ? 9999.9 : (
b /
a));
165 double d = dx * dx + dy * dy;
169 theta = ((std::abs(dy) > 9999.9 * std::abs(dx)) ? 9999.9 : (dy / dx));
173 a = std::sqrt(
a);
if (!(
a > 0))
a = 0.001;
174 b = std::sqrt(
b);
if (!(
b > 0))
b = 0.001;
175 theta = std::atan(theta) * 180.0 /
TMath::Pi();
176 if (theta < -45.0) theta += 180.0;
179 m->SetVariable(0,
"x0", x0, (
xmax -
xmin) / 100.0);
180 m->SetVariable(1,
"y0", y0, (
ymax -
ymin) / 100.0);
181 m->SetVariable(2,
"a",
a,
a / 100.0);
182 m->SetVariable(3,
"b",
b,
b / 100.0);
183 m->SetVariable(4,
"theta", theta, 1);
196 m->SetVariableLimits(2, 0,
a * 3.0);
197 m->SetVariableLimits(3, 0,
b * 3.0);
199 m->SetVariableLimits(4, theta - 45.0, theta + 45.0);
206 const double *xm =
m->X();
207 std::cout <<
"Minimum ( "
208 << xm[0] <<
" , " << xm[1] <<
" , "
209 << xm[2] <<
" , " << xm[3] <<
" , "
245 for (i = 0; i <
n; i++) {
246 x[i] =
a * (std::cos(dt *
double(i)) + 0.1 *
gRandom->
Rndm() - 0.05);
247 y[i] =
b * (std::sin(dt *
double(i)) + 0.1 *
gRandom->
Rndm() - 0.05);
250 x[i] =
x[i] * std::cos(theta) -
y[i] * std::sin(theta);
251 y[i] =
y[i] * std::cos(theta) + tmp * std::sin(theta);
261 g->SetNameTitle(
"g",
"test ellipse");
275 TF2 *ellipse = ((
TF2 *)(
gROOT->GetListOfFunctions()->FindObject(
"ellipse")));
276 if (ellipse)
delete ellipse;
279 ellipse->
SetParNames(
"x0",
"y0",
"a",
"b",
"theta");
292 if (
m && (!(
m->Status())) ) {
293 const double *xm =
m->X();
301 c->Modified();
c->Update();
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 r
R__EXTERN TRandom * gRandom
static ROOT::Math::Minimizer * CreateMinimizer(const std::string &minimizerType="", const std::string &algoType="")
static method to create the corresponding Minimizer given the string Supported Minimizers types are: ...
Documentation for class Functor class.
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
void Clear(Option_t *option="") override
Remove all primitives from the canvas.
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum value along Y for this function In case the function is already drawn,...
virtual void SetParameters(const Double_t *params)
virtual void SetParNames(const char *name0="p0", const char *name1="p1", const char *name2="p2", const char *name3="p3", const char *name4="p4", const char *name5="p5", const char *name6="p6", const char *name7="p7", const char *name8="p8", const char *name9="p9", const char *name10="p10")
Set up to 10 parameter names.
A 2-Dim function with parameters.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void ComputeRange(Double_t &xmin, Double_t &ymin, Double_t &xmax, Double_t &ymax) const
Compute the x/y range of the points in this graph.
virtual void Clear(Option_t *="")
Double_t Rndm() override
Machine independent random number generator.
TGraph * TestGraphRMM(bool randomize=false)
double ellipse_fcn(double x, double y, double x0, double y0, double a, double b, double theta)
void fitEllipseTGraphRMM(TGraph *g=((TGraph *) nullptr))
ROOT::Math::Minimizer * ellipse_TGraph_minimize(TGraph *g)
double ellipse_TGraph_chi2(const double *x)
constexpr Double_t PiOver2()
constexpr Double_t TwoPi()