Skip to content

Commit 8aaf3ea

Browse files
committed
Fix - handle NaN/infinite value when extract bin id for TTree::Draw
1 parent 6cb8a4e commit 8aaf3ea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

modules/tree.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,8 @@ class TDrawSelector extends TSelector {
10611061
res.k = res.nbins / (res.max - res.min);
10621062

10631063
res.GetBin = function(value) {
1064-
const bin = this.lbls?.indexOf(value) ?? Math.floor((value - this.min) * this.k);
1065-
return (bin < 0) ? 0 : ((bin > this.nbins) ? this.nbins + 1 : bin + 1);
1064+
const bin = this.lbls?.indexOf(value) ?? Number.isFinite(value) ? Math.floor((value - this.min) * this.k) : this.nbins + 1;
1065+
return bin < 0 ? 0 : ((bin > this.nbins) ? this.nbins + 1 : bin + 1);
10661066
};
10671067

10681068
return res;
@@ -1237,7 +1237,7 @@ class TDrawSelector extends TSelector {
12371237
/** @summary Fill 2D histogram */
12381238
fill2DHistogram(xvalue, yvalue, weight) {
12391239
let xbin = this.x.GetBin(xvalue),
1240-
ybin = this.y.GetBin(yvalue);
1240+
ybin = this.y.GetBin(yvalue);
12411241

12421242
this.hist.fArray[xbin + (this.x.nbins + 2) * ybin] += weight;
12431243
if (!this.x.lbls && !this.y.lbls) {

0 commit comments

Comments
 (0)