@ndmspc/ndmvr-core 1.1.0-rc.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/dist/assets/{RCanvasPainter-DQGWienR.js → RCanvasPainter-BN1wz_jA.js} +1 -1
  3. package/dist/assets/RNTuple-B19bW6t4.js +1 -0
  4. package/dist/assets/{RPavePainter-CQHUOnSn.js → RPavePainter-BOw0-OFU.js} +1 -1
  5. package/dist/assets/{RTreeMapPainter-B2r2zCJG.js → RTreeMapPainter-DNojexp9.js} +1 -1
  6. package/dist/assets/{TASImagePainter-DRdiRLt1.js → TASImagePainter-BNJ5OAGP.js} +1 -1
  7. package/dist/assets/{TAnnotation3DPainter-BCJen6cS.js → TAnnotation3DPainter-BCGBhq-q.js} +1 -1
  8. package/dist/assets/{TArrowPainter-Dspl2Ikh.js → TArrowPainter-C7a0r3SV.js} +1 -1
  9. package/dist/assets/{TBoxPainter-BQEN4gj8.js → TBoxPainter-Djh43LYY.js} +1 -1
  10. package/dist/assets/{TEfficiencyPainter-TxRejkVD.js → TEfficiencyPainter-dXd5DL3h.js} +1 -1
  11. package/dist/assets/{TF1Painter-BuwSTmhs.js → TF1Painter-DwE8KsBp.js} +1 -1
  12. package/dist/assets/{TF2Painter-BTh6LWBk.js → TF2Painter-SGNNKiK5.js} +1 -1
  13. package/dist/assets/{TF3Painter-R5EVXlD4.js → TF3Painter-yaRyTX9u.js} +1 -1
  14. package/dist/assets/{TGaxisPainter-BJuDLLel.js → TGaxisPainter-DSiIbikC.js} +1 -1
  15. package/dist/assets/{TGraph2DPainter-aeM0xqgu.js → TGraph2DPainter-COqZBIPT.js} +1 -1
  16. package/dist/assets/{TGraphPainter-DLkx_1ES.js → TGraphPainter-Bp7xEbQz.js} +1 -1
  17. package/dist/assets/{TGraphPainter-CtqNpDiH.js → TGraphPainter-CurXuifu.js} +1 -1
  18. package/dist/assets/{TGraphPolarPainter-bMuBuvEZ.js → TGraphPolarPainter-u-FCb_Gb.js} +1 -1
  19. package/dist/assets/{TGraphTimePainter-D_1RHDMz.js → TGraphTimePainter-DDPwiVGX.js} +1 -1
  20. package/dist/assets/{TH1Painter-CMr7gXzd.js → TH1Painter-BXzutgI3.js} +1 -1
  21. package/dist/assets/{TH1Painter--tuoUZTH.js → TH1Painter-DyN-WKyv.js} +1 -1
  22. package/dist/assets/{TH2Painter-DHaL_lR_.js → TH2Painter-BpixRP4j.js} +1 -1
  23. package/dist/assets/{TH2Painter-BLfyBVB5.js → TH2Painter-DceuYQAL.js} +1 -1
  24. package/dist/assets/{TH3Painter-DLCndhZ0.js → TH3Painter-BA_W8tmJ.js} +1 -1
  25. package/dist/assets/{THStackPainter-B3TUpsVt.js → THStackPainter-BWLN_w9A.js} +1 -1
  26. package/dist/assets/{THistPainter-Df-RmCQH.js → THistPainter-B2S5BnuY.js} +1 -1
  27. package/dist/assets/{TLinePainter-RinEQkrM.js → TLinePainter-D8inyuoX.js} +1 -1
  28. package/dist/assets/{TMultiGraphPainter-BQyL8zWX.js → TMultiGraphPainter-DcwdyhOr.js} +1 -1
  29. package/dist/assets/{TPavePainter-Dx40jhkF.js → TPavePainter-1yngbgp8.js} +1 -1
  30. package/dist/assets/{TPiePainter-BaTIH6-e.js → TPiePainter-BgDv4srX.js} +1 -1
  31. package/dist/assets/{TPolyLinePainter-7_jf8MLI.js → TPolyLinePainter-BYlrAjCB.js} +1 -1
  32. package/dist/assets/{TPolyMarker3D-DYlLB9Ww.js → TPolyMarker3D-BaWOSDy6.js} +1 -1
  33. package/dist/assets/{TRatioPlotPainter-BvUop_Na.js → TRatioPlotPainter-CJgkL58z.js} +1 -1
  34. package/dist/assets/{TScatterPainter-CvLCMGW2.js → TScatterPainter-Bt11j8z8.js} +1 -1
  35. package/dist/assets/{TSplinePainter-DJPtQW6I.js → TSplinePainter-p6k_OB02.js} +1 -1
  36. package/dist/assets/{TTextPainter-BwCh-g5B.js → TTextPainter-B26aOYGd.js} +1 -1
  37. package/dist/assets/{TTree-CE4EQRMu.js → TTree-BtFtnLeD.js} +1 -1
  38. package/dist/assets/{TWebPaintingPainter-CexNsDDp.js → TWebPaintingPainter-CZ6lo-7N.js} +1 -1
  39. package/dist/assets/{draw3d-BPJMZpwL.js → draw3d-ejHvJRmG.js} +1 -1
  40. package/dist/assets/{func-C1jNXIub.js → func-C6FX2eN2.js} +1 -1
  41. package/dist/assets/{hist3d-DCmav5Ga.js → hist3d-D9VevdP6.js} +1 -1
  42. package/dist/assets/{latex3d-ITrfFgp8.js → latex3d-8Hbnfz6c.js} +1 -1
  43. package/dist/assets/{main-CvPDcTGr.js → main-DwRPe_ox.js} +191 -191
  44. package/dist/assets/{more-CGvLPt4r.js → more-64laEJ4X.js} +1 -1
  45. package/dist/assets/{ndmvr-aframe-core-Cw91_9_Y.js → ndmvr-aframe-core-DEHQ38JB.js} +4 -4
  46. package/dist/assets/{rntuple-BCwqxNeP.js → rntuple-i8TaG-6V.js} +1 -1
  47. package/dist/assets/{stress-Ihg3ljmc.js → stress-KrXoDujC.js} +1 -1
  48. package/dist/assets/{v7more-H3D-KQGQ.js → v7more-C-UZAxz1.js} +1 -1
  49. package/dist/docs/components/configuration/configuration/index.html +243 -238
  50. package/dist/docs/components/tutorial/canvas/canvas/index.html +1 -1
  51. package/dist/docs/components/tutorial/configurationChapter/configuration-chapter/index.html +1 -1
  52. package/dist/docs/components/tutorial/firstVisualization/first-visualization/index.html +1 -1
  53. package/dist/docs/components/tutorial/interactions/interactions/index.html +1 -1
  54. package/dist/docs/downloads/canvas.zip +0 -0
  55. package/dist/docs/downloads/configuration.zip +0 -0
  56. package/dist/docs/downloads/first-visualization.zip +0 -0
  57. package/dist/docs/downloads/interactions.zip +0 -0
  58. package/dist/docs/index.html +1 -1
  59. package/dist/docs/search/search_index.json +1 -1
  60. package/dist/docs/sitemap.xml.gz +0 -0
  61. package/dist/index.es.js +962 -953
  62. package/dist/index.html +2 -2
  63. package/dist/index.umd.js +10 -10
  64. package/dist/stress.html +2 -2
  65. package/package.json +1 -1
  66. package/dist/assets/RNTuple-L4uyxl3s.js +0 -1
@@ -1 +1 @@
1
- import{bI as Gt,aX as vt,ad as F,ae as et,aU as yt,bv as Ct,az as pt,aA as wt,bT as Ht,bt as zt,a5 as kt}from"./ndmvr-aframe-core-Cw91_9_Y.js";import{T as Et}from"./THistPainter-Df-RmCQH.js";import{g as Dt}from"./func-C1jNXIub.js";const At=["LOGXY","LOGX","LOGY","LOGZ","LOGV","LOG","LOG2X","LOG2Y","LOG2","LNX","LNY","LN","GRIDXY","GRIDX","GRIDY","TICKXY2","TICKX2","TICKY2","TICKXY","TICKX","TICKY","TICKZ","FB","GRAYSCALE"];let Kt=class St extends Et{getHisto(){const t=super.getHisto();if(t?._typename===Gt)switch(t.$getBinContent||(t.$getBinContent=t.getBinContent),this.getOptions().ProfileProj){case"B":t.getBinContent=t.getBinEntries;break;case"C=E":t.getBinContent=t.getBinError;break;case"W":t.getBinContent=function(i){return this.$getBinContent(i)*this.getBinEntries(i)};break;default:t.getBinContent=t.$getBinContent;break}return t}scanContent(t){t&&!this.nbinsx&&(t=!1);const i=this.getHisto(),e=this.getOptions();t||this.extractAxesProperties(1);const s=this.getSelectIndex("x","left"),l=this.getSelectIndex("x","right"),f=this.getPadPainter()?.getPadLog(e.swap_xy()?"x":"y"),u=e.Func?this.findFunction(vt):null;if(t&&s===this.scan_xleft&&l===this.scan_xright)return;this.draw_content=!(e.Axis>0),this.scan_xleft=s,this.scan_xright=l;const b=this.isTProfile(),h=Math.min(0,s),w=Math.max(this.nbinsx,l);let r=0,d=0,n=0,o=0,E=!0,x,m={low:0,up:0};for(let _=h;_<w;++_)if(x=i.getBinContent(_+1),o+=b?i.fBinEntries[_+1]:x,!(_<s||_>=l)&&(x>0&&(d===0||x<d)&&(d=x),E&&(r=n=x,E=!1),e.Error&&(m=this.getBinErrors(i,_+1,x)),r=Math.min(r,x-m.low),n=Math.max(n,x+m.up),u)){const T=i.fXaxis.GetBinCenter(_+1),a=Dt(u,T);a!==void 0&&(n=Math.max(n,a),f&&x>0&&a>.3*x&&(d=Math.min(d,a)))}b?o+=i.fBinEntries[0]+i.fBinEntries[this.nbinsx+1]:o+=i.getBinContent(0)+i.getBinContent(this.nbinsx+1),this.stat_entries=o,this.hmin=r,this.hmax=n,(this.nbinsx===0||Math.abs(r)<1e-300&&Math.abs(n)<1e-300)&&(this.draw_content=!1);let p=!1;(this.draw_content||this.isMainPainter()&&e.Axis>0&&!e.ohmin&&!e.ohmax&&i.fMinimum===F&&i.fMaximum===F)&&(r>=n?r===0?(this.ymin=0,this.ymax=1):r<0?(this.ymin=2*r,this.ymax=0):(this.ymin=0,this.ymax=r*2):f?(this.ymin=(d||r)*.5,this.ymax=n*2*(.9/.95)):(this.ymin=r,this.ymax=n)),r=e.minimum,n=e.maximum,r===n&&r!==F&&(r<0?(r*=2,n=0):(r=0,n=2*n||1));let c=!1,k=!1;if(e.ohmin&&e.ohmax&&!this.draw_content?e.zoom_min_max?(r!==F&&r<=this.ymin&&(r=F),n!==F&&n>=this.ymax&&(n=F),p=!0):r=n=F:r!==F&&n!==F&&!this.draw_content&&(this.ymin===this.ymax||this.ymin>r||this.ymax<n)?(this.ymin=r,this.ymax=n,c=k=!0):(r!==F&&(c=!0,r<this.ymin&&(this.ymin=r),p=!0),n!==F&&(k=!0,n>this.ymax&&(this.ymax=n),p=!0)),!e.exact_values_range()&&!f){if(!c)if(e.BaseLine!==!1&&this.ymin>=0)this.ymin=0;else{const _=this.ymin>=0;this.ymin-=et.fHistTopMargin*(this.ymax-this.ymin),_&&this.ymin<0&&(this.ymin=0)}k||(this.ymax+=et.fHistTopMargin*(this.ymax-this.ymin))}t||(p&&(r!==F||n!==F)?(this.zoom_ymin=r===F?this.ymin:r,this.zoom_ymax=n===F?this.ymax:n):(delete this.zoom_ymin,delete this.zoom_ymax))}get _wheel_zoomy(){return this.getDimension()>1||!this.draw_content}getUserRanges(){const t=this.getHisto();let i=0,e=0;for(let s=0;s<t.fXaxis.fNbins;++s){const l=t.getBinContent(s+1);s===0?i=e=l:(i=Math.min(i,l),e=Math.max(e,l))}return t.fMinimum!==F&&(i=t.fMinimum),t.fMaximum!==F&&(e=t.fMaximum),e<=i&&(e=i+1),{minx:t.fXaxis.fXmin,maxx:t.fXaxis.fXmax,miny:i,maxy:e}}countStat(t,i){const e=this.isTProfile(),s=this.getHisto(),l=s.fXaxis,f=this.getSelectIndex("x","left"),u=this.getSelectIndex("x","right"),b=this.getFramePainter(),h={name:s.fName,meanx:0,meany:0,rmsx:0,rmsy:0,integral:0,entries:s.fEntries>0?s.fEntries:this.stat_entries,eff_entries:0,xmax:0,wmax:0,skewx:0,skewd:0,kurtx:0,kurtd:0},w=!b?.isAxisZoomed("x")&&Math.abs(s.fTsumw)>1e-300;let r=0,d=0,n=0,o=0,E=0,x=0,m,p,c,k=null,_=null;for(kt(t)||(t=null),m=f;m<u;++m)p=l.GetBinCoord(m+.5),!(t&&!t(p))&&(e?(c=s.fBinEntries[m+1],E+=s.fArray[m+1],x+=s.fSumw2[m+1]):c=s.getBinContent(m+1),(k===null||c>_)&&(k=p,_=c),w||(r+=c,d+=c*c,n+=c*p,o+=c*p**2));if(w&&(r=s.fTsumw,d=s.fTsumw2,n=s.fTsumwx,o=s.fTsumwx2),h.integral=r,h.eff_entries=d?r*r/d:Math.abs(r),Math.abs(r)>1e-300&&(h.meanx=n/r,h.meany=E/r,h.rmsx=Math.sqrt(Math.abs(o/r-h.meanx**2)),h.rmsy=Math.sqrt(Math.abs(x/r-h.meany**2))),k!==null&&(h.xmax=k,h.wmax=_),i){let T=0,a=0,B=0;for(m=f;m<u;++m)p=l.GetBinCoord(m+.5),!(t&&!t(p))&&(c=e?s.fBinEntries[m+1]:s.getBinContent(m+1),B+=c,T+=c*Math.pow(p-h.meanx,3),a+=c*Math.pow(p-h.meanx,4));const y=Math.pow(h.rmsx,3),S=Math.pow(h.rmsx,4);B*y&&(h.skewx=T/(B*y)),h.skewd=h.eff_entries>0?Math.sqrt(6/h.eff_entries):0,B*S&&(h.kurtx=a/(B*S)-3),h.kurtd=h.eff_entries>0?Math.sqrt(24/h.eff_entries):0}return h}fillStatistic(t,i,e){if(this.isIgnoreStatsFill())return!1;i===1&&(i=1111),e===1&&(e=111);const s=this.getHisto(),l=i%10,f=Math.floor(i/10)%10,u=Math.floor(i/100)%10,b=Math.floor(i/1e3)%10,h=Math.floor(i/1e4)%10,w=Math.floor(i/1e5)%10,r=Math.floor(i/1e6)%10,d=Math.floor(i/1e7)%10,n=Math.floor(i/1e8)%10,o=this.countStat(void 0,d>0||n>0);return t.clearPave(),l>0&&t.addText(o.name),this.isTProfile()?(f>0&&t.addText("Entries = "+t.format(o.entries,"entries")),u>0&&(t.addText("Mean = "+t.format(o.meanx)),t.addText("Mean y = "+t.format(o.meany))),b>0&&(t.addText("Std Dev = "+t.format(o.rmsx)),t.addText("Std Dev y = "+t.format(o.rmsy)))):(f>0&&t.addText("Entries = "+t.format(o.entries,"entries")),u>0&&t.addText("Mean = "+t.format(o.meanx)),b>0&&t.addText("Std Dev = "+t.format(o.rmsx)),h>0&&t.addText("Underflow = "+t.format(s.fArray.length?s.fArray[0]:0,"entries")),w>0&&t.addText("Overflow = "+t.format(s.fArray.length?s.fArray.at(-1):0,"entries")),r>0&&t.addText("Integral = "+t.format(o.integral,"entries")),d===2?t.addText(`Skewness = ${t.format(o.skewx)} #pm ${t.format(o.skewd)}`):d>0&&t.addText(`Skewness = ${t.format(o.skewx)}`),n===2?t.addText(`Kurtosis = ${t.format(o.kurtx)} #pm ${t.format(o.kurtd)}`):n>0&&t.addText(`Kurtosis = ${t.format(o.kurtx)}`)),e&&t.fillFunctionStat(this.findFunction(vt),e,1),!0}getBarBaseline(t,i){const e=this.getOptions();let s=t.swap_xy()?0:i;return Number.isFinite(e.BaseLine)&&e.BaseLine>=t.scale_ymin&&(s=Math.round(t.gry(e.BaseLine))),s}async drawBars(t,i){const e=this.getSelectIndex("x","left",-1),s=this.getSelectIndex("x","right",1),l=this.getHisto(),f=this.getOptions(),u=l.fXaxis,b=f.Text;let h,w,r,d=f.BarStyle>10?f.BarStyle%10:0,n=Promise.resolve();d>4&&(d=4);const o=this.getBarBaseline(t,i);return b&&(h=this.getColor(l.fMarkerColor),w=-1*f.TextAngle,r=20,l.fMarkerSize!==1&&w&&(r=.02*i*l.fMarkerSize),n=this.startTextDrawingAsync(42,r,void 0,r)),n.then(()=>{let E="",x="",m="";for(let p=e;p<s;++p){const c=u.GetBinLowEdge(p+1),k=u.GetBinLowEdge(p+2);if(t.logx&&k<=0)continue;let _=Math.round(t.grx(c)),T=Math.round(t.grx(k)),a=T-_;const B=l.getBinContent(p+1);if(t.logy&&B<t.scale_ymin)continue;const y=Math.round(t.gry(B));if(_+=Math.round(l.fBarOffset/1e3*a),a=Math.round(l.fBarWidth/1e3*a),t.swap_xy()?E+=`M${o},${_}h${y-o}v${a}h${o-y}z`:E+=`M${_},${y}h${a}v${o-y}h${-a}z`,d>0&&(T=_+a,a=Math.round(a*d/10),t.swap_xy()?(x+=`M${o},${_}h${y-o}v${a}h${o-y}z`,m+=`M${o},${T}h${y-o}v${-a}h${o-y}z`):(x+=`M${_},${y}h${a}v${o-y}h${-a}z`,m+=`M${T},${y}h${-a}v${o-y}h${a}z`)),b&&B){const S=B===Math.round(B)?B.toString():yt(B,et.fPaintTextFormat);t.swap_xy()?this.drawText({align:12,x:Math.round(y+r/2),y:Math.round(_+.1),height:Math.round(a*.8),text:S,color:h,latex:0}):w?this.drawText({align:12,x:_+a/2,y:Math.round(y-2-r/5),width:0,height:0,rotate:w,text:S,color:h,latex:0}):this.drawText({align:22,x:Math.round(_+a*.1),y:Math.round(y-2-r),width:Math.round(a*.8),height:r,text:S,color:h,latex:0})}}if(E&&this.appendPath(E).call(this.fillatt.func),x&&this.appendPath(x).call(this.fillatt.func).style("fill",Ct(this.fillatt.color).brighter(.5).formatRgb()),m&&this.appendPath(m).call(this.fillatt.func).style("fill",Ct(this.fillatt.color).darker(.5).formatRgb()),b)return this.finishTextDrawing()})}drawFilledErrors(t){const i=this.getSelectIndex("x","left",0),e=this.getSelectIndex("x","right",0),s=this.getHisto(),l=[],f=[];for(let w=i;w<e;++w){const r=s.fXaxis.GetBinCoord(w+.5);if(t.logx&&r<=0)continue;const d=Math.round(t.grx(r)),n=s.getBinContent(w+1),o=this.getBinErrors(s,w+1,n);t.logy&&n-o.low<t.scale_ymin||(l.push({grx:d,gry:Math.round(t.gry(n+o.up))}),f.unshift({grx:d,gry:Math.round(t.gry(n-o.low))}))}const u=this.getOptions().ErrorKind!==4,b=pt(l,{line:u}),h=pt(f,{line:u,cmd:"L"});this.appendPath(b+h+"Z").call(this.fillatt.func)}async drawNormal(t,i,e){const s=this.getSelectIndex("x","left",-1),l=this.getSelectIndex("x","right",2),f=this.getHisto(),u=this.getOptions(),b=!this.isBatchMode()&&wt.Tooltip,h=f.fXaxis,w=!u.Zero,r=u.Error,d=u.Curve,n=u.Text,o=n&&u.TextKind==="E"&&this.isTProfile()&&f.fBinEntries,E=[];let x="",m=!1,p=u.Mark,c=u.Line,k,_,T,a,B,y,S,$,g,M,H,A,X,Z,U,rt=null,K=null,W=null,z="",tt=null,st=null,V=null,G=5,lt=!1,ht=!1,N=0,L=0,v,I,J,R,ut,D,Y,P,ft,xt,nt,gt,Mt,it,O,_t=Promise.resolve();r&&!p&&f.fMarkerStyle>1&&(p=!0),u.ErrorKind===2?this.fillatt.empty()?p=!0:rt="":r&&(c=!1,K="",tt=b?"":null,ht=!0),L=this.lineatt.width+et.fEndErrorSize,u.ErrorKind===1&&(N=Math.floor((this.lineatt.width-1)/2)),p&&(this.createAttMarker({attr:f,style:u.MarkStyle}),this.markeratt.size>0?(W="",lt=!0,this.markeratt.resetPos(),tt===null&&b&&(!this.markeratt.fill||this.markeratt.getFullSize()<7)&&(V="",G=Math.max(5,Math.round(this.markeratt.getFullSize()*.7)))):p=!1);const mt=r||p,ct=mt||n||c||d,Q=u.Hist&&(!this.lineatt.empty()||!this.fillatt.empty()),Pt=r&&f.fSumw2?.length,Ft=ct||l-s>3*i;if(!Q&&!ct)return this.removeG();if(n){if(Mt=this.getColor(f.fMarkerColor),it=-1*u.TextAngle,O=20,f.fMarkerSize!==1&&it&&(O=.02*e*f.fMarkerSize),!it&&!u.TextKind){const at=i/(l-s+1);at<3*O&&(it=270,O=Math.round(at*.7))}b&&!Q&&(st=""),_t=this.startTextDrawingAsync(42,O,void 0,O)}return _t.then(()=>{const at=C=>(R=f.getBinContent(C+1),w&&R===0&&(!Pt||!f.fSumw2[C+1])?!1:(D=Math.round(t.grx(h.GetBinLowEdge(C+1))),Y=Math.round(t.grx(h.GetBinLowEdge(C+2))),P=Math.round((D+Y)/2),_===void 0&&(_=P),v=Math.round(t.gry(R)),r?(ut=this.getBinErrors(f,C+1,R),I=Math.round(v-t.gry(R+ut.up)),J=Math.round(t.gry(R-ut.low)-v)):I=J=20,!0)),$t=()=>{let C=5;if(u.errorX>0&&(C=Math.round((Y-D)*u.errorX),nt=P-C,gt=P+C,u.ErrorKind===1?K+=`M${nt+N},${v-L}v${2*L}m0,-${L}h${gt-nt-2*N}m0,-${L}v${2*L}`:K+=`M${nt+N},${v}h${gt-nt-2*N}`),u.ErrorKind===1?K+=`M${P-L},${v-I+N}h${2*L}m${-L},0v${I+J-2*N}m${-L},0h${2*L}`:K+=`M${P},${v-I+N}v${I+J-2*N}`,tt!==null){const j=Math.max(I,5),q=Math.max(J,5);tt+=`M${P-C},${v-j}h${2*C}v${j+q}h${-2*C}z`}},Bt=()=>{t.swap_xy()?(W+=this.markeratt.create(v,P),V!==null&&(V+=`M${v-G},${P-G}v${2*G}h${2*G}v${-2*G}z`)):(W+=this.markeratt.create(P,v),V!==null&&(V+=`M${P-G},${v-G}h${2*G}v${2*G}h${-2*G}z`))},ot=C=>{if(at(C)){if(n){const j=o?f.fBinEntries[C+1]:R;if(j){const q=it?{align:12,x:P,y:Math.round(v-2-O/5),width:0,height:0,rotate:it}:{align:22,x:Math.round(D+(Y-D)*.1),y:Math.round(v-2-O),width:Math.round((Y-D)*.8),height:O};q.text=j===Math.round(j)?j.toString():yt(j,et.fPaintTextFormat),q.color=Mt,q.latex=0,t.swap_xy()&&(q.x=v,q.y=Math.round(P-O/2)),this.drawText(q),st!==null&&(st+=`M${D},${v-G}v${2*G}h${Y-D}v${-2*G}z`)}}c?(t.swap_xy()?z+=(z?"L":"M")+`${v},${P}`:z?ft===P?z+=`v${v-xt}`:xt===v?z+=`h${P-ft}`:z+=`l${P-ft},${v-xt}`:z=`M${P},${v}`,ft=P,xt=v):d&&E.push({grx:(D+Y)/2,gry:t.gry(R)}),mt&&v>=-I&&v<=e+J&&(rt!==null&&(rt+=`M${D},${v-I}h${Y-D}v${I+J+1}h${D-Y}z`),W!==null&&lt&&Bt(),K!==null&&ht&&$t())}};if((lt||ht)&&(!wt.OptimizeDraw||l-s<5e4&&wt.OptimizeDraw===1)){for(X=s;X<l;++X)at(X)&&(W!==null&&Bt(),K!==null&&$t());ht=lt=!1}for(X=s;X<=l;++X)B=h.GetBinLowEdge(X+1),!(this.logx&&B<=0)&&(y=Math.round(t.grx(B)),m=X===l,m&&s<l?$=a:(S=f.getBinContent(X+1),$=Math.round(t.gry(S))),x?Ft?y===T&&!m?($<g?U=X:$>M&&(Z=X),g=Math.min(g,$),M=Math.max(M,$),a=$):(ct&&(Z===U?ot(Z):Z<U?(ot(Z),ot(U)):(ot(U),ot(Z))),Q&&(g!==M||H!==g)&&(A!==T&&(x+="h"+(T-A)),a===g?(M!==H&&(x+="v"+(M-H)),g!==M&&(x+="v"+(g-M))):(g!==H&&(x+="v"+(g-H)),M!==g&&(x+="v"+(M-g)),a!==M&&(x+="v"+(a-M))),A=T,H=a),m&&A!==y&&(x+="h"+(y-A)),Z=U=X,g=M=a=$,T=y):($!==a||m)&&(y!==T&&(x+=`h${y-T}`),$!==a&&(x+=`v${$-a}`),a=$,T=y):(Z=U=X,A=k=T=y,H=g=M=a=$,x=`M${T},${a}`));const bt=b&&this.fillatt.empty()&&Q&&!mt&&!c&&!d&&this.isUseFrame();let dt=e+3;if(!bt){const C=Math.round(t.gry(0));C<=0?dt=-3:C<e&&(dt=C)}const Xt=`L${T},${dt}H${k}Z`,Tt=()=>{this.appendPath(x+(!this.fillatt.empty()||bt?Xt:"")).style("stroke-linejoin","miter").call(this.lineatt.func).call(this.fillatt.func)};if(x&&Q&&!this.fillatt.empty()&&(Tt(),x=""),(mt||c||d)&&(!z&&E.length&&(t.swap_xy()&&E.forEach(C=>{[C.grx,C.gry]=[C.gry,C.grx]}),z=pt(E)),rt?this.appendPath(rt).call(this.fillatt.func):z&&!this.fillatt.empty()&&!Q&&this.appendPath(z+`L${P},${dt}H${_}Z`).call(this.fillatt.func),K&&this.appendPath(K).call(this.lineatt.func),tt&&this.appendPath(tt).style("fill","none").style("pointer-events",this.isBatchMode()?null:"visibleFill"),z&&this.appendPath(z).style("fill","none").call(this.lineatt.func),W&&this.appendPath(W).call(this.markeratt.func),V&&this.appendPath(V).style("fill","none").style("pointer-events",this.isBatchMode()?null:"visibleFill")),x&&Q&&Tt(),st&&this.appendPath(st).style("fill","none").style("pointer-events",this.isBatchMode()?null:"visibleFill"),n)return this.finishTextDrawing()})}draw1DBins(){const t=this.getOptions();t.Same&&!this.isUseFrame()&&this.getPadPainter().getFrameSvg().style("display","none"),this.createHistDrawAttributes();const i=this.getHistGrFuncs(),e=i.getFrameWidth(),s=i.getFrameHeight();return!this.draw_content||e<=0||s<=0?this.removeG():(this.createG(this.isUseFrame()),t.Bar?this.drawBars(i,s).then(()=>{if(t.ErrorKind===1)return this.drawNormal(i,e,s)}):t.ErrorKind===3||t.ErrorKind===4?this.drawFilledErrors(i):this.drawNormal(i,e,s))}getBinTooltips(t){const i=[],e=this.getObjectHint(),s=this.getHistGrFuncs(),l=this.getHisto(),f=this.getOptions(),u=l.fXaxis.GetBinLowEdge(t+1),b=l.fXaxis.GetBinLowEdge(t+2),h=this.getAxisBinTip("x",l.fXaxis,t);let w=l.getBinContent(t+1);if(e&&i.push(e),f.Error||f.Mark||this.isTF1()){if(i.push(`x = ${h}`,`y = ${s.axisAsText("y",w)}`),f.Error){h[0]==="["&&i.push(`error x = ${((b-u)/2).toPrecision(4)}`);const r=this.getBinErrors(l,t+1,w);r.poisson?i.push(`error low = ${r.low.toPrecision(4)}`,`error up = ${r.up.toPrecision(4)}`):i.push(`error y = ${r.up.toPrecision(4)}`)}}else i.push(`bin = ${t+1}`,`x = ${h}`),l.$baseh&&(w-=l.$baseh.getBinContent(t+1)),w===Math.round(w)?i.push(`entries = ${w}`):i.push(`entries = ${yt(w,et.fStatFormat)}`);return i}processTooltipEvent(t){const i=this.getOptions();if(!t||!this.draw_content||!this.getG()||i.Mode3D)return this.getG()?.selectChild(".tooltip_bin").remove(),null;const e=this.getHistGrFuncs(),s=this.getHisto(),l=this.getSelectIndex("x","left",-1),f=this.getSelectIndex("x","right",2),u=this.options.Hist&&(!this.lineatt.empty()||!this.fillatt.empty());let b=e.getFrameWidth(),h=e.getFrameHeight(),w,r,d,n,o,E=2,x=l,m=f,p=t.x,c=t.y;const k=g=>{const M=s.fXaxis.GetBinLowEdge(g+1);return e.logx&&M<=0?null:e.grx(M)},_=g=>{const M=s.getBinContent(g+1);return e.logy&&M<e.scale_ymin?e.swap_xy()?-1e3:10*h:Math.round(e.gry(M))};e.swap_xy()&&([p,c,b,h]=[c,p,h,b]);const T=e.x_handle&&e.swap_xy()!==e.x_handle.reverse;for(;x<m-1;){const g=Math.round((x+m)*.5),M=k(g);M===null||M<p-.5?T?m=g:x=g:M>p+.5?T?x=g:m=g:(x++,m--)}let a=m=x;if(r=k(a),T){for(;x>l&&k(x-1)<r+2;)--x;for(;m<f&&k(m+1)>r-2;)++m}else{for(;x>l&&k(x-1)>r-2;)--x;for(;m<f&&k(m+1)<r+2;)++m}if(x<m){let g=h;for(let M=x;M<=m;M++){const H=Math.abs(_(M)-c);H<g&&(g=H,a=M)}g>h/10&&(a=Math.round(x+(m-x)/h*c)),r=k(a)}if(r=Math.round(r),d=Math.round(k(a+1)),i.Bar){const g=d-r;r+=Math.round(s.fBarOffset/1e3*g),d=r+Math.round(s.fBarWidth/1e3*g)}r>d&&([r,d]=[d,r]);const B=Math.round((r+d)/2),y=n=o=_(a);if(i.Bar)w=!0,E=0,n=this.getBarBaseline(e,h),n>o&&([n,o]=[o,n]),!t.touch&&t.nproc===1&&(c<n||c>o)&&(a=null);else if(i.Error&&i.Hist!==!0||i.Mark||i.Line||i.Curve||i.Text&&!u){w=!this.isTF1();let g=3;if(this.markeratt&&(g=Math.max(g,this.markeratt.getFullSize())),i.Error){const M=s.getBinContent(a+1),H=this.getBinErrors(s,a+1,M);n=Math.round(e.gry(M+H.up)),o=Math.round(e.gry(M-H.low)),M===0&&this.isTProfile()&&(a=null);const A=(d-r)*i.errorX;r=Math.round(B-A),d=Math.round(B+A)}d-r<2*g&&(r=B-g,d=B+g),n=Math.min(n,y-g),o=Math.max(o,y+g),!t.touch&&t.nproc===1&&(c<n||c>o)&&(a=null)}else w=t.nproc===1&&f-l<b,w&&(o=h,this.fillatt.empty()||(o=Math.min(h,Math.max(0,Math.round(e.gry(0)))),o<n&&([n,o]=[o,n])),(t.y<n||t.y>o)&&!t.touch&&(a=null));a!==null&&(a===l&&r>p+E||a===f-1&&d<p-E||p<r-E||p>d+E||!i.Zero&&s.getBinContent(a+1)===0&&s.getBinError(a+1)===0)&&(a=null);let S=this.getG().selectChild(".tooltip_bin");if(a===null||o<=0||n>=h)return S.remove(),null;const $={name:this.getObjectName(),title:s.fTitle,x:B,y,exact:!0,color1:this.lineatt?.color??"green",color2:this.fillatt?.getFillColorAlt("blue")??"blue",lines:this.getBinTooltips(a)};if(t.disabled)S.remove(),$.changed=!0;else if(w)S.empty()&&(S=this.getG().append("svg:rect").attr("class","tooltip_bin").style("pointer-events","none").call(Ht)),$.changed=S.property("current_bin")!==a,$.changed&&S.attr("x",e.swap_xy()?n:r).attr("width",e.swap_xy()?o-n:d-r).attr("y",e.swap_xy()?r:n).attr("height",e.swap_xy()?d-r:o-n).style("opacity","0.3").property("current_bin",a),$.exact=Math.abs(y-c)<=5||c>=n&&c<=o,$.menu=$.exact,$.menu_dist=Math.sqrt((B-p)**2+(y-c)**2);else{const g=this.lineatt.width+3;S.empty()&&(S=this.getG().append("svg:circle").attr("class","tooltip_bin").style("pointer-events","none").attr("r",g).call(this.lineatt.func).call(this.fillatt.func)),$.exact=Math.abs(B-t.x)<=g&&Math.abs(y-t.y)<=g,$.menu=$.exact,$.menu_dist=Math.sqrt((B-t.x)**2+(y-t.y)**2),$.changed=S.property("current_bin")!==a,$.changed&&S.attr("cx",B).attr("cy",y).property("current_bin",a)}return $.changed&&($.user_info={obj:s,name:s.fName,bin:a,cont:s.getBinContent(a+1),grx:B,gry:y}),$}fillHistContextMenu(t){t.add("Auto zoom-in",()=>this.autoZoom());const i=this.getSupportedDrawOptions();t.addDrawMenu("Draw with",i,e=>{if(e.indexOf(zt)===0)return this.showInspector(e);this.decodeOptions(e),this.getOptions().need_fillcol&&this.fillatt?.empty()&&this.fillatt.change(5,1001),this.interactiveRedraw("pad","drawopt")}),!this.hasSnapId()&&!this.isTProfile()&&!this.isTF1()&&t.addRebinMenu(e=>this.rebinHist(e))}rebinHist(t){const i=this.getHisto(),e=i.fXaxis,s=Math.floor(e.fNbins/t);if(s<2)return;const l=new Array(s+2),f=e.fXbins.length?new Array(s):null;l[0]=i.fArray[0];let u=1;for(let h=1;h<=s;++h){f&&(f[h-1]=e.fXbins[u-1]);let w=0;for(let r=0;r<t;++r)w+=i.fArray[u++];l[h]=w}f?(u<=e.fXbins.length&&(e.fXmax=e.fXbins[u-1]),e.fXbins=f):e.fXmax=e.fXmin+(e.fXmax-e.fXmin)/e.fNbins*s*t,e.fNbins=s;let b=0;for(;u<i.fArray.length;)b+=i.fArray[u++];l[s+1]=b,i.fArray=l,i.fSumw2=[],this.scanContent(),this.interactiveRedraw("pad")}autoZoom(){let t=this.getSelectIndex("x","left",-1),i=this.getSelectIndex("x","right",1);const e=i-t,s=this.getHisto();if(e===0||!s)return;let l=s.getBinContent(t+1);for(let f=t;f<i;++f)l=Math.min(l,s.getBinContent(f+1));if(!(l>0)){for(;t<i&&s.getBinContent(t+1)<=l;)++t;for(;t<i&&s.getBinContent(i)<=l;)--i;if(t===i-1&&t>2&&i<this.nbinsx-2&&(--t,++i),i-t<e&&t<i)return this.getFramePainter().zoom(s.fXaxis.GetBinLowEdge(t+1),s.fXaxis.GetBinLowEdge(i+1))}}canZoomInside(t,i,e){const s=this.getHisto();return!!(t==="x"&&s&&s.fXaxis.FindBin(e,.5)-s.fXaxis.FindBin(i,0)>1||t==="y"&&Math.abs(e-i)>Math.abs(this.ymax-this.ymin)*1e-6)}async draw2D(t){return this.clear3DScene(),this.scanContent(t==="zoom"),(this.isMainPainter()?this.drawColorPalette(!1):Promise.resolve(!0)).then(()=>this.drawAxes()).then(()=>this.draw1DBins()).then(()=>this.updateFunctions()).then(()=>this.updateHistTitle()).then(()=>(this.updateStatWebCanvas(),this.addInteractivity()))}async draw3D(t){return console.log("3D drawing is disabled, load ./hist/TH1Painter.mjs"),this.draw2D(t)}async callDrawFunc(t){const i=this.getMainPainter(),e=this.getFramePainter(),s=this.getOptions();return i!==this&&e&&e.mode3d!==s.Mode3D&&this.copyOptionsFrom(i),s.Mode3D?this.draw3D(t).catch(l=>{const f=this.getCanvPainter();return kt(f?.showConsoleError)?f.showConsoleError(l):console.error("Fail to draw histogram in 3D - back to 2D"),s.Mode3D=!1,this.draw2D(t)}):this.draw2D(t)}redraw(t){return this.callDrawFunc(t)}static async draw(t,i,e){return Et._drawHist(new St(t,i),e)}};export{At as P,Kt as T};
1
+ import{bI as Gt,aX as vt,ad as F,ae as et,aU as yt,bv as Ct,az as pt,aA as wt,bT as Ht,bt as zt,a5 as kt}from"./ndmvr-aframe-core-DEHQ38JB.js";import{T as Et}from"./THistPainter-B2S5BnuY.js";import{g as Dt}from"./func-C6FX2eN2.js";const At=["LOGXY","LOGX","LOGY","LOGZ","LOGV","LOG","LOG2X","LOG2Y","LOG2","LNX","LNY","LN","GRIDXY","GRIDX","GRIDY","TICKXY2","TICKX2","TICKY2","TICKXY","TICKX","TICKY","TICKZ","FB","GRAYSCALE"];let Kt=class St extends Et{getHisto(){const t=super.getHisto();if(t?._typename===Gt)switch(t.$getBinContent||(t.$getBinContent=t.getBinContent),this.getOptions().ProfileProj){case"B":t.getBinContent=t.getBinEntries;break;case"C=E":t.getBinContent=t.getBinError;break;case"W":t.getBinContent=function(i){return this.$getBinContent(i)*this.getBinEntries(i)};break;default:t.getBinContent=t.$getBinContent;break}return t}scanContent(t){t&&!this.nbinsx&&(t=!1);const i=this.getHisto(),e=this.getOptions();t||this.extractAxesProperties(1);const s=this.getSelectIndex("x","left"),l=this.getSelectIndex("x","right"),f=this.getPadPainter()?.getPadLog(e.swap_xy()?"x":"y"),u=e.Func?this.findFunction(vt):null;if(t&&s===this.scan_xleft&&l===this.scan_xright)return;this.draw_content=!(e.Axis>0),this.scan_xleft=s,this.scan_xright=l;const b=this.isTProfile(),h=Math.min(0,s),w=Math.max(this.nbinsx,l);let r=0,d=0,n=0,o=0,E=!0,x,m={low:0,up:0};for(let _=h;_<w;++_)if(x=i.getBinContent(_+1),o+=b?i.fBinEntries[_+1]:x,!(_<s||_>=l)&&(x>0&&(d===0||x<d)&&(d=x),E&&(r=n=x,E=!1),e.Error&&(m=this.getBinErrors(i,_+1,x)),r=Math.min(r,x-m.low),n=Math.max(n,x+m.up),u)){const T=i.fXaxis.GetBinCenter(_+1),a=Dt(u,T);a!==void 0&&(n=Math.max(n,a),f&&x>0&&a>.3*x&&(d=Math.min(d,a)))}b?o+=i.fBinEntries[0]+i.fBinEntries[this.nbinsx+1]:o+=i.getBinContent(0)+i.getBinContent(this.nbinsx+1),this.stat_entries=o,this.hmin=r,this.hmax=n,(this.nbinsx===0||Math.abs(r)<1e-300&&Math.abs(n)<1e-300)&&(this.draw_content=!1);let p=!1;(this.draw_content||this.isMainPainter()&&e.Axis>0&&!e.ohmin&&!e.ohmax&&i.fMinimum===F&&i.fMaximum===F)&&(r>=n?r===0?(this.ymin=0,this.ymax=1):r<0?(this.ymin=2*r,this.ymax=0):(this.ymin=0,this.ymax=r*2):f?(this.ymin=(d||r)*.5,this.ymax=n*2*(.9/.95)):(this.ymin=r,this.ymax=n)),r=e.minimum,n=e.maximum,r===n&&r!==F&&(r<0?(r*=2,n=0):(r=0,n=2*n||1));let c=!1,k=!1;if(e.ohmin&&e.ohmax&&!this.draw_content?e.zoom_min_max?(r!==F&&r<=this.ymin&&(r=F),n!==F&&n>=this.ymax&&(n=F),p=!0):r=n=F:r!==F&&n!==F&&!this.draw_content&&(this.ymin===this.ymax||this.ymin>r||this.ymax<n)?(this.ymin=r,this.ymax=n,c=k=!0):(r!==F&&(c=!0,r<this.ymin&&(this.ymin=r),p=!0),n!==F&&(k=!0,n>this.ymax&&(this.ymax=n),p=!0)),!e.exact_values_range()&&!f){if(!c)if(e.BaseLine!==!1&&this.ymin>=0)this.ymin=0;else{const _=this.ymin>=0;this.ymin-=et.fHistTopMargin*(this.ymax-this.ymin),_&&this.ymin<0&&(this.ymin=0)}k||(this.ymax+=et.fHistTopMargin*(this.ymax-this.ymin))}t||(p&&(r!==F||n!==F)?(this.zoom_ymin=r===F?this.ymin:r,this.zoom_ymax=n===F?this.ymax:n):(delete this.zoom_ymin,delete this.zoom_ymax))}get _wheel_zoomy(){return this.getDimension()>1||!this.draw_content}getUserRanges(){const t=this.getHisto();let i=0,e=0;for(let s=0;s<t.fXaxis.fNbins;++s){const l=t.getBinContent(s+1);s===0?i=e=l:(i=Math.min(i,l),e=Math.max(e,l))}return t.fMinimum!==F&&(i=t.fMinimum),t.fMaximum!==F&&(e=t.fMaximum),e<=i&&(e=i+1),{minx:t.fXaxis.fXmin,maxx:t.fXaxis.fXmax,miny:i,maxy:e}}countStat(t,i){const e=this.isTProfile(),s=this.getHisto(),l=s.fXaxis,f=this.getSelectIndex("x","left"),u=this.getSelectIndex("x","right"),b=this.getFramePainter(),h={name:s.fName,meanx:0,meany:0,rmsx:0,rmsy:0,integral:0,entries:s.fEntries>0?s.fEntries:this.stat_entries,eff_entries:0,xmax:0,wmax:0,skewx:0,skewd:0,kurtx:0,kurtd:0},w=!b?.isAxisZoomed("x")&&Math.abs(s.fTsumw)>1e-300;let r=0,d=0,n=0,o=0,E=0,x=0,m,p,c,k=null,_=null;for(kt(t)||(t=null),m=f;m<u;++m)p=l.GetBinCoord(m+.5),!(t&&!t(p))&&(e?(c=s.fBinEntries[m+1],E+=s.fArray[m+1],x+=s.fSumw2[m+1]):c=s.getBinContent(m+1),(k===null||c>_)&&(k=p,_=c),w||(r+=c,d+=c*c,n+=c*p,o+=c*p**2));if(w&&(r=s.fTsumw,d=s.fTsumw2,n=s.fTsumwx,o=s.fTsumwx2),h.integral=r,h.eff_entries=d?r*r/d:Math.abs(r),Math.abs(r)>1e-300&&(h.meanx=n/r,h.meany=E/r,h.rmsx=Math.sqrt(Math.abs(o/r-h.meanx**2)),h.rmsy=Math.sqrt(Math.abs(x/r-h.meany**2))),k!==null&&(h.xmax=k,h.wmax=_),i){let T=0,a=0,B=0;for(m=f;m<u;++m)p=l.GetBinCoord(m+.5),!(t&&!t(p))&&(c=e?s.fBinEntries[m+1]:s.getBinContent(m+1),B+=c,T+=c*Math.pow(p-h.meanx,3),a+=c*Math.pow(p-h.meanx,4));const y=Math.pow(h.rmsx,3),S=Math.pow(h.rmsx,4);B*y&&(h.skewx=T/(B*y)),h.skewd=h.eff_entries>0?Math.sqrt(6/h.eff_entries):0,B*S&&(h.kurtx=a/(B*S)-3),h.kurtd=h.eff_entries>0?Math.sqrt(24/h.eff_entries):0}return h}fillStatistic(t,i,e){if(this.isIgnoreStatsFill())return!1;i===1&&(i=1111),e===1&&(e=111);const s=this.getHisto(),l=i%10,f=Math.floor(i/10)%10,u=Math.floor(i/100)%10,b=Math.floor(i/1e3)%10,h=Math.floor(i/1e4)%10,w=Math.floor(i/1e5)%10,r=Math.floor(i/1e6)%10,d=Math.floor(i/1e7)%10,n=Math.floor(i/1e8)%10,o=this.countStat(void 0,d>0||n>0);return t.clearPave(),l>0&&t.addText(o.name),this.isTProfile()?(f>0&&t.addText("Entries = "+t.format(o.entries,"entries")),u>0&&(t.addText("Mean = "+t.format(o.meanx)),t.addText("Mean y = "+t.format(o.meany))),b>0&&(t.addText("Std Dev = "+t.format(o.rmsx)),t.addText("Std Dev y = "+t.format(o.rmsy)))):(f>0&&t.addText("Entries = "+t.format(o.entries,"entries")),u>0&&t.addText("Mean = "+t.format(o.meanx)),b>0&&t.addText("Std Dev = "+t.format(o.rmsx)),h>0&&t.addText("Underflow = "+t.format(s.fArray.length?s.fArray[0]:0,"entries")),w>0&&t.addText("Overflow = "+t.format(s.fArray.length?s.fArray.at(-1):0,"entries")),r>0&&t.addText("Integral = "+t.format(o.integral,"entries")),d===2?t.addText(`Skewness = ${t.format(o.skewx)} #pm ${t.format(o.skewd)}`):d>0&&t.addText(`Skewness = ${t.format(o.skewx)}`),n===2?t.addText(`Kurtosis = ${t.format(o.kurtx)} #pm ${t.format(o.kurtd)}`):n>0&&t.addText(`Kurtosis = ${t.format(o.kurtx)}`)),e&&t.fillFunctionStat(this.findFunction(vt),e,1),!0}getBarBaseline(t,i){const e=this.getOptions();let s=t.swap_xy()?0:i;return Number.isFinite(e.BaseLine)&&e.BaseLine>=t.scale_ymin&&(s=Math.round(t.gry(e.BaseLine))),s}async drawBars(t,i){const e=this.getSelectIndex("x","left",-1),s=this.getSelectIndex("x","right",1),l=this.getHisto(),f=this.getOptions(),u=l.fXaxis,b=f.Text;let h,w,r,d=f.BarStyle>10?f.BarStyle%10:0,n=Promise.resolve();d>4&&(d=4);const o=this.getBarBaseline(t,i);return b&&(h=this.getColor(l.fMarkerColor),w=-1*f.TextAngle,r=20,l.fMarkerSize!==1&&w&&(r=.02*i*l.fMarkerSize),n=this.startTextDrawingAsync(42,r,void 0,r)),n.then(()=>{let E="",x="",m="";for(let p=e;p<s;++p){const c=u.GetBinLowEdge(p+1),k=u.GetBinLowEdge(p+2);if(t.logx&&k<=0)continue;let _=Math.round(t.grx(c)),T=Math.round(t.grx(k)),a=T-_;const B=l.getBinContent(p+1);if(t.logy&&B<t.scale_ymin)continue;const y=Math.round(t.gry(B));if(_+=Math.round(l.fBarOffset/1e3*a),a=Math.round(l.fBarWidth/1e3*a),t.swap_xy()?E+=`M${o},${_}h${y-o}v${a}h${o-y}z`:E+=`M${_},${y}h${a}v${o-y}h${-a}z`,d>0&&(T=_+a,a=Math.round(a*d/10),t.swap_xy()?(x+=`M${o},${_}h${y-o}v${a}h${o-y}z`,m+=`M${o},${T}h${y-o}v${-a}h${o-y}z`):(x+=`M${_},${y}h${a}v${o-y}h${-a}z`,m+=`M${T},${y}h${-a}v${o-y}h${a}z`)),b&&B){const S=B===Math.round(B)?B.toString():yt(B,et.fPaintTextFormat);t.swap_xy()?this.drawText({align:12,x:Math.round(y+r/2),y:Math.round(_+.1),height:Math.round(a*.8),text:S,color:h,latex:0}):w?this.drawText({align:12,x:_+a/2,y:Math.round(y-2-r/5),width:0,height:0,rotate:w,text:S,color:h,latex:0}):this.drawText({align:22,x:Math.round(_+a*.1),y:Math.round(y-2-r),width:Math.round(a*.8),height:r,text:S,color:h,latex:0})}}if(E&&this.appendPath(E).call(this.fillatt.func),x&&this.appendPath(x).call(this.fillatt.func).style("fill",Ct(this.fillatt.color).brighter(.5).formatRgb()),m&&this.appendPath(m).call(this.fillatt.func).style("fill",Ct(this.fillatt.color).darker(.5).formatRgb()),b)return this.finishTextDrawing()})}drawFilledErrors(t){const i=this.getSelectIndex("x","left",0),e=this.getSelectIndex("x","right",0),s=this.getHisto(),l=[],f=[];for(let w=i;w<e;++w){const r=s.fXaxis.GetBinCoord(w+.5);if(t.logx&&r<=0)continue;const d=Math.round(t.grx(r)),n=s.getBinContent(w+1),o=this.getBinErrors(s,w+1,n);t.logy&&n-o.low<t.scale_ymin||(l.push({grx:d,gry:Math.round(t.gry(n+o.up))}),f.unshift({grx:d,gry:Math.round(t.gry(n-o.low))}))}const u=this.getOptions().ErrorKind!==4,b=pt(l,{line:u}),h=pt(f,{line:u,cmd:"L"});this.appendPath(b+h+"Z").call(this.fillatt.func)}async drawNormal(t,i,e){const s=this.getSelectIndex("x","left",-1),l=this.getSelectIndex("x","right",2),f=this.getHisto(),u=this.getOptions(),b=!this.isBatchMode()&&wt.Tooltip,h=f.fXaxis,w=!u.Zero,r=u.Error,d=u.Curve,n=u.Text,o=n&&u.TextKind==="E"&&this.isTProfile()&&f.fBinEntries,E=[];let x="",m=!1,p=u.Mark,c=u.Line,k,_,T,a,B,y,S,$,g,M,H,A,X,Z,U,rt=null,K=null,W=null,z="",tt=null,st=null,V=null,G=5,lt=!1,ht=!1,N=0,L=0,v,I,J,R,ut,D,Y,P,ft,xt,nt,gt,Mt,it,O,_t=Promise.resolve();r&&!p&&f.fMarkerStyle>1&&(p=!0),u.ErrorKind===2?this.fillatt.empty()?p=!0:rt="":r&&(c=!1,K="",tt=b?"":null,ht=!0),L=this.lineatt.width+et.fEndErrorSize,u.ErrorKind===1&&(N=Math.floor((this.lineatt.width-1)/2)),p&&(this.createAttMarker({attr:f,style:u.MarkStyle}),this.markeratt.size>0?(W="",lt=!0,this.markeratt.resetPos(),tt===null&&b&&(!this.markeratt.fill||this.markeratt.getFullSize()<7)&&(V="",G=Math.max(5,Math.round(this.markeratt.getFullSize()*.7)))):p=!1);const mt=r||p,ct=mt||n||c||d,Q=u.Hist&&(!this.lineatt.empty()||!this.fillatt.empty()),Pt=r&&f.fSumw2?.length,Ft=ct||l-s>3*i;if(!Q&&!ct)return this.removeG();if(n){if(Mt=this.getColor(f.fMarkerColor),it=-1*u.TextAngle,O=20,f.fMarkerSize!==1&&it&&(O=.02*e*f.fMarkerSize),!it&&!u.TextKind){const at=i/(l-s+1);at<3*O&&(it=270,O=Math.round(at*.7))}b&&!Q&&(st=""),_t=this.startTextDrawingAsync(42,O,void 0,O)}return _t.then(()=>{const at=C=>(R=f.getBinContent(C+1),w&&R===0&&(!Pt||!f.fSumw2[C+1])?!1:(D=Math.round(t.grx(h.GetBinLowEdge(C+1))),Y=Math.round(t.grx(h.GetBinLowEdge(C+2))),P=Math.round((D+Y)/2),_===void 0&&(_=P),v=Math.round(t.gry(R)),r?(ut=this.getBinErrors(f,C+1,R),I=Math.round(v-t.gry(R+ut.up)),J=Math.round(t.gry(R-ut.low)-v)):I=J=20,!0)),$t=()=>{let C=5;if(u.errorX>0&&(C=Math.round((Y-D)*u.errorX),nt=P-C,gt=P+C,u.ErrorKind===1?K+=`M${nt+N},${v-L}v${2*L}m0,-${L}h${gt-nt-2*N}m0,-${L}v${2*L}`:K+=`M${nt+N},${v}h${gt-nt-2*N}`),u.ErrorKind===1?K+=`M${P-L},${v-I+N}h${2*L}m${-L},0v${I+J-2*N}m${-L},0h${2*L}`:K+=`M${P},${v-I+N}v${I+J-2*N}`,tt!==null){const j=Math.max(I,5),q=Math.max(J,5);tt+=`M${P-C},${v-j}h${2*C}v${j+q}h${-2*C}z`}},Bt=()=>{t.swap_xy()?(W+=this.markeratt.create(v,P),V!==null&&(V+=`M${v-G},${P-G}v${2*G}h${2*G}v${-2*G}z`)):(W+=this.markeratt.create(P,v),V!==null&&(V+=`M${P-G},${v-G}h${2*G}v${2*G}h${-2*G}z`))},ot=C=>{if(at(C)){if(n){const j=o?f.fBinEntries[C+1]:R;if(j){const q=it?{align:12,x:P,y:Math.round(v-2-O/5),width:0,height:0,rotate:it}:{align:22,x:Math.round(D+(Y-D)*.1),y:Math.round(v-2-O),width:Math.round((Y-D)*.8),height:O};q.text=j===Math.round(j)?j.toString():yt(j,et.fPaintTextFormat),q.color=Mt,q.latex=0,t.swap_xy()&&(q.x=v,q.y=Math.round(P-O/2)),this.drawText(q),st!==null&&(st+=`M${D},${v-G}v${2*G}h${Y-D}v${-2*G}z`)}}c?(t.swap_xy()?z+=(z?"L":"M")+`${v},${P}`:z?ft===P?z+=`v${v-xt}`:xt===v?z+=`h${P-ft}`:z+=`l${P-ft},${v-xt}`:z=`M${P},${v}`,ft=P,xt=v):d&&E.push({grx:(D+Y)/2,gry:t.gry(R)}),mt&&v>=-I&&v<=e+J&&(rt!==null&&(rt+=`M${D},${v-I}h${Y-D}v${I+J+1}h${D-Y}z`),W!==null&&lt&&Bt(),K!==null&&ht&&$t())}};if((lt||ht)&&(!wt.OptimizeDraw||l-s<5e4&&wt.OptimizeDraw===1)){for(X=s;X<l;++X)at(X)&&(W!==null&&Bt(),K!==null&&$t());ht=lt=!1}for(X=s;X<=l;++X)B=h.GetBinLowEdge(X+1),!(this.logx&&B<=0)&&(y=Math.round(t.grx(B)),m=X===l,m&&s<l?$=a:(S=f.getBinContent(X+1),$=Math.round(t.gry(S))),x?Ft?y===T&&!m?($<g?U=X:$>M&&(Z=X),g=Math.min(g,$),M=Math.max(M,$),a=$):(ct&&(Z===U?ot(Z):Z<U?(ot(Z),ot(U)):(ot(U),ot(Z))),Q&&(g!==M||H!==g)&&(A!==T&&(x+="h"+(T-A)),a===g?(M!==H&&(x+="v"+(M-H)),g!==M&&(x+="v"+(g-M))):(g!==H&&(x+="v"+(g-H)),M!==g&&(x+="v"+(M-g)),a!==M&&(x+="v"+(a-M))),A=T,H=a),m&&A!==y&&(x+="h"+(y-A)),Z=U=X,g=M=a=$,T=y):($!==a||m)&&(y!==T&&(x+=`h${y-T}`),$!==a&&(x+=`v${$-a}`),a=$,T=y):(Z=U=X,A=k=T=y,H=g=M=a=$,x=`M${T},${a}`));const bt=b&&this.fillatt.empty()&&Q&&!mt&&!c&&!d&&this.isUseFrame();let dt=e+3;if(!bt){const C=Math.round(t.gry(0));C<=0?dt=-3:C<e&&(dt=C)}const Xt=`L${T},${dt}H${k}Z`,Tt=()=>{this.appendPath(x+(!this.fillatt.empty()||bt?Xt:"")).style("stroke-linejoin","miter").call(this.lineatt.func).call(this.fillatt.func)};if(x&&Q&&!this.fillatt.empty()&&(Tt(),x=""),(mt||c||d)&&(!z&&E.length&&(t.swap_xy()&&E.forEach(C=>{[C.grx,C.gry]=[C.gry,C.grx]}),z=pt(E)),rt?this.appendPath(rt).call(this.fillatt.func):z&&!this.fillatt.empty()&&!Q&&this.appendPath(z+`L${P},${dt}H${_}Z`).call(this.fillatt.func),K&&this.appendPath(K).call(this.lineatt.func),tt&&this.appendPath(tt).style("fill","none").style("pointer-events",this.isBatchMode()?null:"visibleFill"),z&&this.appendPath(z).style("fill","none").call(this.lineatt.func),W&&this.appendPath(W).call(this.markeratt.func),V&&this.appendPath(V).style("fill","none").style("pointer-events",this.isBatchMode()?null:"visibleFill")),x&&Q&&Tt(),st&&this.appendPath(st).style("fill","none").style("pointer-events",this.isBatchMode()?null:"visibleFill"),n)return this.finishTextDrawing()})}draw1DBins(){const t=this.getOptions();t.Same&&!this.isUseFrame()&&this.getPadPainter().getFrameSvg().style("display","none"),this.createHistDrawAttributes();const i=this.getHistGrFuncs(),e=i.getFrameWidth(),s=i.getFrameHeight();return!this.draw_content||e<=0||s<=0?this.removeG():(this.createG(this.isUseFrame()),t.Bar?this.drawBars(i,s).then(()=>{if(t.ErrorKind===1)return this.drawNormal(i,e,s)}):t.ErrorKind===3||t.ErrorKind===4?this.drawFilledErrors(i):this.drawNormal(i,e,s))}getBinTooltips(t){const i=[],e=this.getObjectHint(),s=this.getHistGrFuncs(),l=this.getHisto(),f=this.getOptions(),u=l.fXaxis.GetBinLowEdge(t+1),b=l.fXaxis.GetBinLowEdge(t+2),h=this.getAxisBinTip("x",l.fXaxis,t);let w=l.getBinContent(t+1);if(e&&i.push(e),f.Error||f.Mark||this.isTF1()){if(i.push(`x = ${h}`,`y = ${s.axisAsText("y",w)}`),f.Error){h[0]==="["&&i.push(`error x = ${((b-u)/2).toPrecision(4)}`);const r=this.getBinErrors(l,t+1,w);r.poisson?i.push(`error low = ${r.low.toPrecision(4)}`,`error up = ${r.up.toPrecision(4)}`):i.push(`error y = ${r.up.toPrecision(4)}`)}}else i.push(`bin = ${t+1}`,`x = ${h}`),l.$baseh&&(w-=l.$baseh.getBinContent(t+1)),w===Math.round(w)?i.push(`entries = ${w}`):i.push(`entries = ${yt(w,et.fStatFormat)}`);return i}processTooltipEvent(t){const i=this.getOptions();if(!t||!this.draw_content||!this.getG()||i.Mode3D)return this.getG()?.selectChild(".tooltip_bin").remove(),null;const e=this.getHistGrFuncs(),s=this.getHisto(),l=this.getSelectIndex("x","left",-1),f=this.getSelectIndex("x","right",2),u=this.options.Hist&&(!this.lineatt.empty()||!this.fillatt.empty());let b=e.getFrameWidth(),h=e.getFrameHeight(),w,r,d,n,o,E=2,x=l,m=f,p=t.x,c=t.y;const k=g=>{const M=s.fXaxis.GetBinLowEdge(g+1);return e.logx&&M<=0?null:e.grx(M)},_=g=>{const M=s.getBinContent(g+1);return e.logy&&M<e.scale_ymin?e.swap_xy()?-1e3:10*h:Math.round(e.gry(M))};e.swap_xy()&&([p,c,b,h]=[c,p,h,b]);const T=e.x_handle&&e.swap_xy()!==e.x_handle.reverse;for(;x<m-1;){const g=Math.round((x+m)*.5),M=k(g);M===null||M<p-.5?T?m=g:x=g:M>p+.5?T?x=g:m=g:(x++,m--)}let a=m=x;if(r=k(a),T){for(;x>l&&k(x-1)<r+2;)--x;for(;m<f&&k(m+1)>r-2;)++m}else{for(;x>l&&k(x-1)>r-2;)--x;for(;m<f&&k(m+1)<r+2;)++m}if(x<m){let g=h;for(let M=x;M<=m;M++){const H=Math.abs(_(M)-c);H<g&&(g=H,a=M)}g>h/10&&(a=Math.round(x+(m-x)/h*c)),r=k(a)}if(r=Math.round(r),d=Math.round(k(a+1)),i.Bar){const g=d-r;r+=Math.round(s.fBarOffset/1e3*g),d=r+Math.round(s.fBarWidth/1e3*g)}r>d&&([r,d]=[d,r]);const B=Math.round((r+d)/2),y=n=o=_(a);if(i.Bar)w=!0,E=0,n=this.getBarBaseline(e,h),n>o&&([n,o]=[o,n]),!t.touch&&t.nproc===1&&(c<n||c>o)&&(a=null);else if(i.Error&&i.Hist!==!0||i.Mark||i.Line||i.Curve||i.Text&&!u){w=!this.isTF1();let g=3;if(this.markeratt&&(g=Math.max(g,this.markeratt.getFullSize())),i.Error){const M=s.getBinContent(a+1),H=this.getBinErrors(s,a+1,M);n=Math.round(e.gry(M+H.up)),o=Math.round(e.gry(M-H.low)),M===0&&this.isTProfile()&&(a=null);const A=(d-r)*i.errorX;r=Math.round(B-A),d=Math.round(B+A)}d-r<2*g&&(r=B-g,d=B+g),n=Math.min(n,y-g),o=Math.max(o,y+g),!t.touch&&t.nproc===1&&(c<n||c>o)&&(a=null)}else w=t.nproc===1&&f-l<b,w&&(o=h,this.fillatt.empty()||(o=Math.min(h,Math.max(0,Math.round(e.gry(0)))),o<n&&([n,o]=[o,n])),(t.y<n||t.y>o)&&!t.touch&&(a=null));a!==null&&(a===l&&r>p+E||a===f-1&&d<p-E||p<r-E||p>d+E||!i.Zero&&s.getBinContent(a+1)===0&&s.getBinError(a+1)===0)&&(a=null);let S=this.getG().selectChild(".tooltip_bin");if(a===null||o<=0||n>=h)return S.remove(),null;const $={name:this.getObjectName(),title:s.fTitle,x:B,y,exact:!0,color1:this.lineatt?.color??"green",color2:this.fillatt?.getFillColorAlt("blue")??"blue",lines:this.getBinTooltips(a)};if(t.disabled)S.remove(),$.changed=!0;else if(w)S.empty()&&(S=this.getG().append("svg:rect").attr("class","tooltip_bin").style("pointer-events","none").call(Ht)),$.changed=S.property("current_bin")!==a,$.changed&&S.attr("x",e.swap_xy()?n:r).attr("width",e.swap_xy()?o-n:d-r).attr("y",e.swap_xy()?r:n).attr("height",e.swap_xy()?d-r:o-n).style("opacity","0.3").property("current_bin",a),$.exact=Math.abs(y-c)<=5||c>=n&&c<=o,$.menu=$.exact,$.menu_dist=Math.sqrt((B-p)**2+(y-c)**2);else{const g=this.lineatt.width+3;S.empty()&&(S=this.getG().append("svg:circle").attr("class","tooltip_bin").style("pointer-events","none").attr("r",g).call(this.lineatt.func).call(this.fillatt.func)),$.exact=Math.abs(B-t.x)<=g&&Math.abs(y-t.y)<=g,$.menu=$.exact,$.menu_dist=Math.sqrt((B-t.x)**2+(y-t.y)**2),$.changed=S.property("current_bin")!==a,$.changed&&S.attr("cx",B).attr("cy",y).property("current_bin",a)}return $.changed&&($.user_info={obj:s,name:s.fName,bin:a,cont:s.getBinContent(a+1),grx:B,gry:y}),$}fillHistContextMenu(t){t.add("Auto zoom-in",()=>this.autoZoom());const i=this.getSupportedDrawOptions();t.addDrawMenu("Draw with",i,e=>{if(e.indexOf(zt)===0)return this.showInspector(e);this.decodeOptions(e),this.getOptions().need_fillcol&&this.fillatt?.empty()&&this.fillatt.change(5,1001),this.interactiveRedraw("pad","drawopt")}),!this.hasSnapId()&&!this.isTProfile()&&!this.isTF1()&&t.addRebinMenu(e=>this.rebinHist(e))}rebinHist(t){const i=this.getHisto(),e=i.fXaxis,s=Math.floor(e.fNbins/t);if(s<2)return;const l=new Array(s+2),f=e.fXbins.length?new Array(s):null;l[0]=i.fArray[0];let u=1;for(let h=1;h<=s;++h){f&&(f[h-1]=e.fXbins[u-1]);let w=0;for(let r=0;r<t;++r)w+=i.fArray[u++];l[h]=w}f?(u<=e.fXbins.length&&(e.fXmax=e.fXbins[u-1]),e.fXbins=f):e.fXmax=e.fXmin+(e.fXmax-e.fXmin)/e.fNbins*s*t,e.fNbins=s;let b=0;for(;u<i.fArray.length;)b+=i.fArray[u++];l[s+1]=b,i.fArray=l,i.fSumw2=[],this.scanContent(),this.interactiveRedraw("pad")}autoZoom(){let t=this.getSelectIndex("x","left",-1),i=this.getSelectIndex("x","right",1);const e=i-t,s=this.getHisto();if(e===0||!s)return;let l=s.getBinContent(t+1);for(let f=t;f<i;++f)l=Math.min(l,s.getBinContent(f+1));if(!(l>0)){for(;t<i&&s.getBinContent(t+1)<=l;)++t;for(;t<i&&s.getBinContent(i)<=l;)--i;if(t===i-1&&t>2&&i<this.nbinsx-2&&(--t,++i),i-t<e&&t<i)return this.getFramePainter().zoom(s.fXaxis.GetBinLowEdge(t+1),s.fXaxis.GetBinLowEdge(i+1))}}canZoomInside(t,i,e){const s=this.getHisto();return!!(t==="x"&&s&&s.fXaxis.FindBin(e,.5)-s.fXaxis.FindBin(i,0)>1||t==="y"&&Math.abs(e-i)>Math.abs(this.ymax-this.ymin)*1e-6)}async draw2D(t){return this.clear3DScene(),this.scanContent(t==="zoom"),(this.isMainPainter()?this.drawColorPalette(!1):Promise.resolve(!0)).then(()=>this.drawAxes()).then(()=>this.draw1DBins()).then(()=>this.updateFunctions()).then(()=>this.updateHistTitle()).then(()=>(this.updateStatWebCanvas(),this.addInteractivity()))}async draw3D(t){return console.log("3D drawing is disabled, load ./hist/TH1Painter.mjs"),this.draw2D(t)}async callDrawFunc(t){const i=this.getMainPainter(),e=this.getFramePainter(),s=this.getOptions();return i!==this&&e&&e.mode3d!==s.Mode3D&&this.copyOptionsFrom(i),s.Mode3D?this.draw3D(t).catch(l=>{const f=this.getCanvPainter();return kt(f?.showConsoleError)?f.showConsoleError(l):console.error("Fail to draw histogram in 3D - back to 2D"),s.Mode3D=!1,this.draw2D(t)}):this.draw2D(t)}redraw(t){return this.callDrawFunc(t)}static async draw(t,i,e){return Et._drawHist(new St(t,i),e)}};export{At as P,Kt as T};
@@ -1,2 +1,2 @@
1
- import{bJ as Ct,aK as Lt,bt as Vt,a5 as _t,bp as kt,aT as Zt,aU as ct,ae as et,bv as Ot,br as Yt,$ as jt,aA as Dt,aE as Rt,a0 as Wt,bU as Ut,bV as qt,bW as Kt,bT as St,ag as Gt,aZ as zt,al as Jt,bX as Qt,bY as te,bZ as ee}from"./ndmvr-aframe-core-Cw91_9_Y.js";import{T as Nt,a as ie}from"./THistPainter-Df-RmCQH.js";function ne(mt,t,i,e,n){const a=new Float32Array(4008),r=new Float32Array(2*2004),d=new Int32Array(2*2004),g=i.length,$=i[0],s=i[g-1],h=[],p=[0,0,0,0],l=[0,0,0,0],o=[0,0,0,0],f=[0,0,0,0],m=t.grx,P=t.gry;let _=0;const j=J=>{if(J>=s)return g-1;for(let Y=0;Y<g;++Y)if(J<i[Y])return Y-1;return g-1},u=J=>{if(J<$)return-1;if(J>=s)return g-1;let Y=0,D=g-1,z;for(;D-Y>1;)z=Math.round((D+Y)/2),J<i[z]?D=z:Y=z;return Y},C=g<10?j:u,B=(J,Y,D,z,dt,Mt,lt,nt)=>{const H=D===lt,X=H?nt-z:lt-D,L=dt-J;let Z=Y+1,O=_-1,E=0,F,V,ut,gt;const pt=O+2004/2-3;for(;Z<=Mt&&O<=pt;)gt=i[Z],ut=gt-J,V=ut/L,F=X*V,H?(a[O]=D,r[O]=z+F):(a[O]=D+F,r[O]=z),d[O]=Z,E++,O+=2,Z++;return E};let M,b,x=0,y,S,w,A,T,I,v,N,G,Q,U,at;for(S=t.j1;S<t.j2-1;++S)for(l[1]=l[0]=(P[S]+P[S+1])/2,l[3]=l[2]=(P[S+1]+P[S+2])/2,y=t.i1;y<t.i2-1;++y){for(o[0]=mt.getBinContent(y+1,S+1),o[1]=mt.getBinContent(y+2,S+1),o[2]=mt.getBinContent(y+2,S+2),o[3]=mt.getBinContent(y+1,S+2),w=0;w<4;w++)f[w]=C(o[w]);if(f[0]!==f[1]||f[1]!==f[2]||f[2]!==f[3]||f[3]!==f[0]){for(p[3]=p[0]=(m[y]+m[y+1])/2,p[2]=p[1]=(m[y+1]+m[y+2])/2,T=o[0]<=o[1]?0:1,A=o[2]<=o[3]?2:3,o[T]>o[A]&&(T=A),T++,_=1,U=1;U<=4;U++)A=T%4+1,I=B(o[T-1],f[T-1],p[T-1],l[T-1],o[A-1],f[A-1],p[A-1],l[A-1]),_+=2*I,T=A;for(T=o[0]<=o[1]?0:1,A=o[2]<=o[3]?2:3,o[T]>o[A]&&(T=A),T++,_=2,U=1;U<=4;U++)A=T===1?4:T-1,I=B(o[T-1],f[T-1],p[T-1],l[T-1],o[A-1],f[A-1],p[A-1],l[A-1]),_+=2*I,T=A;for(v=0,U=1;U<=_-5;U+=2)for(;d[U-1]!==d[U];){for(N=a[U],G=r[U],Q=d[U],at=U;at<=_-5;at+=2)a[at]=a[at+2],r[at]=r[at+2],d[at]=d[at+2];if(a[_-3]=N,r[_-3]=G,d[_-3]=Q,v>2e3)break;v++}if(v>100)continue;for(U=1;U<=_-2;U+=2)if(M=d[U-1],M>=0&&M<i.length){b=h[M],b||(b=h[M]=ee(2004*4,!0));const J=b.fLastPoint;J<b.fN-2&&(b.fX[J+1]=Math.round(a[U-1]),b.fY[J+1]=Math.round(r[U-1]),b.fX[J+2]=Math.round(a[U]),b.fY[J+2]=Math.round(r[U]),b.fLastPoint=J+2,x=Math.max(x,b.fLastPoint+1))}}}const q=new Int32Array(i.length);let R=0;for(M=0;M<i.length;M++)if(i[M]>=0){R=M;break}for(w=0,M=R-1;M>=0;M--)q[w++]=M;for(M=R;M<i.length;M++)q[w++]=M;const W=new Float32Array(2*x),K=new Float32Array(2*x),tt=_t(e.calcColorIndex);for(w=0;w<i.length;++w){if(M=q[w],b=h[M],!b)continue;const J=tt?e.calcColorIndex(M,i.length):M,Y=b.fX,D=b.fY,z=b.fLastPoint+1,dt=0,Mt=0;let lt=0,nt,H,X;for(;;){for(nt=x,H=nt+1,W[nt]=Y[lt],K[nt]=D[lt],W[H]=Y[lt+1],K[H]=D[lt+1],Y[lt]=Y[lt+1]=dt,D[lt]=D[lt+1]=Mt;;){for(X=0,y=2;y<z;y+=2)H<2*x-1&&Y[y]===W[H]&&D[y]===K[H]&&(H++,W[H]=Y[y+1],K[H]=D[y+1],Y[y]=Y[y+1]=dt,D[y]=D[y+1]=Mt,X++),nt>0&&Y[y+1]===W[nt]&&D[y+1]===K[nt]&&(nt--,W[nt]=Y[y],K[nt]=D[y],Y[y]=Y[y+1]=dt,D[y]=D[y+1]=Mt,X++);if(X===0)break}for(nt+1<H&&nt>=0&&n(J,W,K,nt,H,M),lt=0,y=2;y<z;y+=2)if(Y[y]!==dt&&D[y]!==Mt){lt=y;break}if(lt===0)break}}}class re{constructor(t,i,e,n,c,k,a){let r=[e,n];if(t){r=new Float32Array(t.length);for(let y=0;y<t.length;++y)r[y]=i(t[y])}Object.assign(this,{grz_min:e,grz_max:n,dolines:c,donormals:k,dogrid:a}),this.loop=0;const d=[],g=[],$=[],s=new Float32Array(18),h=new Float32Array(6),p=(r.at(-1)-r.at(0))/r.length/100;let l=0,o=null,f=0,m=0,P=null,_=0,j=[],u=0,C=0,B=0;function M(y,S,w,A){return y<S-A?-1:y>w+A?1:0}this.createNormIndex=function(y){y.donormals&&(j=new Int32Array((y.i2-y.i1)*(y.j2-y.j1)*8).fill(-1))},this.createBuffers=function(){if(this.loop){for(let y=1;y<r.length;++y)d[y]&&(g[y]=new Float32Array(d[y]*9),$[y]=0);this.dolines&&l>0&&(o=new Float32Array(l*6)),this.dogrid&&m>0&&(P=new Float32Array(m*6))}},this.addLineSegment=function(y,S,w,A,T,I){if(!this.dolines)return;const v=M(w,this.grz_min,this.grz_max,0),N=M(I,this.grz_min,this.grz_max,0);if(!(v===N&&v)){if(!this.loop)return++l;if(v){const G=I-w;w=v<0?this.grz_min:this.grz_max,y=A-(A-y)/G*(I-w),S=T-(T-S)/G*(I-w)}if(N){const G=w-I;I=N<0?this.grz_min:this.grz_max,A=y-(y-A)/G*(w-I),T=S-(S-T)/G*(w-I)}o[f]=y,o[f+1]=S,o[f+2]=w,f+=3,o[f]=A,o[f+1]=T,o[f+2]=I,f+=3}};function b(y,S,w,A,T,I,v,N){u>=s.length&&console.log("more than 6 points???");const G=(v-w)/(I-w);let Q=3;C&&Math.abs(G)<Math.abs(C)&&(s[u]=s[u-3],s[u+1]=s[u-2],s[u+2]=s[u-1],u-=3,Q=6),s[u]=y+G*(A-y),s[u+1]=S+G*(T-S),s[u+2]=v,N&&P&&(h[B]=s[u],h[B+1]=s[u+1],h[B+2]=s[u+2],B+=3),u+=Q,C=G}function x(y,S,w,A){const T=((w-S.i1)*(S.j2-S.j1)+(A-S.j1))*8;if(j[T]>=0)return console.error("More than 8 vertexes for the bin");const I=T+8+j[T];j[T]--,j[I]=y}this.addMainTriangle=function(y,S,w,A,T,I,v,N,G,Q,U,at,q){for(let R=1;R<r.length;++R){let W=M(w,r[R-1],r[R],p),K=M(I,r[R-1],r[R],p),tt=M(G,r[R-1],r[R],p),J=W+K+tt;if(R>1&&R===r.length-1&&J===3&&w<=this.grz_max&&(W=K=tt=J=0),J===3)continue;if(J===-3)return;if(!this.loop){let z=Math.abs(K-W)+Math.abs(tt-K)+Math.abs(W-tt);W===0&&++z,K===0&&++z,tt===0&&++z,(z===1||z===2)&&console.error(`FOUND npnts = ${z}`),z>2&&(d[R]===void 0&&(d[R]=0),d[R]+=z-2),(W>0||K>0||tt>0)&&(W!==K||K!==tt||tt!==W)&&++m;continue}if(B=0,u=0,W===0&&(s[u]=y,s[u+1]=S,s[u+2]=w,u+=3),W!==K&&(C=0,(W<0||K<0)&&b(y,S,w,A,T,I,r[R-1]),(W>0||K>0)&&b(y,S,w,A,T,I,r[R],!0)),K===0&&(s[u]=A,s[u+1]=T,s[u+2]=I,u+=3),K!==tt&&(C=0,(K<0||tt<0)&&b(A,T,I,v,N,G,r[R-1]),(K>0||tt>0)&&b(A,T,I,v,N,G,r[R],!0)),tt===0&&(s[u]=v,s[u+1]=N,s[u+2]=G,u+=3),tt!==W&&(C=0,(tt<0||W<0)&&b(v,N,G,y,S,w,r[R-1]),(tt>0||W>0)&&b(v,N,G,y,S,w,r[R],!0)),u===0)continue;if(u<9){console.log(`found ${u/3} points, must be at least 3`);continue}if(P&&B===6){for(let z=0;z<6;++z)P[_+z]=h[z];_+=6}const Y=g[R];let D=$[R];this.donormals&&u===9&&(x(D,U,at,q),x(D+3,U,at+1,Q?q+1:q),x(D+6,U,Q?at:at+1,q+1));for(let z=3;z<u-3;z+=3)Y[D]=s[0],Y[D+1]=s[1],Y[D+2]=s[2],D+=3,Y[D]=s[z],Y[D+1]=s[z+1],Y[D+2]=s[z+2],D+=3,Y[D]=s[z+3],Y[D+1]=s[z+4],Y[D+2]=s[z+5],D+=3;$[R]=D}},this.callFuncs=function(y,S){for(let w=1;w<r.length;++w)g[w]&&y&&y(w,g[w],j);o&&S&&(l*6!==f&&console.error(`SURF lines mismmatch nsegm=${l} lindx=${f} diff=${l*6-f}`),S(!1,o)),P&&S&&(m*6!==_&&console.error(`SURF grid draw mismatch ngridsegm=${m} gindx=${_} diff=${m*6-_}`),S(!0,P))}}}function se(mt,t,i,e,n){const c=t.grz,k=t.original?t.origx:t.grx,a=t.original?t.origy:t.gry,r=new re(i,t.grz,t.grz_min,t.grz_max,t.dolines,t.donormals,t.dogrid);let d,g,$,s,h,p,l,o,f,m;for(r.createNormIndex(t),r.loop=0;r.loop<2;++r.loop)for(r.createBuffers(),d=t.i1;d<t.i2-1;++d)for($=t.original?.5*(k[d]+k[d+1]):k[d],s=t.original?.5*(k[d+1]+k[d+2]):k[d+1],g=t.j1;g<t.j2-1;++g)h=t.original?.5*(a[g]+a[g+1]):a[g],p=t.original?.5*(a[g+1]+a[g+2]):a[g+1],l=c(mt.getBinContent(d+1,g+1)),o=c(mt.getBinContent(d+1,g+2)),f=c(mt.getBinContent(d+2,g+1)),m=c(mt.getBinContent(d+2,g+2)),r.addMainTriangle($,h,l,s,p,m,$,p,o,!0,t,d,g),r.addMainTriangle($,h,l,s,h,f,s,p,m,!1,t,d,g),r.addLineSegment($,p,o,$,h,l),r.addLineSegment($,h,l,s,h,f),d===t.i2-2&&r.addLineSegment(s,h,f,s,p,m),g===t.j2-2&&r.addLineSegment($,p,o,s,p,m);r.callFuncs(e,n)}let le=class Et extends Nt{#t;#i;#n;#s;#r;#e;get _wheel_zoomy(){return!0}cleanup(){delete this.tt_handle,this.#e=void 0,super.cleanup()}getHisto(){const t=super.getHisto();if(t?._typename===Ct)switch(t.$getBinContent||(t.$getBinContent=t.getBinContent),this.getOptions().Profile2DProj){case"B":t.getBinContent=t.getBinEntries;break;case"C=E":t.getBinContent=function(i,e){return this.getBinError(this.getBin(i,e))};break;case"W":t.getBinContent=function(i,e){return this.$getBinContent(i,e)*this.getBinEntries(i,e)};break;default:t.getBinContent=t.$getBinContent;break}return t}isProjection(){return this.#t}toggleProjection(t,i){(t==="Projections"||t==="Off")&&(t="");const e=a=>{if(a==="all"||a==="ALL")return 1e4;const r=parseInt(a);return r&&Number.isInteger(r)?r:1};let n=i,c=i;if(Lt(t)&&t.indexOf("XY")===0){const a=t.length>2?t.slice(2):"";t="XY",n=c=parseInt(a)||1}else if(Lt(t)&&t.length>1){const a=t.indexOf("_");a>0&&t[0]==="X"&&t[a+1]==="Y"?(n=e(t.slice(1,a)),c=e(t.slice(a+2)),t="XY"):a>0&&t[0]==="Y"&&t[a+1]==="X"?(c=e(t.slice(1,a)),n=e(t.slice(a+2)),t="XY"):(n=c=e(t.slice(1)),t=t[0])}if(!n&&!c&&(n=c=1),t&&this.#t===t)if(this.#i===n&&this.#n===c)t="";else{this.#i=n,this.#n=c;return}delete this.proj_hist;const k=this.#t===t?"":t;return this.#i=n,this.#n=c,this.#t="",this.provideSpecialDrawArea(k).then(()=>(this.#t=k,this.redrawProjection()))}async redrawProjection(t,i,e,n){if(!this.#t)return!1;if(n===void 0){if(!this.tt_handle)return;t=Math.round((this.tt_handle.i1+this.tt_handle.i2)/2),i=t+1,e=Math.round((this.tt_handle.j1+this.tt_handle.j2)/2),n=e+1}const c=this.getCanvPainter();if(c&&!c.isReadonly()&&this.hasSnapId())return(this.#t==="X"||this.#t==="XY")&&!c.websocketTimeout("projX")&&c.sendWebsocket(`EXECANDSEND:DXPROJ:${this.getSnapId()}:ProjectionX("_projx",${e+1},${n},"")`)&&c.websocketTimeout("projX",1e3),(this.#t==="Y"||this.#t==="XY")&&!c.websocketTimeout("projY")&&c.sendWebsocket(`EXECANDSEND:DYPROJ:${this.getSnapId()}:ProjectionY("_projy",${t+1},${i},"")`)&&c.websocketTimeout("projY",1e3),!0;if(this.doing_projection)return!1;this.doing_projection=!0;const k=this.getHisto(),a=()=>{const g=Gt(zt,this.nbinsx);return Object.assign(g.fXaxis,k.fXaxis),g.fName="xproj",g.fTitle="X projection",g},r=()=>{const g=Gt(zt,this.nbinsy);return Object.assign(g.fXaxis,k.fYaxis),g.fName="yproj",g.fTitle="Y projection",g},d=(g,$)=>{let s=0,h=-1;if(g==="X"){for(let p=0;p<this.nbinsx;++p){let l=0;for(let o=e;o<n;++o)l+=k.getBinContent(p+1,o+1);$.setBinContent(p+1,l)}$.fTitle="X projection "+(e+1===n?`bin ${n}`:`bins [${e+1} .. ${n}]`),this.tt_handle&&(s=this.tt_handle.i1+1,h=this.tt_handle.i2)}else{for(let p=0;p<this.nbinsy;++p){let l=0;for(let o=t;o<i;++o)l+=k.getBinContent(o+1,p+1);$.setBinContent(p+1,l)}$.fTitle="Y projection "+(t+1===i?`bin ${i}`:`bins [${t+1} .. ${i}]`),this.tt_handle&&(s=this.tt_handle.j1+1,h=this.tt_handle.j2)}s<h&&($.fXaxis.fFirst=s,$.fXaxis.fLast=h,$.fXaxis.SetBit(Jt.kAxisRange,s!==1||h!==$.fXaxis.fNbins)),$.fEntries=0,$.fTsumw=0};if(!this.proj_hist)switch(this.#t){case"X":this.proj_hist=a();break;case"XY":this.proj_hist=a(),this.proj_hist2=r();break;default:this.proj_hist=r()}return this.#t==="XY"?(d("X",this.proj_hist),d("Y",this.proj_hist2),this.drawInSpecialArea(this.proj_hist,"","X").then(()=>this.drawInSpecialArea(this.proj_hist2,"","Y")).then(g=>(delete this.doing_projection,g))):(d(this.#t,this.proj_hist),this.drawInSpecialArea(this.proj_hist).then(g=>(delete this.doing_projection,g)))}executeMenuCommand(t,i){return super.executeMenuCommand(t,i)?!0:t.fName==="SetShowProjectionX"||t.fName==="SetShowProjectionY"?(this.toggleProjection(t.fName[17],i&&parseInt(i)?parseInt(i):1),!0):t.fName==="SetShowProjectionXY"?(this.toggleProjection("X"+i.replaceAll(",","_Y")),!0):!1}fillHistContextMenu(t){if(!this.isTH2Poly()&&this.getPadPainter()?.isCanvas()){let n=this.#t||"";n&&(n+=this.#i),this.#i!==this.#n&&this.#t==="XY"&&(n=`X${this.#i}_Y${this.#n}`);const c=["1","2","3","5","10","all"];n&&c.unshift(""),t.sub("Projections",()=>t.input("Input projection kind X1 or XY2 or X3_Y4",n,"string").then(k=>this.toggleProjection(k))),["X","Y","XY"].forEach(k=>{t.column(),c.forEach(a=>{const r=a?k+a:"Off";t.addchk(n===r,r,r,d=>this.toggleProjection(d))}),t.endcolumn()}),t.endsub()}this.isTH2Poly()||t.add("Auto zoom-in",()=>this.autoZoom());const i=this.getSupportedDrawOptions(),e=this.getOptions();t.addDrawMenu("Draw with",i,n=>{if(n.indexOf(Vt)===0)return this.showInspector(n);const c=e.Project;this.decodeOptions(n),c===e.Project||this.mode3d?this.interactiveRedraw("pad","drawopt"):this.toggleProjection(e.Project)}),(e.Color||e.Contour||e.Hist||e.Surf||e.Lego===12||e.Lego===14)&&this.fillPaletteMenu(t,!0)}clickButton(t){const i=super.clickButton(t);if(i)return i;if(this.isMainPainter())switch(t){case"ToggleColor":return this.toggleColor();case"Toggle3D":return this.toggleMode3D()}return!1}fillToolbar(){super.fillToolbar(!0);const t=this.getPadPainter(),i=this.getOptions();t&&(!this.isTH2Poly()&&!i.Axis&&t.addPadButton("th2color","Toggle color","ToggleColor"),i.Axis||t.addPadButton("th2colorz","Toggle color palette","ToggleColorZ"),t.addPadButton("th2draw3d","Toggle 3D mode","Toggle3D"),t.showPadButtons())}toggleColor(){const t=this.getOptions();return t.Mode3D?(t.Mode3D=!1,t.Color=!0):(t.Color=!t.Color,t.Scat=!t.Color),this.#s=!0,this.copyOptionsToOthers(),this.interactiveRedraw("pad","drawopt")}autoZoom(){if(this.isTH2Poly())return;const t=this.getSelectIndex("x","left",-1),i=this.getSelectIndex("x","right",1),e=this.getSelectIndex("y","left",-1),n=this.getSelectIndex("y","right",1),c=this.getHisto();if(t===i||e===n)return;let k=c.getBinContent(t+1,e+1);for(let o=t;o<i;++o)for(let f=e;f<n;++f)k=Math.min(k,c.getBinContent(o+1,f+1));if(k>0)return;let a=i,r=t,d=n,g=e;for(let o=t;o<i;++o)for(let f=e;f<n;++f)c.getBinContent(o+1,f+1)>k&&(o<a&&(a=o),o>=r&&(r=o+1),f<d&&(d=f),f>=g&&(g=f+1));let $,s,h,p,l=!1;if(a===r-1&&a>t+1&&r<i-1&&(a--,r++),d===g-1&&d>e+1&&g<n-1&&(d--,g++),(a>t||r<i)&&a<r-1&&($=c.fXaxis.GetBinLowEdge(a+1),s=c.fXaxis.GetBinLowEdge(r+1),l=!0),(d>e||g<n)&&d<g-1&&(h=c.fYaxis.GetBinLowEdge(d+1),p=c.fYaxis.GetBinLowEdge(g+1),l=!0),l)return this.getFramePainter()?.zoom($,s,h,p)}scanContent(t){if(t&&this.nbinsx&&this.nbinsy)return;const i=this.getObject(),e=this.getOptions();let n,c;if(this.extractAxesProperties(2),this.isTH2Poly()){this.gminposbin=null,this.gminbin=this.gmaxbin=0;for(let a=0,r=i.fBins.arr.length;a<r;++a){const d=i.fBins.arr[a].fContent;a===0&&(this.gminbin=this.gmaxbin=d),d<this.gminbin?this.gminbin=d:d>this.gmaxbin&&(this.gmaxbin=d),d>0&&(this.gminposbin===null||this.gminposbin>d)&&(this.gminposbin=d)}}else for(this.gminbin=this.gmaxbin=i.getBinContent(1,1),this.gminposbin=null,n=0;n<this.nbinsx;++n)for(c=0;c<this.nbinsy;++c){const a=i.getBinContent(n+1,c+1);a<this.gminbin?this.gminbin=a:a>this.gmaxbin&&(this.gmaxbin=a),a>0&&(this.gminposbin===null||this.gminposbin>a)&&(this.gminposbin=a)}this.gminposbin===null&&this.gmaxbin>0&&(this.gminposbin=this.gmaxbin*1e-4);let k=this.gmaxbin||this.gminbin;if(!k&&i._typename===Ct){for(n=0;n<this.nbinsx&&!k;++n)for(c=0;c<this.nbinsy;++c)if(i.getBinEntries(n+1,c+1)){k=!0;break}}e.Axis>0?this.draw_content=!1:this.isTH2Poly()?(this.draw_content=k||e.Line||e.Fill||e.Mark,!this.draw_content&&e.Zero&&(this.draw_content=!0,e.Line=1)):this.draw_content=k||e.ShowEmpty}getUserRanges(){const t=this.getHisto();return{minx:t.fXaxis.fXmin,maxx:t.fXaxis.fXmax,miny:t.fYaxis.fXmin,maxy:t.fYaxis.fXmax}}countStat(t,i){const e=this.getHisto(),n=this.getOptions(),c=e.fXaxis,k=e.fYaxis,a=this.getHistGrFuncs(),r={name:e.fName,entries:0,eff_entries:0,integral:0,meanx:0,meany:0,rmsx:0,rmsy:0,matrix:[0,0,0,0,0,0,0,0,0],xmax:0,ymax:0,wmax:null,skewx:0,skewy:0,skewd:0,kurtx:0,kurty:0,kurtd:0},d=!a.isAxisZoomed("x")&&!a.isAxisZoomed("y")&&Math.abs(e.fTsumw)>1e-300&&!t&&!n.cutg;let g=0,$=0,s=0,h=0,p=0,l=0,o,f,m,P,_,j,u,C,B;if(!_t(t)&&n.cutg&&(t=(M,b)=>n.cutg.IsInside(M,b)),this.isTH2Poly()){const M=e.fBins.arr.length;let b,x,y,S,w,A,T;for(b=0;b<M;++b){for(x=e.fBins.arr[b],o=x.fXmin>a.scale_xmax?2:x.fXmax<a.scale_xmin?0:1,f=x.fYmin>a.scale_ymax?2:x.fYmax<a.scale_ymin?0:1,m=P=T=0,S=x.fPoly,A=1,S._typename===kt&&(A=x.fPoly.fGraphs.arr.length,S=null),w=0;w<A;++w)for((!S||w>0)&&(S=x.fPoly.fGraphs.arr[w]),y=0;y<S.fNpoints;++y)++T,m+=S.fX[y],P+=S.fY[y];T>1&&(m/=T,P/=T),_=x.fContent,r.entries+=_,r.matrix[f*3+o]+=_,!(o!==1||f!==1||t&&!t(m,P))&&((r.wmax===null||_>r.wmax)&&(r.wmax=_,r.xmax=m,r.ymax=P),d||(g+=_,$+=_*_,s+=m*_,h+=P*_,p+=m*m*_,l+=P*P*_))}}else{j=this.getSelectIndex("x","left"),u=this.getSelectIndex("x","right"),C=this.getSelectIndex("y","left"),B=this.getSelectIndex("y","right");for(let M=0;M<=this.nbinsx+1;++M){o=M<=j?0:M>u?2:1,m=c.GetBinCoord(M-.5);for(let b=0;b<=this.nbinsy+1;++b)f=b<=C?0:b>B?2:1,P=k.GetBinCoord(b-.5),_=e.getBinContent(M,b),r.entries+=_,r.matrix[f*3+o]+=_,!(o!==1||f!==1||t&&!t(m,P))&&((r.wmax===null||_>r.wmax)&&(r.wmax=_,r.xmax=m,r.ymax=P),d||(g+=_,$+=_*_,s+=m*_,h+=P*_,p+=m**2*_,l+=P**2*_))}}if(d&&(g=e.fTsumw,$=e.fTsumw2,s=e.fTsumwx,p=e.fTsumwx2,h=e.fTsumwy,l=e.fTsumwy2),Math.abs(g)>1e-300&&(r.meanx=s/g,r.meany=h/g,r.rmsx=Math.sqrt(Math.abs(p/g-r.meanx**2)),r.rmsy=Math.sqrt(Math.abs(l/g-r.meany**2))),r.wmax===null&&(r.wmax=0),r.integral=g,e.fEntries>0&&(r.entries=e.fEntries),r.eff_entries=$?g*g/$:Math.abs(g),i&&!this.isTH2Poly()){let M=0,b=0,x=0,y=0,S=0,w;for(let N=j;N<u;++N){m=c.GetBinCoord(N+.5);for(let G=C;G<B;++G)P=k.GetBinCoord(G+.5),!(t&&!t(m,P))&&(w=e.getBinContent(N+1,G+1),S+=w,M+=w*Math.pow(m-r.meanx,3),b+=w*Math.pow(P-r.meany,3),x+=w*Math.pow(m-r.meanx,4),y+=w*Math.pow(P-r.meany,4))}const A=Math.pow(r.rmsx,3),T=Math.pow(r.rmsy,3),I=Math.pow(r.rmsx,4),v=Math.pow(r.rmsy,4);S*A&&(r.skewx=M/(S*A)),S*T&&(r.skewy=b/(S*T)),r.skewd=r.eff_entries>0?Math.sqrt(6/r.eff_entries):0,S*I&&(r.kurtx=x/(S*I)-3),S*v&&(r.kurty=y/(S*v)-3),r.kurtd=r.eff_entries>0?Math.sqrt(24/r.eff_entries):0}return r}fillStatistic(t,i,e){if(this.isIgnoreStatsFill())return!1;i===1&&(i=1111);const n=Math.floor(i%10),c=Math.floor(i/10)%10,k=Math.floor(i/100)%10,a=Math.floor(i/1e3)%10,r=Math.floor(i/1e4)%10,d=Math.floor(i/1e5)%10,g=Math.floor(i/1e6)%10,$=Math.floor(i/1e7)%10,s=Math.floor(i/1e8)%10,h=this.countStat(void 0,$>0||s>0);if(t.clearPave(),n>0&&t.addText(h.name),c>0&&t.addText("Entries = "+t.format(h.entries,"entries")),k>0&&(t.addText("Mean x = "+t.format(h.meanx)),t.addText("Mean y = "+t.format(h.meany))),a>0&&(t.addText("Std Dev x = "+t.format(h.rmsx)),t.addText("Std Dev y = "+t.format(h.rmsy))),g>0&&t.addText("Integral = "+t.format(h.matrix[4],"entries")),$===2?(t.addText(`Skewness x = ${t.format(h.skewx)} #pm ${t.format(h.skewd)}`),t.addText(`Skewness y = ${t.format(h.skewy)} #pm ${t.format(h.skewd)}`)):$>0&&(t.addText(`Skewness x = ${t.format(h.skewx)}`),t.addText(`Skewness y = ${t.format(h.skewy)}`)),s===2?(t.addText(`Kurtosis x = ${t.format(h.kurtx)} #pm ${t.format(h.kurtd)}`),t.addText(`Kurtosis y = ${t.format(h.kurty)} #pm ${t.format(h.kurtd)}`)):s>0&&(t.addText(`Kurtosis x = ${t.format(h.kurtx)}`),t.addText(`Kurtosis y = ${t.format(h.kurty)}`)),r>0||d>0){const p=l=>h.matrix[l].toFixed(0);t.addText(`${p(6)} | ${p(7)} | ${p(7)}`),t.addText(`${p(3)} | ${p(4)} | ${p(5)}`),t.addText(`${p(0)} | ${p(1)} | ${p(2)}`)}return e&&t.fillFunctionStat(this.findFunction(Zt),e,2),!0}drawBinsColor(){const t=this.getHisto(),i=this.getOptions(),e=this.prepareDraw(),n=this.getContour(),c=this.getHistPalette(),k=[],a=t.fSumw2?.length,r=i.ShowEmpty,d=i.Color!==7||e.xbar1===0&&e.xbar2===1,g=i.Color!==7||e.ybar1===0&&e.ybar2===1,$=n.getPaletteIndex(c,0);let s,h,p,l,o,f,m,P=null,_=!i.Zero,j;const u=i.cutg,C=()=>{P.path+=`h${s}v${P.y1-P.y2}h${-s}z`,P=null};!_&&!r&&$===null&&(_=!0),_&&t?._typename===Ct&&(_=1);for(let B=e.i1;B<e.i2;++B){s=e.grx[B+1]-e.grx[B]||1,d?p=e.grx[B]:(p=Math.round(e.grx[B]+s*e.xbar1),s=Math.round(s*(e.xbar2-e.xbar1))||1);for(let M=e.j2-1;M>=e.j1;--M){if(o=t.getBinContent(B+1,M+1),f=o===0&&(!a||t.fSumw2[t.getBin(B+1,M+1)]===0),j=f&&(_===1?!t.getBinEntries(B+1,M+1):_),j||u&&!u.IsInside(t.fXaxis.GetBinCoord(B+.5),t.fYaxis.GetBinCoord(M+.5))){P&&C();continue}if(m=n.getPaletteIndex(c,o),m===null)if(f&&(r||_===1))m=$||0;else{P&&C();continue}h=e.gry[M]-e.gry[M+1]||1,g?l=e.gry[M+1]:(l=Math.round(e.gry[M]-h*e.ybar2),h=Math.round(h*(e.ybar2-e.ybar1))||1);const b=`M${p},${l}`;let x=k[m];if(!x)x=k[m]={path:b};else if(g&&x===P){x.y1=l+h;continue}else{const y=p-x.x1,S=l-x.y2;if(y||S){const w=`m${y},${S}`;x.path+=w.length<b.length?w:b}}P&&C(),x.x1=p,x.y2=l,g?(x.y1=l+h,P=x):x.path+=`h${s}v${h}h${-s}z`}P&&C()}return k.forEach((B,M)=>{B&&this.appendPath(B.path).attr("fill",c.getColor(M))}),e}drawBinsPolar(){const t=this.getHisto(),i=this.getOptions(),e=this.prepareDraw(),n=this.getContour(),c=this.getHistPalette(),k=[],a=t.fSumw2?.length,r=i.ShowEmpty,d=n.getPaletteIndex(c,0);let g,$,s,h=!i.Zero,p;const l=i.cutg;!h&&!r&&d===null&&(h=!0),h&&t?._typename===Ct&&(h=1),e.getBinPath=function(o,f){const m=2*Math.PI*Math.max(0,this.grx[o])/this.width,P=2*Math.PI*Math.min(this.grx[o+1],this.width)/this.width,_=Math.min(this.gry[f],this.height)/this.height,j=Math.max(0,this.gry[f+1])/this.height,u=P-m>Math.PI?1:0;if(P<=m||_<=j)return"";const C=this.width/2,B=this.height/2,M=j*this.width/2,b=_*this.width/2,x=j*this.height/2,y=_*this.height/2,S=C+M*Math.cos(m),w=C+M*Math.cos(P),A=B+x*Math.sin(m),T=B+x*Math.sin(P),I=C+b*Math.cos(m),v=C+b*Math.cos(P),N=B+y*Math.sin(m),G=B+y*Math.sin(P);return`M${S.toFixed(2)},${A.toFixed(2)}A${M.toFixed(2)},${x.toFixed(2)},0,${u},1,${w.toFixed(2)},${T.toFixed(2)}L${v.toFixed(2)},${G.toFixed(2)}A${b.toFixed(2)},${y.toFixed(2)},0,${u},0,${I.toFixed(2)},${N.toFixed(2)}Z`},e.findBin=function(o,f){const m=this.width/2,P=this.height/2;let _=Math.atan2((f-P)/this.height,(o-m)/this.width),j,u;const C=Math.abs(Math.cos(_))>.5?(o-m)/Math.cos(_)/this.width*2:(f-P)/Math.sin(_)/this.height*2;for(_<0&&(_+=2*Math.PI),j=this.i1;j<this.i2;++j){const B=2*Math.PI*this.grx[j]/this.width,M=2*Math.PI*this.grx[j+1]/this.width;if(B<=_&&_<=M)break}for(u=this.j1;u<this.j2;++u){const B=this.gry[u]/this.height;if(this.gry[u+1]/this.height<=C&&C<=B)break}return{i:j,j:u}};for(let o=e.i1;o<e.i2;++o)for(let f=e.j2-1;f>=e.j1;--f){if(g=t.getBinContent(o+1,f+1),$=g===0&&(!a||t.fSumw2[t.getBin(o+1,f+1)]===0),p=$&&(h===1?!t.getBinEntries(o+1,f+1):h),p||l&&!l.IsInside(t.fXaxis.GetBinCoord(o+.5),t.fYaxis.GetBinCoord(f+.5)))continue;if(s=n.getPaletteIndex(c,g),s===null)if($&&(r||h===1))s=d||0;else continue;const m=e.getBinPath(o,f);if(!m)continue;const P=k[s];P?P.path+=m:k[s]={path:m}}return k.forEach((o,f)=>{o&&this.appendPath(o.path).attr("fill",c.getColor(f))}),e}drawBinsProjected(){const t=this.prepareDraw({rounding:!1,nozoom:!0,extra:100,original:!0}),i=this.getHistGrFuncs(),e=this.getContourLevels(),n=this.getHistPalette(),c=_t(i.getProjectionFunc)?i.getProjectionFunc():(k,a)=>({x:k,y:a});return t.grz=k=>k,t.grz_min=e.at(0),t.grz_max=e.at(-1),se(this.getHisto(),t,e,(k,a)=>{let r="",d,g;for(let $=0;$<a.length;$+=3){const s=c(a[$],a[$+1]),h=Math.round(i.grx(s.x)),p=Math.round(i.gry(s.y));if($===0)r=`M${h},${p}`;else{if(h===d&&p===g)continue;$%9===0?r+=`m${h-d},${p-g}`:p===g?r+=`h${h-d}`:h===d?r+=`v${p-g}`:r+=`l${h-d},${p-g}`}d=h,g=p}this.appendPath(r).style("fill",n.calcColor(k,e.length))}),t}drawBinsContour(){const t=this.prepareDraw({rounding:!1,extra:100}),i=this.getContourLevels(),e=this.getHistPalette(),n=this.getOptions(),c=(a,r)=>{const d=a.x2-a.x1,g=a.y2-a.y1,$=r.x2-r.x1,s=r.y2-r.y1,h=d*s-$*g;if(h===0)return 0;const p=h>0,l=a.x1-r.x1,o=a.y1-r.y1,f=d*o-g*l;if(f<0===p)return null;const m=$*o-s*l;if(m<0===p||f>h===p||m>h===p)return null;const P=m/h;return{x:Math.round(a.x1+P*d),y:Math.round(a.y1+P*g)}},k=(a,r,d,g,$,s)=>{let h="",p,l,o,f,m=!1,P,_,j;for(let w=d;w<=g;++w){if(_=Math.round(a[w]),j=Math.round(r[w]),!h)h=`M${_},${j}`,o=_,f=j;else if(w===g&&d!==g&&_===o&&j===f){if(!m)return"";h+="z",$=!1,P=!0}else{const A=_-p,T=j-l;A?(m=!0,h+=T?`l${A},${T}`:`h${A}`):T&&(m=!0,h+=`v${T}`)}p=_,l=j}if(!$||P||!s)return $?h+"z":h;const u=[{x:0,y:0},{x:t.width,y:0},{x:t.width,y:t.height},{x:0,y:t.height}],C=(w,A)=>{const T={x1:a[w],y1:r[w],x2:2*a[w]-a[w+A],y2:2*r[w]-r[w+A]};for(let I=0;I<4;++I){const v=c(T,{x1:u[I].x,y1:u[I].y,x2:u[(I+1)%4].x,y2:u[(I+1)%4].y});if(v)return v.indx=I+.5,v}return null};let B,M;for(d--;d<g-1&&!B;)B=C(++d,1);if(!B)return"";for(g++;d<g-1&&!M;)M=C(--g,-1);if(!M)return"";let b=k(a,r,d,g),x=M.indx;const y=1,S=y*.5;for(b+=`L${M.x},${M.y}`;Math.abs(x-B.indx)>.1;)x=Math.round(x+S)%4,b+=`L${u[x].x},${u[x].y}`,x+=S;return b+`L${B.x},${B.y}z`};return n.Contour===14&&this.appendPath(`M0,0h${t.width}v${t.height}h${-t.width}z`).style("fill",e.calcColor(0,i.length)),ne(this.getHisto(),t,i,e,(a,r,d,g,$,s)=>{const h=e.getColor(a);let p=h,l;switch(n.Contour){case 1:break;case 11:p="none",l=this.createAttLine({color:h,std:!1});break;case 12:p="none",l=this.createAttLine({color:1,style:s%5+1,width:1,std:!1});break;case 13:p="none",l=this.lineatt;break}const o=k(r,d,g,$,p!=="none",!0);o&&this.appendPath(o).style("fill",p).call(l?l.func:()=>{})}),t.hide_only_zeros=!0,t}getGrNPoints(t){const i=t.fX,e=t.fY;let n=t.fNpoints;return n>2&&i[0]===i[n-1]&&e[0]===e[n-1]&&n--,n}createPolyGr(t,i,e){let n="",c=0,k=0;const a=i.fX,r=i.fY,d=()=>{c&&(n+="h"+c,c=0),k&&(n+="v"+k,k=0)},g=(o,f,m,P)=>{const _=Math.sqrt((o-m)**2+(f-P)**2);e.sumx+=(o+m)*_/2,e.sumy+=(f+P)*_/2,e.sum+=_},$=this.getGrNPoints(i);if($<2)return"";const s=Math.round(t.grx(a[0])),h=Math.round(t.gry(r[0]));let p=s,l=h;for(let o=1;o<$;++o){const f=Math.round(t.grx(a[o])),m=Math.round(t.gry(r[o])),P=f-p,_=m-l;e&&g(p,l,f,m),(P||_)&&(P===0?((k===0||_<0!=k<0)&&d(),k+=_):_===0?((c===0||P<0!=c<0)&&d(),c+=P):(d(),n+=`l${P},${_}`),p=f,l=m)}return e&&g(p,l,s,h),d(),n?`M${s},${h}`+n+"z":""}createPolyBin(t,i){const e=i.fPoly._typename===kt?i.fPoly.fGraphs.arr:[i.fPoly];let n="";for(let c=0;c<e.length;++c)n+=this.createPolyGr(t,e[c]);return n}async drawPolyBins(){const t=this.getHisto(),i=this.getOptions(),e=this.getHistGrFuncs(),n=i.Color||!i.Line&&!i.Fill&&!i.Text&&!i.Mark,c=i.Line||i.Text&&!n,k=i.Fill&&!n,a=i.Mark,r=e.getFrameHeight(),d=[],g=t.fBins.arr.length;let $,s,h="",p="",l,o,f,m=null,P=c,_=k,j=a;this.maxbin=this.gmaxbin,this.minbin=this.gminbin,this.minposbin=this.gminposbin;const u=n?this.getContour(!0):null,C=u?this.getHistPalette():null,B=w=>w.fXmin>e.scale_xmax||w.fXmax<e.scale_xmin||w.fYmin>e.scale_ymax||w.fYmax<e.scale_ymin;for(f=0;f<g;++f){if(l=t.fBins.arr[f],B(l))continue;const w=l.fPoly._typename===kt?l.fPoly.fGraphs.arr:[l.fPoly];for(let A=0;A<w.length;++A){const T=w[A];if(!m){m=T;continue}P&&(m.fLineColor!==T.fLineColor||m.fLineWidth!==T.fLineWidth||m.fLineStyle!==T.fLineStyle)&&(P=!1),_&&(m.fFillColor!==T.fFillColor||m.fFillStyle!==T.fFillStyle)&&(_=!1),j&&(m.fMarkerColor!==T.fMarkerColor||m.fMarkerStyle!==T.fMarkerStyle||m.fMarkerSize!==T.fMarkerSize)&&(j=!1)}if(!P&&!_&&!j)break}const M=P&&m?this.createAttLine(m):null,b=_&&m?this.createAttFill(m):null,x=j&&m?this.createAttMarker({attr:m,style:i.MarkStyle,std:!1}):null,y=!n&&(c?P:!0)&&(k?_:!0);for(f=0;f<g;++f){if(l=t.fBins.arr[f],B(l))continue;const w=l.fContent||i.Zero,A=l.fPoly._typename===kt?l.fPoly.fGraphs.arr:[l.fPoly];$=n&&w?u.getPaletteIndex(C,l.fContent):null;const T=i.Text&&w?{bin:l,sumx:0,sumy:0,sum:0}:null;for(let I=0;I<A.length;++I){const v=A[I];if(x){const N=this.getGrNPoints(v);for(let G=0;G<N;++G)p+=x.create(e.grx(v.fX[G]),e.gry(v.fY[G]))}s=this.createPolyGr(e,v,T),s&&(y?h+=s:($!==null||k||c)&&(o=this.appendPath(s),n&&$!==null?o.style("fill",C.getColor($)):k?o.call(this.createAttFill(v).func):o.style("fill","none"),c&&o.call(this.createAttLine(v).func)))}T?.sum&&d.push(T)}if(y&&(o=this.appendPath(h),k&&b?o.call(b.func):o.style("fill","none"),c&&M&&o.call(M.func)),x&&!x.empty()&&p)this.appendPath(p).call(x.func);else if(a)for(f=0;f<g;++f){if(l=t.fBins.arr[f],B(l))continue;const w=l.fPoly._typename===kt?l.fPoly.fGraphs.arr:[l.fPoly];for(let A=0;A<w.length;++A){const T=w[A],I=this.getGrNPoints(T),v=this.createAttMarker({attr:T,style:i.MarkStyle,std:!1});if(!I||v.empty())continue;let N="";for(let G=0;G<I;++G)N+=v.create(e.grx(T.fX[G]),e.gry(T.fY[G]));this.appendPath(N).call(v.func)}}let S=Promise.resolve();if(d.length){const w=this.getColor(t.fMarkerColor),A=-1*i.TextAngle,T=this.getG().append("svg:g").attr("class","th2poly_text"),I=t.fMarkerSize!==1&&A?Math.round(.02*r*t.fMarkerSize):12;S=this.startTextDrawingAsync(42,I,T,I).then(()=>{for(f=0;f<d.length;++f){const v=d[f];l=v.bin,v.sum>0?(v.midx=Math.round(v.sumx/v.sum),v.midy=Math.round(v.sumy/v.sum)):(v.midx=Math.round(e.grx((l.fXmin+l.fXmax)/2)),v.midy=Math.round(e.gry((l.fYmin+l.fYmax)/2)));let N;i.TextKind?(N=l.fPoly?.fName,(!N||N==="Graph")&&(N=l.fNumber.toString())):N=Math.round(l.fContent)===l.fContent?l.fContent.toString():ct(l.fContent,et.fPaintTextFormat),this.drawText({align:22,x:v.midx,y:v.midy,rotate:A,text:N,color:w,latex:0,draw_g:T})}return this.finishTextDrawing(T,!0)})}return S.then(()=>({poly:!0}))}async drawBinsText(t){t||(t=this.prepareDraw({rounding:!1}));const i=this.getHisto(),e=this.getOptions(),n=e.cutg,c=this.getColor(i.fMarkerColor),k=-1*e.TextAngle,a=this.getG().append("svg:g").attr("class","th2_text"),r=e.TextKind==="E",d=r&&!e.TextLine?1:0,g=i.fBarOffset*.001,$=i.fMarkerSize===1||!k?20:Math.round(.02*i.fMarkerSize*t.height);return this.startTextDrawingAsync(42,$,a,$).then(()=>{for(let s=t.i1;s<t.i2;++s){const h=t.grx[s+1]-t.grx[s];for(let p=t.j1;p<t.j2;++p){const l=i.getBinContent(s+1,p+1);if(l===0&&!e.ShowEmpty||n&&!n.IsInside(i.fXaxis.GetBinCoord(s+.5),i.fYaxis.GetBinCoord(p+.5)))continue;const o=t.gry[p]-t.gry[p+1];let f=l===Math.round(l)?l.toString():ct(l,et.fPaintTextFormat);if(r){const u=this.getBinErrors(i,i.getBin(s+1,p+1),l);if(u.poisson){const C=`-${ct(u.low,et.fPaintTextFormat)} +${ct(u.up,et.fPaintTextFormat)}`;e.TextLine?f+=" "+C:f=`#splitmline{${f}}{${C}}`}else{const C=u.up===Math.round(u.up)?u.up.toString():ct(u.up,et.fPaintTextFormat);e.TextLine?f+="±"+C:f=`#splitmline{${f}}{#pm${C}}`}}let m,P,_,j;k?(m=Math.round(t.grx[s]+h*.5),P=Math.round(t.gry[p+1]+o*(.5+g)),_=j=0):(m=Math.round(t.grx[s]+h*.1),P=Math.round(t.gry[p+1]+o*(.1+g)),_=Math.round(h*.8),j=Math.round(o*.8)),this.drawText({align:22,x:m,y:P,width:_,height:j,rotate:k,text:f,color:c,latex:d,draw_g:a})}}return t.hide_only_zeros=!0,this.finishTextDrawing(a,!0)}).then(()=>t)}drawBinsArrow(){const t=this.getHisto(),i=this.getOptions(),e=i.cutg,n=this.prepareDraw({rounding:!1}),c=i.Color?this.getContour():null,k=i.Color?this.getHistPalette():null,a=(n.grx[n.i2]-n.grx[n.i1])/(n.i2-n.i1+1)/2,r=(n.gry[n.j2]-n.gry[n.j1])/(n.j2-n.j1+1)/2,d=(C,B)=>C?B?`l${C},${B}`:`h${C}`:B?`v${B}`:"",g=[];let $=1e-30,s,h,p,l,o="",f,m,P,_,j,u;for(let C=0;C<2;++C)for(let B=n.i1;B<n.i2;++B)for(let M=n.j1;M<n.j2;++M){if(e&&!e.IsInside(t.fXaxis.GetBinCoord(B+.5),t.fYaxis.GetBinCoord(M+.5)))continue;const b=t.getBinContent(B+1,M+1);if(B===n.i1?s=t.getBinContent(B+2,M+1)-b:B===n.i2-1?s=b-t.getBinContent(B,M+1):s=.5*(t.getBinContent(B+2,M+1)-t.getBinContent(B,M+1)),M===n.j1?h=t.getBinContent(B+1,M+2)-b:M===n.j2-1?h=b-t.getBinContent(B+1,M):h=.5*(t.getBinContent(B+1,M+2)-t.getBinContent(B+1,M)),C===0)$=Math.max($,Math.abs(s),Math.abs(h));else if(p=(n.grx[B]+n.grx[B+1])/2,l=(n.gry[M]+n.gry[M+1])/2,f=a*s/$,m=r*h/$,P=p-f,_=p+f,j=l-m,u=l+m,s=Math.round(_-P),h=Math.round(u-j),s||h){let x=`M${Math.round(P)},${Math.round(j)}${d(s,h)}`;if(Math.abs(s)>5||Math.abs(h)>5){const y=Math.sqrt(9/(s**2+h**2)),S=Math.round(y*(s+h)),w=Math.round(y*(s-h));(S||w)&&(x+=`m${-S},${w}${d(S,-w)}${d(-w,-S)}`)}if(k&&c){const y=c.getPaletteIndex(k,b);if(y!==null){const S=g[y];S?S.path+=x:g[y]={path:x}}}else o+=x}}return o&&this.appendPath(o).style("fill","none").call(this.lineatt.func),g.forEach((C,B)=>{if(C){const M=this.lineatt.color;this.lineatt.color=k.getColor(B),this.appendPath(C.path).attr("fill","none").call(this.lineatt.func),this.lineatt.color=M}}),n}drawBinsBox(){const t=this.getHisto(),i=this.getOptions(),e=this.prepareDraw({rounding:!1,zrange:!0}),n=Math.max(Math.abs(e.zmin),Math.abs(e.zmax)),c=Math.max(0,e.zmin),k=this.getPadPainter().getRootPad(!0),a=i.cutg;let r,d,g,$,s="",h="",p="",l="",o,f,m,P,_,j,u,C,B=!1,M=0;if((k?.fLogv??k?.fLogz)&&n>0){B=!0;const b=Math.log(n);c>0?M=Math.log(c):e.zminpos>=1&&e.zminpos<100?M=Math.log(.7):M=e.zminpos>0?Math.log(.7*e.zminpos):b-10,M>=b&&(M=b-10),C=1/(b-M)}else C=1/(n-c);for(r=e.i1;r<e.i2;++r)for(d=e.j1;d<e.j2;++d)if(g=t.getBinContent(r+1,d+1),$=Math.abs(g),!($===0||$<c)&&!(a&&!a.IsInside(t.fXaxis.GetBinCoord(r+.5),t.fYaxis.GetBinCoord(d+.5)))&&(o=B?$>0?Math.log($)-M:0:$-c,o=.5*(o<0?1:1-Math.sqrt(o*C)),o<0&&(o=0),j=e.grx[r+1]-e.grx[r],u=e.gry[d]-e.gry[d+1],f=o*j,m=o*u,P=Math.round(e.grx[r]+f),_=Math.round(e.gry[d+1]+m),j=Math.max(Math.round(j-2*f),1),u=Math.max(Math.round(u-2*m),1),s+=`M${P},${_}v${u}h${j}v${-u}z`,g<0&&i.BoxStyle===10&&(h+=`M${P},${_}l${j},${u}m0,${-u}l${-j},${u}`),i.BoxStyle===11&&j>5&&u>5)){const b=Qt(P,_,j,u,g<0?-1:1,Math.round(j*.1),Math.round(u*.1));p+=b[0],l+=b[1]}if(s){const b=this.appendPath(s).call(this.fillatt.func);i.BoxStyle!==11&&this.fillatt.empty()&&b.call(this.lineatt.func)}if(p&&this.fillatt.hasColor()&&this.appendPath(p).call(this.fillatt.func).style("fill",Ot(this.fillatt.color).brighter(.5).formatRgb()),l&&this.appendPath(l).call(this.fillatt.func).style("fill",this.fillatt.hasColor()?Ot(this.fillatt.color).darker(.5).formatRgb():"red"),h){const b=this.appendPath(h).style("fill","none");this.lineatt.empty()?b.style("stroke","black"):b.call(this.lineatt.func)}return e}drawBinsCandle(){let j=0;const u=this.getOptions(),C=H=>{let X=1;for(;H>=X;)X*=10;return X/=10,Math.floor(j/X)%10===Math.floor(H/X)},B=(H,X)=>{let L="",Z="",O=0;const E=H[0],F=H[1];if(E>="A"&&E<="Z"&&(L=E),E>="1"&&E<="9"&&(Z=E),F>="A"&&F<="Z"&&Z&&(L=F),F>="1"&&F<="9"&&L&&(Z=F),X)switch(Z){case"1":O+=11311;break;case"2":O+=112111;break;case"3":O+=112311;break;case"4":O+=112321;break;case"5":O+=212111;break;case"6":O+=312311;break;default:O+=11311}else switch(Z){case"1":O+=13001300;break;case"2":O+=13102300;break;default:O+=13001300}const V=H.indexOf("("),ut=H.lastIndexOf(")");V>=0&&ut>V+1&&(O=parseInt(H.slice(V+1,ut))),j=O,(L==="Y"||L==="H")&&!C(1e8)&&(j+=1e8)},M=(H,X,L)=>{let Z=0,O=0,E=0;const F={max:0,first:-1,last:-1,entries:0};for(let V=0;V<X.length;++V)X[V]>0&&(F.max=Math.max(F.max,X[V]),F.first<0&&(F.first=V),F.last=V),Z+=X[V],E+=X[V]*(H[V]+H[V+1])/2;if(Z<=0)return null;F.entries=Z,F.mean=E/Z,F.quantiles=new Array(L.length),F.indx=new Array(L.length);for(let V=0,ut=0,gt=0;V<X.length;++V){const pt=gt;let wt=H[V];if(pt===L[O]&&X[V]===0&&pt<.99){for(;X[V]===0&&V<X.length;)V++;wt=(H[V]+wt)/2}for(ut+=X[V],gt=ut/Z;L[O]>=pt&&L[O]<gt;){if(F.indx[O]=V,F.quantiles[O]=wt+(L[O]-pt)/(gt-pt)*(H[V+1]-wt),O++===L.length)return F;wt=H[V]}}for(;O<L.length;)F.indx[O]=X.length-1,F.quantiles[O++]=H.at(-1);return F};u.Candle?B(u.Candle,!0):u.Violin&&B(u.Violin,!1);const b=this.getHisto(),x=this.prepareDraw(),y=this.getCanvPainter(),S=this.getHistGrFuncs(),w=C(1e8);let A=et.fViolinScaled,T=et.fCandleScaled,I=0,v="",N="",G=null;if(u.Scaled!==null?A=T=u.Scaled:y?.online_canvas||(b.fTitle.indexOf("unscaled")>=0?A=T=!1:b.fTitle.indexOf("scaled")>=0&&(A=T=!0)),A&&(C(2e6)||C(1e6)||C(3e6)))for(let H=0;H<this.nbinsx;++H)for(let X=0;X<this.nbinsy;++X)I=Math.max(I,b.getBinContent(H+1,X+1));const Q=(...H)=>{H[1]==="array"&&(H=H[0]);const X=H.length;let L=2,Z=H[0],O=H[1],E=w?`M${O},${Z}`:`M${Z},${O}`;for(;L<X;){switch(H[L]){case"Z":return E+"z";case"V":O!==H[L+1]&&(E+=(w?"h":"v")+(H[L+1]-O),O=H[L+1]);break;case"H":Z!==H[L+1]&&(E+=(w?"v":"h")+(H[L+1]-Z),Z=H[L+1]);break;default:E+=w?`l${H[L+1]-O},${H[L]-Z}`:`l${H[L]-Z},${H[L+1]-O}`,Z=H[L],O=H[L+1]}L+=2}return E},U=(H,X)=>{if(!v){const L=et.fCandleCrossLineWidth??1;this.createAttMarker({attr:b,style:C(3e5)?0:L===1?5:18*L+16}),this.markeratt.resetPos()}v+=w?this.markeratt.create(X,H):this.markeratt.create(H,X)},at=(H,X)=>{if(!G){const L=et.fCandleCircleLineWidth??1;G=this.createAttMarker({attr:b,style:L===1?24:18*L+17,std:!1}),G.resetPos()}N+=w?G.create(X,H):G.create(H,X)};b.fMarkerColor===1&&(b.fMarkerColor=b.fLineColor),x.candle=[];let q,R="",W="",K="",tt="",J="",Y,D=0;const z=et.fCandleWhiskerRange,dt=et.fCandleBoxRange,Mt=[z>=1?1e-15:.5-z/2,dt>=1?1e-14:.5-dt/2,.5,dt>=1?1-1e-14:.5+dt/2,z>=1?1-1e-15:.5+z/2],lt=(H,X,L,Z,O)=>{const E=M(q,Y,Mt);if(!E)return;const F={bin:H,swapXY:w,fBoxDown:E.quantiles[1],fMedian:E.quantiles[2],fBoxUp:E.quantiles[3]},V=F.fBoxUp-F.fBoxDown;let ut=E.quantiles[0],gt=E.quantiles[4];if(C(2e3)){let rt=F.fBoxDown-1.5*V,st=E.indx[1];for(;q[st]>rt&&st>0;)st--;for(;!Y[st];)st++;for(ut=q[st],rt=F.fBoxUp+1.5*V,st=E.indx[3];q[st]<rt&&st<Y.length;)st++;for(;!Y[st];)st--;gt=q[st+1]}const pt=E.mean,wt=1.57*V/Math.sqrt(E.entries);if(ut<=0&&(w&&S.logx||!w&&S.logy))return;const $t=L-X;let bt,Bt,it=(X+L)/2+b.fBarOffset/1e3*$t;b.fBarWidth>0&&b.fBarWidth!==1e3?bt=Bt=$t*b.fBarWidth/1e3:(bt=$t*.66,Bt=$t*.8),A&&I>0&&(Bt*=E.max/I),T&&D>0&&(bt*=E.entries/D),F.x1=Math.round(it-bt/2),F.x2=Math.round(it+bt/2),it=Math.round(it);const Ht=Math.round(it-bt/3),At=Math.round(it+bt/3),ht=w?S.grx:S.gry;F.yy1=Math.round(ht(gt)),F.y1=Math.round(ht(F.fBoxUp)),F.y0=Math.round(ht(F.fMedian)),F.y2=Math.round(ht(F.fBoxDown)),F.yy2=Math.round(ht(ut));const Ft=Math.round(ht(pt)),Xt=Math.round(ht(F.fMedian+wt)),vt=Math.round(ht(F.fMedian-wt));if(C(1e7)&&(J+=Q(it,Math.round(ht(q[Z])),"V",Math.round(ht(q[O])))),C(10)?W+=Q(F.x1,F.y0,"H",F.x2):C(20)?W+=Q(Ht,F.y0,"H",At):C(30)&&at(it,F.y0),C(300)?at(it,Ft):C(100)&&(K+=Q(F.x1,Ft,"H",F.x2)),C(1)&&(C(20)?R+=Q(F.x1,F.y1,"V",Xt,Ht,F.y0,F.x1,vt,"V",F.y2,"H",F.x2,"V",vt,At,F.y0,F.x2,Xt,"V",F.y1,"Z"):R+=Q(F.x1,F.y1,"V",F.y2,"H",F.x2,"V",F.y1,"Z")),C(1e4)&&(W+=Q(F.x1,F.yy1,"H",F.x2)+Q(F.x1,F.yy2,"H",F.x2)),C(1e3)&&!C(1e7)?K+=Q(it,F.y1,"V",F.yy1)+Q(it,F.y2,"V",F.yy2):(C(1e3)&&C(1e7)||C(2e3))&&(W+=Q(it,F.y1,"V",F.yy1)+Q(it,F.y2,"V",F.yy2)),C(1e5)||C(2e5)||C(3e5)){const rt=new Yt(H*7521+Math.round(E.integral)),st=!C(1e5),yt=C(3e5);for(let ot=0;ot<Y.length;++ot){const ft=Y[ot],xt=(q[ot]+q[ot+1])/2;let Pt=it,Tt;if(ft&&!(!st&&xt>=ut&&xt<=gt))for(let It=0;It<ft;It++)yt&&(Pt=it+Math.round((rt.random()-.5)*bt)),ft===1&&!yt?Tt=Math.round(ht(xt)):Tt=Math.round(ht(q[ot]+rt.random()*(q[ot+1]-q[ot]))),U(Pt,Tt)}}if((C(2e6)||C(1e6)||C(3e6))&&E.max>0&&E.first>=0){const rt=[],st=(w?-.5:.5)*Bt/E.max;if(Z=Math.max(Z,E.first),O=Math.min(O-1,E.last),C(2e6)||C(3e6)){let yt=it,ot=Math.round(ht(q[Z]));rt.push(yt,ot);for(let ft=Z;ft<=O;ft++){const xt=Math.round(it+st*Y[ft]),Pt=Math.round(ht(q[ft+1]));xt!==yt&&(ft!==Z&&rt.push("V",ot),rt.push("H",xt)),yt=xt,ot=Pt}rt.push("V",ot)}if(C(1e6)||C(3e6)){let yt=it,ot=Math.round(ht(q[O+1]));rt.length||rt.push(yt,ot);for(let ft=O;ft>=Z;ft--){const xt=Math.round(it-st*Y[ft]),Pt=Math.round(ht(q[ft]));xt!==yt&&(ft!==O&&rt.push("V",ot),rt.push("H",xt)),yt=xt,ot=Pt}rt.push("V",ot)}rt.push("H",it),tt+=Q(rt,"array"),this.fillatt.empty()||(tt+="Z")}x.candle.push(F)};if(w){q=new Array(this.nbinsx+1),Y=new Array(this.nbinsx);for(let H=0;H<this.nbinsx+1;++H)q[H]=b.fXaxis.GetBinLowEdge(H+1);if(T)for(let H=0;H<this.nbinsy;++H){let X=0;for(let L=0;L<this.nbinsx;++L)X+=b.getBinContent(L+1,H+1);D=Math.max(D,X)}for(let H=x.j1;H<x.j2;++H){for(let X=0;X<this.nbinsx;++X)Y[X]=b.getBinContent(X+1,H+1);lt(H,x.gry[H+1],x.gry[H],x.i1,x.i2)}}else{q=new Array(this.nbinsy+1),Y=new Array(this.nbinsy);for(let H=0;H<this.nbinsy+1;++H)q[H]=b.fYaxis.GetBinLowEdge(H+1);if(T)for(let H=0;H<this.nbinsx;++H){let X=0;for(let L=0;L<this.nbinsy;++L)X+=b.getBinContent(H+1,L+1);D=Math.max(D,X)}for(let H=x.i1;H<x.i2;++H){for(let X=0;X<this.nbinsy;++X)Y[X]=b.getBinContent(H+1,X+1);lt(H,x.grx[H],x.grx[H+1],x.j1,x.j2)}}J&&b.fFillColor>0&&this.appendPath(J).style("stroke",this.getColor(b.fFillColor));const nt=C(1e7)&&b.fFillStyle?this.fillatt.color:this.lineatt.color;if(tt&&(!this.fillatt.empty()||nt!=="none")&&this.appendPath(tt).style("stroke",nt!=="none"?nt:null).style("pointer-events",this.isBatchMode()?null:"visibleFill").call(this.fillatt.func),R&&this.appendPath(R).call(this.lineatt.func).call(this.fillatt.func),W&&this.appendPath(W).call(this.lineatt.func).style("fill","none"),K){const H=this.createAttLine({attr:b,style:2,std:!1,color:te});this.appendPath(K).call(H.func).style("fill","none")}return N&&this.appendPath(N).call(G.func),v&&this.appendPath(v).call(this.markeratt.func),x}drawBinsScatter(){const t=this.getHisto(),i=this.getOptions(),e=this.prepareDraw({rounding:!0,pixel_density:!0}),n=i.cutg,c=[],k=[],a=[],r=[],d=[],g=i.ScatCoef*(this.gmaxbin>2e3?2e3/this.gmaxbin:1),$=new Yt(e.sumz);let s,h,p,l,o,f,m,P,_=1;if(e.ScatterPlot=!0,g*e.sumz<1e5){this.createAttMarker({attr:t}),this.markeratt.resetPos();let b="";for(l=e.i1;l<e.i2;++l)for(m=e.grx[l+1]-e.grx[l],o=e.j1;o<e.j2;++o){P=e.gry[o]-e.gry[o+1],f=t.getBinContent(l+1,o+1);const x=Math.round(g*f);if(!(x<=0)&&!(n&&!n.IsInside(t.fXaxis.GetBinCoord(l+.5),t.fYaxis.GetBinCoord(o+.5))))for(let y=0;y<x;++y)b+=this.markeratt.create(Math.round(e.grx[l]+m*$.random()),Math.round(e.gry[o+1]+P*$.random()))}return this.appendPath(b).call(this.markeratt.func),e}this.maxbin>.7&&(_=.7/this.maxbin);const j=Math.round(e.max-e.min),u=this.createContour(j>50?50:j,this.minposbin,this.maxbin,this.minposbin);for(l=e.i1;l<e.i2;++l)for(o=e.j1;o<e.j2;++o)f=t.getBinContent(l+1,o+1),!(f<=0||f<this.minbin)&&(m=e.grx[l+1]-e.grx[l],P=e.gry[o]-e.gry[o+1],!(m*P<=0)&&(s=u.getContourIndex(f/m/P),!(s<0)&&(n&&!n.IsInside(t.fXaxis.GetBinCoord(l+.5),t.fYaxis.GetBinCoord(o+.5))||(h=`M${e.grx[l]},${e.gry[o+1]}`,c[s]===void 0?(c[s]=h,r[s]=m,d[s]=P):(p=`m${e.grx[l]-k[s]},${e.gry[o+1]-a[s]}`,c[s]+=p.length<h.length?p:h,r[s]=Math.max(r[s],m),d[s]=Math.max(d[s],P)),k[s]=e.grx[l],a[s]=e.gry[o+1],c[s]+=`v${P}h${m}v${-P}z`))));const C=this.getPadPainter(),B=C.selectChild(".main_layer");let M=B.selectChild("defs");for(M.empty()&&c.length&&(M=B.insert("svg:defs",":first-child")),this.createAttMarker({attr:t}),s=0;s<c.length;++s)if(c[s]!==void 0&&s<u.arr.length){const b=(C.getPadName()||"canv")+`_scatter_${s}`;let x=M.selectChild(`#${b}`);x.empty()?x=M.append("svg:pattern").attr("id",b).attr("patternUnits","userSpaceOnUse"):x.selectAll("*").remove();let y=Math.round(_*u.arr[s]*r[s]*d[s]);y=Math.max(1,y);const S=new Float32Array(y),w=new Float32Array(y);if(y===1)S[0]=w[0]=.5;else for(let T=0;T<y;++T)S[T]=$.random(),w[T]=$.random();this.markeratt.resetPos();let A="";for(let T=0;T<y;++T)A+=this.markeratt.create(S[T]*r[s],w[T]*d[s]);x.attr("width",r[s]).attr("height",d[s]).append("svg:path").attr("d",A).call(this.markeratt.func),this.appendPath(c[s]).attr("scatter-index",s).style("fill",`url(#${b})`)}return e}draw2DBins(){const t=this.getOptions();if(this.#r&&this.isMainPainter()?(this.getPadPainter().getFrameSvg().style("display",null),this.#r=void 0):t.Same&&!this.isUseFrame()&&this.getPadPainter().getFrameSvg().style("display","none"),!this.draw_content)return t.Zscale&&t.ohmin&&t.ohmax&&(this.getContour(!0),this.getHistPalette()),this.removeG();this.createHistDrawAttributes(),this.createG(this.isUseFrame());let i,e;if(this.isTH2Poly()?e=this.drawPolyBins():(t.Scat&&(i=this.drawBinsScatter()),t.System===ie?i=this.drawBinsPolar():t.Arrow?i=this.drawBinsArrow():t.Color?i=this.drawBinsColor():t.Box?i=this.drawBinsBox():t.Proj?i=this.drawBinsProjected():t.Contour?i=this.drawBinsContour():(t.Candle||t.Violin)&&(i=this.drawBinsCandle()),t.Text&&(e=this.drawBinsText(i)),!i&&!e&&(i=this.drawBinsColor())),i)this.tt_handle=i;else if(e)return e.then(n=>{this.tt_handle=n})}async drawBinsCircular(){this.#r=!0;const t=this.getPadPainter(),i=t.getFrameRect(),e=this.getHisto(),n=this.getOptions().Circular,c=n>10?this.getHistPalette():null,k=20,a=16,r=e.fXaxis,d=this.createG(),g=s=>{if(r.fLabels)for(let h=0;h<r.fLabels.arr.length;++h){const p=r.fLabels.arr[h];if(p.fUniqueID===s+1)return p.fString}return s.toString()};t.getFrameSvg().style("display","none"),this.assignChordCircInteractive(Math.round(i.x+i.width/2),Math.round(i.y+i.height/2));const $=Math.min(this.nbinsx,this.nbinsy);return this.startTextDrawingAsync(42,k,d).then(()=>{const s=[];for(let o=0;o<$;o++){const f=(.5-o/$)*Math.PI*2,m=Math.round((.9*i.width/2-2*a)*Math.cos(f)),P=Math.round((.9*i.height/2-2*a)*Math.sin(f)),_=Math.round(.9*i.width/2*Math.cos(f)),j=Math.round(.9*i.height/2*Math.sin(f)),u=c?.calcColor(o,$)??"black";let C=Math.round(f/Math.PI*180),B=12;s.push({x:m,y:P,a:f,color:u}),(C<-90||C>90)&&(C+=180,B=32);const M=Math.round(k/2),b=2*M;d.append("path").attr("d",`M${m-M},${P} a${M},${M},0,1,0,${b},0a${M},${M},0,1,0,${-b},0z`).style("stroke",u).style("fill","none"),this.drawText({align:B,rotate:C,x:_,y:j,text:g(o)})}const h=a/2;let p=0,l=0;if(n>11)for(let o=0;o<$-1;++o)for(let f=o+1;f<$;++f){const m=e.getBinContent(o+1,f+1);m>0&&(p=Math.max(p,m),(!l||m<l)&&(l=m))}for(let o=0;o<$-1;++o){const f=s[o];let m="";for(let P=o+1;P<$;++P){const _=e.getBinContent(o+1,P+1);if(_<=0)continue;const j=s[P],u=(f.a+j.a)/2,C=.5*(1-Math.abs(f.a-j.a)/Math.PI),B=Math.round(C*i.width/2*Math.cos(u)),M=Math.round(C*i.height/2*Math.sin(u));if(m+=`M${f.x},${f.y}Q${B},${M},${j.x},${j.y}`,n>11&&p>l){const b=Math.round((_-l)/(p-l)*(h-1)+1);d.append("path").attr("d",m).style("stroke",f.color).style("stroke-width",b).style("fill","none"),m=""}}m&&d.append("path").attr("d",m).style("stroke",f.color).style("fill","none")}return this.finishTextDrawing()}).then(()=>(this.isBatchMode()||d.insert("path",":first-child").attr("d",`M${-i.width/2},${-i.height/2}h${i.width}v${i.height}h${-i.width}z`).style("opacity",0).style("fill","none").style("pointer-events","visibleFill"),this))}assignChordCircInteractive(t,i){this.#e||(this.#e={x:0,y:0,zoom:1}),jt(this.getG(),t+this.#e.x,i+this.#e.y,this.#e.zoom),!this.isBatchMode()&&(Dt.Zooming&&Dt.ZoomWheel&&this.getG().on("wheel",e=>{const n=Rt(e,this.getG().node()),c=e.wheelDelta?-e.wheelDelta:e.deltaY||e.detail,k=this.#e.zoom;this.#e.zoom*=c>0?.8:1.2,this.#e.x+=n[0]*(k-this.#e.zoom),this.#e.y+=n[1]*(k-this.#e.zoom),jt(this.getG(),t+this.#e.x,i+this.#e.y,this.#e.zoom)}).on("dblclick",()=>{this.#e.x=this.#e.y=0,this.#e.zoom=1,jt(this.getG(),t,i)}),Wt(this))}async drawBinsChord(){this.getPadPainter().getFrameSvg().style("display","none"),this.#r=!0;const t=[],i=Math.min(this.nbinsx,this.nbinsy),e=this.getHisto();let n=0,c=!0;for(let x=0;x<i;++x){let y=0;for(let S=0;S<i;++S){const w=e.getBinContent(x+1,S+1);w>0&&(y+=w,c&&Math.round(w)!==w&&(c=!1))}y>0&&t.push(x),n+=y}if(t.length<2)return!0;let k=0,a=1;const r=this.getPadPainter().getFrameRect(),d=Math.round(r.x+r.width/2),g=Math.round(r.y+r.height/2),$=this.getHistPalette(),s=Math.max(10,Math.min(r.width,r.height)*.5-60),h=Math.max(2,s-10),p=[],l=[],o=x=>x.toString(),f=x=>k>3?x.toExponential(0):x.toFixed(k),m=(x,y)=>y<x?-1:y>x?1:y>=x?0:Number.NaN;if(!c&&n<10){const x=Math.round(Math.log10(n)-2.3);k=-x,a=Math.pow(10,x)}else if(n>200){const x=Math.round(Math.log10(n)-2.3);a=Math.pow(10,x)}a*250<n?a*=5:a*100<n&&(a*=2);for(let x=0;x<t.length;++x){p[x]=[];for(let w=0;w<t.length;++w)p[x].push(e.getBinContent(t[x]+1,t[w]+1));const y=e.fXaxis;let S="indx_"+t[x].toString();if(y.fLabels)for(let w=0;w<y.fLabels.arr.length;++w){const A=y.fLabels.arr[w];if(A.fUniqueID===t[x]+1){S=A.fString;break}}l.push(S)}const P=this.createG();this.assignChordCircInteractive(d,g);const _=Ut().padAngle(10/h).sortSubgroups(m).sortChords(m),j=_(p),u=P.append("g").attr("font-size",10).attr("font-family","sans-serif").selectAll("g").data(j.groups).join("g"),C=qt().innerRadius(h).outerRadius(s),B=Kt().radius(h-1).padAngle(1/h);function M({startAngle:x,endAngle:y,value:S}){const w=(y-x)/S,A=[];for(let T=0;T<=S;T+=a)A.push({value:T,angle:T*w+x});return A}u.append("path").attr("fill",x=>$.calcColor(x.index,t.length)).attr("d",C),u.append("title").text(x=>`${l[x.index]} ${o(x.value)}`);const b=u.append("g").selectAll("g").data(M).join("g").attr("transform",x=>`rotate(${Math.round(x.angle*180/Math.PI-90)}) translate(${s})`);return b.append("line").attr("stroke","currentColor").attr("x2",6),b.append("text").attr("x",8).attr("dy","0.35em").attr("transform",x=>x.angle>Math.PI?"rotate(180) translate(-16)":null).attr("text-anchor",x=>x.angle>Math.PI?"end":null).text(x=>f(x.value)),u.select("text").attr("font-weight","bold").text(function(x){return this.getAttribute("text-anchor")==="end"?`↑ ${l[x.index]}`:`${l[x.index]} ↓`}),P.append("g").attr("fill-opacity",.8).selectAll("path").data(j).join("path").style("mix-blend-mode","multiply").attr("fill",x=>$.calcColor(x.source.index,t.length)).attr("d",B).append("title").text(x=>`${o(x.source.value)} ${l[x.target.index]} → ${l[x.source.index]}${x.source.index===x.target.index?"":`
1
+ import{bJ as Ct,aK as Lt,bt as Vt,a5 as _t,bp as kt,aT as Zt,aU as ct,ae as et,bv as Ot,br as Yt,$ as jt,aA as Dt,aE as Rt,a0 as Wt,bU as Ut,bV as qt,bW as Kt,bT as St,ag as Gt,aZ as zt,al as Jt,bX as Qt,bY as te,bZ as ee}from"./ndmvr-aframe-core-DEHQ38JB.js";import{T as Nt,a as ie}from"./THistPainter-B2S5BnuY.js";function ne(mt,t,i,e,n){const a=new Float32Array(4008),r=new Float32Array(2*2004),d=new Int32Array(2*2004),g=i.length,$=i[0],s=i[g-1],h=[],p=[0,0,0,0],l=[0,0,0,0],o=[0,0,0,0],f=[0,0,0,0],m=t.grx,P=t.gry;let _=0;const j=J=>{if(J>=s)return g-1;for(let Y=0;Y<g;++Y)if(J<i[Y])return Y-1;return g-1},u=J=>{if(J<$)return-1;if(J>=s)return g-1;let Y=0,D=g-1,z;for(;D-Y>1;)z=Math.round((D+Y)/2),J<i[z]?D=z:Y=z;return Y},C=g<10?j:u,B=(J,Y,D,z,dt,Mt,lt,nt)=>{const H=D===lt,X=H?nt-z:lt-D,L=dt-J;let Z=Y+1,O=_-1,E=0,F,V,ut,gt;const pt=O+2004/2-3;for(;Z<=Mt&&O<=pt;)gt=i[Z],ut=gt-J,V=ut/L,F=X*V,H?(a[O]=D,r[O]=z+F):(a[O]=D+F,r[O]=z),d[O]=Z,E++,O+=2,Z++;return E};let M,b,x=0,y,S,w,A,T,I,v,N,G,Q,U,at;for(S=t.j1;S<t.j2-1;++S)for(l[1]=l[0]=(P[S]+P[S+1])/2,l[3]=l[2]=(P[S+1]+P[S+2])/2,y=t.i1;y<t.i2-1;++y){for(o[0]=mt.getBinContent(y+1,S+1),o[1]=mt.getBinContent(y+2,S+1),o[2]=mt.getBinContent(y+2,S+2),o[3]=mt.getBinContent(y+1,S+2),w=0;w<4;w++)f[w]=C(o[w]);if(f[0]!==f[1]||f[1]!==f[2]||f[2]!==f[3]||f[3]!==f[0]){for(p[3]=p[0]=(m[y]+m[y+1])/2,p[2]=p[1]=(m[y+1]+m[y+2])/2,T=o[0]<=o[1]?0:1,A=o[2]<=o[3]?2:3,o[T]>o[A]&&(T=A),T++,_=1,U=1;U<=4;U++)A=T%4+1,I=B(o[T-1],f[T-1],p[T-1],l[T-1],o[A-1],f[A-1],p[A-1],l[A-1]),_+=2*I,T=A;for(T=o[0]<=o[1]?0:1,A=o[2]<=o[3]?2:3,o[T]>o[A]&&(T=A),T++,_=2,U=1;U<=4;U++)A=T===1?4:T-1,I=B(o[T-1],f[T-1],p[T-1],l[T-1],o[A-1],f[A-1],p[A-1],l[A-1]),_+=2*I,T=A;for(v=0,U=1;U<=_-5;U+=2)for(;d[U-1]!==d[U];){for(N=a[U],G=r[U],Q=d[U],at=U;at<=_-5;at+=2)a[at]=a[at+2],r[at]=r[at+2],d[at]=d[at+2];if(a[_-3]=N,r[_-3]=G,d[_-3]=Q,v>2e3)break;v++}if(v>100)continue;for(U=1;U<=_-2;U+=2)if(M=d[U-1],M>=0&&M<i.length){b=h[M],b||(b=h[M]=ee(2004*4,!0));const J=b.fLastPoint;J<b.fN-2&&(b.fX[J+1]=Math.round(a[U-1]),b.fY[J+1]=Math.round(r[U-1]),b.fX[J+2]=Math.round(a[U]),b.fY[J+2]=Math.round(r[U]),b.fLastPoint=J+2,x=Math.max(x,b.fLastPoint+1))}}}const q=new Int32Array(i.length);let R=0;for(M=0;M<i.length;M++)if(i[M]>=0){R=M;break}for(w=0,M=R-1;M>=0;M--)q[w++]=M;for(M=R;M<i.length;M++)q[w++]=M;const W=new Float32Array(2*x),K=new Float32Array(2*x),tt=_t(e.calcColorIndex);for(w=0;w<i.length;++w){if(M=q[w],b=h[M],!b)continue;const J=tt?e.calcColorIndex(M,i.length):M,Y=b.fX,D=b.fY,z=b.fLastPoint+1,dt=0,Mt=0;let lt=0,nt,H,X;for(;;){for(nt=x,H=nt+1,W[nt]=Y[lt],K[nt]=D[lt],W[H]=Y[lt+1],K[H]=D[lt+1],Y[lt]=Y[lt+1]=dt,D[lt]=D[lt+1]=Mt;;){for(X=0,y=2;y<z;y+=2)H<2*x-1&&Y[y]===W[H]&&D[y]===K[H]&&(H++,W[H]=Y[y+1],K[H]=D[y+1],Y[y]=Y[y+1]=dt,D[y]=D[y+1]=Mt,X++),nt>0&&Y[y+1]===W[nt]&&D[y+1]===K[nt]&&(nt--,W[nt]=Y[y],K[nt]=D[y],Y[y]=Y[y+1]=dt,D[y]=D[y+1]=Mt,X++);if(X===0)break}for(nt+1<H&&nt>=0&&n(J,W,K,nt,H,M),lt=0,y=2;y<z;y+=2)if(Y[y]!==dt&&D[y]!==Mt){lt=y;break}if(lt===0)break}}}class re{constructor(t,i,e,n,c,k,a){let r=[e,n];if(t){r=new Float32Array(t.length);for(let y=0;y<t.length;++y)r[y]=i(t[y])}Object.assign(this,{grz_min:e,grz_max:n,dolines:c,donormals:k,dogrid:a}),this.loop=0;const d=[],g=[],$=[],s=new Float32Array(18),h=new Float32Array(6),p=(r.at(-1)-r.at(0))/r.length/100;let l=0,o=null,f=0,m=0,P=null,_=0,j=[],u=0,C=0,B=0;function M(y,S,w,A){return y<S-A?-1:y>w+A?1:0}this.createNormIndex=function(y){y.donormals&&(j=new Int32Array((y.i2-y.i1)*(y.j2-y.j1)*8).fill(-1))},this.createBuffers=function(){if(this.loop){for(let y=1;y<r.length;++y)d[y]&&(g[y]=new Float32Array(d[y]*9),$[y]=0);this.dolines&&l>0&&(o=new Float32Array(l*6)),this.dogrid&&m>0&&(P=new Float32Array(m*6))}},this.addLineSegment=function(y,S,w,A,T,I){if(!this.dolines)return;const v=M(w,this.grz_min,this.grz_max,0),N=M(I,this.grz_min,this.grz_max,0);if(!(v===N&&v)){if(!this.loop)return++l;if(v){const G=I-w;w=v<0?this.grz_min:this.grz_max,y=A-(A-y)/G*(I-w),S=T-(T-S)/G*(I-w)}if(N){const G=w-I;I=N<0?this.grz_min:this.grz_max,A=y-(y-A)/G*(w-I),T=S-(S-T)/G*(w-I)}o[f]=y,o[f+1]=S,o[f+2]=w,f+=3,o[f]=A,o[f+1]=T,o[f+2]=I,f+=3}};function b(y,S,w,A,T,I,v,N){u>=s.length&&console.log("more than 6 points???");const G=(v-w)/(I-w);let Q=3;C&&Math.abs(G)<Math.abs(C)&&(s[u]=s[u-3],s[u+1]=s[u-2],s[u+2]=s[u-1],u-=3,Q=6),s[u]=y+G*(A-y),s[u+1]=S+G*(T-S),s[u+2]=v,N&&P&&(h[B]=s[u],h[B+1]=s[u+1],h[B+2]=s[u+2],B+=3),u+=Q,C=G}function x(y,S,w,A){const T=((w-S.i1)*(S.j2-S.j1)+(A-S.j1))*8;if(j[T]>=0)return console.error("More than 8 vertexes for the bin");const I=T+8+j[T];j[T]--,j[I]=y}this.addMainTriangle=function(y,S,w,A,T,I,v,N,G,Q,U,at,q){for(let R=1;R<r.length;++R){let W=M(w,r[R-1],r[R],p),K=M(I,r[R-1],r[R],p),tt=M(G,r[R-1],r[R],p),J=W+K+tt;if(R>1&&R===r.length-1&&J===3&&w<=this.grz_max&&(W=K=tt=J=0),J===3)continue;if(J===-3)return;if(!this.loop){let z=Math.abs(K-W)+Math.abs(tt-K)+Math.abs(W-tt);W===0&&++z,K===0&&++z,tt===0&&++z,(z===1||z===2)&&console.error(`FOUND npnts = ${z}`),z>2&&(d[R]===void 0&&(d[R]=0),d[R]+=z-2),(W>0||K>0||tt>0)&&(W!==K||K!==tt||tt!==W)&&++m;continue}if(B=0,u=0,W===0&&(s[u]=y,s[u+1]=S,s[u+2]=w,u+=3),W!==K&&(C=0,(W<0||K<0)&&b(y,S,w,A,T,I,r[R-1]),(W>0||K>0)&&b(y,S,w,A,T,I,r[R],!0)),K===0&&(s[u]=A,s[u+1]=T,s[u+2]=I,u+=3),K!==tt&&(C=0,(K<0||tt<0)&&b(A,T,I,v,N,G,r[R-1]),(K>0||tt>0)&&b(A,T,I,v,N,G,r[R],!0)),tt===0&&(s[u]=v,s[u+1]=N,s[u+2]=G,u+=3),tt!==W&&(C=0,(tt<0||W<0)&&b(v,N,G,y,S,w,r[R-1]),(tt>0||W>0)&&b(v,N,G,y,S,w,r[R],!0)),u===0)continue;if(u<9){console.log(`found ${u/3} points, must be at least 3`);continue}if(P&&B===6){for(let z=0;z<6;++z)P[_+z]=h[z];_+=6}const Y=g[R];let D=$[R];this.donormals&&u===9&&(x(D,U,at,q),x(D+3,U,at+1,Q?q+1:q),x(D+6,U,Q?at:at+1,q+1));for(let z=3;z<u-3;z+=3)Y[D]=s[0],Y[D+1]=s[1],Y[D+2]=s[2],D+=3,Y[D]=s[z],Y[D+1]=s[z+1],Y[D+2]=s[z+2],D+=3,Y[D]=s[z+3],Y[D+1]=s[z+4],Y[D+2]=s[z+5],D+=3;$[R]=D}},this.callFuncs=function(y,S){for(let w=1;w<r.length;++w)g[w]&&y&&y(w,g[w],j);o&&S&&(l*6!==f&&console.error(`SURF lines mismmatch nsegm=${l} lindx=${f} diff=${l*6-f}`),S(!1,o)),P&&S&&(m*6!==_&&console.error(`SURF grid draw mismatch ngridsegm=${m} gindx=${_} diff=${m*6-_}`),S(!0,P))}}}function se(mt,t,i,e,n){const c=t.grz,k=t.original?t.origx:t.grx,a=t.original?t.origy:t.gry,r=new re(i,t.grz,t.grz_min,t.grz_max,t.dolines,t.donormals,t.dogrid);let d,g,$,s,h,p,l,o,f,m;for(r.createNormIndex(t),r.loop=0;r.loop<2;++r.loop)for(r.createBuffers(),d=t.i1;d<t.i2-1;++d)for($=t.original?.5*(k[d]+k[d+1]):k[d],s=t.original?.5*(k[d+1]+k[d+2]):k[d+1],g=t.j1;g<t.j2-1;++g)h=t.original?.5*(a[g]+a[g+1]):a[g],p=t.original?.5*(a[g+1]+a[g+2]):a[g+1],l=c(mt.getBinContent(d+1,g+1)),o=c(mt.getBinContent(d+1,g+2)),f=c(mt.getBinContent(d+2,g+1)),m=c(mt.getBinContent(d+2,g+2)),r.addMainTriangle($,h,l,s,p,m,$,p,o,!0,t,d,g),r.addMainTriangle($,h,l,s,h,f,s,p,m,!1,t,d,g),r.addLineSegment($,p,o,$,h,l),r.addLineSegment($,h,l,s,h,f),d===t.i2-2&&r.addLineSegment(s,h,f,s,p,m),g===t.j2-2&&r.addLineSegment($,p,o,s,p,m);r.callFuncs(e,n)}let le=class Et extends Nt{#t;#i;#n;#s;#r;#e;get _wheel_zoomy(){return!0}cleanup(){delete this.tt_handle,this.#e=void 0,super.cleanup()}getHisto(){const t=super.getHisto();if(t?._typename===Ct)switch(t.$getBinContent||(t.$getBinContent=t.getBinContent),this.getOptions().Profile2DProj){case"B":t.getBinContent=t.getBinEntries;break;case"C=E":t.getBinContent=function(i,e){return this.getBinError(this.getBin(i,e))};break;case"W":t.getBinContent=function(i,e){return this.$getBinContent(i,e)*this.getBinEntries(i,e)};break;default:t.getBinContent=t.$getBinContent;break}return t}isProjection(){return this.#t}toggleProjection(t,i){(t==="Projections"||t==="Off")&&(t="");const e=a=>{if(a==="all"||a==="ALL")return 1e4;const r=parseInt(a);return r&&Number.isInteger(r)?r:1};let n=i,c=i;if(Lt(t)&&t.indexOf("XY")===0){const a=t.length>2?t.slice(2):"";t="XY",n=c=parseInt(a)||1}else if(Lt(t)&&t.length>1){const a=t.indexOf("_");a>0&&t[0]==="X"&&t[a+1]==="Y"?(n=e(t.slice(1,a)),c=e(t.slice(a+2)),t="XY"):a>0&&t[0]==="Y"&&t[a+1]==="X"?(c=e(t.slice(1,a)),n=e(t.slice(a+2)),t="XY"):(n=c=e(t.slice(1)),t=t[0])}if(!n&&!c&&(n=c=1),t&&this.#t===t)if(this.#i===n&&this.#n===c)t="";else{this.#i=n,this.#n=c;return}delete this.proj_hist;const k=this.#t===t?"":t;return this.#i=n,this.#n=c,this.#t="",this.provideSpecialDrawArea(k).then(()=>(this.#t=k,this.redrawProjection()))}async redrawProjection(t,i,e,n){if(!this.#t)return!1;if(n===void 0){if(!this.tt_handle)return;t=Math.round((this.tt_handle.i1+this.tt_handle.i2)/2),i=t+1,e=Math.round((this.tt_handle.j1+this.tt_handle.j2)/2),n=e+1}const c=this.getCanvPainter();if(c&&!c.isReadonly()&&this.hasSnapId())return(this.#t==="X"||this.#t==="XY")&&!c.websocketTimeout("projX")&&c.sendWebsocket(`EXECANDSEND:DXPROJ:${this.getSnapId()}:ProjectionX("_projx",${e+1},${n},"")`)&&c.websocketTimeout("projX",1e3),(this.#t==="Y"||this.#t==="XY")&&!c.websocketTimeout("projY")&&c.sendWebsocket(`EXECANDSEND:DYPROJ:${this.getSnapId()}:ProjectionY("_projy",${t+1},${i},"")`)&&c.websocketTimeout("projY",1e3),!0;if(this.doing_projection)return!1;this.doing_projection=!0;const k=this.getHisto(),a=()=>{const g=Gt(zt,this.nbinsx);return Object.assign(g.fXaxis,k.fXaxis),g.fName="xproj",g.fTitle="X projection",g},r=()=>{const g=Gt(zt,this.nbinsy);return Object.assign(g.fXaxis,k.fYaxis),g.fName="yproj",g.fTitle="Y projection",g},d=(g,$)=>{let s=0,h=-1;if(g==="X"){for(let p=0;p<this.nbinsx;++p){let l=0;for(let o=e;o<n;++o)l+=k.getBinContent(p+1,o+1);$.setBinContent(p+1,l)}$.fTitle="X projection "+(e+1===n?`bin ${n}`:`bins [${e+1} .. ${n}]`),this.tt_handle&&(s=this.tt_handle.i1+1,h=this.tt_handle.i2)}else{for(let p=0;p<this.nbinsy;++p){let l=0;for(let o=t;o<i;++o)l+=k.getBinContent(o+1,p+1);$.setBinContent(p+1,l)}$.fTitle="Y projection "+(t+1===i?`bin ${i}`:`bins [${t+1} .. ${i}]`),this.tt_handle&&(s=this.tt_handle.j1+1,h=this.tt_handle.j2)}s<h&&($.fXaxis.fFirst=s,$.fXaxis.fLast=h,$.fXaxis.SetBit(Jt.kAxisRange,s!==1||h!==$.fXaxis.fNbins)),$.fEntries=0,$.fTsumw=0};if(!this.proj_hist)switch(this.#t){case"X":this.proj_hist=a();break;case"XY":this.proj_hist=a(),this.proj_hist2=r();break;default:this.proj_hist=r()}return this.#t==="XY"?(d("X",this.proj_hist),d("Y",this.proj_hist2),this.drawInSpecialArea(this.proj_hist,"","X").then(()=>this.drawInSpecialArea(this.proj_hist2,"","Y")).then(g=>(delete this.doing_projection,g))):(d(this.#t,this.proj_hist),this.drawInSpecialArea(this.proj_hist).then(g=>(delete this.doing_projection,g)))}executeMenuCommand(t,i){return super.executeMenuCommand(t,i)?!0:t.fName==="SetShowProjectionX"||t.fName==="SetShowProjectionY"?(this.toggleProjection(t.fName[17],i&&parseInt(i)?parseInt(i):1),!0):t.fName==="SetShowProjectionXY"?(this.toggleProjection("X"+i.replaceAll(",","_Y")),!0):!1}fillHistContextMenu(t){if(!this.isTH2Poly()&&this.getPadPainter()?.isCanvas()){let n=this.#t||"";n&&(n+=this.#i),this.#i!==this.#n&&this.#t==="XY"&&(n=`X${this.#i}_Y${this.#n}`);const c=["1","2","3","5","10","all"];n&&c.unshift(""),t.sub("Projections",()=>t.input("Input projection kind X1 or XY2 or X3_Y4",n,"string").then(k=>this.toggleProjection(k))),["X","Y","XY"].forEach(k=>{t.column(),c.forEach(a=>{const r=a?k+a:"Off";t.addchk(n===r,r,r,d=>this.toggleProjection(d))}),t.endcolumn()}),t.endsub()}this.isTH2Poly()||t.add("Auto zoom-in",()=>this.autoZoom());const i=this.getSupportedDrawOptions(),e=this.getOptions();t.addDrawMenu("Draw with",i,n=>{if(n.indexOf(Vt)===0)return this.showInspector(n);const c=e.Project;this.decodeOptions(n),c===e.Project||this.mode3d?this.interactiveRedraw("pad","drawopt"):this.toggleProjection(e.Project)}),(e.Color||e.Contour||e.Hist||e.Surf||e.Lego===12||e.Lego===14)&&this.fillPaletteMenu(t,!0)}clickButton(t){const i=super.clickButton(t);if(i)return i;if(this.isMainPainter())switch(t){case"ToggleColor":return this.toggleColor();case"Toggle3D":return this.toggleMode3D()}return!1}fillToolbar(){super.fillToolbar(!0);const t=this.getPadPainter(),i=this.getOptions();t&&(!this.isTH2Poly()&&!i.Axis&&t.addPadButton("th2color","Toggle color","ToggleColor"),i.Axis||t.addPadButton("th2colorz","Toggle color palette","ToggleColorZ"),t.addPadButton("th2draw3d","Toggle 3D mode","Toggle3D"),t.showPadButtons())}toggleColor(){const t=this.getOptions();return t.Mode3D?(t.Mode3D=!1,t.Color=!0):(t.Color=!t.Color,t.Scat=!t.Color),this.#s=!0,this.copyOptionsToOthers(),this.interactiveRedraw("pad","drawopt")}autoZoom(){if(this.isTH2Poly())return;const t=this.getSelectIndex("x","left",-1),i=this.getSelectIndex("x","right",1),e=this.getSelectIndex("y","left",-1),n=this.getSelectIndex("y","right",1),c=this.getHisto();if(t===i||e===n)return;let k=c.getBinContent(t+1,e+1);for(let o=t;o<i;++o)for(let f=e;f<n;++f)k=Math.min(k,c.getBinContent(o+1,f+1));if(k>0)return;let a=i,r=t,d=n,g=e;for(let o=t;o<i;++o)for(let f=e;f<n;++f)c.getBinContent(o+1,f+1)>k&&(o<a&&(a=o),o>=r&&(r=o+1),f<d&&(d=f),f>=g&&(g=f+1));let $,s,h,p,l=!1;if(a===r-1&&a>t+1&&r<i-1&&(a--,r++),d===g-1&&d>e+1&&g<n-1&&(d--,g++),(a>t||r<i)&&a<r-1&&($=c.fXaxis.GetBinLowEdge(a+1),s=c.fXaxis.GetBinLowEdge(r+1),l=!0),(d>e||g<n)&&d<g-1&&(h=c.fYaxis.GetBinLowEdge(d+1),p=c.fYaxis.GetBinLowEdge(g+1),l=!0),l)return this.getFramePainter()?.zoom($,s,h,p)}scanContent(t){if(t&&this.nbinsx&&this.nbinsy)return;const i=this.getObject(),e=this.getOptions();let n,c;if(this.extractAxesProperties(2),this.isTH2Poly()){this.gminposbin=null,this.gminbin=this.gmaxbin=0;for(let a=0,r=i.fBins.arr.length;a<r;++a){const d=i.fBins.arr[a].fContent;a===0&&(this.gminbin=this.gmaxbin=d),d<this.gminbin?this.gminbin=d:d>this.gmaxbin&&(this.gmaxbin=d),d>0&&(this.gminposbin===null||this.gminposbin>d)&&(this.gminposbin=d)}}else for(this.gminbin=this.gmaxbin=i.getBinContent(1,1),this.gminposbin=null,n=0;n<this.nbinsx;++n)for(c=0;c<this.nbinsy;++c){const a=i.getBinContent(n+1,c+1);a<this.gminbin?this.gminbin=a:a>this.gmaxbin&&(this.gmaxbin=a),a>0&&(this.gminposbin===null||this.gminposbin>a)&&(this.gminposbin=a)}this.gminposbin===null&&this.gmaxbin>0&&(this.gminposbin=this.gmaxbin*1e-4);let k=this.gmaxbin||this.gminbin;if(!k&&i._typename===Ct){for(n=0;n<this.nbinsx&&!k;++n)for(c=0;c<this.nbinsy;++c)if(i.getBinEntries(n+1,c+1)){k=!0;break}}e.Axis>0?this.draw_content=!1:this.isTH2Poly()?(this.draw_content=k||e.Line||e.Fill||e.Mark,!this.draw_content&&e.Zero&&(this.draw_content=!0,e.Line=1)):this.draw_content=k||e.ShowEmpty}getUserRanges(){const t=this.getHisto();return{minx:t.fXaxis.fXmin,maxx:t.fXaxis.fXmax,miny:t.fYaxis.fXmin,maxy:t.fYaxis.fXmax}}countStat(t,i){const e=this.getHisto(),n=this.getOptions(),c=e.fXaxis,k=e.fYaxis,a=this.getHistGrFuncs(),r={name:e.fName,entries:0,eff_entries:0,integral:0,meanx:0,meany:0,rmsx:0,rmsy:0,matrix:[0,0,0,0,0,0,0,0,0],xmax:0,ymax:0,wmax:null,skewx:0,skewy:0,skewd:0,kurtx:0,kurty:0,kurtd:0},d=!a.isAxisZoomed("x")&&!a.isAxisZoomed("y")&&Math.abs(e.fTsumw)>1e-300&&!t&&!n.cutg;let g=0,$=0,s=0,h=0,p=0,l=0,o,f,m,P,_,j,u,C,B;if(!_t(t)&&n.cutg&&(t=(M,b)=>n.cutg.IsInside(M,b)),this.isTH2Poly()){const M=e.fBins.arr.length;let b,x,y,S,w,A,T;for(b=0;b<M;++b){for(x=e.fBins.arr[b],o=x.fXmin>a.scale_xmax?2:x.fXmax<a.scale_xmin?0:1,f=x.fYmin>a.scale_ymax?2:x.fYmax<a.scale_ymin?0:1,m=P=T=0,S=x.fPoly,A=1,S._typename===kt&&(A=x.fPoly.fGraphs.arr.length,S=null),w=0;w<A;++w)for((!S||w>0)&&(S=x.fPoly.fGraphs.arr[w]),y=0;y<S.fNpoints;++y)++T,m+=S.fX[y],P+=S.fY[y];T>1&&(m/=T,P/=T),_=x.fContent,r.entries+=_,r.matrix[f*3+o]+=_,!(o!==1||f!==1||t&&!t(m,P))&&((r.wmax===null||_>r.wmax)&&(r.wmax=_,r.xmax=m,r.ymax=P),d||(g+=_,$+=_*_,s+=m*_,h+=P*_,p+=m*m*_,l+=P*P*_))}}else{j=this.getSelectIndex("x","left"),u=this.getSelectIndex("x","right"),C=this.getSelectIndex("y","left"),B=this.getSelectIndex("y","right");for(let M=0;M<=this.nbinsx+1;++M){o=M<=j?0:M>u?2:1,m=c.GetBinCoord(M-.5);for(let b=0;b<=this.nbinsy+1;++b)f=b<=C?0:b>B?2:1,P=k.GetBinCoord(b-.5),_=e.getBinContent(M,b),r.entries+=_,r.matrix[f*3+o]+=_,!(o!==1||f!==1||t&&!t(m,P))&&((r.wmax===null||_>r.wmax)&&(r.wmax=_,r.xmax=m,r.ymax=P),d||(g+=_,$+=_*_,s+=m*_,h+=P*_,p+=m**2*_,l+=P**2*_))}}if(d&&(g=e.fTsumw,$=e.fTsumw2,s=e.fTsumwx,p=e.fTsumwx2,h=e.fTsumwy,l=e.fTsumwy2),Math.abs(g)>1e-300&&(r.meanx=s/g,r.meany=h/g,r.rmsx=Math.sqrt(Math.abs(p/g-r.meanx**2)),r.rmsy=Math.sqrt(Math.abs(l/g-r.meany**2))),r.wmax===null&&(r.wmax=0),r.integral=g,e.fEntries>0&&(r.entries=e.fEntries),r.eff_entries=$?g*g/$:Math.abs(g),i&&!this.isTH2Poly()){let M=0,b=0,x=0,y=0,S=0,w;for(let N=j;N<u;++N){m=c.GetBinCoord(N+.5);for(let G=C;G<B;++G)P=k.GetBinCoord(G+.5),!(t&&!t(m,P))&&(w=e.getBinContent(N+1,G+1),S+=w,M+=w*Math.pow(m-r.meanx,3),b+=w*Math.pow(P-r.meany,3),x+=w*Math.pow(m-r.meanx,4),y+=w*Math.pow(P-r.meany,4))}const A=Math.pow(r.rmsx,3),T=Math.pow(r.rmsy,3),I=Math.pow(r.rmsx,4),v=Math.pow(r.rmsy,4);S*A&&(r.skewx=M/(S*A)),S*T&&(r.skewy=b/(S*T)),r.skewd=r.eff_entries>0?Math.sqrt(6/r.eff_entries):0,S*I&&(r.kurtx=x/(S*I)-3),S*v&&(r.kurty=y/(S*v)-3),r.kurtd=r.eff_entries>0?Math.sqrt(24/r.eff_entries):0}return r}fillStatistic(t,i,e){if(this.isIgnoreStatsFill())return!1;i===1&&(i=1111);const n=Math.floor(i%10),c=Math.floor(i/10)%10,k=Math.floor(i/100)%10,a=Math.floor(i/1e3)%10,r=Math.floor(i/1e4)%10,d=Math.floor(i/1e5)%10,g=Math.floor(i/1e6)%10,$=Math.floor(i/1e7)%10,s=Math.floor(i/1e8)%10,h=this.countStat(void 0,$>0||s>0);if(t.clearPave(),n>0&&t.addText(h.name),c>0&&t.addText("Entries = "+t.format(h.entries,"entries")),k>0&&(t.addText("Mean x = "+t.format(h.meanx)),t.addText("Mean y = "+t.format(h.meany))),a>0&&(t.addText("Std Dev x = "+t.format(h.rmsx)),t.addText("Std Dev y = "+t.format(h.rmsy))),g>0&&t.addText("Integral = "+t.format(h.matrix[4],"entries")),$===2?(t.addText(`Skewness x = ${t.format(h.skewx)} #pm ${t.format(h.skewd)}`),t.addText(`Skewness y = ${t.format(h.skewy)} #pm ${t.format(h.skewd)}`)):$>0&&(t.addText(`Skewness x = ${t.format(h.skewx)}`),t.addText(`Skewness y = ${t.format(h.skewy)}`)),s===2?(t.addText(`Kurtosis x = ${t.format(h.kurtx)} #pm ${t.format(h.kurtd)}`),t.addText(`Kurtosis y = ${t.format(h.kurty)} #pm ${t.format(h.kurtd)}`)):s>0&&(t.addText(`Kurtosis x = ${t.format(h.kurtx)}`),t.addText(`Kurtosis y = ${t.format(h.kurty)}`)),r>0||d>0){const p=l=>h.matrix[l].toFixed(0);t.addText(`${p(6)} | ${p(7)} | ${p(7)}`),t.addText(`${p(3)} | ${p(4)} | ${p(5)}`),t.addText(`${p(0)} | ${p(1)} | ${p(2)}`)}return e&&t.fillFunctionStat(this.findFunction(Zt),e,2),!0}drawBinsColor(){const t=this.getHisto(),i=this.getOptions(),e=this.prepareDraw(),n=this.getContour(),c=this.getHistPalette(),k=[],a=t.fSumw2?.length,r=i.ShowEmpty,d=i.Color!==7||e.xbar1===0&&e.xbar2===1,g=i.Color!==7||e.ybar1===0&&e.ybar2===1,$=n.getPaletteIndex(c,0);let s,h,p,l,o,f,m,P=null,_=!i.Zero,j;const u=i.cutg,C=()=>{P.path+=`h${s}v${P.y1-P.y2}h${-s}z`,P=null};!_&&!r&&$===null&&(_=!0),_&&t?._typename===Ct&&(_=1);for(let B=e.i1;B<e.i2;++B){s=e.grx[B+1]-e.grx[B]||1,d?p=e.grx[B]:(p=Math.round(e.grx[B]+s*e.xbar1),s=Math.round(s*(e.xbar2-e.xbar1))||1);for(let M=e.j2-1;M>=e.j1;--M){if(o=t.getBinContent(B+1,M+1),f=o===0&&(!a||t.fSumw2[t.getBin(B+1,M+1)]===0),j=f&&(_===1?!t.getBinEntries(B+1,M+1):_),j||u&&!u.IsInside(t.fXaxis.GetBinCoord(B+.5),t.fYaxis.GetBinCoord(M+.5))){P&&C();continue}if(m=n.getPaletteIndex(c,o),m===null)if(f&&(r||_===1))m=$||0;else{P&&C();continue}h=e.gry[M]-e.gry[M+1]||1,g?l=e.gry[M+1]:(l=Math.round(e.gry[M]-h*e.ybar2),h=Math.round(h*(e.ybar2-e.ybar1))||1);const b=`M${p},${l}`;let x=k[m];if(!x)x=k[m]={path:b};else if(g&&x===P){x.y1=l+h;continue}else{const y=p-x.x1,S=l-x.y2;if(y||S){const w=`m${y},${S}`;x.path+=w.length<b.length?w:b}}P&&C(),x.x1=p,x.y2=l,g?(x.y1=l+h,P=x):x.path+=`h${s}v${h}h${-s}z`}P&&C()}return k.forEach((B,M)=>{B&&this.appendPath(B.path).attr("fill",c.getColor(M))}),e}drawBinsPolar(){const t=this.getHisto(),i=this.getOptions(),e=this.prepareDraw(),n=this.getContour(),c=this.getHistPalette(),k=[],a=t.fSumw2?.length,r=i.ShowEmpty,d=n.getPaletteIndex(c,0);let g,$,s,h=!i.Zero,p;const l=i.cutg;!h&&!r&&d===null&&(h=!0),h&&t?._typename===Ct&&(h=1),e.getBinPath=function(o,f){const m=2*Math.PI*Math.max(0,this.grx[o])/this.width,P=2*Math.PI*Math.min(this.grx[o+1],this.width)/this.width,_=Math.min(this.gry[f],this.height)/this.height,j=Math.max(0,this.gry[f+1])/this.height,u=P-m>Math.PI?1:0;if(P<=m||_<=j)return"";const C=this.width/2,B=this.height/2,M=j*this.width/2,b=_*this.width/2,x=j*this.height/2,y=_*this.height/2,S=C+M*Math.cos(m),w=C+M*Math.cos(P),A=B+x*Math.sin(m),T=B+x*Math.sin(P),I=C+b*Math.cos(m),v=C+b*Math.cos(P),N=B+y*Math.sin(m),G=B+y*Math.sin(P);return`M${S.toFixed(2)},${A.toFixed(2)}A${M.toFixed(2)},${x.toFixed(2)},0,${u},1,${w.toFixed(2)},${T.toFixed(2)}L${v.toFixed(2)},${G.toFixed(2)}A${b.toFixed(2)},${y.toFixed(2)},0,${u},0,${I.toFixed(2)},${N.toFixed(2)}Z`},e.findBin=function(o,f){const m=this.width/2,P=this.height/2;let _=Math.atan2((f-P)/this.height,(o-m)/this.width),j,u;const C=Math.abs(Math.cos(_))>.5?(o-m)/Math.cos(_)/this.width*2:(f-P)/Math.sin(_)/this.height*2;for(_<0&&(_+=2*Math.PI),j=this.i1;j<this.i2;++j){const B=2*Math.PI*this.grx[j]/this.width,M=2*Math.PI*this.grx[j+1]/this.width;if(B<=_&&_<=M)break}for(u=this.j1;u<this.j2;++u){const B=this.gry[u]/this.height;if(this.gry[u+1]/this.height<=C&&C<=B)break}return{i:j,j:u}};for(let o=e.i1;o<e.i2;++o)for(let f=e.j2-1;f>=e.j1;--f){if(g=t.getBinContent(o+1,f+1),$=g===0&&(!a||t.fSumw2[t.getBin(o+1,f+1)]===0),p=$&&(h===1?!t.getBinEntries(o+1,f+1):h),p||l&&!l.IsInside(t.fXaxis.GetBinCoord(o+.5),t.fYaxis.GetBinCoord(f+.5)))continue;if(s=n.getPaletteIndex(c,g),s===null)if($&&(r||h===1))s=d||0;else continue;const m=e.getBinPath(o,f);if(!m)continue;const P=k[s];P?P.path+=m:k[s]={path:m}}return k.forEach((o,f)=>{o&&this.appendPath(o.path).attr("fill",c.getColor(f))}),e}drawBinsProjected(){const t=this.prepareDraw({rounding:!1,nozoom:!0,extra:100,original:!0}),i=this.getHistGrFuncs(),e=this.getContourLevels(),n=this.getHistPalette(),c=_t(i.getProjectionFunc)?i.getProjectionFunc():(k,a)=>({x:k,y:a});return t.grz=k=>k,t.grz_min=e.at(0),t.grz_max=e.at(-1),se(this.getHisto(),t,e,(k,a)=>{let r="",d,g;for(let $=0;$<a.length;$+=3){const s=c(a[$],a[$+1]),h=Math.round(i.grx(s.x)),p=Math.round(i.gry(s.y));if($===0)r=`M${h},${p}`;else{if(h===d&&p===g)continue;$%9===0?r+=`m${h-d},${p-g}`:p===g?r+=`h${h-d}`:h===d?r+=`v${p-g}`:r+=`l${h-d},${p-g}`}d=h,g=p}this.appendPath(r).style("fill",n.calcColor(k,e.length))}),t}drawBinsContour(){const t=this.prepareDraw({rounding:!1,extra:100}),i=this.getContourLevels(),e=this.getHistPalette(),n=this.getOptions(),c=(a,r)=>{const d=a.x2-a.x1,g=a.y2-a.y1,$=r.x2-r.x1,s=r.y2-r.y1,h=d*s-$*g;if(h===0)return 0;const p=h>0,l=a.x1-r.x1,o=a.y1-r.y1,f=d*o-g*l;if(f<0===p)return null;const m=$*o-s*l;if(m<0===p||f>h===p||m>h===p)return null;const P=m/h;return{x:Math.round(a.x1+P*d),y:Math.round(a.y1+P*g)}},k=(a,r,d,g,$,s)=>{let h="",p,l,o,f,m=!1,P,_,j;for(let w=d;w<=g;++w){if(_=Math.round(a[w]),j=Math.round(r[w]),!h)h=`M${_},${j}`,o=_,f=j;else if(w===g&&d!==g&&_===o&&j===f){if(!m)return"";h+="z",$=!1,P=!0}else{const A=_-p,T=j-l;A?(m=!0,h+=T?`l${A},${T}`:`h${A}`):T&&(m=!0,h+=`v${T}`)}p=_,l=j}if(!$||P||!s)return $?h+"z":h;const u=[{x:0,y:0},{x:t.width,y:0},{x:t.width,y:t.height},{x:0,y:t.height}],C=(w,A)=>{const T={x1:a[w],y1:r[w],x2:2*a[w]-a[w+A],y2:2*r[w]-r[w+A]};for(let I=0;I<4;++I){const v=c(T,{x1:u[I].x,y1:u[I].y,x2:u[(I+1)%4].x,y2:u[(I+1)%4].y});if(v)return v.indx=I+.5,v}return null};let B,M;for(d--;d<g-1&&!B;)B=C(++d,1);if(!B)return"";for(g++;d<g-1&&!M;)M=C(--g,-1);if(!M)return"";let b=k(a,r,d,g),x=M.indx;const y=1,S=y*.5;for(b+=`L${M.x},${M.y}`;Math.abs(x-B.indx)>.1;)x=Math.round(x+S)%4,b+=`L${u[x].x},${u[x].y}`,x+=S;return b+`L${B.x},${B.y}z`};return n.Contour===14&&this.appendPath(`M0,0h${t.width}v${t.height}h${-t.width}z`).style("fill",e.calcColor(0,i.length)),ne(this.getHisto(),t,i,e,(a,r,d,g,$,s)=>{const h=e.getColor(a);let p=h,l;switch(n.Contour){case 1:break;case 11:p="none",l=this.createAttLine({color:h,std:!1});break;case 12:p="none",l=this.createAttLine({color:1,style:s%5+1,width:1,std:!1});break;case 13:p="none",l=this.lineatt;break}const o=k(r,d,g,$,p!=="none",!0);o&&this.appendPath(o).style("fill",p).call(l?l.func:()=>{})}),t.hide_only_zeros=!0,t}getGrNPoints(t){const i=t.fX,e=t.fY;let n=t.fNpoints;return n>2&&i[0]===i[n-1]&&e[0]===e[n-1]&&n--,n}createPolyGr(t,i,e){let n="",c=0,k=0;const a=i.fX,r=i.fY,d=()=>{c&&(n+="h"+c,c=0),k&&(n+="v"+k,k=0)},g=(o,f,m,P)=>{const _=Math.sqrt((o-m)**2+(f-P)**2);e.sumx+=(o+m)*_/2,e.sumy+=(f+P)*_/2,e.sum+=_},$=this.getGrNPoints(i);if($<2)return"";const s=Math.round(t.grx(a[0])),h=Math.round(t.gry(r[0]));let p=s,l=h;for(let o=1;o<$;++o){const f=Math.round(t.grx(a[o])),m=Math.round(t.gry(r[o])),P=f-p,_=m-l;e&&g(p,l,f,m),(P||_)&&(P===0?((k===0||_<0!=k<0)&&d(),k+=_):_===0?((c===0||P<0!=c<0)&&d(),c+=P):(d(),n+=`l${P},${_}`),p=f,l=m)}return e&&g(p,l,s,h),d(),n?`M${s},${h}`+n+"z":""}createPolyBin(t,i){const e=i.fPoly._typename===kt?i.fPoly.fGraphs.arr:[i.fPoly];let n="";for(let c=0;c<e.length;++c)n+=this.createPolyGr(t,e[c]);return n}async drawPolyBins(){const t=this.getHisto(),i=this.getOptions(),e=this.getHistGrFuncs(),n=i.Color||!i.Line&&!i.Fill&&!i.Text&&!i.Mark,c=i.Line||i.Text&&!n,k=i.Fill&&!n,a=i.Mark,r=e.getFrameHeight(),d=[],g=t.fBins.arr.length;let $,s,h="",p="",l,o,f,m=null,P=c,_=k,j=a;this.maxbin=this.gmaxbin,this.minbin=this.gminbin,this.minposbin=this.gminposbin;const u=n?this.getContour(!0):null,C=u?this.getHistPalette():null,B=w=>w.fXmin>e.scale_xmax||w.fXmax<e.scale_xmin||w.fYmin>e.scale_ymax||w.fYmax<e.scale_ymin;for(f=0;f<g;++f){if(l=t.fBins.arr[f],B(l))continue;const w=l.fPoly._typename===kt?l.fPoly.fGraphs.arr:[l.fPoly];for(let A=0;A<w.length;++A){const T=w[A];if(!m){m=T;continue}P&&(m.fLineColor!==T.fLineColor||m.fLineWidth!==T.fLineWidth||m.fLineStyle!==T.fLineStyle)&&(P=!1),_&&(m.fFillColor!==T.fFillColor||m.fFillStyle!==T.fFillStyle)&&(_=!1),j&&(m.fMarkerColor!==T.fMarkerColor||m.fMarkerStyle!==T.fMarkerStyle||m.fMarkerSize!==T.fMarkerSize)&&(j=!1)}if(!P&&!_&&!j)break}const M=P&&m?this.createAttLine(m):null,b=_&&m?this.createAttFill(m):null,x=j&&m?this.createAttMarker({attr:m,style:i.MarkStyle,std:!1}):null,y=!n&&(c?P:!0)&&(k?_:!0);for(f=0;f<g;++f){if(l=t.fBins.arr[f],B(l))continue;const w=l.fContent||i.Zero,A=l.fPoly._typename===kt?l.fPoly.fGraphs.arr:[l.fPoly];$=n&&w?u.getPaletteIndex(C,l.fContent):null;const T=i.Text&&w?{bin:l,sumx:0,sumy:0,sum:0}:null;for(let I=0;I<A.length;++I){const v=A[I];if(x){const N=this.getGrNPoints(v);for(let G=0;G<N;++G)p+=x.create(e.grx(v.fX[G]),e.gry(v.fY[G]))}s=this.createPolyGr(e,v,T),s&&(y?h+=s:($!==null||k||c)&&(o=this.appendPath(s),n&&$!==null?o.style("fill",C.getColor($)):k?o.call(this.createAttFill(v).func):o.style("fill","none"),c&&o.call(this.createAttLine(v).func)))}T?.sum&&d.push(T)}if(y&&(o=this.appendPath(h),k&&b?o.call(b.func):o.style("fill","none"),c&&M&&o.call(M.func)),x&&!x.empty()&&p)this.appendPath(p).call(x.func);else if(a)for(f=0;f<g;++f){if(l=t.fBins.arr[f],B(l))continue;const w=l.fPoly._typename===kt?l.fPoly.fGraphs.arr:[l.fPoly];for(let A=0;A<w.length;++A){const T=w[A],I=this.getGrNPoints(T),v=this.createAttMarker({attr:T,style:i.MarkStyle,std:!1});if(!I||v.empty())continue;let N="";for(let G=0;G<I;++G)N+=v.create(e.grx(T.fX[G]),e.gry(T.fY[G]));this.appendPath(N).call(v.func)}}let S=Promise.resolve();if(d.length){const w=this.getColor(t.fMarkerColor),A=-1*i.TextAngle,T=this.getG().append("svg:g").attr("class","th2poly_text"),I=t.fMarkerSize!==1&&A?Math.round(.02*r*t.fMarkerSize):12;S=this.startTextDrawingAsync(42,I,T,I).then(()=>{for(f=0;f<d.length;++f){const v=d[f];l=v.bin,v.sum>0?(v.midx=Math.round(v.sumx/v.sum),v.midy=Math.round(v.sumy/v.sum)):(v.midx=Math.round(e.grx((l.fXmin+l.fXmax)/2)),v.midy=Math.round(e.gry((l.fYmin+l.fYmax)/2)));let N;i.TextKind?(N=l.fPoly?.fName,(!N||N==="Graph")&&(N=l.fNumber.toString())):N=Math.round(l.fContent)===l.fContent?l.fContent.toString():ct(l.fContent,et.fPaintTextFormat),this.drawText({align:22,x:v.midx,y:v.midy,rotate:A,text:N,color:w,latex:0,draw_g:T})}return this.finishTextDrawing(T,!0)})}return S.then(()=>({poly:!0}))}async drawBinsText(t){t||(t=this.prepareDraw({rounding:!1}));const i=this.getHisto(),e=this.getOptions(),n=e.cutg,c=this.getColor(i.fMarkerColor),k=-1*e.TextAngle,a=this.getG().append("svg:g").attr("class","th2_text"),r=e.TextKind==="E",d=r&&!e.TextLine?1:0,g=i.fBarOffset*.001,$=i.fMarkerSize===1||!k?20:Math.round(.02*i.fMarkerSize*t.height);return this.startTextDrawingAsync(42,$,a,$).then(()=>{for(let s=t.i1;s<t.i2;++s){const h=t.grx[s+1]-t.grx[s];for(let p=t.j1;p<t.j2;++p){const l=i.getBinContent(s+1,p+1);if(l===0&&!e.ShowEmpty||n&&!n.IsInside(i.fXaxis.GetBinCoord(s+.5),i.fYaxis.GetBinCoord(p+.5)))continue;const o=t.gry[p]-t.gry[p+1];let f=l===Math.round(l)?l.toString():ct(l,et.fPaintTextFormat);if(r){const u=this.getBinErrors(i,i.getBin(s+1,p+1),l);if(u.poisson){const C=`-${ct(u.low,et.fPaintTextFormat)} +${ct(u.up,et.fPaintTextFormat)}`;e.TextLine?f+=" "+C:f=`#splitmline{${f}}{${C}}`}else{const C=u.up===Math.round(u.up)?u.up.toString():ct(u.up,et.fPaintTextFormat);e.TextLine?f+="±"+C:f=`#splitmline{${f}}{#pm${C}}`}}let m,P,_,j;k?(m=Math.round(t.grx[s]+h*.5),P=Math.round(t.gry[p+1]+o*(.5+g)),_=j=0):(m=Math.round(t.grx[s]+h*.1),P=Math.round(t.gry[p+1]+o*(.1+g)),_=Math.round(h*.8),j=Math.round(o*.8)),this.drawText({align:22,x:m,y:P,width:_,height:j,rotate:k,text:f,color:c,latex:d,draw_g:a})}}return t.hide_only_zeros=!0,this.finishTextDrawing(a,!0)}).then(()=>t)}drawBinsArrow(){const t=this.getHisto(),i=this.getOptions(),e=i.cutg,n=this.prepareDraw({rounding:!1}),c=i.Color?this.getContour():null,k=i.Color?this.getHistPalette():null,a=(n.grx[n.i2]-n.grx[n.i1])/(n.i2-n.i1+1)/2,r=(n.gry[n.j2]-n.gry[n.j1])/(n.j2-n.j1+1)/2,d=(C,B)=>C?B?`l${C},${B}`:`h${C}`:B?`v${B}`:"",g=[];let $=1e-30,s,h,p,l,o="",f,m,P,_,j,u;for(let C=0;C<2;++C)for(let B=n.i1;B<n.i2;++B)for(let M=n.j1;M<n.j2;++M){if(e&&!e.IsInside(t.fXaxis.GetBinCoord(B+.5),t.fYaxis.GetBinCoord(M+.5)))continue;const b=t.getBinContent(B+1,M+1);if(B===n.i1?s=t.getBinContent(B+2,M+1)-b:B===n.i2-1?s=b-t.getBinContent(B,M+1):s=.5*(t.getBinContent(B+2,M+1)-t.getBinContent(B,M+1)),M===n.j1?h=t.getBinContent(B+1,M+2)-b:M===n.j2-1?h=b-t.getBinContent(B+1,M):h=.5*(t.getBinContent(B+1,M+2)-t.getBinContent(B+1,M)),C===0)$=Math.max($,Math.abs(s),Math.abs(h));else if(p=(n.grx[B]+n.grx[B+1])/2,l=(n.gry[M]+n.gry[M+1])/2,f=a*s/$,m=r*h/$,P=p-f,_=p+f,j=l-m,u=l+m,s=Math.round(_-P),h=Math.round(u-j),s||h){let x=`M${Math.round(P)},${Math.round(j)}${d(s,h)}`;if(Math.abs(s)>5||Math.abs(h)>5){const y=Math.sqrt(9/(s**2+h**2)),S=Math.round(y*(s+h)),w=Math.round(y*(s-h));(S||w)&&(x+=`m${-S},${w}${d(S,-w)}${d(-w,-S)}`)}if(k&&c){const y=c.getPaletteIndex(k,b);if(y!==null){const S=g[y];S?S.path+=x:g[y]={path:x}}}else o+=x}}return o&&this.appendPath(o).style("fill","none").call(this.lineatt.func),g.forEach((C,B)=>{if(C){const M=this.lineatt.color;this.lineatt.color=k.getColor(B),this.appendPath(C.path).attr("fill","none").call(this.lineatt.func),this.lineatt.color=M}}),n}drawBinsBox(){const t=this.getHisto(),i=this.getOptions(),e=this.prepareDraw({rounding:!1,zrange:!0}),n=Math.max(Math.abs(e.zmin),Math.abs(e.zmax)),c=Math.max(0,e.zmin),k=this.getPadPainter().getRootPad(!0),a=i.cutg;let r,d,g,$,s="",h="",p="",l="",o,f,m,P,_,j,u,C,B=!1,M=0;if((k?.fLogv??k?.fLogz)&&n>0){B=!0;const b=Math.log(n);c>0?M=Math.log(c):e.zminpos>=1&&e.zminpos<100?M=Math.log(.7):M=e.zminpos>0?Math.log(.7*e.zminpos):b-10,M>=b&&(M=b-10),C=1/(b-M)}else C=1/(n-c);for(r=e.i1;r<e.i2;++r)for(d=e.j1;d<e.j2;++d)if(g=t.getBinContent(r+1,d+1),$=Math.abs(g),!($===0||$<c)&&!(a&&!a.IsInside(t.fXaxis.GetBinCoord(r+.5),t.fYaxis.GetBinCoord(d+.5)))&&(o=B?$>0?Math.log($)-M:0:$-c,o=.5*(o<0?1:1-Math.sqrt(o*C)),o<0&&(o=0),j=e.grx[r+1]-e.grx[r],u=e.gry[d]-e.gry[d+1],f=o*j,m=o*u,P=Math.round(e.grx[r]+f),_=Math.round(e.gry[d+1]+m),j=Math.max(Math.round(j-2*f),1),u=Math.max(Math.round(u-2*m),1),s+=`M${P},${_}v${u}h${j}v${-u}z`,g<0&&i.BoxStyle===10&&(h+=`M${P},${_}l${j},${u}m0,${-u}l${-j},${u}`),i.BoxStyle===11&&j>5&&u>5)){const b=Qt(P,_,j,u,g<0?-1:1,Math.round(j*.1),Math.round(u*.1));p+=b[0],l+=b[1]}if(s){const b=this.appendPath(s).call(this.fillatt.func);i.BoxStyle!==11&&this.fillatt.empty()&&b.call(this.lineatt.func)}if(p&&this.fillatt.hasColor()&&this.appendPath(p).call(this.fillatt.func).style("fill",Ot(this.fillatt.color).brighter(.5).formatRgb()),l&&this.appendPath(l).call(this.fillatt.func).style("fill",this.fillatt.hasColor()?Ot(this.fillatt.color).darker(.5).formatRgb():"red"),h){const b=this.appendPath(h).style("fill","none");this.lineatt.empty()?b.style("stroke","black"):b.call(this.lineatt.func)}return e}drawBinsCandle(){let j=0;const u=this.getOptions(),C=H=>{let X=1;for(;H>=X;)X*=10;return X/=10,Math.floor(j/X)%10===Math.floor(H/X)},B=(H,X)=>{let L="",Z="",O=0;const E=H[0],F=H[1];if(E>="A"&&E<="Z"&&(L=E),E>="1"&&E<="9"&&(Z=E),F>="A"&&F<="Z"&&Z&&(L=F),F>="1"&&F<="9"&&L&&(Z=F),X)switch(Z){case"1":O+=11311;break;case"2":O+=112111;break;case"3":O+=112311;break;case"4":O+=112321;break;case"5":O+=212111;break;case"6":O+=312311;break;default:O+=11311}else switch(Z){case"1":O+=13001300;break;case"2":O+=13102300;break;default:O+=13001300}const V=H.indexOf("("),ut=H.lastIndexOf(")");V>=0&&ut>V+1&&(O=parseInt(H.slice(V+1,ut))),j=O,(L==="Y"||L==="H")&&!C(1e8)&&(j+=1e8)},M=(H,X,L)=>{let Z=0,O=0,E=0;const F={max:0,first:-1,last:-1,entries:0};for(let V=0;V<X.length;++V)X[V]>0&&(F.max=Math.max(F.max,X[V]),F.first<0&&(F.first=V),F.last=V),Z+=X[V],E+=X[V]*(H[V]+H[V+1])/2;if(Z<=0)return null;F.entries=Z,F.mean=E/Z,F.quantiles=new Array(L.length),F.indx=new Array(L.length);for(let V=0,ut=0,gt=0;V<X.length;++V){const pt=gt;let wt=H[V];if(pt===L[O]&&X[V]===0&&pt<.99){for(;X[V]===0&&V<X.length;)V++;wt=(H[V]+wt)/2}for(ut+=X[V],gt=ut/Z;L[O]>=pt&&L[O]<gt;){if(F.indx[O]=V,F.quantiles[O]=wt+(L[O]-pt)/(gt-pt)*(H[V+1]-wt),O++===L.length)return F;wt=H[V]}}for(;O<L.length;)F.indx[O]=X.length-1,F.quantiles[O++]=H.at(-1);return F};u.Candle?B(u.Candle,!0):u.Violin&&B(u.Violin,!1);const b=this.getHisto(),x=this.prepareDraw(),y=this.getCanvPainter(),S=this.getHistGrFuncs(),w=C(1e8);let A=et.fViolinScaled,T=et.fCandleScaled,I=0,v="",N="",G=null;if(u.Scaled!==null?A=T=u.Scaled:y?.online_canvas||(b.fTitle.indexOf("unscaled")>=0?A=T=!1:b.fTitle.indexOf("scaled")>=0&&(A=T=!0)),A&&(C(2e6)||C(1e6)||C(3e6)))for(let H=0;H<this.nbinsx;++H)for(let X=0;X<this.nbinsy;++X)I=Math.max(I,b.getBinContent(H+1,X+1));const Q=(...H)=>{H[1]==="array"&&(H=H[0]);const X=H.length;let L=2,Z=H[0],O=H[1],E=w?`M${O},${Z}`:`M${Z},${O}`;for(;L<X;){switch(H[L]){case"Z":return E+"z";case"V":O!==H[L+1]&&(E+=(w?"h":"v")+(H[L+1]-O),O=H[L+1]);break;case"H":Z!==H[L+1]&&(E+=(w?"v":"h")+(H[L+1]-Z),Z=H[L+1]);break;default:E+=w?`l${H[L+1]-O},${H[L]-Z}`:`l${H[L]-Z},${H[L+1]-O}`,Z=H[L],O=H[L+1]}L+=2}return E},U=(H,X)=>{if(!v){const L=et.fCandleCrossLineWidth??1;this.createAttMarker({attr:b,style:C(3e5)?0:L===1?5:18*L+16}),this.markeratt.resetPos()}v+=w?this.markeratt.create(X,H):this.markeratt.create(H,X)},at=(H,X)=>{if(!G){const L=et.fCandleCircleLineWidth??1;G=this.createAttMarker({attr:b,style:L===1?24:18*L+17,std:!1}),G.resetPos()}N+=w?G.create(X,H):G.create(H,X)};b.fMarkerColor===1&&(b.fMarkerColor=b.fLineColor),x.candle=[];let q,R="",W="",K="",tt="",J="",Y,D=0;const z=et.fCandleWhiskerRange,dt=et.fCandleBoxRange,Mt=[z>=1?1e-15:.5-z/2,dt>=1?1e-14:.5-dt/2,.5,dt>=1?1-1e-14:.5+dt/2,z>=1?1-1e-15:.5+z/2],lt=(H,X,L,Z,O)=>{const E=M(q,Y,Mt);if(!E)return;const F={bin:H,swapXY:w,fBoxDown:E.quantiles[1],fMedian:E.quantiles[2],fBoxUp:E.quantiles[3]},V=F.fBoxUp-F.fBoxDown;let ut=E.quantiles[0],gt=E.quantiles[4];if(C(2e3)){let rt=F.fBoxDown-1.5*V,st=E.indx[1];for(;q[st]>rt&&st>0;)st--;for(;!Y[st];)st++;for(ut=q[st],rt=F.fBoxUp+1.5*V,st=E.indx[3];q[st]<rt&&st<Y.length;)st++;for(;!Y[st];)st--;gt=q[st+1]}const pt=E.mean,wt=1.57*V/Math.sqrt(E.entries);if(ut<=0&&(w&&S.logx||!w&&S.logy))return;const $t=L-X;let bt,Bt,it=(X+L)/2+b.fBarOffset/1e3*$t;b.fBarWidth>0&&b.fBarWidth!==1e3?bt=Bt=$t*b.fBarWidth/1e3:(bt=$t*.66,Bt=$t*.8),A&&I>0&&(Bt*=E.max/I),T&&D>0&&(bt*=E.entries/D),F.x1=Math.round(it-bt/2),F.x2=Math.round(it+bt/2),it=Math.round(it);const Ht=Math.round(it-bt/3),At=Math.round(it+bt/3),ht=w?S.grx:S.gry;F.yy1=Math.round(ht(gt)),F.y1=Math.round(ht(F.fBoxUp)),F.y0=Math.round(ht(F.fMedian)),F.y2=Math.round(ht(F.fBoxDown)),F.yy2=Math.round(ht(ut));const Ft=Math.round(ht(pt)),Xt=Math.round(ht(F.fMedian+wt)),vt=Math.round(ht(F.fMedian-wt));if(C(1e7)&&(J+=Q(it,Math.round(ht(q[Z])),"V",Math.round(ht(q[O])))),C(10)?W+=Q(F.x1,F.y0,"H",F.x2):C(20)?W+=Q(Ht,F.y0,"H",At):C(30)&&at(it,F.y0),C(300)?at(it,Ft):C(100)&&(K+=Q(F.x1,Ft,"H",F.x2)),C(1)&&(C(20)?R+=Q(F.x1,F.y1,"V",Xt,Ht,F.y0,F.x1,vt,"V",F.y2,"H",F.x2,"V",vt,At,F.y0,F.x2,Xt,"V",F.y1,"Z"):R+=Q(F.x1,F.y1,"V",F.y2,"H",F.x2,"V",F.y1,"Z")),C(1e4)&&(W+=Q(F.x1,F.yy1,"H",F.x2)+Q(F.x1,F.yy2,"H",F.x2)),C(1e3)&&!C(1e7)?K+=Q(it,F.y1,"V",F.yy1)+Q(it,F.y2,"V",F.yy2):(C(1e3)&&C(1e7)||C(2e3))&&(W+=Q(it,F.y1,"V",F.yy1)+Q(it,F.y2,"V",F.yy2)),C(1e5)||C(2e5)||C(3e5)){const rt=new Yt(H*7521+Math.round(E.integral)),st=!C(1e5),yt=C(3e5);for(let ot=0;ot<Y.length;++ot){const ft=Y[ot],xt=(q[ot]+q[ot+1])/2;let Pt=it,Tt;if(ft&&!(!st&&xt>=ut&&xt<=gt))for(let It=0;It<ft;It++)yt&&(Pt=it+Math.round((rt.random()-.5)*bt)),ft===1&&!yt?Tt=Math.round(ht(xt)):Tt=Math.round(ht(q[ot]+rt.random()*(q[ot+1]-q[ot]))),U(Pt,Tt)}}if((C(2e6)||C(1e6)||C(3e6))&&E.max>0&&E.first>=0){const rt=[],st=(w?-.5:.5)*Bt/E.max;if(Z=Math.max(Z,E.first),O=Math.min(O-1,E.last),C(2e6)||C(3e6)){let yt=it,ot=Math.round(ht(q[Z]));rt.push(yt,ot);for(let ft=Z;ft<=O;ft++){const xt=Math.round(it+st*Y[ft]),Pt=Math.round(ht(q[ft+1]));xt!==yt&&(ft!==Z&&rt.push("V",ot),rt.push("H",xt)),yt=xt,ot=Pt}rt.push("V",ot)}if(C(1e6)||C(3e6)){let yt=it,ot=Math.round(ht(q[O+1]));rt.length||rt.push(yt,ot);for(let ft=O;ft>=Z;ft--){const xt=Math.round(it-st*Y[ft]),Pt=Math.round(ht(q[ft]));xt!==yt&&(ft!==O&&rt.push("V",ot),rt.push("H",xt)),yt=xt,ot=Pt}rt.push("V",ot)}rt.push("H",it),tt+=Q(rt,"array"),this.fillatt.empty()||(tt+="Z")}x.candle.push(F)};if(w){q=new Array(this.nbinsx+1),Y=new Array(this.nbinsx);for(let H=0;H<this.nbinsx+1;++H)q[H]=b.fXaxis.GetBinLowEdge(H+1);if(T)for(let H=0;H<this.nbinsy;++H){let X=0;for(let L=0;L<this.nbinsx;++L)X+=b.getBinContent(L+1,H+1);D=Math.max(D,X)}for(let H=x.j1;H<x.j2;++H){for(let X=0;X<this.nbinsx;++X)Y[X]=b.getBinContent(X+1,H+1);lt(H,x.gry[H+1],x.gry[H],x.i1,x.i2)}}else{q=new Array(this.nbinsy+1),Y=new Array(this.nbinsy);for(let H=0;H<this.nbinsy+1;++H)q[H]=b.fYaxis.GetBinLowEdge(H+1);if(T)for(let H=0;H<this.nbinsx;++H){let X=0;for(let L=0;L<this.nbinsy;++L)X+=b.getBinContent(H+1,L+1);D=Math.max(D,X)}for(let H=x.i1;H<x.i2;++H){for(let X=0;X<this.nbinsy;++X)Y[X]=b.getBinContent(H+1,X+1);lt(H,x.grx[H],x.grx[H+1],x.j1,x.j2)}}J&&b.fFillColor>0&&this.appendPath(J).style("stroke",this.getColor(b.fFillColor));const nt=C(1e7)&&b.fFillStyle?this.fillatt.color:this.lineatt.color;if(tt&&(!this.fillatt.empty()||nt!=="none")&&this.appendPath(tt).style("stroke",nt!=="none"?nt:null).style("pointer-events",this.isBatchMode()?null:"visibleFill").call(this.fillatt.func),R&&this.appendPath(R).call(this.lineatt.func).call(this.fillatt.func),W&&this.appendPath(W).call(this.lineatt.func).style("fill","none"),K){const H=this.createAttLine({attr:b,style:2,std:!1,color:te});this.appendPath(K).call(H.func).style("fill","none")}return N&&this.appendPath(N).call(G.func),v&&this.appendPath(v).call(this.markeratt.func),x}drawBinsScatter(){const t=this.getHisto(),i=this.getOptions(),e=this.prepareDraw({rounding:!0,pixel_density:!0}),n=i.cutg,c=[],k=[],a=[],r=[],d=[],g=i.ScatCoef*(this.gmaxbin>2e3?2e3/this.gmaxbin:1),$=new Yt(e.sumz);let s,h,p,l,o,f,m,P,_=1;if(e.ScatterPlot=!0,g*e.sumz<1e5){this.createAttMarker({attr:t}),this.markeratt.resetPos();let b="";for(l=e.i1;l<e.i2;++l)for(m=e.grx[l+1]-e.grx[l],o=e.j1;o<e.j2;++o){P=e.gry[o]-e.gry[o+1],f=t.getBinContent(l+1,o+1);const x=Math.round(g*f);if(!(x<=0)&&!(n&&!n.IsInside(t.fXaxis.GetBinCoord(l+.5),t.fYaxis.GetBinCoord(o+.5))))for(let y=0;y<x;++y)b+=this.markeratt.create(Math.round(e.grx[l]+m*$.random()),Math.round(e.gry[o+1]+P*$.random()))}return this.appendPath(b).call(this.markeratt.func),e}this.maxbin>.7&&(_=.7/this.maxbin);const j=Math.round(e.max-e.min),u=this.createContour(j>50?50:j,this.minposbin,this.maxbin,this.minposbin);for(l=e.i1;l<e.i2;++l)for(o=e.j1;o<e.j2;++o)f=t.getBinContent(l+1,o+1),!(f<=0||f<this.minbin)&&(m=e.grx[l+1]-e.grx[l],P=e.gry[o]-e.gry[o+1],!(m*P<=0)&&(s=u.getContourIndex(f/m/P),!(s<0)&&(n&&!n.IsInside(t.fXaxis.GetBinCoord(l+.5),t.fYaxis.GetBinCoord(o+.5))||(h=`M${e.grx[l]},${e.gry[o+1]}`,c[s]===void 0?(c[s]=h,r[s]=m,d[s]=P):(p=`m${e.grx[l]-k[s]},${e.gry[o+1]-a[s]}`,c[s]+=p.length<h.length?p:h,r[s]=Math.max(r[s],m),d[s]=Math.max(d[s],P)),k[s]=e.grx[l],a[s]=e.gry[o+1],c[s]+=`v${P}h${m}v${-P}z`))));const C=this.getPadPainter(),B=C.selectChild(".main_layer");let M=B.selectChild("defs");for(M.empty()&&c.length&&(M=B.insert("svg:defs",":first-child")),this.createAttMarker({attr:t}),s=0;s<c.length;++s)if(c[s]!==void 0&&s<u.arr.length){const b=(C.getPadName()||"canv")+`_scatter_${s}`;let x=M.selectChild(`#${b}`);x.empty()?x=M.append("svg:pattern").attr("id",b).attr("patternUnits","userSpaceOnUse"):x.selectAll("*").remove();let y=Math.round(_*u.arr[s]*r[s]*d[s]);y=Math.max(1,y);const S=new Float32Array(y),w=new Float32Array(y);if(y===1)S[0]=w[0]=.5;else for(let T=0;T<y;++T)S[T]=$.random(),w[T]=$.random();this.markeratt.resetPos();let A="";for(let T=0;T<y;++T)A+=this.markeratt.create(S[T]*r[s],w[T]*d[s]);x.attr("width",r[s]).attr("height",d[s]).append("svg:path").attr("d",A).call(this.markeratt.func),this.appendPath(c[s]).attr("scatter-index",s).style("fill",`url(#${b})`)}return e}draw2DBins(){const t=this.getOptions();if(this.#r&&this.isMainPainter()?(this.getPadPainter().getFrameSvg().style("display",null),this.#r=void 0):t.Same&&!this.isUseFrame()&&this.getPadPainter().getFrameSvg().style("display","none"),!this.draw_content)return t.Zscale&&t.ohmin&&t.ohmax&&(this.getContour(!0),this.getHistPalette()),this.removeG();this.createHistDrawAttributes(),this.createG(this.isUseFrame());let i,e;if(this.isTH2Poly()?e=this.drawPolyBins():(t.Scat&&(i=this.drawBinsScatter()),t.System===ie?i=this.drawBinsPolar():t.Arrow?i=this.drawBinsArrow():t.Color?i=this.drawBinsColor():t.Box?i=this.drawBinsBox():t.Proj?i=this.drawBinsProjected():t.Contour?i=this.drawBinsContour():(t.Candle||t.Violin)&&(i=this.drawBinsCandle()),t.Text&&(e=this.drawBinsText(i)),!i&&!e&&(i=this.drawBinsColor())),i)this.tt_handle=i;else if(e)return e.then(n=>{this.tt_handle=n})}async drawBinsCircular(){this.#r=!0;const t=this.getPadPainter(),i=t.getFrameRect(),e=this.getHisto(),n=this.getOptions().Circular,c=n>10?this.getHistPalette():null,k=20,a=16,r=e.fXaxis,d=this.createG(),g=s=>{if(r.fLabels)for(let h=0;h<r.fLabels.arr.length;++h){const p=r.fLabels.arr[h];if(p.fUniqueID===s+1)return p.fString}return s.toString()};t.getFrameSvg().style("display","none"),this.assignChordCircInteractive(Math.round(i.x+i.width/2),Math.round(i.y+i.height/2));const $=Math.min(this.nbinsx,this.nbinsy);return this.startTextDrawingAsync(42,k,d).then(()=>{const s=[];for(let o=0;o<$;o++){const f=(.5-o/$)*Math.PI*2,m=Math.round((.9*i.width/2-2*a)*Math.cos(f)),P=Math.round((.9*i.height/2-2*a)*Math.sin(f)),_=Math.round(.9*i.width/2*Math.cos(f)),j=Math.round(.9*i.height/2*Math.sin(f)),u=c?.calcColor(o,$)??"black";let C=Math.round(f/Math.PI*180),B=12;s.push({x:m,y:P,a:f,color:u}),(C<-90||C>90)&&(C+=180,B=32);const M=Math.round(k/2),b=2*M;d.append("path").attr("d",`M${m-M},${P} a${M},${M},0,1,0,${b},0a${M},${M},0,1,0,${-b},0z`).style("stroke",u).style("fill","none"),this.drawText({align:B,rotate:C,x:_,y:j,text:g(o)})}const h=a/2;let p=0,l=0;if(n>11)for(let o=0;o<$-1;++o)for(let f=o+1;f<$;++f){const m=e.getBinContent(o+1,f+1);m>0&&(p=Math.max(p,m),(!l||m<l)&&(l=m))}for(let o=0;o<$-1;++o){const f=s[o];let m="";for(let P=o+1;P<$;++P){const _=e.getBinContent(o+1,P+1);if(_<=0)continue;const j=s[P],u=(f.a+j.a)/2,C=.5*(1-Math.abs(f.a-j.a)/Math.PI),B=Math.round(C*i.width/2*Math.cos(u)),M=Math.round(C*i.height/2*Math.sin(u));if(m+=`M${f.x},${f.y}Q${B},${M},${j.x},${j.y}`,n>11&&p>l){const b=Math.round((_-l)/(p-l)*(h-1)+1);d.append("path").attr("d",m).style("stroke",f.color).style("stroke-width",b).style("fill","none"),m=""}}m&&d.append("path").attr("d",m).style("stroke",f.color).style("fill","none")}return this.finishTextDrawing()}).then(()=>(this.isBatchMode()||d.insert("path",":first-child").attr("d",`M${-i.width/2},${-i.height/2}h${i.width}v${i.height}h${-i.width}z`).style("opacity",0).style("fill","none").style("pointer-events","visibleFill"),this))}assignChordCircInteractive(t,i){this.#e||(this.#e={x:0,y:0,zoom:1}),jt(this.getG(),t+this.#e.x,i+this.#e.y,this.#e.zoom),!this.isBatchMode()&&(Dt.Zooming&&Dt.ZoomWheel&&this.getG().on("wheel",e=>{const n=Rt(e,this.getG().node()),c=e.wheelDelta?-e.wheelDelta:e.deltaY||e.detail,k=this.#e.zoom;this.#e.zoom*=c>0?.8:1.2,this.#e.x+=n[0]*(k-this.#e.zoom),this.#e.y+=n[1]*(k-this.#e.zoom),jt(this.getG(),t+this.#e.x,i+this.#e.y,this.#e.zoom)}).on("dblclick",()=>{this.#e.x=this.#e.y=0,this.#e.zoom=1,jt(this.getG(),t,i)}),Wt(this))}async drawBinsChord(){this.getPadPainter().getFrameSvg().style("display","none"),this.#r=!0;const t=[],i=Math.min(this.nbinsx,this.nbinsy),e=this.getHisto();let n=0,c=!0;for(let x=0;x<i;++x){let y=0;for(let S=0;S<i;++S){const w=e.getBinContent(x+1,S+1);w>0&&(y+=w,c&&Math.round(w)!==w&&(c=!1))}y>0&&t.push(x),n+=y}if(t.length<2)return!0;let k=0,a=1;const r=this.getPadPainter().getFrameRect(),d=Math.round(r.x+r.width/2),g=Math.round(r.y+r.height/2),$=this.getHistPalette(),s=Math.max(10,Math.min(r.width,r.height)*.5-60),h=Math.max(2,s-10),p=[],l=[],o=x=>x.toString(),f=x=>k>3?x.toExponential(0):x.toFixed(k),m=(x,y)=>y<x?-1:y>x?1:y>=x?0:Number.NaN;if(!c&&n<10){const x=Math.round(Math.log10(n)-2.3);k=-x,a=Math.pow(10,x)}else if(n>200){const x=Math.round(Math.log10(n)-2.3);a=Math.pow(10,x)}a*250<n?a*=5:a*100<n&&(a*=2);for(let x=0;x<t.length;++x){p[x]=[];for(let w=0;w<t.length;++w)p[x].push(e.getBinContent(t[x]+1,t[w]+1));const y=e.fXaxis;let S="indx_"+t[x].toString();if(y.fLabels)for(let w=0;w<y.fLabels.arr.length;++w){const A=y.fLabels.arr[w];if(A.fUniqueID===t[x]+1){S=A.fString;break}}l.push(S)}const P=this.createG();this.assignChordCircInteractive(d,g);const _=Ut().padAngle(10/h).sortSubgroups(m).sortChords(m),j=_(p),u=P.append("g").attr("font-size",10).attr("font-family","sans-serif").selectAll("g").data(j.groups).join("g"),C=qt().innerRadius(h).outerRadius(s),B=Kt().radius(h-1).padAngle(1/h);function M({startAngle:x,endAngle:y,value:S}){const w=(y-x)/S,A=[];for(let T=0;T<=S;T+=a)A.push({value:T,angle:T*w+x});return A}u.append("path").attr("fill",x=>$.calcColor(x.index,t.length)).attr("d",C),u.append("title").text(x=>`${l[x.index]} ${o(x.value)}`);const b=u.append("g").selectAll("g").data(M).join("g").attr("transform",x=>`rotate(${Math.round(x.angle*180/Math.PI-90)}) translate(${s})`);return b.append("line").attr("stroke","currentColor").attr("x2",6),b.append("text").attr("x",8).attr("dy","0.35em").attr("transform",x=>x.angle>Math.PI?"rotate(180) translate(-16)":null).attr("text-anchor",x=>x.angle>Math.PI?"end":null).text(x=>f(x.value)),u.select("text").attr("font-weight","bold").text(function(x){return this.getAttribute("text-anchor")==="end"?`↑ ${l[x.index]}`:`${l[x.index]} ↓`}),P.append("g").attr("fill-opacity",.8).selectAll("path").data(j).join("path").style("mix-blend-mode","multiply").attr("fill",x=>$.calcColor(x.source.index,t.length)).attr("d",B).append("title").text(x=>`${o(x.source.value)} ${l[x.target.index]} → ${l[x.source.index]}${x.source.index===x.target.index?"":`
2
2
  ${o(x.target.value)} ${l[x.source.index]} → ${l[x.target.index]}`}`),this.isBatchMode()||P.insert("ellipse",":first-child").attr("cx",0).attr("cy",0).attr("rx",s*1.2).attr("ry",s*1.2).style("opacity",0).style("fill","none").style("pointer-events","visibleFill"),!0}getBinTooltips(t,i){const e=this.getHisto(),n=this.matchObjectType(Ct)&&_t(e.getBinEntries),c=e.getBinContent(t+1,i+1);let k=c;e.$baseh&&(k-=e.$baseh.getBinContent(t+1,i+1));const a=[this.getObjectHint(),"x = "+this.getAxisBinTip("x",e.fXaxis,t),"y = "+this.getAxisBinTip("y",e.fYaxis,i),`bin = ${e.getBin(t+1,i+1)} x: ${t+1} y: ${i+1}`,"content = "+(k===Math.round(k)?k:ct(k,et.fStatFormat))];if(this.getOptions().TextKind==="E"||n||e.fSumw2?.length){const r=this.getBinErrors(e,e.getBin(t+1,i+1),c);r.poisson?a.push("error low = "+ct(r.low,et.fPaintTextFormat),"error up = "+ct(r.up,et.fPaintTextFormat)):a.push("error = "+ct(r.up,et.fPaintTextFormat))}if(n){const r=e.getBinEntries(t+1,i+1);a.push("entries = "+(r===Math.round(r)?r:ct(r,et.fStatFormat)))}return a}getCandleTooltips(t){const i=this.getHistGrFuncs(),e=this.getHisto();return[this.getObjectHint(),t.swapXY?"y = "+i.axisAsText("y",e.fYaxis.GetBinLowEdge(t.bin+1)):"x = "+i.axisAsText("x",e.fXaxis.GetBinLowEdge(t.bin+1)),"m-25% = "+ct(t.fBoxDown,et.fStatFormat),"median = "+ct(t.fMedian,et.fStatFormat),"m+25% = "+ct(t.fBoxUp,et.fStatFormat)]}getPolyBinTooltips(t,i,e){const n=this.getHisto(),c=n.fBins.arr[t],k=this.getHistGrFuncs(),a=[];let r=c.fPoly.fName,d=0;if(r==="Graph"&&(r=""),r||(r=c.fNumber),i===void 0&&e===void 0){i=e=0;let g=c.fPoly,$=1;g._typename===kt&&($=c.fPoly.fGraphs.arr.length,g=null);for(let s=0;s<$;++s){(!g||s>0)&&(g=c.fPoly.fGraphs.arr[s]);for(let h=0;h<g.fNpoints;++h)++d,i+=g.fX[h],e+=g.fY[h]}d>1&&(i/=d,e/=d)}return a.push(this.getObjectHint(),"x = "+k.axisAsText("x",i),"y = "+k.axisAsText("y",e)),d>0&&a.push("npnts = "+d),a.push(`bin = ${r}`),c.fContent===Math.round(c.fContent)?a.push("content = "+c.fContent):a.push("content = "+ct(c.fContent,et.fStatFormat)),a}processTooltipEvent(t){const i=this.getHisto(),e=this.getOptions(),n=this.tt_handle;let c=this.getG()?.selectChild(".tooltip_bin");if(!t||!this.draw_content||!this.getG()||!n||e.Proj)return c?.remove(),null;if(n.poly){const j=this.getHistGrFuncs(),u=j.revertAxis("x",t.x),C=j.revertAxis("y",t.y);let B=-1,M;if(u!==void 0&&C!==void 0){const x=i.fBins.arr.length;for(let y=0;y<x&&B<0;++y){if(M=i.fBins.arr[y],u<M.fXmin||u>M.fXmax||C<M.fYmin||C>M.fYmax||!M.fContent&&!e.Zero)continue;let S=M.fPoly,w=1;S._typename===kt&&(w=M.fPoly.fGraphs.arr.length,S=null);for(let A=0;A<w;++A)if((!S||A>0)&&(S=M.fPoly.fGraphs.arr[A]),S.IsInside(u,C)){B=y;break}}}if(B<0)return c.remove(),null;const b={name:i.fName,title:i.fTitle,x:t.x,y:t.y,color1:this.lineatt?.color??"green",color2:this.fillatt?.getFillColorAlt("blue")??"blue",exact:!0,menu:!0,lines:this.getPolyBinTooltips(B,u,C)};return t.disabled?(c.remove(),b.changed=!0):(c.empty()&&(c=this.appendPath().attr("class","tooltip_bin").style("pointer-events","none").call(St)),b.changed=c.property("current_bin")!==B,b.changed&&c.attr("d",this.createPolyBin(j,M)).style("opacity","0.7").property("current_bin",B)),b.changed&&(b.user_info={obj:i,name:i.fName,bin:B,cont:M.fContent,grx:t.x,gry:t.y}),b}else if(n.candle){let j,u,C;for(j=0;j<n.candle.length&&(u=n.candle[j],C=u.swapXY?u.x1<=t.y&&t.y<=u.x2&&u.yy1>=t.x&&t.x>=u.yy2:u.x1<=t.x&&t.x<=u.x2&&u.yy1<=t.y&&t.y<=u.yy2,!C);++j);if(!C)return c.remove(),null;const B={name:i.fName,title:i.fTitle,x:t.x,y:t.y,color1:this.lineatt?.color??"green",color2:this.fillatt?.getFillColorAlt("blue")??"blue",lines:this.getCandleTooltips(u),exact:!0,menu:!0};return t.disabled?(c.remove(),B.changed=!0):(c.empty()&&(c=this.appendPath().attr("class","tooltip_bin").style("pointer-events","none").call(St).style("opacity","0.7")),B.changed=c.property("current_bin")!==j,B.changed&&c.attr("d",u.swapXY?`M${u.yy1},${u.x1}H${u.yy2}V${u.x2}H${u.yy1}Z`:`M${u.x1},${u.yy1}H${u.x2}V${u.yy2}H${u.x1}Z`).property("current_bin",j)),B.changed&&(B.user_info={obj:i,name:i.fName,bin:j+1,cont:u.fMedian,binx:j+1,biny:1,grx:t.x,gry:t.y}),B}const k=this.getFramePainter();let a,r,d=0,g=null,$=!1,s,h,p,l,o,f,m,P;if(_t(n.findBin)){const j=n.findBin(t.x,t.y);a=j?.i??n.i2,r=j?.j??n.j2,$=!0}else{if(k.reverse_x())for(a=n.i1;a<n.i2&&(t.x>n.grx[a]||t.x<n.grx[a+1]);++a);else for(a=n.i1;a<n.i2&&(t.x<n.grx[a]||t.x>n.grx[a+1]);++a);if(k.reverse_y())for(r=n.j1;r<n.j2&&(t.y>n.gry[r+1]||t.y<n.gry[r]);++r);else for(r=n.j1;r<n.j2&&(t.y<n.gry[r+1]||t.y>n.gry[r]);++r);}if(a<n.i2&&r<n.j2){s=a,h=a+1,p=r,l=r+1,o=n.grx[s],f=n.grx[h],m=n.gry[l],P=n.gry[p];let j=!0;if(e.Color&&!$){const u=f-o,C=P-m;f=Math.round(o+u*n.xbar2),o=Math.round(o+u*n.xbar1),P=Math.round(m+C*n.ybar2),m=Math.round(m+C*n.ybar1),k.reverse_x()?(t.x>o||t.x<=f)&&(j=!1):(t.x<o||t.x>=f)&&(j=!1),k.reverse_y()?(t.y>m||t.y<=P)&&(j=!1):(t.y<m||t.y>=P)&&(j=!1)}d=i.getBinContent(a+1,r+1),this.#t?g=0:j?n.hide_only_zeros?g=d===0&&!e.ShowEmpty?null:0:(g=this.getContour().getPaletteIndex(this.getHistPalette(),d),g===null&&d===0&&(e.ShowEmpty||i._typename===Ct&&i.getBinEntries(a+1,r+1))&&(g=0)):g=null}if(g===null)return c.remove(),null;const _={name:i.fName,title:i.fTitle,x:t.x,y:t.y,color1:this.lineatt?.color??"green",color2:this.fillatt?.getFillColorAlt("blue")??"blue",lines:this.getBinTooltips(a,r),exact:!0,menu:!0};if(e.Color&&(_.color2=this.getHistPalette().getColor(g)),t.disabled&&!this.#t)c.remove(),_.changed=!0;else{c.empty()&&(c=this.appendPath().attr("class","tooltip_bin").style("pointer-events","none").call(St));let j=a*1e4+r,u;if(this.#t){const C=this.#i||1,B=(C-1)/2;this.#t.indexOf("X")>=0&&C>1&&(l+B>=n.j2?(l=Math.min(Math.round(l+B),n.j2),p=Math.max(l-C,n.j1)):(p=Math.max(Math.round(p-B),n.j1),l=Math.min(p+C,n.j2)));const M=this.#n||1,b=(M-1)/2;this.#t.indexOf("Y")>=0&&M>1&&(h+b>=n.i2?(h=Math.min(Math.round(h+b),n.i2),s=Math.max(h-M,n.i1)):(s=Math.max(Math.round(s-b),n.i1),h=Math.min(s+M,n.i2)))}$?u=n.getBinPath(a,r):this.#t==="X"?(o=0,f=k.getFrameWidth(),m=n.gry[l],P=n.gry[p],j=p*777+l*333):this.#t==="Y"?(m=0,P=k.getFrameHeight(),o=n.grx[s],f=n.grx[h],j=s*777+h*333):this.#t==="XY"&&(m=n.gry[l],P=n.gry[p],o=n.grx[s],f=n.grx[h],j=s*789+h*653+p*12345+l*654321,u=`M${o},0H${f}V${m}H${k.getFrameWidth()}V${P}H${f}V${k.getFrameHeight()}H${o}V${P}H0V${m}H${o}Z`),_.changed=c.property("current_bin")!==j,_.changed&&c.attr("d",u||`M${o},${m}H${f}V${P}H${o}Z`).style("opacity","0.7").property("current_bin",j),this.#t&&_.changed&&this.redrawProjection(s,h,p,l)}return _.changed&&(_.user_info={obj:i,name:i.fName,bin:i.getBin(a+1,r+1),cont:d,binx:a+1,biny:r+1,grx:t.x,gry:t.y}),_}canZoomInside(t,i,e){const n=this.getOptions();if(n.Proj)return!0;if(t==="z"){if(this.mode3d)return!0;if(n.IgnorePalette)return!1;const k=this.getFramePainter(),a=Math.max(2*et.fNumberContours,100),r=this.getPadPainter().getRootPad(!0),d=r?.fLogv??r?.fLogz;return!k||k.zmin===k.zmax?!0:d&&k.zmin>0&&i>0?a*Math.log(e/i)>Math.log(k.zmax/k.zmin):k.zmax-k.zmin<(e-i)*a}let c=this.getHisto();return c&&(c=t==="y"?c.fYaxis:c.fXaxis),!c||c.FindBin(e,.5)-c.FindBin(i,0)>1}completePalette(t){if(!t)return!0;const i=this.getOptions();return t.$main_painter=this,i.Zvert=t.isPaletteVertical(),t.drawPave(i.Cjust?"cjust":"")}async draw2D(){this.clear3DScene();const t=this.getOptions(),i=t.Zscale&&t.canHavePalette()&&this.isUseFrame();return this.drawColorPalette(i,!0,this.#s).then(async e=>{this.#s=void 0;let n;return t.Circular&&this.isMainPainter()?n=this.drawBinsCircular():t.Chord&&this.isMainPainter()?n=this.drawBinsChord():n=this.drawAxes().then(()=>this.draw2DBins()),n.then(()=>this.completePalette(e))}).then(()=>this.updateFunctions()).then(()=>this.updateHistTitle()).then(()=>(this.updateStatWebCanvas(),this.addInteractivity()))}async draw3D(t){return console.log("3D drawing is disabled, load ./hist/TH2Painter.mjs"),this.draw2D(t)}async callDrawFunc(t){const i=this.getMainPainter(),e=this.getFramePainter(),n=this.getOptions();return i!==this&&e&&e.mode3d!==n.Mode3D&&this.copyOptionsFrom(i),n.Mode3D?this.draw3D(t).catch(c=>{const k=this.getCanvPainter();return _t(k?.showConsoleError)?k.showConsoleError(c):console.error("Fail to draw histogram in 3D - back to 2D"),n.Mode3D=!1,this.draw2D(t)}):this.draw2D(t)}async redraw(t){return this.callDrawFunc(t)}static async draw(t,i,e){return Nt._drawHist(new Et(t,i),e)}};export{le as T,re as a,ne as b,se as c};
@@ -1 +1 @@
1
- import{ad as R,ae as N,bn as k,bo as Z,bp as V,aw as y,ax as j}from"./ndmvr-aframe-core-Cw91_9_Y.js";import{e as I,f as K,g as U,d as W,b as X}from"./hist3d-DCmav5Ga.js";import{T as $}from"./THistPainter-Df-RmCQH.js";import{T as q}from"./TH2Painter-DHaL_lR_.js";import"./latex3d-ITrfFgp8.js";import"./TPavePainter-Dx40jhkF.js";function J(g){const s=g.getHisto(),e=g.getFramePainter(),h=e.z_handle.getScaleMin(),i=e.z_handle.getScaleMax(),m=s.fBins.arr.length,l=e.grz(h);let z,c,_,d;g.maxbin=g.gmaxbin,g.minbin=g.gminbin,g.minposbin=g.gminposbin;const Y=g.getContour(!0),E=g.getHistPalette();for(_=0;_<m;++_){if(c=s.fBins.arr[_],c.fContent<h||(z=Y.getPaletteIndex(E,c.fContent),z===null)||c.fXmin>e.scale_xmax||c.fXmax<e.scale_xmin||c.fYmin>e.scale_ymax||c.fYmax<e.scale_ymin)continue;d=e.grz(c.fContent>i?i:c.fContent);const T=[],v=[];let A=1,x=c.fPoly,F=0;x._typename===V&&(A=c.fPoly.fGraphs.arr.length,x=null);for(let u=0;u<A;++u){(!x||u>0)&&(x=c.fPoly.fGraphs.arr[u]);const f=x.fX,w=x.fY;let r=x.fNpoints;for(;r>2&&f[0]===f[r-1]&&w[0]===w[r-1];)--r;let a,o;for(let b=0;b<2;++b){let P,D,C,H,M=e.size_x3d*e.size_z3d;const O=b>0?0:M/1e6;a=[],o=null;for(let B=0;B<r;++B)C=e.grx(f[B]),H=e.gry(w[B]),B>0&&(M=(C-P)**2+(H-D)**2),M>O&&(a.push(new y.Vector2(C,H)),P=C,D=H);try{a.length>2&&(o=y.ShapeUtils.triangulateShape(a,[]))}catch{o=null}if(o&&o.length>a.length-3)break}o?.length&&a&&(T.push(a),v.push(o),F+=o.length*2,d>l&&(F+=a.length*2))}const n=new Float32Array(F*9);let t=0;for(let u=0;u<T.length;++u){const f=T[u],w=v[u];for(let r=0;r<2;++r)for(let a=0;a<w.length;++a){const o=w[a],b=f[o[0]],P=f[o[r===0?2:1]],D=f[o[r===0?1:2]];n[t]=b.x,n[t+1]=b.y,n[t+2]=r?d:l,t+=3,n[t]=P.x,n[t+1]=P.y,n[t+2]=r?d:l,t+=3,n[t]=D.x,n[t+1]=D.y,n[t+2]=r?d:l,t+=3}if(d>l)for(let r=0;r<f.length;++r){const a=f.at(r),o=f.at(r>0?r-1:-1);n[t]=a.x,n[t+1]=a.y,n[t+2]=l,t+=3,n[t]=o.x,n[t+1]=o.y,n[t+2]=l,t+=3,n[t]=o.x,n[t+1]=o.y,n[t+2]=d,t+=3,n[t]=a.x,n[t+1]=a.y,n[t+2]=l,t+=3,n[t]=o.x,n[t+1]=o.y,n[t+2]=d,t+=3,n[t]=a.x,n[t+1]=a.y,n[t+2]=d,t+=3}}const S=new y.BufferGeometry;S.setAttribute("position",new y.BufferAttribute(n,3)),S.computeVertexNormals();const G=new y.MeshBasicMaterial(j(g.getHistPalette()?.getColor(z),{vertexColors:!1,side:y.DoubleSide})),p=new y.Mesh(S,G);e.add3DMesh(p),p.painter=g,p.bins_index=_,p.draw_z0=l,p.draw_z1=d,p.tip_color=65280,p.tooltip=function(){const u=this.painter,f=u.getObject().fBins.arr[this.bins_index];return{use_itself:!0,x1:e.grx(f.fXmin),x2:e.grx(f.fXmax),y1:e.gry(f.fYmin),y2:e.gry(f.fYmax),z1:this.draw_z0,z2:this.draw_z1,bin:this.bins_index,value:c.fContent,color:this.tip_color,lines:u.getPolyBinTooltips(this.bins_index)}}}}class L extends q{checkRangeFor3D(s){const e=this.getPadPainter()?.getRootPad(!0),h=e?.fLogv??e?.fLogz;let i=1;return s.ohmin&&s.ohmax?(this.zmin=s.hmin,this.zmax=s.hmax):s.minimum!==R&&s.maximum!==R?(this.zmin=s.minimum,this.zmax=s.maximum):(this.draw_content||this.gmaxbin)&&(this.zmin=h?this.gminposbin*.3:this.gminbin,this.zmax=this.gmaxbin,i=1+2*N.fHistTopMargin),h&&this.zmin<=0&&(this.zmin=this.zmax*1e-5),this.createHistDrawAttributes(!0),i}draw3DBins(s){this.isTH2Poly()?J(this):s.Contour?I(this,!0):s.Surf?K(this):s.Error?U(this):W(this)}async draw3D(s){this.mode3d=!0;const e=this.getFramePainter(),h=this.isMainPainter(),i=this.getOptions();let m=Promise.resolve(!0),l=!0;if(s==="resize"){const z=h?e.resize3D():!1;z!==1&&(l=!1,z&&e.render3D())}return l&&(i.zmult=this.checkRangeFor3D(i),h&&(m=X(this,k,i.Render3D)),e.mode3d&&(m=m.then(()=>{this.draw_content?this.draw3DBins(i):i.Axis&&i.Zscale&&(this.getContourLevels(!0),this.getHistPalette()),e.render3D(),this.updateStatWebCanvas(),e.addKeysHandler()}))),h&&(m=m.then(()=>this.drawColorPalette(i.Zscale&&(i.Lego===12||i.Lego===14||i.Surf===11||i.Surf===12)))),m.then(()=>this.updateFunctions()).then(()=>this.updateHistTitle()).then(()=>this)}static async build3d(s,e,h){const i=new L(null,s);i.decodeOptions(e);const m=i.getOptions();i.isTH2Poly()&&(m.Lego=12),i.scanContent(),m.zmult=i.checkRangeFor3D(m);const l=new Z(null,null);return i.getFramePainter=()=>l,X(i,k).then(()=>(i.draw_content&&i.draw3DBins(m),h?i:l.create3DScene(-1,!0)))}static async draw(s,e,h){return $._drawHist(new L(s,e),h)}}export{L as TH2Painter};
1
+ import{ad as R,ae as N,bn as k,bo as Z,bp as V,aw as y,ax as j}from"./ndmvr-aframe-core-DEHQ38JB.js";import{e as I,f as K,g as U,d as W,b as X}from"./hist3d-D9VevdP6.js";import{T as $}from"./THistPainter-B2S5BnuY.js";import{T as q}from"./TH2Painter-BpixRP4j.js";import"./latex3d-8Hbnfz6c.js";import"./TPavePainter-1yngbgp8.js";function J(g){const s=g.getHisto(),e=g.getFramePainter(),h=e.z_handle.getScaleMin(),i=e.z_handle.getScaleMax(),m=s.fBins.arr.length,l=e.grz(h);let z,c,_,d;g.maxbin=g.gmaxbin,g.minbin=g.gminbin,g.minposbin=g.gminposbin;const Y=g.getContour(!0),E=g.getHistPalette();for(_=0;_<m;++_){if(c=s.fBins.arr[_],c.fContent<h||(z=Y.getPaletteIndex(E,c.fContent),z===null)||c.fXmin>e.scale_xmax||c.fXmax<e.scale_xmin||c.fYmin>e.scale_ymax||c.fYmax<e.scale_ymin)continue;d=e.grz(c.fContent>i?i:c.fContent);const T=[],v=[];let A=1,x=c.fPoly,F=0;x._typename===V&&(A=c.fPoly.fGraphs.arr.length,x=null);for(let u=0;u<A;++u){(!x||u>0)&&(x=c.fPoly.fGraphs.arr[u]);const f=x.fX,w=x.fY;let r=x.fNpoints;for(;r>2&&f[0]===f[r-1]&&w[0]===w[r-1];)--r;let a,o;for(let b=0;b<2;++b){let P,D,C,H,M=e.size_x3d*e.size_z3d;const O=b>0?0:M/1e6;a=[],o=null;for(let B=0;B<r;++B)C=e.grx(f[B]),H=e.gry(w[B]),B>0&&(M=(C-P)**2+(H-D)**2),M>O&&(a.push(new y.Vector2(C,H)),P=C,D=H);try{a.length>2&&(o=y.ShapeUtils.triangulateShape(a,[]))}catch{o=null}if(o&&o.length>a.length-3)break}o?.length&&a&&(T.push(a),v.push(o),F+=o.length*2,d>l&&(F+=a.length*2))}const n=new Float32Array(F*9);let t=0;for(let u=0;u<T.length;++u){const f=T[u],w=v[u];for(let r=0;r<2;++r)for(let a=0;a<w.length;++a){const o=w[a],b=f[o[0]],P=f[o[r===0?2:1]],D=f[o[r===0?1:2]];n[t]=b.x,n[t+1]=b.y,n[t+2]=r?d:l,t+=3,n[t]=P.x,n[t+1]=P.y,n[t+2]=r?d:l,t+=3,n[t]=D.x,n[t+1]=D.y,n[t+2]=r?d:l,t+=3}if(d>l)for(let r=0;r<f.length;++r){const a=f.at(r),o=f.at(r>0?r-1:-1);n[t]=a.x,n[t+1]=a.y,n[t+2]=l,t+=3,n[t]=o.x,n[t+1]=o.y,n[t+2]=l,t+=3,n[t]=o.x,n[t+1]=o.y,n[t+2]=d,t+=3,n[t]=a.x,n[t+1]=a.y,n[t+2]=l,t+=3,n[t]=o.x,n[t+1]=o.y,n[t+2]=d,t+=3,n[t]=a.x,n[t+1]=a.y,n[t+2]=d,t+=3}}const S=new y.BufferGeometry;S.setAttribute("position",new y.BufferAttribute(n,3)),S.computeVertexNormals();const G=new y.MeshBasicMaterial(j(g.getHistPalette()?.getColor(z),{vertexColors:!1,side:y.DoubleSide})),p=new y.Mesh(S,G);e.add3DMesh(p),p.painter=g,p.bins_index=_,p.draw_z0=l,p.draw_z1=d,p.tip_color=65280,p.tooltip=function(){const u=this.painter,f=u.getObject().fBins.arr[this.bins_index];return{use_itself:!0,x1:e.grx(f.fXmin),x2:e.grx(f.fXmax),y1:e.gry(f.fYmin),y2:e.gry(f.fYmax),z1:this.draw_z0,z2:this.draw_z1,bin:this.bins_index,value:c.fContent,color:this.tip_color,lines:u.getPolyBinTooltips(this.bins_index)}}}}class L extends q{checkRangeFor3D(s){const e=this.getPadPainter()?.getRootPad(!0),h=e?.fLogv??e?.fLogz;let i=1;return s.ohmin&&s.ohmax?(this.zmin=s.hmin,this.zmax=s.hmax):s.minimum!==R&&s.maximum!==R?(this.zmin=s.minimum,this.zmax=s.maximum):(this.draw_content||this.gmaxbin)&&(this.zmin=h?this.gminposbin*.3:this.gminbin,this.zmax=this.gmaxbin,i=1+2*N.fHistTopMargin),h&&this.zmin<=0&&(this.zmin=this.zmax*1e-5),this.createHistDrawAttributes(!0),i}draw3DBins(s){this.isTH2Poly()?J(this):s.Contour?I(this,!0):s.Surf?K(this):s.Error?U(this):W(this)}async draw3D(s){this.mode3d=!0;const e=this.getFramePainter(),h=this.isMainPainter(),i=this.getOptions();let m=Promise.resolve(!0),l=!0;if(s==="resize"){const z=h?e.resize3D():!1;z!==1&&(l=!1,z&&e.render3D())}return l&&(i.zmult=this.checkRangeFor3D(i),h&&(m=X(this,k,i.Render3D)),e.mode3d&&(m=m.then(()=>{this.draw_content?this.draw3DBins(i):i.Axis&&i.Zscale&&(this.getContourLevels(!0),this.getHistPalette()),e.render3D(),this.updateStatWebCanvas(),e.addKeysHandler()}))),h&&(m=m.then(()=>this.drawColorPalette(i.Zscale&&(i.Lego===12||i.Lego===14||i.Surf===11||i.Surf===12)))),m.then(()=>this.updateFunctions()).then(()=>this.updateHistTitle()).then(()=>this)}static async build3d(s,e,h){const i=new L(null,s);i.decodeOptions(e);const m=i.getOptions();i.isTH2Poly()&&(m.Lego=12),i.scanContent(),m.zmult=i.checkRangeFor3D(m);const l=new Z(null,null);return i.getFramePainter=()=>l,X(i,k).then(()=>(i.draw_content&&i.draw3DBins(m),h?i:l.create3DScene(-1,!0)))}static async draw(s,e,h){return $._drawHist(new L(s,e),h)}}export{L as TH2Painter};
@@ -1 +1 @@
1
- import{aX as tt,a2 as et,aW as it,aU as U,ae as W,bq as nt,aB as st,br as rt,aw as L,bs as R,bn as J,bt as ot,bo as at,a6 as ft,a5 as lt,an as ht}from"./ndmvr-aframe-core-Cw91_9_Y.js";import{T as gt}from"./THistPainter-Df-RmCQH.js";import{b as Q}from"./hist3d-DCmav5Ga.js";import{p as xt,g as dt}from"./func-C1jNXIub.js";import"./TPavePainter-Dx40jhkF.js";import"./latex3d-ITrfFgp8.js";import"./TH2Painter-DHaL_lR_.js";class V extends gt{#t;getDimension(){return 3}scanContent(t){if(t&&this.nbinsx&&this.nbinsy&&this.nbinsz)return;const n=this.getHisto();this.extractAxesProperties(3),this.gminbin=this.gmaxbin=n.getBinContent(1,1,1),this.gminposbin=null;for(let e=0;e<this.nbinsx;++e)for(let i=0;i<this.nbinsy;++i)for(let l=0;l<this.nbinsz;++l){const f=n.getBinContent(e+1,i+1,l+1);f<this.gminbin?this.gminbin=f:f>this.gmaxbin&&(this.gmaxbin=f),f>0&&(this.gminposbin===null||this.gminposbin>f)&&(this.gminposbin=f)}this.gminposbin===null&&this.gmaxbin>0&&(this.gminposbin=this.gmaxbin*1e-4),this.draw_content=this.gmaxbin||this.gminbin,this.transferFunc=this.findFunction(tt,"TransferFunction"),this.transferFunc?.SetBit(et(9),!0)}countStat(t,n){const e=this.getHisto(),i=e.fXaxis,l=e.fYaxis,f=e.fZaxis,h=this.getSelectIndex("x","left"),B=this.getSelectIndex("x","right"),g=this.getSelectIndex("y","left"),x=this.getSelectIndex("y","right"),r=this.getSelectIndex("z","left"),T=this.getSelectIndex("z","right"),S=this.getFramePainter(),s={name:e.fName,entries:0,eff_entries:0,integral:0,meanx:0,meany:0,meanz:0,rmsx:0,rmsy:0,rmsz:0,skewx:0,skewy:0,skewz:0,skewd:0,kurtx:0,kurty:0,kurtz:0,kurtd:0},M=Math.abs(e.fTsumw)>1e-300&&!S.isAxisZoomed("x")&&!S.isAxisZoomed("y")&&!S.isAxisZoomed("z");let p,b,C,G,E,k,D,I,P,w,d=0,A=0,O=0,Y=0,Z=0,K=0,a=0,m=0;for(lt(t)||(t=null),p=0;p<this.nbinsx+2;++p)for(G=i.GetBinCoord(p-.5),E=p<h?0:p>B?2:1,b=0;b<this.nbinsy+2;++b)for(k=l.GetBinCoord(b-.5),D=b<g?0:b>x?2:1,C=0;C<this.nbinsz+2;++C)I=f.GetBinCoord(C-.5),P=C<r?0:C>T?2:1,!(t&&!t(G,k,I))&&(w=e.getBinContent(p,b,C),s.entries+=w,!M&&E===1&&D===1&&P===1&&(d+=w,A+=w*w,O+=G*w,Y+=k*w,Z+=I*w,K+=G**2*w,a+=k**2*w,m+=I**2*w));if(M&&(d=e.fTsumw,A=e.fTsumw2,O=e.fTsumwx,K=e.fTsumwx2,Y=e.fTsumwy,a=e.fTsumwy2,Z=e.fTsumwz,m=e.fTsumwz2),Math.abs(d)>1e-300&&(s.meanx=O/d,s.meany=Y/d,s.meanz=Z/d,s.rmsx=Math.sqrt(Math.abs(K/d-s.meanx*s.meanx)),s.rmsy=Math.sqrt(Math.abs(a/d-s.meany*s.meany)),s.rmsz=Math.sqrt(Math.abs(m/d-s.meanz*s.meanz))),s.integral=d,e.fEntries>0&&(s.entries=e.fEntries),s.eff_entries=A?d*d/A:Math.abs(d),n&&!this.isTH2Poly()){let _=0,y=0,o=0,F=0,c=0,z=0,u=0;for(p=h;p<B;++p)for(G=i.GetBinCoord(p+.5),b=g;b<x;++b)for(k=l.GetBinCoord(b+.5),C=r;C<T;++C){if(I=f.GetBinCoord(C+.5),t&&!t(G,k,I))continue;const X=e.getBinContent(p+1,b+1,C+1);u+=X,_+=X*Math.pow(G-s.meanx,3),y+=X*Math.pow(k-s.meany,3),o+=X*Math.pow(I-s.meany,3),F+=X*Math.pow(G-s.meanx,4),c+=X*Math.pow(k-s.meany,4),z+=X*Math.pow(k-s.meany,4)}const v=Math.pow(s.rmsx,3),j=Math.pow(s.rmsy,3),$=Math.pow(s.rmsz,3),q=Math.pow(s.rmsx,4),H=Math.pow(s.rmsy,4),N=Math.pow(s.rmsz,4);u*v&&(s.skewx=_/(u*v)),u*j&&(s.skewy=y/(u*j)),u*$&&(s.skewz=o/(u*$)),s.skewd=s.eff_entries>0?Math.sqrt(6/s.eff_entries):0,u*q&&(s.kurtx=F/(u*q)-3),u*H&&(s.kurty=c/(u*H)-3),u*N&&(s.kurtz=z/(u*N)-3),s.kurtd=s.eff_entries>0?Math.sqrt(24/s.eff_entries):0}return s}fillStatistic(t,n,e){if(this.isIgnoreStatsFill())return!1;n===1&&(n=1111);const i=n%10,l=Math.floor(n/10)%10,f=Math.floor(n/100)%10,h=Math.floor(n/1e3)%10,B=Math.floor(n/1e6)%10,g=Math.floor(n/1e7)%10,x=Math.floor(n/1e8)%10,r=this.countStat(void 0,g>0||x>0);return t.clearPave(),i>0&&t.addText(r.name),l>0&&t.addText("Entries = "+t.format(r.entries,"entries")),f>0&&(t.addText("Mean x = "+t.format(r.meanx)),t.addText("Mean y = "+t.format(r.meany)),t.addText("Mean z = "+t.format(r.meanz))),h>0&&(t.addText("Std Dev x = "+t.format(r.rmsx)),t.addText("Std Dev y = "+t.format(r.rmsy)),t.addText("Std Dev z = "+t.format(r.rmsz))),B>0&&t.addText("Integral = "+t.format(r.integral,"entries")),g===2?(t.addText(`Skewness x = ${t.format(r.skewx)} #pm ${t.format(r.skewd)}`),t.addText(`Skewness y = ${t.format(r.skewy)} #pm ${t.format(r.skewd)}`),t.addText(`Skewness z = ${t.format(r.skewz)} #pm ${t.format(r.skewd)}`)):g>0&&(t.addText(`Skewness x = ${t.format(r.skewx)}`),t.addText(`Skewness y = ${t.format(r.skewy)}`),t.addText(`Skewness z = ${t.format(r.skewz)}`)),x===2?(t.addText(`Kurtosis x = ${t.format(r.kurtx)} #pm ${t.format(r.kurtd)}`),t.addText(`Kurtosis y = ${t.format(r.kurty)} #pm ${t.format(r.kurtd)}`),t.addText(`Kurtosis z = ${t.format(r.kurtz)} #pm ${t.format(r.kurtd)}`)):x>0&&(t.addText(`Kurtosis x = ${t.format(r.kurtx)}`),t.addText(`Kurtosis y = ${t.format(r.kurty)}`),t.addText(`Kurtosis z = ${t.format(r.kurtz)}`)),e&&t.fillFunctionStat(this.findFunction(it),e,3),!0}getBinTooltips(t,n,e){const i=[],l=this.getHisto();i.push(this.getObjectHint(),`x = ${this.getAxisBinTip("x",l.fXaxis,t)} xbin=${t+1}`,`y = ${this.getAxisBinTip("y",l.fYaxis,n)} ybin=${n+1}`,`z = ${this.getAxisBinTip("z",l.fZaxis,e)} zbin=${e+1}`);const f=l.getBinContent(t+1,n+1,e+1);if(f===Math.round(f)?i.push(`entries = ${f}`):i.push(`entries = ${U(f,W.fStatFormat)}`),this.matchObjectType(nt)){const h=l.getBinError(l.getBin(t+1,n+1,e+1));i.push("error = "+(h===Math.round(h)?h.toString():U(h,W.fPaintTextFormat)))}return i}draw3DScatter(){const t=this.getObject(),n=this.getFramePainter(),e=this.getSelectIndex("x","left",.5),i=this.getSelectIndex("x","right",0),l=this.getSelectIndex("y","left",.5),f=this.getSelectIndex("y","right",0),h=this.getSelectIndex("z","left",.5),B=this.getSelectIndex("z","right",0);let g,x,r,T;if(i<=e||f<=l||B<=h)return Promise.resolve(!0);const S=this.gmaxbin>1e3?1e3/this.gmaxbin:1,s=Math.max(0,this.gminbin);let M=0,p=0;for(g=e;g<i;++g)for(x=l;x<f;++x)for(r=h;r<B;++r)T=t.getBinContent(g+1,x+1,r+1),p+=T,T>s&&(M+=Math.round(T*S));if(M>(n.webgl?1e5:3e4))return!1;const b=new st(M,n.webgl,n.size_x3d/200),C=new Int32Array(M),G=new rt(p);let E=0;for(g=e;g<i;++g)for(x=l;x<f;++x)for(r=h;r<B;++r){if(T=t.getBinContent(g+1,x+1,r+1),T<=s)continue;const k=Math.round(T*S);for(let D=0;D<k;++D){const I=t.fXaxis.GetBinCoord(g+G.random()),P=t.fYaxis.GetBinCoord(x+G.random()),w=t.fZaxis.GetBinCoord(r+G.random());C[E++]=t.getBin(g+1,x+1,r+1),b.addPoint(n.grx(I),n.gry(P),n.grz(w))}}return b.createPoints({color:this.getColor(t.fMarkerColor)}).then(k=>(n.add3DMesh(k),k.bins=C,k.tip_painter=this,k.tip_color=t.fMarkerColor===3?16711680:65280,k.tooltip=function(D){const I=Math.floor(D.index/this.nvertex);if(I<0||I>=this.bins.length)return null;const P=this.tip_painter,w=P.getHisto(),d=P.get3DToolTip(this.bins[I]);return d.x1=n.grx(w.fXaxis.GetBinLowEdge(d.ix)),d.x2=n.grx(w.fXaxis.GetBinLowEdge(d.ix+1)),d.y1=n.gry(w.fYaxis.GetBinLowEdge(d.iy)),d.y2=n.gry(w.fYaxis.GetBinLowEdge(d.iy+1)),d.z1=n.grz(w.fZaxis.GetBinLowEdge(d.iz)),d.z2=n.grz(w.fZaxis.GetBinLowEdge(d.iz+1)),d.color=this.tip_color,d.opacity=.3,d},!0))}async draw3DBins(){if(!this.draw_content)return!1;const t=this.getOptions();let n=t.BoxStyle;if(!n&&t.Scat){const a=this.draw3DScatter();if(a!==!1)return a;n=12}else!n&&!t.GLBox&&!t.GLColor&&!t.Lego&&(n=12);const e=this.getHisto(),i=this.getFramePainter();let l=!1,f=!1,h=!1,B=1,g=-1,x=this.getPadPainter()?.getRootPad()?.fLogv,r=!0,T=0,S=this.getColor(e.fFillColor),s=.5,M;if(!n&&t.Lego&&(n=t.Lego===1?10:t.Lego),t.GLBox===11||t.GLBox===12)s=.4,l=!0,t.GLBox===12&&(h=!0),M=new L.SphereGeometry(.5,i.webgl?16:8,i.webgl?12:6),M.applyMatrix4(new L.Matrix4().makeRotationX(Math.PI/2)),M.computeVertexNormals();else{const a=R.Indexes,m=R.Normals,_=R.Vertices,y=a.length*3,o=new Float32Array(y),F=new Float32Array(y);for(let c=0,z=-3;c<a.length;++c){const u=_[a[c]];o[c*3]=u.x-.5,o[c*3+1]=u.y-.5,o[c*3+2]=u.z-.5,c%6===0&&(z+=3),F[c*3]=m[z],F[c*3+1]=m[z+1],F[c*3+2]=m[z+2]}f=!0,n===12?h=!0:n===13?(h=!0,f=!1):t.GLColor&&(h=!0,B=.5,r=!1,f=!1,g=0,l=!0),M=new L.BufferGeometry,M.setAttribute("position",new L.BufferAttribute(o,3)),M.setAttribute("normal",new L.BufferAttribute(F,3))}this.#t=n,r&&x?this.gminposbin&&this.gmaxbin>this.gminposbin?(T=Math.log(this.gminposbin)-.1,r=1/(Math.log(this.gmaxbin)-T)):(x=0,r=1):r&&(r=this.gminbin||this.gmaxbin?1/Math.max(Math.abs(this.gminbin),Math.abs(this.gmaxbin)):1);const p=a=>{if(g>=0&&a<g)return 0;if(!r)return 1;if(x){if(a<=0)return 0;a=Math.log(a)-T}return Math.pow(Math.abs(a*r),.3333)},b=this.getSelectIndex("x","left",.5),C=this.getSelectIndex("x","right",0),G=this.getSelectIndex("y","left",.5),E=this.getSelectIndex("y","right",0),k=this.getSelectIndex("z","left",.5),D=this.getSelectIndex("z","right",0);if(C<=b||E<=G||D<=k)return!1;const I=h?this.getContour():null,P=h?this.getHistPalette():null,w=[],d=[],A=[],O=[],Y=[],Z=this.transferFunc&&xt(this.transferFunc,!0)?this.transferFunc:null;for(let a=b;a<C;++a){const m=i.grx(e.fXaxis.GetBinLowEdge(a+1)),_=i.grx(e.fXaxis.GetBinLowEdge(a+2));for(let y=G;y<E;++y){const o=i.gry(e.fYaxis.GetBinLowEdge(y+1)),F=i.gry(e.fYaxis.GetBinLowEdge(y+2));for(let c=k;c<D;++c){const z=e.getBinContent(a+1,y+1,c+1);if(!t.GLColor&&(z===0||z<this.gminbin))continue;const u=p(z);if(u<.001)continue;if(h){const q=I.getPaletteIndex(P,z);if(q===null)continue;if(d.push(P.getColor(q)),Z){const H=dt(Z,z,!1)*3;Y.push(!H||H<0?0:H>1?1:H)}}const v=i.grz(e.fZaxis.GetBinLowEdge(c+1)),j=i.grz(e.fZaxis.GetBinLowEdge(c+2));A.push(e.getBin(a+1,y+1,c+1));const $=new L.Matrix4;$.scale(new L.Vector3((_-m)*u,(F-o)*u,(j-v)*u)),$.setPosition((_+m)/2,(F+o)/2,(j+v)/2),w.push($),z<0&&O.push($)}}}function K(a){let m=this.binid;if(m===void 0){if(a.instanceId===void 0||a.instanceId>=this.bins.length)return;m=this.bins[a.instanceId]}const _=this.tip_painter,y=_.getHisto(),o=_.get3DToolTip(m),F=i.grx(y.fXaxis.GetBinCoord(o.ix-1)),c=i.grx(y.fXaxis.GetBinCoord(o.ix)),z=i.gry(y.fYaxis.GetBinCoord(o.iy-1)),u=i.gry(y.fYaxis.GetBinCoord(o.iy)),v=i.grz(y.fZaxis.GetBinCoord(o.iz-1)),j=i.grz(y.fZaxis.GetBinCoord(o.iz)),$=this.get_weight(o.value)*this.tipscale;return o.x1=(c+F)/2-(c-F)*$,o.x2=(c+F)/2+(c-F)*$,o.y1=(u+z)/2-(u-z)*$,o.y2=(u+z)/2+(u-z)*$,o.z1=(j+v)/2-(j-v)*$,o.z2=(j+v)/2+(j-v)*$,o.color=this.tip_color,o}if(h&&(Z||B!==1))for(let a=0;a<w.length;++a){const m=Z?Y[a]:B,_=new L.Color(d[a]),y=l?new L.MeshLambertMaterial({color:_,opacity:m,transparent:m<1,vertexColors:!1}):new L.MeshBasicMaterial({color:_,opacity:m,transparent:m<1,vertexColors:!1}),o=new L.Mesh(M,y);o.applyMatrix4(w[a]),o.tip_painter=this,o.binid=A[a],o.tipscale=s,o.tip_color=e.fFillColor===3?16711680:65280,o.get_weight=p,o.tooltip=K,i.add3DMesh(o)}else{h&&(S=new L.Color(1,1,1));const a=l?new L.MeshLambertMaterial({color:S,vertexColors:!1}):new L.MeshBasicMaterial({color:S,vertexColors:!1}),m=new L.InstancedMesh(M,a,w.length);for(let _=0;_<w.length;++_)m.setMatrixAt(_,w[_]),h&&m.setColorAt(_,new L.Color(d[_]));m.tip_painter=this,m.bins=A,m.tipscale=s,m.tip_color=e.fFillColor===3?16711680:65280,m.get_weight=p,m.tooltip=K,i.add3DMesh(m)}if(f){let m=function(_,y){if(!y)return;const o=new Float32Array(y.length*_.length*3);for(let F=0,c=0;F<y.length;++F){const z=y[F].elements;for(let u=0;u<_.length;++u,c+=3){const v=R.Vertices[_[u]];o[c]=z[12]+(v.x-.5)*z[0],o[c+1]=z[13]+(v.y-.5)*z[5],o[c+2]=z[14]+(v.z-.5)*z[10]}}i.add3DMesh(ht(o,a))};const a=new L.LineBasicMaterial({color:this.getColor(e.fLineColor)});m(R.Segments,w),m(R.Crosses,O)}return!0}async redraw(t){const n=this.getFramePainter(),e=this.getOptions();let i=Promise.resolve(!0),l=!0;if(t==="resize"){const f=n.resize3D();f!==1&&(l=!1,f&&n.render3D())}return l&&(i=Q(this,J,e.Render3D).then(()=>this.draw3DBins()).then(()=>{n.render3D(),this.updateStatWebCanvas(),n.addKeysHandler()})),this.isMainPainter()&&(i=i.then(()=>this.drawColorPalette(e.Zscale&&(this.#t===12||this.#t===13||e.GLBox===12)))),i.then(()=>this.updateFunctions()).then(()=>this.updateHistTitle()).then(()=>this)}fillToolbar(){const t=this.getPadPainter();t&&(t.addPadButton("auto_zoom","Unzoom all axes","ToggleZoom","Ctrl *"),this.draw_content&&t.addPadButton("statbox","Toggle stat box","ToggleStatBox"),t.addPadButton("th2colorz","Toggle color palette","ToggleColorZ"),t.showPadButtons())}canZoomInside(t,n,e){let i=this.getHisto();return i&&(i=i[`f${t.toUpperCase()}axis`]),!i||i.FindBin(e,.5)-i.FindBin(n,0)>1}autoZoom(){const t=this.getSelectIndex("x","left"),n=this.getSelectIndex("x","right"),e=this.getSelectIndex("y","left"),i=this.getSelectIndex("y","right"),l=this.getSelectIndex("z","left"),f=this.getSelectIndex("z","right"),h=this.getObject();let B,g,x;if(t===n||e===i||l===f)return;let r=h.getBinContent(t+1,e+1,l+1);for(B=t;B<n;++B)for(g=e;g<i;++g)for(x=l;x<f;++x)r=Math.min(r,h.getBinContent(B+1,g+1,x+1));if(r>0)return;let T=n,S=t,s=i,M=e,p=f,b=l;for(B=t;B<n;++B)for(g=e;g<i;++g)for(x=l;x<f;++x)h.getBinContent(B+1,g+1,x+1)>r&&(B<T&&(T=B),B>=S&&(S=B+1),g<s&&(s=g),g>=M&&(M=g+1),x<p&&(p=x),x>=b&&(b=x+1));let C,G,E,k,D,I,P=!1;if(T===S-1&&T>t+1&&S<n-1&&(T--,S++),s===M-1&&s>e+1&&M<i-1&&(s--,M++),p===b-1&&p>l+1&&b<f-1&&(p--,b++),(T>t||S<n)&&T<S-1&&(C=h.fXaxis.GetBinLowEdge(T+1),G=h.fXaxis.GetBinLowEdge(S+1),P=!0),(s>e||M<i)&&s<M-1&&(E=h.fYaxis.GetBinLowEdge(s+1),k=h.fYaxis.GetBinLowEdge(M+1),P=!0),(p>l||b<f)&&p<b-1&&(D=h.fZaxis.GetBinLowEdge(p+1),I=h.fZaxis.GetBinLowEdge(b+1),P=!0),P)return this.getFramePainter().zoom(C,G,E,k,D,I)}fillHistContextMenu(t){const n=this.getSupportedDrawOptions();t.addDrawMenu("Draw with",n,e=>{if(e.indexOf(ot)===0)return this.showInspector(e);this.decodeOptions(e),this.interactiveRedraw(!0,"drawopt")})}static async build3d(t,n){const e=new V(null,t);e.mode3d=!0,e.decodeOptions(n),e.scanContent();const i=new at(null,null);return e.getFramePainter=()=>i,Q(e,J).then(()=>e.draw3DBins()).then(()=>i.create3DScene(-1,!0))}static async draw(t,n,e){const i=new V(t,n);return i.mode3d=!0,ft(i,"3d").then(()=>(i.setAsMainPainter(),i.decodeOptions(e),i.checkPadRange(),i.scanContent(),i.createStat(),i.redraw())).then(()=>i.drawFunctions()).then(()=>(i.fillToolbar(),i))}}export{V as TH3Painter};
1
+ import{aX as tt,a2 as et,aW as it,aU as U,ae as W,bq as nt,aB as st,br as rt,aw as L,bs as R,bn as J,bt as ot,bo as at,a6 as ft,a5 as lt,an as ht}from"./ndmvr-aframe-core-DEHQ38JB.js";import{T as gt}from"./THistPainter-B2S5BnuY.js";import{b as Q}from"./hist3d-D9VevdP6.js";import{p as xt,g as dt}from"./func-C6FX2eN2.js";import"./TPavePainter-1yngbgp8.js";import"./latex3d-8Hbnfz6c.js";import"./TH2Painter-BpixRP4j.js";class V extends gt{#t;getDimension(){return 3}scanContent(t){if(t&&this.nbinsx&&this.nbinsy&&this.nbinsz)return;const n=this.getHisto();this.extractAxesProperties(3),this.gminbin=this.gmaxbin=n.getBinContent(1,1,1),this.gminposbin=null;for(let e=0;e<this.nbinsx;++e)for(let i=0;i<this.nbinsy;++i)for(let l=0;l<this.nbinsz;++l){const f=n.getBinContent(e+1,i+1,l+1);f<this.gminbin?this.gminbin=f:f>this.gmaxbin&&(this.gmaxbin=f),f>0&&(this.gminposbin===null||this.gminposbin>f)&&(this.gminposbin=f)}this.gminposbin===null&&this.gmaxbin>0&&(this.gminposbin=this.gmaxbin*1e-4),this.draw_content=this.gmaxbin||this.gminbin,this.transferFunc=this.findFunction(tt,"TransferFunction"),this.transferFunc?.SetBit(et(9),!0)}countStat(t,n){const e=this.getHisto(),i=e.fXaxis,l=e.fYaxis,f=e.fZaxis,h=this.getSelectIndex("x","left"),B=this.getSelectIndex("x","right"),g=this.getSelectIndex("y","left"),x=this.getSelectIndex("y","right"),r=this.getSelectIndex("z","left"),T=this.getSelectIndex("z","right"),S=this.getFramePainter(),s={name:e.fName,entries:0,eff_entries:0,integral:0,meanx:0,meany:0,meanz:0,rmsx:0,rmsy:0,rmsz:0,skewx:0,skewy:0,skewz:0,skewd:0,kurtx:0,kurty:0,kurtz:0,kurtd:0},M=Math.abs(e.fTsumw)>1e-300&&!S.isAxisZoomed("x")&&!S.isAxisZoomed("y")&&!S.isAxisZoomed("z");let p,b,C,G,E,k,D,I,P,w,d=0,A=0,O=0,Y=0,Z=0,K=0,a=0,m=0;for(lt(t)||(t=null),p=0;p<this.nbinsx+2;++p)for(G=i.GetBinCoord(p-.5),E=p<h?0:p>B?2:1,b=0;b<this.nbinsy+2;++b)for(k=l.GetBinCoord(b-.5),D=b<g?0:b>x?2:1,C=0;C<this.nbinsz+2;++C)I=f.GetBinCoord(C-.5),P=C<r?0:C>T?2:1,!(t&&!t(G,k,I))&&(w=e.getBinContent(p,b,C),s.entries+=w,!M&&E===1&&D===1&&P===1&&(d+=w,A+=w*w,O+=G*w,Y+=k*w,Z+=I*w,K+=G**2*w,a+=k**2*w,m+=I**2*w));if(M&&(d=e.fTsumw,A=e.fTsumw2,O=e.fTsumwx,K=e.fTsumwx2,Y=e.fTsumwy,a=e.fTsumwy2,Z=e.fTsumwz,m=e.fTsumwz2),Math.abs(d)>1e-300&&(s.meanx=O/d,s.meany=Y/d,s.meanz=Z/d,s.rmsx=Math.sqrt(Math.abs(K/d-s.meanx*s.meanx)),s.rmsy=Math.sqrt(Math.abs(a/d-s.meany*s.meany)),s.rmsz=Math.sqrt(Math.abs(m/d-s.meanz*s.meanz))),s.integral=d,e.fEntries>0&&(s.entries=e.fEntries),s.eff_entries=A?d*d/A:Math.abs(d),n&&!this.isTH2Poly()){let _=0,y=0,o=0,F=0,c=0,z=0,u=0;for(p=h;p<B;++p)for(G=i.GetBinCoord(p+.5),b=g;b<x;++b)for(k=l.GetBinCoord(b+.5),C=r;C<T;++C){if(I=f.GetBinCoord(C+.5),t&&!t(G,k,I))continue;const X=e.getBinContent(p+1,b+1,C+1);u+=X,_+=X*Math.pow(G-s.meanx,3),y+=X*Math.pow(k-s.meany,3),o+=X*Math.pow(I-s.meany,3),F+=X*Math.pow(G-s.meanx,4),c+=X*Math.pow(k-s.meany,4),z+=X*Math.pow(k-s.meany,4)}const v=Math.pow(s.rmsx,3),j=Math.pow(s.rmsy,3),$=Math.pow(s.rmsz,3),q=Math.pow(s.rmsx,4),H=Math.pow(s.rmsy,4),N=Math.pow(s.rmsz,4);u*v&&(s.skewx=_/(u*v)),u*j&&(s.skewy=y/(u*j)),u*$&&(s.skewz=o/(u*$)),s.skewd=s.eff_entries>0?Math.sqrt(6/s.eff_entries):0,u*q&&(s.kurtx=F/(u*q)-3),u*H&&(s.kurty=c/(u*H)-3),u*N&&(s.kurtz=z/(u*N)-3),s.kurtd=s.eff_entries>0?Math.sqrt(24/s.eff_entries):0}return s}fillStatistic(t,n,e){if(this.isIgnoreStatsFill())return!1;n===1&&(n=1111);const i=n%10,l=Math.floor(n/10)%10,f=Math.floor(n/100)%10,h=Math.floor(n/1e3)%10,B=Math.floor(n/1e6)%10,g=Math.floor(n/1e7)%10,x=Math.floor(n/1e8)%10,r=this.countStat(void 0,g>0||x>0);return t.clearPave(),i>0&&t.addText(r.name),l>0&&t.addText("Entries = "+t.format(r.entries,"entries")),f>0&&(t.addText("Mean x = "+t.format(r.meanx)),t.addText("Mean y = "+t.format(r.meany)),t.addText("Mean z = "+t.format(r.meanz))),h>0&&(t.addText("Std Dev x = "+t.format(r.rmsx)),t.addText("Std Dev y = "+t.format(r.rmsy)),t.addText("Std Dev z = "+t.format(r.rmsz))),B>0&&t.addText("Integral = "+t.format(r.integral,"entries")),g===2?(t.addText(`Skewness x = ${t.format(r.skewx)} #pm ${t.format(r.skewd)}`),t.addText(`Skewness y = ${t.format(r.skewy)} #pm ${t.format(r.skewd)}`),t.addText(`Skewness z = ${t.format(r.skewz)} #pm ${t.format(r.skewd)}`)):g>0&&(t.addText(`Skewness x = ${t.format(r.skewx)}`),t.addText(`Skewness y = ${t.format(r.skewy)}`),t.addText(`Skewness z = ${t.format(r.skewz)}`)),x===2?(t.addText(`Kurtosis x = ${t.format(r.kurtx)} #pm ${t.format(r.kurtd)}`),t.addText(`Kurtosis y = ${t.format(r.kurty)} #pm ${t.format(r.kurtd)}`),t.addText(`Kurtosis z = ${t.format(r.kurtz)} #pm ${t.format(r.kurtd)}`)):x>0&&(t.addText(`Kurtosis x = ${t.format(r.kurtx)}`),t.addText(`Kurtosis y = ${t.format(r.kurty)}`),t.addText(`Kurtosis z = ${t.format(r.kurtz)}`)),e&&t.fillFunctionStat(this.findFunction(it),e,3),!0}getBinTooltips(t,n,e){const i=[],l=this.getHisto();i.push(this.getObjectHint(),`x = ${this.getAxisBinTip("x",l.fXaxis,t)} xbin=${t+1}`,`y = ${this.getAxisBinTip("y",l.fYaxis,n)} ybin=${n+1}`,`z = ${this.getAxisBinTip("z",l.fZaxis,e)} zbin=${e+1}`);const f=l.getBinContent(t+1,n+1,e+1);if(f===Math.round(f)?i.push(`entries = ${f}`):i.push(`entries = ${U(f,W.fStatFormat)}`),this.matchObjectType(nt)){const h=l.getBinError(l.getBin(t+1,n+1,e+1));i.push("error = "+(h===Math.round(h)?h.toString():U(h,W.fPaintTextFormat)))}return i}draw3DScatter(){const t=this.getObject(),n=this.getFramePainter(),e=this.getSelectIndex("x","left",.5),i=this.getSelectIndex("x","right",0),l=this.getSelectIndex("y","left",.5),f=this.getSelectIndex("y","right",0),h=this.getSelectIndex("z","left",.5),B=this.getSelectIndex("z","right",0);let g,x,r,T;if(i<=e||f<=l||B<=h)return Promise.resolve(!0);const S=this.gmaxbin>1e3?1e3/this.gmaxbin:1,s=Math.max(0,this.gminbin);let M=0,p=0;for(g=e;g<i;++g)for(x=l;x<f;++x)for(r=h;r<B;++r)T=t.getBinContent(g+1,x+1,r+1),p+=T,T>s&&(M+=Math.round(T*S));if(M>(n.webgl?1e5:3e4))return!1;const b=new st(M,n.webgl,n.size_x3d/200),C=new Int32Array(M),G=new rt(p);let E=0;for(g=e;g<i;++g)for(x=l;x<f;++x)for(r=h;r<B;++r){if(T=t.getBinContent(g+1,x+1,r+1),T<=s)continue;const k=Math.round(T*S);for(let D=0;D<k;++D){const I=t.fXaxis.GetBinCoord(g+G.random()),P=t.fYaxis.GetBinCoord(x+G.random()),w=t.fZaxis.GetBinCoord(r+G.random());C[E++]=t.getBin(g+1,x+1,r+1),b.addPoint(n.grx(I),n.gry(P),n.grz(w))}}return b.createPoints({color:this.getColor(t.fMarkerColor)}).then(k=>(n.add3DMesh(k),k.bins=C,k.tip_painter=this,k.tip_color=t.fMarkerColor===3?16711680:65280,k.tooltip=function(D){const I=Math.floor(D.index/this.nvertex);if(I<0||I>=this.bins.length)return null;const P=this.tip_painter,w=P.getHisto(),d=P.get3DToolTip(this.bins[I]);return d.x1=n.grx(w.fXaxis.GetBinLowEdge(d.ix)),d.x2=n.grx(w.fXaxis.GetBinLowEdge(d.ix+1)),d.y1=n.gry(w.fYaxis.GetBinLowEdge(d.iy)),d.y2=n.gry(w.fYaxis.GetBinLowEdge(d.iy+1)),d.z1=n.grz(w.fZaxis.GetBinLowEdge(d.iz)),d.z2=n.grz(w.fZaxis.GetBinLowEdge(d.iz+1)),d.color=this.tip_color,d.opacity=.3,d},!0))}async draw3DBins(){if(!this.draw_content)return!1;const t=this.getOptions();let n=t.BoxStyle;if(!n&&t.Scat){const a=this.draw3DScatter();if(a!==!1)return a;n=12}else!n&&!t.GLBox&&!t.GLColor&&!t.Lego&&(n=12);const e=this.getHisto(),i=this.getFramePainter();let l=!1,f=!1,h=!1,B=1,g=-1,x=this.getPadPainter()?.getRootPad()?.fLogv,r=!0,T=0,S=this.getColor(e.fFillColor),s=.5,M;if(!n&&t.Lego&&(n=t.Lego===1?10:t.Lego),t.GLBox===11||t.GLBox===12)s=.4,l=!0,t.GLBox===12&&(h=!0),M=new L.SphereGeometry(.5,i.webgl?16:8,i.webgl?12:6),M.applyMatrix4(new L.Matrix4().makeRotationX(Math.PI/2)),M.computeVertexNormals();else{const a=R.Indexes,m=R.Normals,_=R.Vertices,y=a.length*3,o=new Float32Array(y),F=new Float32Array(y);for(let c=0,z=-3;c<a.length;++c){const u=_[a[c]];o[c*3]=u.x-.5,o[c*3+1]=u.y-.5,o[c*3+2]=u.z-.5,c%6===0&&(z+=3),F[c*3]=m[z],F[c*3+1]=m[z+1],F[c*3+2]=m[z+2]}f=!0,n===12?h=!0:n===13?(h=!0,f=!1):t.GLColor&&(h=!0,B=.5,r=!1,f=!1,g=0,l=!0),M=new L.BufferGeometry,M.setAttribute("position",new L.BufferAttribute(o,3)),M.setAttribute("normal",new L.BufferAttribute(F,3))}this.#t=n,r&&x?this.gminposbin&&this.gmaxbin>this.gminposbin?(T=Math.log(this.gminposbin)-.1,r=1/(Math.log(this.gmaxbin)-T)):(x=0,r=1):r&&(r=this.gminbin||this.gmaxbin?1/Math.max(Math.abs(this.gminbin),Math.abs(this.gmaxbin)):1);const p=a=>{if(g>=0&&a<g)return 0;if(!r)return 1;if(x){if(a<=0)return 0;a=Math.log(a)-T}return Math.pow(Math.abs(a*r),.3333)},b=this.getSelectIndex("x","left",.5),C=this.getSelectIndex("x","right",0),G=this.getSelectIndex("y","left",.5),E=this.getSelectIndex("y","right",0),k=this.getSelectIndex("z","left",.5),D=this.getSelectIndex("z","right",0);if(C<=b||E<=G||D<=k)return!1;const I=h?this.getContour():null,P=h?this.getHistPalette():null,w=[],d=[],A=[],O=[],Y=[],Z=this.transferFunc&&xt(this.transferFunc,!0)?this.transferFunc:null;for(let a=b;a<C;++a){const m=i.grx(e.fXaxis.GetBinLowEdge(a+1)),_=i.grx(e.fXaxis.GetBinLowEdge(a+2));for(let y=G;y<E;++y){const o=i.gry(e.fYaxis.GetBinLowEdge(y+1)),F=i.gry(e.fYaxis.GetBinLowEdge(y+2));for(let c=k;c<D;++c){const z=e.getBinContent(a+1,y+1,c+1);if(!t.GLColor&&(z===0||z<this.gminbin))continue;const u=p(z);if(u<.001)continue;if(h){const q=I.getPaletteIndex(P,z);if(q===null)continue;if(d.push(P.getColor(q)),Z){const H=dt(Z,z,!1)*3;Y.push(!H||H<0?0:H>1?1:H)}}const v=i.grz(e.fZaxis.GetBinLowEdge(c+1)),j=i.grz(e.fZaxis.GetBinLowEdge(c+2));A.push(e.getBin(a+1,y+1,c+1));const $=new L.Matrix4;$.scale(new L.Vector3((_-m)*u,(F-o)*u,(j-v)*u)),$.setPosition((_+m)/2,(F+o)/2,(j+v)/2),w.push($),z<0&&O.push($)}}}function K(a){let m=this.binid;if(m===void 0){if(a.instanceId===void 0||a.instanceId>=this.bins.length)return;m=this.bins[a.instanceId]}const _=this.tip_painter,y=_.getHisto(),o=_.get3DToolTip(m),F=i.grx(y.fXaxis.GetBinCoord(o.ix-1)),c=i.grx(y.fXaxis.GetBinCoord(o.ix)),z=i.gry(y.fYaxis.GetBinCoord(o.iy-1)),u=i.gry(y.fYaxis.GetBinCoord(o.iy)),v=i.grz(y.fZaxis.GetBinCoord(o.iz-1)),j=i.grz(y.fZaxis.GetBinCoord(o.iz)),$=this.get_weight(o.value)*this.tipscale;return o.x1=(c+F)/2-(c-F)*$,o.x2=(c+F)/2+(c-F)*$,o.y1=(u+z)/2-(u-z)*$,o.y2=(u+z)/2+(u-z)*$,o.z1=(j+v)/2-(j-v)*$,o.z2=(j+v)/2+(j-v)*$,o.color=this.tip_color,o}if(h&&(Z||B!==1))for(let a=0;a<w.length;++a){const m=Z?Y[a]:B,_=new L.Color(d[a]),y=l?new L.MeshLambertMaterial({color:_,opacity:m,transparent:m<1,vertexColors:!1}):new L.MeshBasicMaterial({color:_,opacity:m,transparent:m<1,vertexColors:!1}),o=new L.Mesh(M,y);o.applyMatrix4(w[a]),o.tip_painter=this,o.binid=A[a],o.tipscale=s,o.tip_color=e.fFillColor===3?16711680:65280,o.get_weight=p,o.tooltip=K,i.add3DMesh(o)}else{h&&(S=new L.Color(1,1,1));const a=l?new L.MeshLambertMaterial({color:S,vertexColors:!1}):new L.MeshBasicMaterial({color:S,vertexColors:!1}),m=new L.InstancedMesh(M,a,w.length);for(let _=0;_<w.length;++_)m.setMatrixAt(_,w[_]),h&&m.setColorAt(_,new L.Color(d[_]));m.tip_painter=this,m.bins=A,m.tipscale=s,m.tip_color=e.fFillColor===3?16711680:65280,m.get_weight=p,m.tooltip=K,i.add3DMesh(m)}if(f){let m=function(_,y){if(!y)return;const o=new Float32Array(y.length*_.length*3);for(let F=0,c=0;F<y.length;++F){const z=y[F].elements;for(let u=0;u<_.length;++u,c+=3){const v=R.Vertices[_[u]];o[c]=z[12]+(v.x-.5)*z[0],o[c+1]=z[13]+(v.y-.5)*z[5],o[c+2]=z[14]+(v.z-.5)*z[10]}}i.add3DMesh(ht(o,a))};const a=new L.LineBasicMaterial({color:this.getColor(e.fLineColor)});m(R.Segments,w),m(R.Crosses,O)}return!0}async redraw(t){const n=this.getFramePainter(),e=this.getOptions();let i=Promise.resolve(!0),l=!0;if(t==="resize"){const f=n.resize3D();f!==1&&(l=!1,f&&n.render3D())}return l&&(i=Q(this,J,e.Render3D).then(()=>this.draw3DBins()).then(()=>{n.render3D(),this.updateStatWebCanvas(),n.addKeysHandler()})),this.isMainPainter()&&(i=i.then(()=>this.drawColorPalette(e.Zscale&&(this.#t===12||this.#t===13||e.GLBox===12)))),i.then(()=>this.updateFunctions()).then(()=>this.updateHistTitle()).then(()=>this)}fillToolbar(){const t=this.getPadPainter();t&&(t.addPadButton("auto_zoom","Unzoom all axes","ToggleZoom","Ctrl *"),this.draw_content&&t.addPadButton("statbox","Toggle stat box","ToggleStatBox"),t.addPadButton("th2colorz","Toggle color palette","ToggleColorZ"),t.showPadButtons())}canZoomInside(t,n,e){let i=this.getHisto();return i&&(i=i[`f${t.toUpperCase()}axis`]),!i||i.FindBin(e,.5)-i.FindBin(n,0)>1}autoZoom(){const t=this.getSelectIndex("x","left"),n=this.getSelectIndex("x","right"),e=this.getSelectIndex("y","left"),i=this.getSelectIndex("y","right"),l=this.getSelectIndex("z","left"),f=this.getSelectIndex("z","right"),h=this.getObject();let B,g,x;if(t===n||e===i||l===f)return;let r=h.getBinContent(t+1,e+1,l+1);for(B=t;B<n;++B)for(g=e;g<i;++g)for(x=l;x<f;++x)r=Math.min(r,h.getBinContent(B+1,g+1,x+1));if(r>0)return;let T=n,S=t,s=i,M=e,p=f,b=l;for(B=t;B<n;++B)for(g=e;g<i;++g)for(x=l;x<f;++x)h.getBinContent(B+1,g+1,x+1)>r&&(B<T&&(T=B),B>=S&&(S=B+1),g<s&&(s=g),g>=M&&(M=g+1),x<p&&(p=x),x>=b&&(b=x+1));let C,G,E,k,D,I,P=!1;if(T===S-1&&T>t+1&&S<n-1&&(T--,S++),s===M-1&&s>e+1&&M<i-1&&(s--,M++),p===b-1&&p>l+1&&b<f-1&&(p--,b++),(T>t||S<n)&&T<S-1&&(C=h.fXaxis.GetBinLowEdge(T+1),G=h.fXaxis.GetBinLowEdge(S+1),P=!0),(s>e||M<i)&&s<M-1&&(E=h.fYaxis.GetBinLowEdge(s+1),k=h.fYaxis.GetBinLowEdge(M+1),P=!0),(p>l||b<f)&&p<b-1&&(D=h.fZaxis.GetBinLowEdge(p+1),I=h.fZaxis.GetBinLowEdge(b+1),P=!0),P)return this.getFramePainter().zoom(C,G,E,k,D,I)}fillHistContextMenu(t){const n=this.getSupportedDrawOptions();t.addDrawMenu("Draw with",n,e=>{if(e.indexOf(ot)===0)return this.showInspector(e);this.decodeOptions(e),this.interactiveRedraw(!0,"drawopt")})}static async build3d(t,n){const e=new V(null,t);e.mode3d=!0,e.decodeOptions(n),e.scanContent();const i=new at(null,null);return e.getFramePainter=()=>i,Q(e,J).then(()=>e.draw3DBins()).then(()=>i.create3DScene(-1,!0))}static async draw(t,n,e){const i=new V(t,n);return i.mode3d=!0,ft(i,"3d").then(()=>(i.setAsMainPainter(),i.decodeOptions(e),i.checkPadRange(),i.scanContent(),i.createStat(),i.redraw())).then(()=>i.drawFunctions()).then(()=>(i.fillToolbar(),i))}}export{V as TH3Painter};
@@ -1 +1 @@
1
- import{a7 as C,ab as X,s as Y,ac as T,ad as l,ae as $,a2 as L,af as b,a3 as B,ag as N,ah as D,ai as _,aj as S,ak as E,a6 as z,al as y}from"./ndmvr-aframe-core-Cw91_9_Y.js";import{T as I}from"./TH1Painter--tuoUZTH.js";import{T as R}from"./TH2Painter-DHaL_lR_.js";import{TH1Painter as F}from"./TH1Painter-CMr7gXzd.js";import{TH2Painter as W}from"./TH2Painter-BLfyBVB5.js";import"./THistPainter-Df-RmCQH.js";import"./TPavePainter-Dx40jhkF.js";import"./func-C1jNXIub.js";import"./hist3d-DCmav5Ga.js";import"./latex3d-ITrfFgp8.js";const A=L(16);let Z=class j extends C{#t;#i;#s;#e;constructor(r,t,a){super(r,t,a),this.#t=null,this.#i=[]}cleanup(){this.getPadPainter()?.cleanPrimitives(r=>r===this.#t||this.#i.indexOf(r)>=0),this.#t=null,this.#i=[],this.#s=void 0,super.cleanup()}buildStack(r,t){if(this.#s=null,!r.fHists)return!1;const a=r.fHists.arr.length;if(a<=0)return!1;let s=t?.findInPrimitives(void 0,X);if(s?.arr.length===a&&s?.name===r.fName)return this.#s=s,!0;s=Y(X);let n=T(r.fHists.arr[0]);s.arr.push(n);for(let e=1;e<a;++e){const i=T(r.fHists.arr[e]),f=i.fXaxis,o=n.fXaxis;let h=f.fNbins===o.fNbins&&f.fXmin===o.fXmin&&f.fXmax===o.fXmax;if(!h&&f.fNbins>0&&f.fNbins<o.fNbins&&f.fXmin===o.fXmin&&Math.abs((f.fXmax-f.fXmin)/f.fNbins-(o.fXmax-o.fXmin)/o.fNbins)<1e-4){const c=new Array(n.fNcells).fill(0);for(let m=1;m<=f.fNbins;++m)c[m]=i.fArray[m];i.fNcells=n.fNcells,Object.assign(f,o),i.fArray=c,h=!0}if(!h)return console.warn(`When drawing THStack, cannot sum-up histograms ${i.fName} and ${n.fName}`),!1;for(let c=0;c<i.fArray.length;++c)i.fArray[c]+=n.fArray[c];s.arr.push(i),n=i}return this.#s=s,!0}getMinMax(r){const t=this.getObject(),a=this.getOptions(),s=this.getPadPainter()?.getRootPad(!0),n=s?.fLogv??(a.ndim===1?s?.fLogy:s?.fLogz);let e=0,i=0;const f=(h,c)=>{const m={min:0,max:0};let d=!0,H=!0;if(h.fMinimum!==l&&(m.min=h.fMinimum,d=!1),h.fMaximum!==l&&(m.max=h.fMaximum,H=!1),!d&&!H)return m;let k=1,M=h.fXaxis.fNbins,P=1,w=1,O=!0;h.fXaxis.TestBit(y.kAxisRange)&&(k=h.fXaxis.fFirst,M=h.fXaxis.fLast),h._typename.indexOf(b)===0&&(w=h.fYaxis.fNbins,h.fYaxis.TestBit(y.kAxisRange)&&(P=h.fYaxis.fFirst,w=h.fYaxis.fLast));let u=0;for(let p=P;p<=w;++p)for(let g=k;g<=M;++g){const x=h.getBinContent(g,p);c&&(u=h.getBinError(h.getBin(g,p))),!(n&&x-u<=0)&&(d&&(O||x-u<m.min)&&(m.min=x-u),H&&(O||x+u>m.max)&&(m.max=x+u),O=!1)}return m};if(a.nostack)for(let h=0;h<t.fHists.arr.length;++h){const c=f(t.fHists.arr[h],r);h===0?(e=c.min,i=c.max):(e=Math.min(e,c.min),i=Math.max(i,c.max))}else e=f(this.#s.arr.at(0),r).min,i=f(this.#s.arr.at(-1),r).max;n?e=e>0?e*.9:i*.001:e>0&&(e=0),t.fMaximum!==l&&(i=t.fMaximum),t.fMinimum!==l&&(e=t.fMinimum),(!a.nostack||t.fMaximum===l)&&(n?e>0&&(i*=1+.2*Math.log10(i/e)):t.fMaximum===l&&(i*=1+$.fHistTopMargin)),(!a.nostack||t.fMinimum===l)&&n&&(e=e>0?e/(1+.5*Math.log10(i/e)):.001*i);const o={min:e,max:i,hopt:`;hmin:${e};hmax:${i}`};return t.fHistogram?.TestBit(A)&&(o.hopt+=";zoom_min_max"),o}getHistDrawOption(r,t){const a=this.getOptions();let s=t||r.fOption||a.hopt;if(s.toUpperCase().indexOf(a.hopt)<0&&(s+=" "+a.hopt),a.draw_errors&&!s&&(s="E"),a.zscale){const n=s.toUpperCase().indexOf("COLZ");n>=0&&(s=s.slice(0,n+3)+s.slice(n+4))}return a.pads||(s+=" same nostat"+a.auto),s}async drawNextHisto(r,t){const a=this.getObject(),s=this.getOptions(),n=s.nostack?a.fHists:this.#s,e=n?.arr?.length||0;if(r>=e)return this;const i=s.horder?r:e-r-1,f=s.nostack?`hists_${i}`:`stack_${i}`,o=n.arr[i],h=this.getHistDrawOption(o,a.fHists.opt[i]);if(t){const m=t.getSubPadPainter(r+1);return m?(m.cleanPrimitives(!0),this.drawHist(m,o,h).then(d=>(d&&(d.setSecondaryId(this,f),this.#i.push(d)),this.drawNextHisto(r+1,t)))):this}i>0&&!s.nostack&&(o.$baseh=n.arr[i-1]),s.auto&&(o.$num_histos=e);const c=this.#t?.getPadPainter()||this.getDrawDom();return this.drawHist(c,o,h).then(m=>(m.setSecondaryId(this,f),this.#i.push(m),this.drawNextHisto(r+1,t)))}decodeOptions(r){const t=this.setOptions({ndim:1,nostack:!1,same:!1,horder:!0,has_errors:!1,draw_errors:!1,hopt:"",auto:""}),a=this.getObject();(a.fHistogram||a.fHists?.arr[0]||this.#s?.arr[0])?._typename.indexOf(b)===0&&(t.ndim=2),t.ndim===2&&!r&&(r="lego1"),t.nostack||a.fHists?.arr.forEach(i=>{const f=i.fSumw2?.length??0;for(let o=0;o<f;++o)if(i.fSumw2[o]>0){t.has_errors=!0;break}}),t.nhist=a.fHists?.arr?.length??1;const n=new B(r);t.nostack=n.check("NOSTACK"),n.check("STACK")&&(t.nostack=!1),t.same=n.check("SAME"),n.check("NOCLEAR"),["PFC","PLC","PMC"].forEach(i=>{n.check(i)&&(t.auto+=" "+i)}),t.pads=n.check("PADS"),t.pads&&(t.nostack=!0),t.hopt=n.remain().trim();const e=n.check("LEGO");t.errors=n.check("E"),t.zscale=n.check("COLZ"),!t.nostack&&t.has_errors&&!e&&!n.check("HIST")&&t.hopt.indexOf("E")<0&&(t.draw_errors=!0),t.horder=t.nostack||e}createHistogram(r){const t=this.getOptions(),a=r.fHists,s=a?.arr.length??0;if(!s){const i=N(S,100);return D(i,r.fTitle),i.fBits|=_,i}const n=a.arr[0],e=N(t.ndim===1?S:E,n.fXaxis.fNbins,n.fYaxis.fNbins);e.fName="axis_hist",e.fBits|=_,Object.assign(e.fXaxis,n.fXaxis),t.ndim===2&&Object.assign(e.fYaxis,n.fYaxis);for(let i=1;i<s;++i){const f=a.arr[i];e.fXaxis.fLabels||(e.fXaxis.fXmin=Math.min(e.fXaxis.fXmin,f.fXaxis.fXmin),e.fXaxis.fXmax=Math.max(e.fXaxis.fXmax,f.fXaxis.fXmax)),t.ndim===2&&!e.fYaxis.fLabels&&(e.fYaxis.fXmin=Math.min(e.fYaxis.fXmin,f.fYaxis.fXmin),e.fYaxis.fXmax=Math.max(e.fYaxis.fXmax,f.fYaxis.fXmax))}return e.fTitle=r.fTitle,e}updateObject(r){if(!this.matchObjectType(r))return!1;const t=this.getObject(),a=this.getPadPainter(),s=this.getOptions();if(t.fHists=r.fHists,t.fTitle=r.fTitle,t.fMinimum=r.fMinimum,t.fMaximum=r.fMaximum,s.nostack||(s.nostack=!this.buildStack(t,a)),this.#t){let i=r.fHistogram;i||(i=t.fHistogram=this.createHistogram(t));const f=this.getMinMax(s.errors||s.draw_errors);this.#t.options.hmin=f.min,this.#t.options.hmax=f.max,this.#t._checked_zooming=!1,s.ndim===1?(this.#t.ymin=f.min,this.#t.ymax=f.max):(this.#t.zmin=f.min,this.#t.zmax=f.max),this.#t.updateObject(i),this.#t.options.zoom_min_max=i.TestBit(A)}const n=s.nostack?t.fHists:this.#s,e=n?.arr?.length??0;if(e!==this.#i.length)this.#e=1,a?.cleanPrimitives(i=>this.#i.indexOf(i)>=0),this.#i=[];else{this.#e=2;for(let i=0;i<e;++i){const f=s.horder?i:e-i-1,o=n.arr[f];this.#i[i].updateObject(o,this.getHistDrawOption(o,t.fHists.opt[f]))}}return!0}redraw(r){if(!this.#e)return;const t=this.#e===1;this.#e=void 0;let a=Promise.resolve(this);const s=this.getOptions();if(this.#t){const n=this.getMinMax(s.errors||s.draw_errors);this.#t.decodeOptions(s.hopt+n.hopt),a=this.#t.redraw(r)}return a.then(()=>{if(t)return this.drawNextHisto(0,s.pads?this.getPadPainter():null);const n=e=>e>=this.#i.length?this:this.#i[e].redraw(r).then(()=>n(e+1));return n(0)})}fillContextMenuItems(r){const t=this.getOptions();r.addRedrawMenu(this),t.pads||r.addchk(t.draw_errors,"Draw errors",a=>{t.draw_errors=a;const s=this.getObject(),n=t.nostack?s.fHists:this.#s,e=n?.arr?.length??0;for(let i=0;i<e;++i){const f=t.horder?i:e-i-1,o=n.arr[f];this.#i[i].decodeOptions(this.getHistDrawOption(o,s.fHists.opt[f]))}this.redrawPad()},"Change draw erros in the stack")}drawHist(r,t,a){return(this.getOptions().ndim===1?I.draw:R.draw)(r,t,a)}accessMM(r,t){const a=r?"fMinimum":"fMaximum",s=this.getObject();if(t===void 0)return s[a];this.#e=2,s[a]=t,this.interactiveRedraw("pad",r?`exec:SetMinimum(${t})`:`exec:SetMaximum(${t})`)}async redrawWith(r,t){const a=this.getPadPainter(),s=this.getOptions();!t&&a&&(this.#t=null,this.#i=[],s.pads&&a.divide(0,0),a.removePrimitive(this,!0)),this.decodeOptions(r);const n=this.getObject();let e=Promise.resolve(this),i=null;if(s.pads)e=z(this,!1).then(()=>(i=this.getPadPainter(),i.divide(s.nhist,0,!0)));else if(s.nostack||(s.nostack=!this.buildStack(n,a)),!s.same&&n.fHists?.arr.length){n.fHistogram||(n.fHistogram=this.createHistogram(n));const f=this.getMinMax(s.errors||s.draw_errors);e=this.drawHist(this.getDrawDom(),n.fHistogram,s.hopt+f.hopt).then(o=>{this.#t=o,o.$stack_hist=!0,o.setSecondaryId(this,"hist")})}return e.then(()=>this.drawNextHisto(0,i)).then(()=>(s.pads||this.addToPadPrimitives(),this))}static async draw(r,t,a){return!t.fHists||!t.fHists.arr?null:new j(r,t,a).redrawWith(a,!0)}};class v extends Z{drawHist(r,t,a){return(this.getOptions().ndim===1?F.draw:W.draw)(r,t,a)}static async draw(r,t,a){return!t.fHists||!t.fHists.arr?null:new v(r,t,a).redrawWith(a,!0)}}export{v as THStackPainter};
1
+ import{a7 as C,ab as X,s as Y,ac as T,ad as l,ae as $,a2 as L,af as b,a3 as B,ag as N,ah as D,ai as _,aj as S,ak as E,a6 as z,al as y}from"./ndmvr-aframe-core-DEHQ38JB.js";import{T as I}from"./TH1Painter-DyN-WKyv.js";import{T as R}from"./TH2Painter-BpixRP4j.js";import{TH1Painter as F}from"./TH1Painter-BXzutgI3.js";import{TH2Painter as W}from"./TH2Painter-DceuYQAL.js";import"./THistPainter-B2S5BnuY.js";import"./TPavePainter-1yngbgp8.js";import"./func-C6FX2eN2.js";import"./hist3d-D9VevdP6.js";import"./latex3d-8Hbnfz6c.js";const A=L(16);let Z=class j extends C{#t;#i;#s;#e;constructor(r,t,a){super(r,t,a),this.#t=null,this.#i=[]}cleanup(){this.getPadPainter()?.cleanPrimitives(r=>r===this.#t||this.#i.indexOf(r)>=0),this.#t=null,this.#i=[],this.#s=void 0,super.cleanup()}buildStack(r,t){if(this.#s=null,!r.fHists)return!1;const a=r.fHists.arr.length;if(a<=0)return!1;let s=t?.findInPrimitives(void 0,X);if(s?.arr.length===a&&s?.name===r.fName)return this.#s=s,!0;s=Y(X);let n=T(r.fHists.arr[0]);s.arr.push(n);for(let e=1;e<a;++e){const i=T(r.fHists.arr[e]),f=i.fXaxis,o=n.fXaxis;let h=f.fNbins===o.fNbins&&f.fXmin===o.fXmin&&f.fXmax===o.fXmax;if(!h&&f.fNbins>0&&f.fNbins<o.fNbins&&f.fXmin===o.fXmin&&Math.abs((f.fXmax-f.fXmin)/f.fNbins-(o.fXmax-o.fXmin)/o.fNbins)<1e-4){const c=new Array(n.fNcells).fill(0);for(let m=1;m<=f.fNbins;++m)c[m]=i.fArray[m];i.fNcells=n.fNcells,Object.assign(f,o),i.fArray=c,h=!0}if(!h)return console.warn(`When drawing THStack, cannot sum-up histograms ${i.fName} and ${n.fName}`),!1;for(let c=0;c<i.fArray.length;++c)i.fArray[c]+=n.fArray[c];s.arr.push(i),n=i}return this.#s=s,!0}getMinMax(r){const t=this.getObject(),a=this.getOptions(),s=this.getPadPainter()?.getRootPad(!0),n=s?.fLogv??(a.ndim===1?s?.fLogy:s?.fLogz);let e=0,i=0;const f=(h,c)=>{const m={min:0,max:0};let d=!0,H=!0;if(h.fMinimum!==l&&(m.min=h.fMinimum,d=!1),h.fMaximum!==l&&(m.max=h.fMaximum,H=!1),!d&&!H)return m;let k=1,M=h.fXaxis.fNbins,P=1,w=1,O=!0;h.fXaxis.TestBit(y.kAxisRange)&&(k=h.fXaxis.fFirst,M=h.fXaxis.fLast),h._typename.indexOf(b)===0&&(w=h.fYaxis.fNbins,h.fYaxis.TestBit(y.kAxisRange)&&(P=h.fYaxis.fFirst,w=h.fYaxis.fLast));let u=0;for(let p=P;p<=w;++p)for(let g=k;g<=M;++g){const x=h.getBinContent(g,p);c&&(u=h.getBinError(h.getBin(g,p))),!(n&&x-u<=0)&&(d&&(O||x-u<m.min)&&(m.min=x-u),H&&(O||x+u>m.max)&&(m.max=x+u),O=!1)}return m};if(a.nostack)for(let h=0;h<t.fHists.arr.length;++h){const c=f(t.fHists.arr[h],r);h===0?(e=c.min,i=c.max):(e=Math.min(e,c.min),i=Math.max(i,c.max))}else e=f(this.#s.arr.at(0),r).min,i=f(this.#s.arr.at(-1),r).max;n?e=e>0?e*.9:i*.001:e>0&&(e=0),t.fMaximum!==l&&(i=t.fMaximum),t.fMinimum!==l&&(e=t.fMinimum),(!a.nostack||t.fMaximum===l)&&(n?e>0&&(i*=1+.2*Math.log10(i/e)):t.fMaximum===l&&(i*=1+$.fHistTopMargin)),(!a.nostack||t.fMinimum===l)&&n&&(e=e>0?e/(1+.5*Math.log10(i/e)):.001*i);const o={min:e,max:i,hopt:`;hmin:${e};hmax:${i}`};return t.fHistogram?.TestBit(A)&&(o.hopt+=";zoom_min_max"),o}getHistDrawOption(r,t){const a=this.getOptions();let s=t||r.fOption||a.hopt;if(s.toUpperCase().indexOf(a.hopt)<0&&(s+=" "+a.hopt),a.draw_errors&&!s&&(s="E"),a.zscale){const n=s.toUpperCase().indexOf("COLZ");n>=0&&(s=s.slice(0,n+3)+s.slice(n+4))}return a.pads||(s+=" same nostat"+a.auto),s}async drawNextHisto(r,t){const a=this.getObject(),s=this.getOptions(),n=s.nostack?a.fHists:this.#s,e=n?.arr?.length||0;if(r>=e)return this;const i=s.horder?r:e-r-1,f=s.nostack?`hists_${i}`:`stack_${i}`,o=n.arr[i],h=this.getHistDrawOption(o,a.fHists.opt[i]);if(t){const m=t.getSubPadPainter(r+1);return m?(m.cleanPrimitives(!0),this.drawHist(m,o,h).then(d=>(d&&(d.setSecondaryId(this,f),this.#i.push(d)),this.drawNextHisto(r+1,t)))):this}i>0&&!s.nostack&&(o.$baseh=n.arr[i-1]),s.auto&&(o.$num_histos=e);const c=this.#t?.getPadPainter()||this.getDrawDom();return this.drawHist(c,o,h).then(m=>(m.setSecondaryId(this,f),this.#i.push(m),this.drawNextHisto(r+1,t)))}decodeOptions(r){const t=this.setOptions({ndim:1,nostack:!1,same:!1,horder:!0,has_errors:!1,draw_errors:!1,hopt:"",auto:""}),a=this.getObject();(a.fHistogram||a.fHists?.arr[0]||this.#s?.arr[0])?._typename.indexOf(b)===0&&(t.ndim=2),t.ndim===2&&!r&&(r="lego1"),t.nostack||a.fHists?.arr.forEach(i=>{const f=i.fSumw2?.length??0;for(let o=0;o<f;++o)if(i.fSumw2[o]>0){t.has_errors=!0;break}}),t.nhist=a.fHists?.arr?.length??1;const n=new B(r);t.nostack=n.check("NOSTACK"),n.check("STACK")&&(t.nostack=!1),t.same=n.check("SAME"),n.check("NOCLEAR"),["PFC","PLC","PMC"].forEach(i=>{n.check(i)&&(t.auto+=" "+i)}),t.pads=n.check("PADS"),t.pads&&(t.nostack=!0),t.hopt=n.remain().trim();const e=n.check("LEGO");t.errors=n.check("E"),t.zscale=n.check("COLZ"),!t.nostack&&t.has_errors&&!e&&!n.check("HIST")&&t.hopt.indexOf("E")<0&&(t.draw_errors=!0),t.horder=t.nostack||e}createHistogram(r){const t=this.getOptions(),a=r.fHists,s=a?.arr.length??0;if(!s){const i=N(S,100);return D(i,r.fTitle),i.fBits|=_,i}const n=a.arr[0],e=N(t.ndim===1?S:E,n.fXaxis.fNbins,n.fYaxis.fNbins);e.fName="axis_hist",e.fBits|=_,Object.assign(e.fXaxis,n.fXaxis),t.ndim===2&&Object.assign(e.fYaxis,n.fYaxis);for(let i=1;i<s;++i){const f=a.arr[i];e.fXaxis.fLabels||(e.fXaxis.fXmin=Math.min(e.fXaxis.fXmin,f.fXaxis.fXmin),e.fXaxis.fXmax=Math.max(e.fXaxis.fXmax,f.fXaxis.fXmax)),t.ndim===2&&!e.fYaxis.fLabels&&(e.fYaxis.fXmin=Math.min(e.fYaxis.fXmin,f.fYaxis.fXmin),e.fYaxis.fXmax=Math.max(e.fYaxis.fXmax,f.fYaxis.fXmax))}return e.fTitle=r.fTitle,e}updateObject(r){if(!this.matchObjectType(r))return!1;const t=this.getObject(),a=this.getPadPainter(),s=this.getOptions();if(t.fHists=r.fHists,t.fTitle=r.fTitle,t.fMinimum=r.fMinimum,t.fMaximum=r.fMaximum,s.nostack||(s.nostack=!this.buildStack(t,a)),this.#t){let i=r.fHistogram;i||(i=t.fHistogram=this.createHistogram(t));const f=this.getMinMax(s.errors||s.draw_errors);this.#t.options.hmin=f.min,this.#t.options.hmax=f.max,this.#t._checked_zooming=!1,s.ndim===1?(this.#t.ymin=f.min,this.#t.ymax=f.max):(this.#t.zmin=f.min,this.#t.zmax=f.max),this.#t.updateObject(i),this.#t.options.zoom_min_max=i.TestBit(A)}const n=s.nostack?t.fHists:this.#s,e=n?.arr?.length??0;if(e!==this.#i.length)this.#e=1,a?.cleanPrimitives(i=>this.#i.indexOf(i)>=0),this.#i=[];else{this.#e=2;for(let i=0;i<e;++i){const f=s.horder?i:e-i-1,o=n.arr[f];this.#i[i].updateObject(o,this.getHistDrawOption(o,t.fHists.opt[f]))}}return!0}redraw(r){if(!this.#e)return;const t=this.#e===1;this.#e=void 0;let a=Promise.resolve(this);const s=this.getOptions();if(this.#t){const n=this.getMinMax(s.errors||s.draw_errors);this.#t.decodeOptions(s.hopt+n.hopt),a=this.#t.redraw(r)}return a.then(()=>{if(t)return this.drawNextHisto(0,s.pads?this.getPadPainter():null);const n=e=>e>=this.#i.length?this:this.#i[e].redraw(r).then(()=>n(e+1));return n(0)})}fillContextMenuItems(r){const t=this.getOptions();r.addRedrawMenu(this),t.pads||r.addchk(t.draw_errors,"Draw errors",a=>{t.draw_errors=a;const s=this.getObject(),n=t.nostack?s.fHists:this.#s,e=n?.arr?.length??0;for(let i=0;i<e;++i){const f=t.horder?i:e-i-1,o=n.arr[f];this.#i[i].decodeOptions(this.getHistDrawOption(o,s.fHists.opt[f]))}this.redrawPad()},"Change draw erros in the stack")}drawHist(r,t,a){return(this.getOptions().ndim===1?I.draw:R.draw)(r,t,a)}accessMM(r,t){const a=r?"fMinimum":"fMaximum",s=this.getObject();if(t===void 0)return s[a];this.#e=2,s[a]=t,this.interactiveRedraw("pad",r?`exec:SetMinimum(${t})`:`exec:SetMaximum(${t})`)}async redrawWith(r,t){const a=this.getPadPainter(),s=this.getOptions();!t&&a&&(this.#t=null,this.#i=[],s.pads&&a.divide(0,0),a.removePrimitive(this,!0)),this.decodeOptions(r);const n=this.getObject();let e=Promise.resolve(this),i=null;if(s.pads)e=z(this,!1).then(()=>(i=this.getPadPainter(),i.divide(s.nhist,0,!0)));else if(s.nostack||(s.nostack=!this.buildStack(n,a)),!s.same&&n.fHists?.arr.length){n.fHistogram||(n.fHistogram=this.createHistogram(n));const f=this.getMinMax(s.errors||s.draw_errors);e=this.drawHist(this.getDrawDom(),n.fHistogram,s.hopt+f.hopt).then(o=>{this.#t=o,o.$stack_hist=!0,o.setSecondaryId(this,"hist")})}return e.then(()=>this.drawNextHisto(0,i)).then(()=>(s.pads||this.addToPadPrimitives(),this))}static async draw(r,t,a){return!t.fHists||!t.fHists.arr?null:new j(r,t,a).redrawWith(a,!0)}};class v extends Z{drawHist(r,t,a){return(this.getOptions().ndim===1?F.draw:W.draw)(r,t,a)}static async draw(r,t,a){return!t.fHists||!t.fHists.arr?null:new v(r,t,a).redrawWith(a,!0)}}export{v as THStackPainter};