Skip to content

Commit 2f63847

Browse files
bellenotlinev
authored andcommitted
Fix fitting with gaus(0)/gaus and properly make use of GetParValue(n) instead of fParams[n] (fixes differences between ROOT 5 & ROOT 6)
1 parent 55d8e94 commit 2f63847

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

scripts/JSRootCore.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,7 @@
11701170
if (! ('_func' in this) || (this._title !== this.fTitle)) {
11711171

11721172
var _func = this.fTitle;
1173+
if (_func === "gaus") _func = "gaus(0)";
11731174

11741175
if ('formulas' in this)
11751176
for (var i=0;i<this.formulas.length;++i)

scripts/JSRootMath.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,23 +573,23 @@
573573

574574
JSROOT.Math.gaus = function(f, x, i) {
575575
// function used when gaus(0) used in the TFormula
576-
return f.fParams[i+0] * Math.exp(-0.5 * Math.pow((x-f.fParams[i+1]) / f.fParams[i+2], 2));
576+
return f.GetParValue(i+0) * Math.exp(-0.5 * Math.pow((x-f.GetParValue(i+1)) / f.GetParValue(i+2), 2));
577577
};
578578

579579
JSROOT.Math.gausn = function(f, x, i) {
580-
return JSROOT.Math.gaus(f, x, i)/(Math.sqrt(2 * Math.PI) * f.fParams[i+2]);
580+
return JSROOT.Math.gaus(f, x, i)/(Math.sqrt(2 * Math.PI) * f.GetParValue(i+2));
581581
};
582582

583583
JSROOT.Math.expo = function(f, x, i) {
584-
return Math.exp(f.fParams[i+0] + f.fParams[i+1] * x);
584+
return Math.exp(f.GetParValue(i+0) + f.GetParValue(i+1) * x);
585585
};
586586

587587
JSROOT.Math.landau = function(f, x, i) {
588-
return JSROOT.Math.Landau(x, f.fParams[i+1],f.fParams[i+2], false);
588+
return JSROOT.Math.Landau(x, f.GetParValue(i+1),f.GetParValue(i+2), false);
589589
}
590590

591591
JSROOT.Math.landaun = function(f, x, i) {
592-
return JSROOT.Math.Landau(x, f['fParams'][i+1],f['fParams'][i+2], true);
592+
return JSROOT.Math.Landau(x, f.GetParValue(i+1),f.GetParValue(i+2), true);
593593
}
594594

595595
return JSROOT;

0 commit comments

Comments
 (0)