diff --git a/uhepp-js/src/components/UheppHistUI.jsx b/uhepp-js/src/components/UheppHistUI.jsx index 5cb81b17f371d6ecdab4fb063c7a738778c7e581..829d1003ba26e6f1ffac7c00dcbd888378bd12c0 100644 --- a/uhepp-js/src/components/UheppHistUI.jsx +++ b/uhepp-js/src/components/UheppHistUI.jsx @@ -249,8 +249,6 @@ const UheppHistUIWithSyst = ({ setRebin(uhepp.bins.rebin || uhepp.bins.edges) setDensity(uhepp.bins.density_width) onReset() - - } const handleRebin = (e) => { @@ -276,9 +274,22 @@ const UheppHistUIWithSyst = ({ setIsClean(false) } + // Fallback to original rebin or original binning + const takeFirstIfSubset = (rebin, orig) => { + let isSubset = true + rebin.forEach(e => { + if (orig.indexOf(e) < 0) { + isSubset = false + } + }) + return isSubset ? rebin : orig + } + const rebin_singleFallback = rebin.length > 1 ? rebin : (uhepp.bins.rebin) + const rebin_subsetFallback = takeFirstIfSubset(rebin_singleFallback, uhepp.bins.edges) + const uhepp_derived = Object.assign({}, uhepp, {bins: Object.assign({}, uhepp.bins, { - rebin: rebin.length > 1 ? rebin : (uhepp.bins.rebin), + rebin: rebin_subsetFallback, include_underflow, include_overflow, density_width,