1 (
function(a){
if(typeof define===
"function"&&define.amd){define([
"d3",
"JSRootPainter",
"JSRootMath"],a)}
else{
if(typeof d3!=
"object"){
throw new Error(
"This extension requires d3.v3.js",
"JSRootPainter.more.js")}
if(typeof JSROOT==
"undefined"){
throw new Error(
"JSROOT is not defined",
"JSRootPainter.more.js")}
if(typeof JSROOT.Painter!=
"object"){
throw new Error(
"JSROOT.Painter not defined",
"JSRootPainter.more.js")}a(d3,JSROOT)}}(
function(b,a){a.ToolbarIcons.th2color={recs:[{x:0,y:256,w:13,h:39,f:
"rgb(38,62,168)"},{x:13,y:371,w:39,h:39},{y:294,h:39},{y:256,h:39},{y:218,h:39},{x:51,y:410,w:39,h:39},{y:371,h:39},{y:333,h:39},{y:294},{y:256,h:39},{y:218,h:39},{y:179,h:39},{y:141,h:39},{y:102,h:39},{y:64},{x:90,y:448,w:39,h:39},{y:410},{y:371,h:39},{y:333,h:39,f:
"rgb(22,82,205)"},{y:294},{y:256,h:39,f:
"rgb(16,100,220)"},{y:218,h:39},{y:179,h:39,f:
"rgb(22,82,205)"},{y:141,h:39},{y:102,h:39,f:
"rgb(38,62,168)"},{y:64},{y:0,h:27},{x:128,y:448,w:39,h:39},{y:410},{y:371,h:39},{y:333,h:39,f:
"rgb(22,82,205)"},{y:294,f:
"rgb(20,129,214)"},{y:256,h:39,f:
"rgb(9,157,204)"},{y:218,h:39,f:
"rgb(14,143,209)"},{y:179,h:39,f:
"rgb(20,129,214)"},{y:141,h:39,f:
"rgb(16,100,220)"},{y:102,h:39,f:
"rgb(22,82,205)"},{y:64,f:
"rgb(38,62,168)"},{y:26,h:39},{y:0,h:27},{x:166,y:486,h:14},{y:448,h:39},{y:410},{y:371,h:39,f:
"rgb(22,82,205)"},{y:333,h:39,f:
"rgb(20,129,214)"},{y:294,f:
"rgb(82,186,146)"},{y:256,h:39,f:
"rgb(179,189,101)"},{y:218,h:39,f:
"rgb(116,189,129)"},{y:179,h:39,f:
"rgb(82,186,146)"},{y:141,h:39,f:
"rgb(14,143,209)"},{y:102,h:39,f:
"rgb(16,100,220)"},{y:64,f:
"rgb(38,62,168)"},{y:26,h:39},{x:205,y:486,w:39,h:14},{y:448,h:39},{y:410},{y:371,h:39,f:
"rgb(16,100,220)"},{y:333,h:39,f:
"rgb(9,157,204)"},{y:294,f:
"rgb(149,190,113)"},{y:256,h:39,f:
"rgb(244,198,59)"},{y:218,h:39},{y:179,h:39,f:
"rgb(226,192,75)"},{y:141,h:39,f:
"rgb(13,167,195)"},{y:102,h:39,f:
"rgb(18,114,217)"},{y:64,f:
"rgb(22,82,205)"},{y:26,h:39,f:
"rgb(38,62,168)"},{x:243,y:448,w:39,h:39},{y:410},{y:371,h:39,f:
"rgb(18,114,217)"},{y:333,h:39,f:
"rgb(30,175,179)"},{y:294,f:
"rgb(209,187,89)"},{y:256,h:39,f:
"rgb(251,230,29)"},{y:218,h:39,f:
"rgb(249,249,15)"},{y:179,h:39,f:
"rgb(226,192,75)"},{y:141,h:39,f:
"rgb(30,175,179)"},{y:102,h:39,f:
"rgb(18,114,217)"},{y:64,f:
"rgb(38,62,168)"},{y:26,h:39},{x:282,y:448,h:39},{y:410},{y:371,h:39,f:
"rgb(18,114,217)"},{y:333,h:39,f:
"rgb(14,143,209)"},{y:294,f:
"rgb(149,190,113)"},{y:256,h:39,f:
"rgb(226,192,75)"},{y:218,h:39,f:
"rgb(244,198,59)"},{y:179,h:39,f:
"rgb(149,190,113)"},{y:141,h:39,f:
"rgb(9,157,204)"},{y:102,h:39,f:
"rgb(18,114,217)"},{y:64,f:
"rgb(38,62,168)"},{y:26,h:39},{x:320,y:448,w:39,h:39},{y:410},{y:371,h:39,f:
"rgb(22,82,205)"},{y:333,h:39,f:
"rgb(20,129,214)"},{y:294,f:
"rgb(46,183,164)"},{y:256,h:39},{y:218,h:39,f:
"rgb(82,186,146)"},{y:179,h:39,f:
"rgb(9,157,204)"},{y:141,h:39,f:
"rgb(20,129,214)"},{y:102,h:39,f:
"rgb(16,100,220)"},{y:64,f:
"rgb(38,62,168)"},{y:26,h:39},{x:358,y:448,h:39},{y:410},{y:371,h:39,f:
"rgb(22,82,205)"},{y:333,h:39},{y:294,f:
"rgb(16,100,220)"},{y:256,h:39,f:
"rgb(20,129,214)"},{y:218,h:39,f:
"rgb(14,143,209)"},{y:179,h:39,f:
"rgb(18,114,217)"},{y:141,h:39,f:
"rgb(22,82,205)"},{y:102,h:39,f:
"rgb(38,62,168)"},{y:64},{y:26,h:39},{x:397,y:448,w:39,h:39},{y:371,h:39},{y:333,h:39},{y:294,f:
"rgb(22,82,205)"},{y:256,h:39},{y:218,h:39},{y:179,h:39,f:
"rgb(38,62,168)"},{y:141,h:39},{y:102,h:39},{y:64},{y:26,h:39},{x:435,y:410,h:39},{y:371,h:39},{y:333,h:39},{y:294},{y:256,h:39},{y:218,h:39},{y:179,h:39},{y:141,h:39},{y:102,h:39},{y:64},{x:474,y:256,h:39},{y:179,h:39}]};a.ToolbarIcons.th2colorz={recs:[{x:128,y:486,w:256,h:26,f:
"rgb(38,62,168)"},{y:461,f:
"rgb(22,82,205)"},{y:435,f:
"rgb(16,100,220)"},{y:410,f:
"rgb(18,114,217)"},{y:384,f:
"rgb(20,129,214)"},{y:358,f:
"rgb(14,143,209)"},{y:333,f:
"rgb(9,157,204)"},{y:307,f:
"rgb(13,167,195)"},{y:282,f:
"rgb(30,175,179)"},{y:256,f:
"rgb(46,183,164)"},{y:230,f:
"rgb(82,186,146)"},{y:205,f:
"rgb(116,189,129)"},{y:179,f:
"rgb(149,190,113)"},{y:154,f:
"rgb(179,189,101)"},{y:128,f:
"rgb(209,187,89)"},{y:102,f:
"rgb(226,192,75)"},{y:77,f:
"rgb(244,198,59)"},{y:51,f:
"rgb(253,210,43)"},{y:26,f:
"rgb(251,230,29)"},{y:0,f:
"rgb(249,249,15)"}]};a.ToolbarIcons.th2draw3d={path:
"M172.768,0H51.726C23.202,0,0.002,23.194,0.002,51.712v89.918c0,28.512,23.2,51.718,51.724,51.718h121.042 c28.518,0,51.724-23.2,51.724-51.718V51.712C224.486,23.194,201.286,0,172.768,0z M177.512,141.63c0,2.611-2.124,4.745-4.75,4.745 H51.726c-2.626,0-4.751-2.134-4.751-4.745V51.712c0-2.614,2.125-4.739,4.751-4.739h121.042c2.62,0,4.75,2.125,4.75,4.739 L177.512,141.63L177.512,141.63z M460.293,0H339.237c-28.521,0-51.721,23.194-51.721,51.712v89.918c0,28.512,23.2,51.718,51.721,51.718h121.045 c28.521,0,51.721-23.2,51.721-51.718V51.712C512.002,23.194,488.802,0,460.293,0z M465.03,141.63c0,2.611-2.122,4.745-4.748,4.745 H339.237c-2.614,0-4.747-2.128-4.747-4.745V51.712c0-2.614,2.133-4.739,4.747-4.739h121.045c2.626,0,4.748,2.125,4.748,4.739 V141.63z M172.768,256.149H51.726c-28.524,0-51.724,23.205-51.724,51.726v89.915c0,28.504,23.2,51.715,51.724,51.715h121.042 c28.518,0,51.724-23.199,51.724-51.715v-89.915C224.486,279.354,201.286,256.149,172.768,256.149z M177.512,397.784 c0,2.615-2.124,4.736-4.75,4.736H51.726c-2.626-0.006-4.751-2.121-4.751-4.736v-89.909c0-2.626,2.125-4.753,4.751-4.753h121.042 c2.62,0,4.75,2.116,4.75,4.753L177.512,397.784L177.512,397.784z M460.293,256.149H339.237c-28.521,0-51.721,23.199-51.721,51.726v89.915c0,28.504,23.2,51.715,51.721,51.715h121.045 c28.521,0,51.721-23.199,51.721-51.715v-89.915C512.002,279.354,488.802,256.149,460.293,256.149z M465.03,397.784 c0,2.615-2.122,4.736-4.748,4.736H339.237c-2.614,0-4.747-2.121-4.747-4.736v-89.909c0-2.626,2.121-4.753,4.747-4.753h121.045 c2.615,0,4.748,2.116,4.748,4.753V397.784z"};a.Painter.CreateDefaultPalette=
function(){
function l(w,v,z){var i,x,y;
if(z<1e-300){i=x=y=v}
else{
function u(A,s,r){
if(r<0){r+=1}
if(r>1){r-=1}
if(r<1/6){
return A+(s-A)*6*r}
if(r<1/2){
return s}
if(r<2/3){
return A+(s-A)*(2/3-r)*6}
return A}var o=v<0.5?v*(1+z):v+z-v*z;var t=2*v-o;i=u(t,o,w+1/3);x=u(t,o,w);y=u(t,o,w-1/3)}
return"rgb("+Math.round(i*255)+
","+Math.round(x*255)+
","+Math.round(y*255)+
")"}var d=[],g=1,m=0.5,e=280,c=0,k=50;
for(var f=0;f<k;++f){var h=(e-(f+1)*((e-c)/k))/360;var j=l(h,m,g);d.push(j)}
return d};a.Painter.CreateGrayPalette=
function(){var c=[];
for(var d=0;d<50;++d){var e=Math.round((d+2)/60*255);c.push(
"rgb("+e+
","+e+
","+e+
")")}
return c};a.Painter.CreateGradientColorTable=
function(p,k,d,e,m,j){var i=[];
for(var l=1;l<p.length;l++){var h=parseInt(Math.floor(m*p[l])-Math.floor(m*p[l-1]));
for(var o=0;o<h;o++){var f=Math.round(k[l-1]+o*(k[l]-k[l-1])/h)+
","+Math.round(d[l-1]+o*(d[l]-d[l-1])/h)+
","+Math.round(e[l-1]+o*(e[l]-e[l-1])/h);i.push(
"rgb("+f+
")")}}
return i};a.Painter.GetColorPalette=
function(d,h){
if((d==null)||(d==0)){d=a.gStyle.Palette}
if((d>0)&&(d<10)){
return a.Painter.CreateGrayPalette()}
if(d<51){
return a.Painter.CreateDefaultPalette()}
if(d>112){d=57}var g,f,c,e=[0,0.125,0.25,0.375,0.5,0.625,0.75,0.875,1];
switch(d){
case 51:g=[0,9,13,17,24,32,27,25,29];f=[0,0,0,2,37,74,113,160,221];c=[28,42,59,78,98,129,154,184,221];
break;
case 52:g=[0,32,64,96,128,160,192,224,255];f=[0,32,64,96,128,160,192,224,255];c=[0,32,64,96,128,160,192,224,255];
break;
case 53:g=[0,45,99,156,212,230,237,234,242];f=[0,0,0,45,101,168,238,238,243];c=[0,1,1,3,9,8,11,95,230];
break;
case 54:g=[0,22,44,68,93,124,160,192,237];f=[0,16,41,67,93,125,162,194,241];c=[97,100,99,99,93,68,44,26,74];
break;
case 55:g=[0,5,15,35,102,196,208,199,110];f=[0,48,124,192,206,226,97,16,0];c=[99,142,198,201,90,22,13,8,2];
break;
case 56:g=[242,234,237,230,212,156,99,45,0];f=[243,238,238,168,101,45,0,0,0];c=[230,95,11,8,9,3,1,1,0];
break;
case 57:g=[0.2082*255,0.0592*255,0.078*255,0.0232*255,0.1802*255,0.5301*255,0.8186*255,0.9956*255,0.9764*255];f=[0.1664*255,0.3599*255,0.5041*255,0.6419*255,0.7178*255,0.7492*255,0.7328*255,0.7862*255,0.9832*255];c=[0.5293*255,0.8684*255,0.8385*255,0.7914*255,0.6425*255,0.4662*255,0.3499*255,0.1968*255,0.0539*255];
break;
case 58:g=[0,0.0956*255,0.0098*255,0.2124*255,0.6905*255,0.9242*255,0.7914*255,0.7596*255,1*255];f=[0,0.1147*255,0.3616*255,0.5041*255,0.4577*255,0.4691*255,0.6905*255,0.9237*255,1*255];c=[0,0.2669*255,0.3121*255,0.1318*255,0.2236*255,0.6741*255,0.9882*255,0.9593*255,1*255];
break;
case 59:g=[13,23,25,63,76,104,137,161,206];f=[95,67,37,21,0,12,35,52,79];c=[4,3,2,6,11,22,49,98,208];
break;
case 60:g=[0,61,89,122,143,160,185,204,231];f=[0,0,0,0,14,37,72,132,235];c=[0,140,224,144,4,5,6,9,13];
break;
case 61:g=[14,7,2,0,5,11,55,131,229];f=[105,56,26,1,42,74,131,171,229];c=[2,21,35,60,92,113,160,185,229];
break;
case 62:g=[0,0,0,70,148,231,235,237,244];f=[0,0,0,0,0,69,67,216,244];c=[0,102,228,231,177,124,137,20,244];
break;
case 63:g=[50,56,63,68,93,121,165,192,241];f=[66,81,91,96,111,128,155,189,241];c=[97,91,75,65,77,103,143,167,217];
break;
case 64:g=[145,166,167,156,131,114,101,112,132];f=[158,178,179,181,163,154,144,152,159];c=[190,199,201,192,176,169,160,166,190];
break;
case 65:g=[93,91,99,108,130,125,132,155,174];f=[126,124,128,129,131,121,119,153,173];c=[103,94,87,85,80,85,107,120,146];
break;
case 66:g=[24,40,69,90,104,114,120,132,103];f=[29,52,94,127,150,162,159,151,101];c=[29,52,96,132,162,181,184,186,131];
break;
case 67:g=[46,38,61,92,113,121,132,150,191];f=[46,36,40,69,110,135,131,92,34];c=[46,80,74,70,81,105,165,211,225];
break;
case 68:g=[0,4,12,30,52,101,142,190,237];f=[0,40,86,121,140,172,187,213,240];c=[0,9,14,18,21,23,27,35,101];
break;
case 69:g=[198,206,206,211,198,181,161,171,244];f=[103,133,150,172,178,174,163,175,244];c=[49,54,55,66,91,130,184,224,244];
break;
case 70:g=[243,243,240,240,241,239,186,151,129];f=[0,46,99,149,194,220,183,166,147];c=[6,8,36,91,169,235,246,240,233];
break;
case 71:g=[22,19,19,25,35,53,88,139,210];f=[0,32,69,108,135,159,183,198,215];c=[77,96,110,116,110,100,90,78,70];
break;
case 72:g=[68,116,165,182,189,180,145,111,71];f=[37,82,135,178,204,225,221,202,147];c=[16,55,105,147,196,226,232,224,178];
break;
case 73:g=[61,99,136,181,213,225,198,136,24];f=[149,140,96,83,132,178,190,135,22];c=[214,203,168,135,110,100,111,113,22];
break;
case 74:g=[76,120,156,183,197,180,162,154,140];f=[34,35,42,69,102,137,164,188,197];c=[64,69,78,105,142,177,205,217,198];
break;
case 75:g=[37,102,157,188,196,214,223,235,251];f=[37,29,25,37,67,91,132,185,251];c=[37,32,33,45,66,98,137,187,251];
break;
case 76:g=[79,100,119,137,153,172,192,205,250];f=[63,79,93,103,115,135,167,196,250];c=[51,59,66,61,62,70,110,160,250];
break;
case 77:g=[43,44,50,66,125,172,178,155,157];f=[63,63,85,101,138,163,122,51,39];c=[121,101,58,44,47,55,57,44,43];
break;
case 78:g=[0,41,62,79,90,87,99,140,228];f=[0,57,81,93,85,70,71,125,228];c=[95,91,91,82,60,43,44,112,228];
break;
case 79:g=[49,59,72,88,114,141,176,205,222];f=[78,72,66,57,59,75,106,142,173];c=[78,55,46,40,39,39,40,41,47];
break;
case 80:g=[243,222,201,185,165,158,166,187,219];f=[94,108,132,135,125,96,68,51,61];c=[7,9,12,19,45,89,118,146,118];
break;
case 81:g=[19,44,74,105,137,166,194,206,220];f=[19,28,40,55,82,110,159,181,220];c=[19,42,68,96,129,157,188,203,220];
break;
case 82:g=[33,44,70,99,140,165,199,211,216];f=[38,50,76,105,140,165,191,189,167];c=[55,67,97,124,140,166,163,129,52];
break;
case 83:g=[0,33,73,124,136,152,159,171,223];f=[0,43,92,124,134,126,121,144,223];c=[0,43,68,76,73,64,72,114,223];
break;
case 84:g=[5,18,45,124,193,223,205,128,49];f=[48,134,207,230,193,113,28,0,7];c=[6,15,41,121,193,226,208,130,49];
break;
case 85:g=[180,106,104,135,164,188,189,165,144];f=[72,126,154,184,198,207,205,190,179];c=[41,120,158,188,194,181,145,100,62];
break;
case 86:g=[57,72,94,117,136,154,174,192,215];f=[0,33,68,109,140,171,192,196,209];c=[116,137,173,201,200,201,203,190,187];
break;
case 87:g=[31,71,123,160,210,222,214,199,183];f=[40,117,171,211,231,220,190,132,65];c=[234,214,228,222,210,160,105,60,34];
break;
case 88:g=[123,108,109,126,154,172,188,196,218];f=[184,138,130,133,154,175,188,196,218];c=[208,130,109,99,110,122,150,171,218];
break;
case 89:g=[105,106,122,143,159,172,176,181,207];f=[252,197,194,187,174,162,153,136,125];c=[146,133,144,155,163,167,166,162,174];
break;
case 90:g=[171,141,145,152,154,159,163,158,177];f=[236,143,100,63,53,55,44,31,6];c=[59,48,46,44,42,54,82,112,179];
break;
case 91:g=[180,190,209,223,204,228,205,152,91];f=[93,125,147,172,181,224,233,198,158];c=[236,218,160,133,114,132,162,220,218];
break;
case 92:g=[225,183,162,135,115,111,119,145,211];f=[205,177,166,135,124,117,117,132,172];c=[186,165,155,135,126,130,150,178,226];
break;
case 93:g=[39,43,59,63,80,116,153,177,223];f=[39,43,59,74,91,114,139,165,223];c=[39,50,59,70,85,115,151,176,223];
break;
case 94:g=[0,38,60,76,84,89,101,128,204];f=[0,10,15,23,35,57,83,123,199];c=[0,11,22,40,63,86,97,94,85];
break;
case 95:g=[94,112,141,165,167,140,91,49,27];f=[27,46,88,135,166,161,135,97,58];c=[42,52,81,106,139,158,155,137,116];
break;
case 96:g=[30,49,79,117,135,151,146,138,147];f=[63,60,72,90,94,94,68,46,16];c=[18,28,41,56,62,63,50,36,21];
break;
case 97:g=[0,30,63,101,143,152,169,187,230];f=[0,14,28,42,58,61,67,74,91];c=[39,26,21,18,15,14,14,13,13];
break;
case 98:g=[149,140,164,179,182,181,131,87,61];f=[62,70,107,136,144,138,117,87,74];c=[40,38,45,49,49,49,38,32,34];
break;
case 99:g=[99,112,148,165,179,182,183,183,208];f=[39,40,57,79,104,127,148,161,198];c=[15,16,18,33,51,79,103,129,177];
break;
case 100:g=[99,116,154,174,200,196,201,201,230];f=[0,0,8,32,58,83,119,136,173];c=[5,6,7,9,9,14,17,19,24];
break;
case 101:g=[82,106,126,141,155,163,142,107,66];f=[62,44,69,107,135,152,149,132,119];c=[39,25,31,60,73,68,49,72,188];
break;
case 102:g=[18,29,44,72,116,158,184,208,221];f=[27,46,71,105,146,177,189,190,183];c=[39,55,80,108,130,133,124,100,76];
break;
case 103:g=[0,48,119,173,212,224,228,228,245];f=[0,13,30,47,79,127,167,205,245];c=[0,68,75,43,16,22,55,128,245];
break;
case 104:g=[34,70,129,187,225,226,216,193,179];f=[48,91,147,194,226,229,196,110,12];c=[234,212,216,224,206,110,53,40,29];
break;
case 105:g=[30,55,103,147,174,203,188,151,105];f=[0,65,138,182,187,175,121,53,9];c=[191,202,212,208,171,140,97,57,30];
break;
case 106:g=[112,97,113,125,138,159,178,188,225];f=[16,17,24,37,56,81,110,136,189];c=[38,35,46,59,78,103,130,152,201];
break;
case 107:g=[18,72,5,23,29,201,200,98,29];f=[0,0,43,167,211,117,0,0,0];c=[51,203,177,26,10,9,8,3,0];
break;
case 108:g=[19,42,64,88,118,147,175,187,205];f=[19,55,89,125,154,169,161,129,70];c=[19,32,47,70,100,128,145,130,75];
break;
case 109:g=[33,31,42,68,86,111,141,172,227];f=[255,175,145,106,88,55,15,0,0];c=[255,205,202,203,208,205,203,206,231];
break;
case 110:g=[0,25,50,79,110,145,181,201,254];f=[0,16,30,46,63,82,101,124,179];c=[0,12,21,29,39,49,61,74,103];
break;
case 111:g=[0,13,30,44,72,120,156,200,247];f=[0,36,84,117,141,153,151,158,247];c=[0,94,100,82,56,66,76,131,247];
break;
case 112:g=[26,51,43,33,28,35,74,144,246];f=[9,24,55,87,118,150,180,200,222];c=[30,96,112,114,112,101,72,35,0];
break;
default:
return a.Painter.CreateDefaultPalette()}
return a.Painter.CreateGradientColorTable(e,g,f,c,255,h)};a.Painter.drawEllipse=
function(e,d,c){this.SetDivId(e);this.Redraw=
function(){var j=this.GetObject();
if(!this.lineatt){this.lineatt=a.Painter.createAttLine(j)}
if(!this.fillatt){this.fillatt=this.createAttFill(j)}this.RecreateDrawG(this.main_painter()==null);var r=this.AxisToSvg(
"x",j.fX1);var p=this.AxisToSvg(
"y",j.fY1);var i=this.AxisToSvg(
"x",j.fX1+j.fR1)-r;var g=p-this.AxisToSvg(
"y",j.fY1+j.fR2);
if((j.fPhimin==0)&&(j.fPhimax==360)&&(j.fTheta==0)){this.draw_g.append(
"svg:ellipse").attr(
"cx",r.toFixed(1)).attr(
"cy",p.toFixed(1)).attr(
"rx",i.toFixed(1)).attr(
"ry",g.toFixed(1)).call(this.lineatt.func).call(this.fillatt.func);
return}var m=Math.cos(Math.PI*j.fTheta/180);var u=Math.sin(Math.PI*j.fTheta/180);var t=i*Math.cos(j.fPhimin*Math.PI/180);var l=g*Math.sin(j.fPhimin*Math.PI/180);var h=t*m-l*u;var q=-t*u-l*m;var s=i*Math.cos(j.fPhimax*Math.PI/180);var k=g*Math.sin(j.fPhimax*Math.PI/180);var f=s*m-k*u;var o=-s*u-k*m;this.draw_g.attr(
"transform",
"translate("+r.toFixed(1)+
","+p.toFixed(1)+
")").append(
"svg:path").attr(
"d",
"M 0,0 L "+h.toFixed(1)+
","+q.toFixed(1)+
" A "+i.toFixed(1)+
" "+g.toFixed(1)+
" "+-j.fTheta.toFixed(1)+
" 1 0 "+f.toFixed(1)+
","+o.toFixed(1)+
" L 0,0 Z").call(this.lineatt.func).call(this.fillatt.func)};this.Redraw();
return this.DrawingReady()};a.Painter.drawLine=
function(e,d,c){this.SetDivId(e);this.Redraw=
function(){var g=this.GetObject(),f=a.Painter.createAttLine(g);this.RecreateDrawG(this.main_painter()==null);this.draw_g.append(
"svg:line").attr(
"x1",this.AxisToSvg(
"x",g.fX1).toFixed(1)).attr(
"y1",this.AxisToSvg(
"y",g.fY1).toFixed(1)).attr(
"x2",this.AxisToSvg(
"x",g.fX2).toFixed(1)).attr(
"y2",this.AxisToSvg(
"y",g.fY2).toFixed(1)).call(f.func)};this.Redraw();
return this.DrawingReady()};a.Painter.drawBox=
function(e,d,c){this.SetDivId(e);this.Redraw=
function(){var l=this.GetObject(),f=a.Painter.createAttLine(l),k=this.createAttFill(l);this.RecreateDrawG(this.main_painter()==null);var h=Math.round(this.AxisToSvg(
"x",l.fX1)),g=Math.round(this.AxisToSvg(
"x",l.fX2)),j=Math.round(this.AxisToSvg(
"y",l.fY1)),i=Math.round(this.AxisToSvg(
"y",l.fY2));this.draw_g.append(
"svg:rect").attr(
"x",Math.min(h,g)).attr(
"y",Math.min(j,i)).attr(
"width",Math.abs(g-h)).attr(
"height",Math.abs(j-i)).call(f.func).call(k.func)};this.Redraw();
return this.DrawingReady()};a.Painter.drawArrow=
function(e,d,c){this.SetDivId(e);this.Redraw=
function(){var k=this.GetObject();
if(!this.lineatt){this.lineatt=a.Painter.createAttLine(k)}
if(!this.fillatt){this.fillatt=this.createAttFill(k)}var f=Math.max(this.pad_width(),this.pad_height())*k.fArrowSize;
if(f<3){f=3}var w=f*Math.tan(k.fAngle/2*(Math.PI/180));this.RecreateDrawG(this.main_painter()==null);var z=this.AxisToSvg(
"x",k.fX1),l=this.AxisToSvg(
"y",k.fY1),y=this.AxisToSvg(
"x",k.fX2),i=this.AxisToSvg(
"y",k.fY2),g=
"M0,0 L"+f.toFixed(1)+
","+w.toFixed(1)+
" L0,"+(w*2).toFixed(1),s=
"M"+f.toFixed(1)+
", 0 L 0,"+w.toFixed(1)+
" L "+f.toFixed(1)+
","+(w*2).toFixed(1),o=null,p=null,u=null,h=null,t=k.fOption,x=t.length;
if(t.indexOf(
"<")==0){var j=(t.indexOf(
"<|")==0);
if(!h){h=this.draw_g.append(
"defs")}o=
"jsroot_arrowmarker_"+a.Painter.arrowcnt++;var r=h.append(
"svg:marker").attr(
"id",o).attr(
"markerWidth",f.toFixed(1)).attr(
"markerHeight",(w*2).toFixed(1)).attr(
"refX",
"0").attr(
"refY",w.toFixed(1)).attr(
"orient",
"auto").attr(
"markerUnits",
"userSpaceOnUse").append(
"svg:path").style(
"fill",
"none").attr(
"d",s+(j?
" Z":
"")).call(this.lineatt.func);
if(j){r.call(this.fillatt.func)}}var q=0;
if(t.indexOf(
"->-")>=0){q=1}
else{
if(t.indexOf(
"-|>-")>=0){q=11}
else{
if(t.indexOf(
"-<-")>=0){q=2}
else{
if(t.indexOf(
"-<|-")>=0){q=12}}}}
if(q>0){var j=q>10;
if(!h){h=this.draw_g.append(
"defs")}p=
"jsroot_arrowmarker_"+a.Painter.arrowcnt++;var A=h.append(
"svg:marker").attr(
"id",p).attr(
"markerWidth",f.toFixed(1)).attr(
"markerHeight",(w*2).toFixed(1)).attr(
"refX",(f*0.5).toFixed(1)).attr(
"refY",w.toFixed(1)).attr(
"orient",
"auto").attr(
"markerUnits",
"userSpaceOnUse").append(
"svg:path").style(
"fill",
"none").attr(
"d",((q%10==1)?g:s)+((q>10)?
" Z":
"")).call(this.lineatt.func);
if(q>10){A.call(this.fillatt.func)}}
if(t.lastIndexOf(
">")==x-1){var j=(t.lastIndexOf(
"|>")==x-2)&&(x>1);
if(!h){h=this.draw_g.append(
"defs")}u=
"jsroot_arrowmarker_"+a.Painter.arrowcnt++;var m=h.append(
"svg:marker").attr(
"id",u).attr(
"markerWidth",f.toFixed(1)).attr(
"markerHeight",(w*2).toFixed(1)).attr(
"refX",f.toFixed(1)).attr(
"refY",w.toFixed(1)).attr(
"orient",
"auto").attr(
"markerUnits",
"userSpaceOnUse").append(
"svg:path").style(
"fill",
"none").attr(
"d",g+(j?
" Z":
"")).call(this.lineatt.func);
if(j){m.call(this.fillatt.func)}}var v=this.draw_g.append(
"svg:path").attr(
"d",
"M"+z.toFixed(1)+
","+l.toFixed(1)+((p==null)?
"":
"L"+(z/2+y/2).toFixed(1)+
","+(l/2+i/2).toFixed(1))+
" L"+y.toFixed(1)+
","+i.toFixed(1)).call(this.lineatt.func);
if(o!=null){v.style(
"marker-start",
"url(#"+o+
")")}
if(p!=null){v.style(
"marker-mid",
"url(#"+p+
")")}
if(u!=null){v.style(
"marker-end",
"url(#"+u+
")")}};
if(!(
"arrowcnt" in a.Painter)){a.Painter.arrowcnt=0}this.Redraw();
return this.DrawingReady()};a.Painter.BuildSvgPath=
function(h,s,o,d){var f=h.indexOf(
"bezier")>=0;
if(d===undefined){d=f?2:0}
if(o===undefined){o=0}
function e(u,t){
return(t.gry-u.gry)/(t.grx-u.grx)}
function k(w){var v=0,u=w.length-1,t=[],z=w[0],y=w[1],x=t[0]=e(z,y);
while(++v<u){t[v]=(x+(x=e(z=y,y=w[v+1])))/2}t[v]=x;
return t}
function c(z){var A,v,u,y,t=k(z),x=-1,w=z.length-1;
while(++x<w){A=e(z[x],z[x+1]);
if(Math.abs(A)<0.000001){t[x]=t[x+1]=0}
else{v=t[x]/A;u=t[x+1]/A;y=v*v+u*u;
if(y>9){y=A*3/Math.sqrt(y);t[x]=y*v;t[x+1]=y*u}}}x=-1;
while(++x<=w){y=(z[Math.min(w,x+1)].grx-z[Math.max(0,x-1)].grx)/(6*(1+t[x]*t[x]));z[x].dgrx=y||0;z[x].dgry=t[x]*y||0}}var j={},r=s[0],g,i=Math.max(r.gry,o+5),m=Math.round(r.grx),l=Math.round(r.gry),q,p;j.path=((h.charAt(0)==
"L")?
"L":
"M")+r.grx.toFixed(d)+
","+r.gry.toFixed(d);
if(f||h.indexOf(
"calc")>=0){c(s)}
if(f){j.path+=
"c"+r.dgrx.toFixed(d)+
","+r.dgry.toFixed(d)+
","}
for(n=1;n<s.length;++n){g=r;r=s[n];
if(f){
if(n>1){j.path+=
"s"}j.path+=(r.grx-r.dgrx-g.grx).toFixed(d)+
","+(r.gry-r.dgry-g.gry).toFixed(d)+
","+(r.grx-g.grx).toFixed(d)+
","+(r.gry-g.gry).toFixed(d);i=Math.max(i,g.gry)}
else{q=Math.round(r.grx-m);p=Math.round(r.gry-l);j.path+=
"l"+q+
","+p;m+=q;l+=p;i=Math.max(i,l)}}
if(o>0){j.close=
"L"+r.grx.toFixed(d)+
","+i.toFixed(d)+
"L"+s[0].grx.toFixed(d)+
","+i.toFixed(d)+
"Z"}
return j};a.Painter.drawFunction=
function(f,e,d){this.bins=null;this.Eval=
function(g){
return this.GetObject().evalPar(g)};this.CreateBins=
function(t){var k=this.main_painter(),i=0,m=0,o=this.GetObject();
if((k!==null)&&!t){
if(k.zoom_xmin!==k.zoom_xmax){i=k.zoom_xmin;m=k.zoom_xmax}
else{i=k.xmin;m=k.xmax}}
if(o.fSave.length>0){var r=o.fSave.length-2,h=o.fSave[r],l=o.fSave[r+1],u=(l-h)/(r-1),q=[];
for(var j=0;j<r;++j){var g=h+u*j;
if((i!==m)&&((g+2*u<i)||(g-2*u>m))){
continue}q.push({x:g,y:o.fSave[j]})}
return q}var h=o.fXmin,l=o.fXmax,s=
false;
if(i!==m){
if(i>h){h=i}
if(m<l){l=m}}
if((k!==null)&&k.options.Logx&&(h>0)&&(l>0)){s=
true;h=Math.log(h);l=Math.log(l)}var r=Math.max(o.fNpx,101);var u=(l-h)/(r-1);var q=[];
for(var j=0;j<r;j++){var g=h+j*u;
if(s){g=Math.exp(g)}var p=this.Eval(g);
if(!isNaN(p)){q.push({x:g,y:p})}}
return q};this.CreateDummyHisto=
function(){var l=0,i=1,j=0,g=1;var k=this.CreateBins(
true);
if(k!==null){l=i=k[0].x;j=g=k[0].y;k.forEach(
function(o){l=Math.min(o.x,l);i=Math.max(o.x,i);j=Math.min(o.y,j);g=Math.max(o.y,g)});
if(g>0){g*=1.05}
if(j<0){j*=1.05}}var h=a.Create(
"TH1I"),m=this.GetObject();h.fName=m.fName+
"_hist";h.fTitle=m.fTitle;h.fXaxis.fXmin=l;h.fXaxis.fXmax=i;h.fYaxis.fXmin=j;h.fYaxis.fXmax=g;
return h};this.ProcessTooltipFunc=
function(g){var i=
false;
if((g===null)||(this.bins===null)){i=
true}
else{
if((this.bins.length==0)||(g.x<this.bins[0].grx)||(g.x>
this.bins[
this.bins.length-1].grx)){i=
true}}
if(i){
if(this.draw_g!==null){this.draw_g.select(
".tooltip_bin").remove()}
return null}var m=100000,l=-1,s;
for(var k=0;k<this.bins.length;++k){s=this.bins[k];var r=Math.abs(s.grx-g.x);
if(r<m){m=r;l=k}}s=this.bins[l];var j=this.draw_g.select(
".tooltip_bin");var o=this.lineatt.width+3;
if(j.empty()){j=this.draw_g.append(
"svg:circle").attr(
"class",
"tooltip_bin").style(
"pointer-events",
"none").attr(
"r",o).call(this.lineatt.func).call(this.fillatt.func)}var q={x:s.grx,y:s.gry,color1:this.lineatt.color,color2:this.fillatt.color,lines:[],exact:(Math.abs(s.grx-g.x)<o)&&(Math.abs(s.gry-g.y)<o)};q.changed=j.property(
"current_bin")!==l;q.menu=q.exact;q.menu_dist=Math.sqrt((s.grx-g.x)*(s.grx-g.x)+(s.gry-g.y)*(s.grx-g.x));
if(q.changed){j.attr(
"cx",s.grx).attr(
"cy",s.gry).property(
"current_bin",l)}var h=this.GetTipName();
if(h.length>0){q.lines.push(h)}var p=this.main_painter();
if(p!==null){q.lines.push(
"x = "+p.AxisAsText(
"x",s.x)+
" y = "+p.AxisAsText(
"y",s.y))}
return q};this.Redraw=
function(){var p=this.frame_width(),k=this.frame_height(),l=this.GetObject();this.RecreateDrawG(
false,
"main_layer");this.bins=this.CreateBins(
false);var i=
this;var m=this.main_painter();var g=this.GetTipName(
"\n");
if(!this.lineatt){this.lineatt=a.Painter.createAttLine(l)}this.lineatt.used=
false;
if(!this.fillatt){this.fillatt=this.createAttFill(l,undefined,undefined,1)}this.fillatt.used=
false;var j,r;
for(j=0;j<this.bins.length;++j){r=this.bins[j];r.grx=m.grx(r.x);r.gry=m.gry(r.y)}
if(this.bins.length>2){var o=k;
if((m.hmin!==undefined)&&(m.hmin>=0)){o=Math.round(m.gry(0));
if((o>k)||(o<0)){o=k}}var q=a.Painter.BuildSvgPath(
"bezier",this.bins,o,2);
if(this.lineatt.color!=
"none"){this.draw_g.append(
"svg:path").attr(
"class",
"line").attr(
"d",q.path).style(
"fill",
"none").call(this.lineatt.func)}
if(this.fillatt.color!=
"none"){this.draw_g.append(
"svg:path").attr(
"class",
"area").attr(
"d",q.path+q.close).style(
"stroke",
"none").call(this.fillatt.func)}}
delete this.ProcessTooltip;
if(a.gStyle.Tooltip>0){this.ProcessTooltip=this.ProcessTooltipFunc}};this.CanZoomIn=
function(j,i,g){
if(j!==
"x"){
return false}var m=this.GetObject();
if(m.fSave.length>0){var l=m.fNpx;var k=m.fSave[l+1];var h=m.fSave[l+2];
return Math.abs(k-h)/l<Math.abs(i-g)}
return true};this.SetDivId(f,-1);
if(this.main_painter()===null){var c=this.CreateDummyHisto();a.Painter.drawHistogram1D(f,c,
"AXIS")}this.SetDivId(f);this.Redraw();
return this.DrawingReady()};a.Painter.drawHStack=
function(e,c,d){this.nostack=
false;this.firstpainter=null;this.painters=
new Array;this.SetDivId(e);
if(!(
"fHists" in c)||(c.fHists.arr.length==0)){
return this.DrawingReady()}
this[
"BuildStack"]=
function(){var h=this.GetObject();
if(!(
"fHists" in h)){
return false}var g=h.fHists.arr.length;
if(g<=0){
return false}var f=a.Create(
"TList");f.Add(a.clone(h.fHists.arr[0]));
for(var l=1;l<g;++l){var j=a.clone(h.fHists.arr[l]);var k=f.arr[l-1];
if((j.fNbins!=k.fNbins)||(j.fXaxis.fXmin!=k.fXaxis.fXmin)||(j.fXaxis.fXmax!=k.fXaxis.fXmax)){a.console(
"When drawing THStack, cannot sum-up histograms "+j.fName+
" and "+k.fName);
delete j;
delete f;
return false}
for(var m=0;m<j.fArray.length;++m){j.fArray[m]+=k.fArray[m]}f.Add(j)}h.fStack=f;
return true};
this[
"GetHistMinMax"]=
function(j,m){var k={min:0,max:0};var l=
false,f=
false;
if(j.fMinimum!=-1111){k.min=j.fMinimum}
else{l=
true}
if(j.fMaximum!=-1111){k.max=j.fMaximum}
else{f=
true}
if(l||f){var h=1,o=j.fXaxis.fNbins;
if(j.fXaxis.TestBit(a.EAxisBits.kAxisRange)){h=j.fXaxis.fFirst;o=j.fXaxis.fLast}
for(var p=h;p<=o;++p){var g=j.getBinContent(p);var i=m?j.getBinError(p):0;
if(l&&((p==h)||(g-i<k.min))){k.min=g-i}
if(f&&((p==h)||(g+i>k.max))){k.max=g+i}}}
return k};
this[
"GetMinMax"]=
function(j){var h={min:0,max:0},k=(j.indexOf(
"e")>=0),f=this.GetObject();
if(this.nostack){
for(var g=0;g<f.fHists.arr.length;++g){var l=this.GetHistMinMax(f.fHists.arr[g],k);
if(g==0){h=l}
else{
if(l.min<h.min){h.min=l.min}
if(l.max>h.max){h.max=l.max}}}
if(f.fMaximum!=-1111){h.max=f.fMaximum}
else{h.max*=1.05}
if(f.fMinimum!=-1111){h.min=f.fMinimum}}
else{h.min=this.GetHistMinMax(f.fStack.arr[0],k).min;h.max=this.GetHistMinMax(f.fStack.arr[f.fStack.arr.length-1],k).max*1.05}var m=this.root_pad();
if((m!=null)&&(m.fLogy>0)){
if(h.min<0){h.min=h.max*0.0001}}
return h};
this[
"DrawNextHisto"]=
function(j,i){var l=null,h=this.GetObject(),g=h.fHists.arr.length;
if(j>=g){
return this.DrawingReady()}
if(j<0){l=h.fHistogram}
else{
if(this.nostack){l=h.fHists.arr[j]}
else{l=h.fStack.arr[g-j-1]}}var f=l.fOption;
if((i!=
"")&&(f.indexOf(i)==-1)){f+=i}
if(j>=0){f+=
"same"}var k=a.draw(this.divid,l,f);
if(j<0){this.firstpainter=k}
else{this.painters.push(k)}k.WhenReady(this.DrawNextHisto.bind(
this,j+1,i))};
this[
"drawStack"]=
function(g){var k=this.root_pad(),t=this.GetObject(),p=t.fHists,v=p.arr.length;
if(g==null){g=
""}
else{g=g.toLowerCase()}var o=
false;
if(g.indexOf(
"same")!=-1){o=
true;g.replace(
"same",
"")}this.nostack=g.indexOf(
"nostack")<0?
false:
true;
if(!this.nostack){this.nostack=!this.BuildStack()}var l=this.GetMinMax(g);
if(t.fHistogram===null){var f=0,r=0,u=0,j=0;
for(var q=0;q<v;++q){var s=p.arr[q];
if(q==0||s.fXaxis.fXmin<f){f=s.fXaxis.fXmin}
if(q==0||s.fXaxis.fXmax>r){r=s.fXaxis.fXmax}
if(q==0||s.fYaxis.fXmin<u){u=s.fYaxis.fXmin}
if(q==0||s.fYaxis.fXmax>j){j=s.fYaxis.fXmax}}var s=t.fHists.arr[0];t.fHistogram=a.Create(
"TH1I");t.fHistogram.fName=
"unnamed";t.fHistogram.fXaxis=a.clone(s.fXaxis);t.fHistogram.fYaxis=a.clone(s.fYaxis);t.fHistogram.fXaxis.fXmin=f;t.fHistogram.fXaxis.fXmax=r;t.fHistogram.fYaxis.fXmin=u;t.fHistogram.fYaxis.fXmax=j}t.fHistogram.fTitle=t.fTitle;var m=t.fHistogram;
if(!m.TestBit(a.TH1StatusBits.kIsZoomed)){
if(k&&k.fLogy){m.fMaximum=l.max*(1+0.2*a.log10(l.max/l.min))}
else{m.fMaximum=l.max}
if(k&&k.fLogy){m.fMinimum=l.min/(1+0.5*a.log10(l.max/l.min))}
else{m.fMinimum=l.min}}this.DrawNextHisto(!o?-1:0,g);
return this};
this[
"UpdateObject"]=
function(k){
if(!this.MatchObjectType(k)){
return false}var h=
false;
if(this.firstpainter){
if(this.firstpainter.UpdateObject(k.fHistogram)){h=
true}}var f=k.fHists.arr.length;
for(var g=0;g<f;++g){var j=this.nostack?k.fHists.arr[g]:k.fStack.arr[f-g-1];
if(this.painters[g].UpdateObject(j)){h=
true}}
return h};
return this.drawStack(d)};a.TGraphPainter=
function(c){a.TObjectPainter.call(
this,c);this.ownhisto=
false;this.bins=null;this.xmin=this.ymin=this.xmax=this.ymax=0};a.TGraphPainter.prototype=Object.create(a.TObjectPainter.prototype);a.TGraphPainter.prototype.Redraw=
function(){this.DrawBins()};a.TGraphPainter.prototype.DecodeOptions=
function(c){this.draw_all=
true;a.extend(
this,{optionLine:0,optionAxis:0,optionCurve:0,optionRect:0,optionMark:0,optionBar:0,optionR:0,optionE:0,optionEF:0,optionFill:0,optionZ:0,optionBrackets:0,opt:
"LP",out_of_range:
false,has_errors:
false,draw_errors:
false,is_bent:
false});var d=this.GetObject();this.is_bent=d._typename==
"TGraphBentErrors";this.has_errors=(d._typename==
"TGraphErrors"||d._typename==
"TGraphAsymmErrors"||this.is_bent||d._typename.match(/^RooHist/));this.draw_errors=this.has_errors;
if((c!=null)&&(c!=
"")){this.opt=c.toUpperCase();this.opt.replace(
"SAME",
"")}
if(this.opt.indexOf(
"L")!=-1){this.optionLine=1}
if(this.opt.indexOf(
"F")!=-1){this.optionFill=1}
if(this.opt.indexOf(
"A")!=-1){this.optionAxis=1}
if(this.opt.indexOf(
"C")!=-1){this.optionCurve=1;
if(this.optionFill==0){this.optionLine=1}}
if(this.opt.indexOf(
"*")!=-1){this.optionMark=2}
if(this.opt.indexOf(
"P")!=-1){this.optionMark=1}
if(this.opt.indexOf(
"B")!=-1){this.optionBar=1;this.draw_errors=
false}
if(this.opt.indexOf(
"R")!=-1){this.optionR=1}
if(this.opt.indexOf(
"[]")!=-1){this.optionBrackets=1;this.draw_errors=
false}
if(this.opt.indexOf(
"0")!=-1){this.optionMark=1;this.draw_errors=
true;this.out_of_range=
true}
if(this.opt.indexOf(
"1")!=-1){
if(this.optionBar==1){this.optionBar=2}}
if(this.opt.indexOf(
"2")!=-1){this.optionRect=1}
if(this.opt.indexOf(
"3")!=-1){this.optionEF=1;this.optionLine=0;this.draw_errors=
false}
if(this.opt.indexOf(
"4")!=-1){this.optionEF=2;this.optionLine=0;this.draw_errors=
false}
if(this.opt.indexOf(
"2")!=-1||this.opt.indexOf(
"5")!=-1){this.optionE=1}
if((this.optionMark==1)&&(d.fMarkerStyle==1)){this.optionMark=3}
if(this.optionLine+this.optionFill+this.optionMark+this.optionBar+this.optionE+this.optionEF+this.optionRect+this.optionBrackets==0){
if(this.opt.length==0){this.optionLine=1}}
if(d._typename==
"TGraphErrors"){var f=b.max(d.fEX);var e=b.max(d.fEY);
if(f<1e-300&&e<1e-300){this.draw_errors=
false}}};a.TGraphPainter.prototype.CreateBins=
function(){var c=this.GetObject();
if(c===null){
return}var f,e=0,g=c.fNpoints;
if((c._typename===
"TCutG")&&(g>3)){g--}
if(c._typename==
"TGraphErrors"){e=1}
else{
if(c._typename==
"TGraphAsymmErrors"||c._typename==
"TGraphBentErrors"||c._typename.match(/^RooHist/)){e=2}}this.bins=[];
for(f=0;f<g;++f){var d={x:c.fX[f],y:c.fY[f]};
if(e===1){d.exlow=d.exhigh=c.fEX[f];d.eylow=d.eyhigh=c.fEY[f]}
else{
if(e===2){d.exlow=c.fEXlow[f];d.exhigh=c.fEXhigh[f];d.eylow=c.fEYlow[f];d.eyhigh=c.fEYhigh[f]}}this.bins.push(d);
if(f===0){this.xmin=this.xmax=d.x;this.ymin=this.ymax=d.y}
if(e>0){this.xmin=Math.min(this.xmin,d.x-d.exlow,d.x+d.exhigh);this.xmax=Math.max(this.xmax,d.x-d.exlow,d.x+d.exhigh);this.ymin=Math.min(this.ymin,d.y-d.eylow,d.y+d.eyhigh);this.ymax=Math.max(this.ymax,d.y-d.eylow,d.y+d.eyhigh)}
else{this.xmin=Math.min(this.xmin,d.x);this.xmax=Math.max(this.xmax,d.x);this.ymin=Math.min(this.ymin,d.y);this.ymax=Math.max(this.ymax,d.y)}}};a.TGraphPainter.prototype.CreateHistogram=
function(){var c=this.xmin,h=this.xmax,j=this.ymin,d=this.ymax;
if(c>=h){h=c+1}
if(j>=d){d=j+1}var o=(h-c)*0.1,m=(d-j)*0.1,l=c-o,e=h+o,i=j-m,f=d+m;
if((l<0)&&(c>=0)){l=c*0.9}
if((e>0)&&(h<=0)){e=0}var k=this.GetObject();
if(k.fMinimum!=-1111){i=j=k.fMinimum}
if(k.fMaximum!=-1111){f=d=k.fMaximum}
if((i<0)&&(j>=0)){i=0.9*j}var g=a.CreateTH1(100);g.fName=k.fName+
"_h";g.fTitle=k.fTitle;g.fXaxis.fXmin=l;g.fXaxis.fXmax=e;g.fYaxis.fXmin=i;g.fYaxis.fXmax=f;g.fMinimum=i;g.fMaximum=f;g.fBits=g.fBits|a.TH1StatusBits.kNoStats;
return g};a.TGraphPainter.prototype.OptimizeBins=
function(c){
if((this.bins.length<30)&&!c){
return this.bins}var g=null;
if(typeof c==
"function"){
for(var f=0;f<this.bins.length;++f){
if(c(this.bins[f],f)){
if(g==null){g=(f==0)?[]:this.bins.slice(0,f)}}
else{
if(g!=null){g.push(this.bins[f])}}}}
if(g==null){g=this.bins}
if((g.length<5000)||(a.gStyle.OptimizeDraw==0)){
return g}var e=Math.floor(g.length/5000);
if(e<2){e=2}var d=[];
for(var f=0;f<g.length;f+=e){d.push(g[f])}
return d};a.TGraphPainter.prototype.TooltipText=
function(h,g){var e=this.main_painter(),c=[];c.push(this.GetTipName());c.push(
"x = "+e.AxisAsText(
"x",h.x));c.push(
"y = "+e.AxisAsText(
"y",h.y));
if(this.draw_errors&&(e.x_kind==
"normal")&&(
"exlow" in h)&&((h.exlow!=0)||(h.exhigh!=0))){c.push(
"error x = -"+e.AxisAsText(
"x",h.exlow)+
"/+"+e.AxisAsText(
"x",h.exhigh))}
if((this.draw_errors||(this.optionEF>0))&&(e.y_kind==
"normal")&&(
"eylow" in h)&&((h.eylow!=0)||(h.eyhigh!=0))){c.push(
"error y = -"+e.AxisAsText(
"y",h.eylow)+
"/+"+e.AxisAsText(
"y",h.eyhigh))}
if(g){
return c}var f=
"";
for(var i=0;i<c.length;++i){f+=((i>0?
"\n":
"")+c[i])}
return f};a.TGraphPainter.prototype.DrawBins=
function(){this.RecreateDrawG(
false,
"main_layer");var o=
this,t=this.main_painter(),u=this.frame_width(),G=this.frame_height(),k=this.GetObject(),D=0;
if(!this.lineatt){this.lineatt=a.Painter.createAttLine(k,undefined,
true)}
if(!this.fillatt){this.fillatt=this.createAttFill(k,undefined,undefined,1)}this.fillatt.used=
false;
if(this.fillatt){this.fillatt.used=
false}this.draw_kind=
"none";this.marker_size=0;
if(this.lineatt.excl_side!=0){D=this.lineatt.excl_side*this.lineatt.excl_width;
if(this.lineatt.width>0){this.optionLine=1}}var v=null;
if(this.optionEF>0){v=this.OptimizeBins();
for(var B=0;B<v.length;++B){var x=v[B];x.grx=t.grx(x.x);x.gry=t.gry(x.y-x.eylow)}var g=a.Painter.BuildSvgPath(this.optionEF>1?
"bezier":
"line",v),d=[];
for(var B=v.length-1;B>=0;--B){var x=v[B];x.gry=t.gry(x.y+x.eyhigh);d.push(x)}var e=a.Painter.BuildSvgPath(this.optionEF>1?
"Lbezier":
"Lline",d);this.draw_g.append(
"svg:path").attr(
"d",g.path+e.path+
"Z").style(
"stroke",
"none").call(this.fillatt.func);this.draw_kind=
"lines"}
if(this.optionLine==1||this.optionFill==1||(D!==0)){var c=
"";
if(k._typename==
"TCutG"){this.optionFill=1}
if(this.optionFill==1){c=
"Z";D=0}
if(v===null){v=this.OptimizeBins()}
for(var B=0;B<v.length;++B){var x=v[B];x.grx=t.grx(x.x);x.gry=t.gry(x.y)}var s=
"line";
if(this.optionCurve===1){s=
"bezier"}
else{
if(D!==0){s+=
"calc"}}var y=a.Painter.BuildSvgPath(s,v);
if(D!==0){var f=[];
for(var B=v.length-1;B>=0;--B){var x=v[B];var C=Math.sqrt(x.dgrx*x.dgrx+x.dgry*x.dgry);x.grx+=D*x.dgry/C;x.gry-=D*x.dgrx/C;f.push(x)}var e=a.Painter.BuildSvgPath(
"L"+((this.optionCurve===1)?
"bezier":
"line"),f);this.draw_g.append(
"svg:path").attr(
"d",y.path+e.path+
"Z").style(
"stroke",
"none").call(this.fillatt.func).style(
"opacity",0.75)}
if(this.optionLine||this.optionFill){var H=this.draw_g.append(
"svg:path").attr(
"d",y.path+c);
if(this.optionLine){H.call(this.lineatt.func)}
else{H.style(
"stroke",
"none")}
if(this.optionFill>0){H.call(this.fillatt.func)}
else{H.style(
"fill",
"none")}}this.draw_kind=
"lines"}var A=null;
if(this.draw_errors||this.optionRect||this.optionBrackets||this.optionBar){v=this.OptimizeBins(
function(K,J){var w=t.grx(K.x);
if(!o.optionBar&&((w<0)||(w>u))){
return true}var h=t.gry(K.y);
if(!o.optionBar&&!o.out_of_range&&((h<0)||(h>G))){
return true}K.grx1=Math.round(w);K.gry1=Math.round(h);
if(o.has_errors){K.grx0=Math.round(t.grx(K.x-K.exlow)-w);K.grx2=Math.round(t.grx(K.x+K.exhigh)-w);K.gry0=Math.round(t.gry(K.y-K.eylow)-h);K.gry2=Math.round(t.gry(K.y+K.eyhigh)-h);
if(o.is_bent){K.grdx0=Math.round(t.gry(K.y+k.fEXlowd[J])-h);K.grdx2=Math.round(t.gry(K.y+k.fEXhighd[J])-h);K.grdy0=Math.round(t.grx(K.x+k.fEYlowd[J])-w);K.grdy2=Math.round(t.grx(K.x+k.fEYhighd[J])-w)}
else{K.grdx0=K.grdx2=K.grdy0=K.grdy2=0}}
return false});this.draw_kind=
"nodes";A=this.draw_g.selectAll(
".grpoint").data(v).enter().append(
"svg:g").attr(
"class",
"grpoint").attr(
"transform",
function(h){
return"translate("+h.grx1+
","+h.gry1+
")"})}
if(this.optionBar){
for(var E=1;E<v.length-1;++E){v[E].width=Math.max(2,(v[E+1].grx1-v[E-1].grx1)/2-2)}
switch(v.length){
case 0:
break;
case 1:v[0].width=u/4;
break;
case 2:v[0].width=v[1].width=(v[1].grx1-v[0].grx1)/2;
break;
default:v[0].width=v[1].width;v[v.length-1].width=v[v.length-2].width}var j=Math.round(t.gry(0));A.append(
"svg:rect").attr(
"x",
function(h){
return Math.round(-h.width/2)}).attr(
"y",
function(h){h.bar=
true;
if(o.optionBar!==1){
return 0}
return(h.gry1>j)?j-h.gry1:0}).attr(
"width",
function(h){
return Math.round(h.width)}).attr(
"height",
function(h){
if(o.optionBar!==1){
return G>h.gry1?G-h.gry1:0}
return Math.abs(j-h.gry1)}).call(this.fillatt.func)}
if(this.optionRect){A.filter(
function(h){
return(h.exlow>0)&&(h.exhigh>0)&&(h.eylow>0)&&(h.eyhigh>0)}).append(
"svg:rect").attr(
"x",
function(h){h.rect=
true;
return h.grx0}).attr(
"y",
function(h){
return h.gry2}).attr(
"width",
function(h){
return h.grx2-h.grx0}).attr(
"height",
function(h){
return h.gry0-h.gry2}).call(this.fillatt.func)}
if(this.optionBrackets){A.filter(
function(h){
return(h.eylow>0)||(h.eyhigh>0)}).append(
"svg:path").call(this.lineatt.func).style(
"fill",
"none").attr(
"d",
function(h){h.bracket=
true;
return((h.eylow>0)?
"M-5,"+(h.gry0-3)+
"v3h10v-3":
"")+((h.eyhigh>0)?
"M-5,"+(h.gry2+3)+
"v-3h10v3":
"")})}
if(this.draw_errors){var q=this.lineatt.width+a.gStyle.EndErrorSize,z=
"m0,"+q+
"v-"+2*q,l=
"m"+q+
",0h-"+2*q;q=Math.floor((this.lineatt.width-1)/2);A.filter(
function(h){
return(h.exlow>0)||(h.exhigh>0)||(h.eylow>0)||(h.eyhigh>0)}).append(
"svg:path").call(this.lineatt.func).style(
"fill",
"none").attr(
"d",
function(h){h.error=
true;
return((h.exlow>0)?
"M0,0L"+(h.grx0+q)+
","+h.grdx0+z:
"")+((h.exhigh>0)?
"M0,0L"+(h.grx2-q)+
","+h.grdx2+z:
"")+((h.eylow>0)?
"M0,0L"+h.grdy0+
","+(h.gry0-q)+l:
"")+((h.eyhigh>0)?
"M0,0L"+h.grdy2+
","+(h.gry2+q)+l:
"")})}
if(this.optionMark>0){var r=Math.max(1,Math.round(
this.bins.length/50000)),y=
"",B,I,p,m,F;
if(this.optionMark==2){F=3}
else{
if(this.optionMark==3){F=1}}
if(!this.markeratt){this.markeratt=a.Painter.createAttMarker(k,F)}
else{this.markeratt.Change(undefined,F)}this.marker_size=this.markeratt.size;this.markeratt.reset_pos();
for(B=0;B<this.bins.length;B+=r){I=this.bins[B];p=t.grx(I.x);
if((p>-this.marker_size)&&(p<u+this.marker_size)){m=t.gry(I.y);
if((m>-this.marker_size)&&(m<G+this.marker_size)){y+=this.markeratt.create(p,m)}}}
if(y.length>0){this.draw_g.append(
"svg:path").attr(
"d",y).call(this.markeratt.func);
if((A===null)&&(this.draw_kind==
"none")){this.draw_kind=(this.optionMark==3)?
"path":
"mark"}}}};a.TGraphPainter.prototype.ProcessTooltip=
function(c){
if(c===null){
if(this.draw_g!==null){this.draw_g.select(
".tooltip_bin").remove()}
return null}
if((this.draw_kind==
"lines")||(this.draw_kind==
"path")||(this.draw_kind==
"mark")){
return this.ProcessTooltipForPath(c)}
if(this.draw_kind!=
"nodes"){
return null}var e=this.frame_width(),o=this.frame_height(),h=this.main_painter(),l=
this,m=null,k=10000000000,g=null;this.draw_g.selectAll(
".grpoint").each(
function(){var u=b.select(
this).datum();
if(u===undefined){
return}var t=Math.pow(c.x-u.grx1,2);
if(c.nproc===1){t+=Math.pow(c.y-u.gry1,2)}
if(t>=k){
return}var s=null;
if(u.error||u.rect||u.marker||u.bracket){s={x1:Math.min(-3,u.grx0),x2:Math.max(3,u.grx2),y1:Math.min(-3,u.gry2),y2:Math.max(3,u.gry0)};
if(u.bracket){s.x1=-5;s.x2=5}}
else{
if(u.bar){s={x1:-u.width/2,x2:u.width/2,y1:0,y2:o-u.gry1};
if(l.optionBar===1){var r=h.gry(0);s.y1=(u.gry1>r)?r-u.gry1:0;s.y2=(u.gry1>r)?0:r-u.gry1}}
else{s={x1:-5,x2:5,y1:-5,y2:5}}}var q=(c.x>=u.grx1+s.x1)&&(c.x<=u.grx1+s.x2);var p=(c.y>=u.gry1+s.y1)&&(c.y<=u.gry1+s.y2);
if(q&&(p||(c.nproc>1))){k=t;m=
this;g=s;g.exact=q&&p}});var f=this.draw_g.select(
".tooltip_bin");
if(m==null){f.remove();
return null}var j=b.select(m).datum();var i={x:j.grx1,y:j.gry1,color1:this.lineatt.color,lines:this.TooltipText(j,
true)};
if(this.fillatt&&this.fillatt.used){i.color2=this.fillatt.color}
if(g.exact){i.exact=
true}i.menu=i.exact;i.menu_dist=3;
if(f.empty()){f=this.draw_g.append(
"svg:rect").attr(
"class",
"tooltip_bin h1bin").style(
"pointer-events",
"none")}i.changed=f.property(
"current_bin")!==m;
if(i.changed){f.attr(
"x",j.grx1+g.x1).attr(
"width",g.x2-g.x1).attr(
"y",j.gry1+g.y1).attr(
"height",g.y2-g.y1).style(
"opacity",
"0.3").property(
"current_bin",m)}
return i};a.TGraphPainter.prototype.ProcessTooltipForPath=
function(c){
if(this.bins===null){
return null}var d=(this.draw_kind==
"lines"),j=(this.draw_kind==
"mark"),r=null,t=10000000000,k=this.main_painter(),q,h,g,e,s;
for(e=0;e<this.bins.length;++e){s=this.bins[e];h=k.grx(s.x);q=c.x-h;
if(d){
if((e==0)&&(q<-10)){r=null;
break}}
else{g=k.gry(s.y);q=q*q+(c.y-g)*(c.y-g)}
if(Math.abs(q)<t){t=q;r=s}}
if((q>10)&&d){r=null}var i=Math.max(this.lineatt.width+3,4);
if(this.marker_size>0){i=Math.max(Math.round(
this.marker_size*7),i)}
if(r!==null){t=Math.sqrt(Math.pow(c.x-k.grx(r.x),2)+Math.pow(c.y-k.gry(r.y),2))}
if(!d&&!j&&(t>i)){r=null}
if(j&&(r!==null)){
if((c.nproc==1)&&(t>i)){r=null}
else{
if((this.bins.length==1)&&(t>3*i)){r=null}}}var o=this.draw_g.select(
".tooltip_bin");
if(r===null){o.remove();
return null}var m={x:k.grx(r.x),y:k.gry(r.y),color1:this.lineatt.color,lines:this.TooltipText(r,
true)};
if(this.fillatt&&this.fillatt.used){m.color2=this.fillatt.color}
if(!d){m.color1=a.Painter.root_colors[this.GetObject().fMarkerColor];
if(!m.color2){m.color2=m.color1}}
if(o.empty()){o=this.draw_g.append(
"svg:g").attr(
"class",
"tooltip_bin")}var p,l;
if((this.optionEF>0)&&d){p=k.gry(r.y-r.eylow);l=k.gry(r.y+r.eyhigh)}
else{p=l=k.gry(r.y)}m.exact=(Math.abs(c.x-m.x)<=i)&&((Math.abs(c.y-p)<=i)||(Math.abs(c.y-l)<=i));m.menu=m.exact;m.menu_dist=Math.sqrt((c.x-m.x)*(c.x-m.x)+Math.pow(Math.min(Math.abs(c.y-p),Math.abs(c.y-l)),2));m.changed=o.property(
"current_bin")!==r;
if(m.changed){o.selectAll(
"*").remove();o.property(
"current_bin",r);
if(j){o.append(
"svg:rect").attr(
"class",
"h1bin").style(
"pointer-events",
"none").style(
"opacity",
"0.3").attr(
"x",(m.x-i).toFixed(1)).attr(
"y",(m.y-i).toFixed(1)).attr(
"width",(2*i).toFixed(1)).attr(
"height",(2*i).toFixed(1))}
else{o.append(
"svg:circle").attr(
"cy",p.toFixed(1));
if(Math.abs(p-l)>1){o.append(
"svg:circle").attr(
"cy",l.toFixed(1))}var f=o.selectAll(
"circle").attr(
"r",i).attr(
"cx",m.x.toFixed(1));
if(!d){f.style(
"stroke",m.color1==
"black"?
"green":
"black").style(
"fill",
"none")}
else{
if(this.optionLine){f.call(this.lineatt.func)}
else{f.style(
"stroke",
"black")}
if(this.optionFill>0){f.call(this.fillatt.func)}
else{f.style(
"fill",
"none")}}}}
return m};a.TGraphPainter.prototype.UpdateObject=
function(d){
if(!this.MatchObjectType(d)){
return false}
if(this.ownhisto){this.main_painter().UpdateObject(d.fHistogram)}var c=this.GetObject();c.fX=d.fX;c.fY=d.fY;c.fNpoints=d.fNpoints;this.CreateBins();
return true};a.TGraphPainter.prototype.CanZoomIn=
function(f,e,c){var d=this.GetObject();
if((d===null)||(f!==
"x")){
return false}
for(var g=0;g<d.fNpoints;++g){
if((e<d.fX[g])&&(d.fX[g]<c)){
return true}}
return false};a.TGraphPainter.prototype.ButtonClick=
function(d){
if(d!==
"ToggleZoom"){
return false}var c=this.main_painter();
if(c===null){
return false}
if((this.xmin===this.xmax)&&(this.ymin=this.ymax)){
return false}c.Zoom(this.xmin,this.xmax,this.ymin,this.ymax);
return true};a.TGraphPainter.prototype.DrawNextFunction=
function(f,h){var g=this.GetObject();
if((g.fFunctions===null)||(f>=g.fFunctions.arr.length)){
return a.CallBack(h)}var e=g.fFunctions.arr[f];var d=g.fFunctions.opt[f];var c=a.draw(this.divid,e,d);
if(c){
return c.WhenReady(this.DrawNextFunction.bind(
this,f+1,h))}this.DrawNextFunction(f+1,h)};a.Painter.drawGraph=
function(e,d,c){a.extend(
this,
new a.TGraphPainter(d));this.CreateBins();this.SetDivId(e,-1);
if(this.main_painter()==null){
if(d.fHistogram==null){d.fHistogram=this.CreateHistogram()}a.Painter.drawHistogram1D(e,d.fHistogram,
"AXIS");this.ownhisto=
true}this.SetDivId(e);this.DecodeOptions(c);this.DrawBins();this.DrawNextFunction(0,this.DrawingReady.bind(
this));
return this};a.Painter.drawMultiGraph=
function(e,d,c){this.firstpainter=null;this.autorange=
false;this.painters=[];this.SetDivId(e,-1);this.UpdateObject=
function(k){
if(!this.MatchObjectType(k)){
return false}var l=this.GetObject(),g=k.fGraphs;l.fTitle=k.fTitle;var j=
false;
if(this.firstpainter){var f=k.fHistogram;
if(this.autorange&&(f==null)){f=this.ScanGraphsRange(g)}
if(this.firstpainter.UpdateObject(f)){j=
true}}
for(var h=0;h<g.arr.length;++h){
if(h<this.painters.length){
if(this.painters[h].UpdateObject(g.arr[h])){j=
true}}}
return j};this.ComputeGraphRange=
function(h,f){
if(f.fNpoints==0){
return}
if(h.first){h.xmin=h.xmax=f.fX[0];h.ymin=h.ymax=f.fY[0];h.first=
false}
for(var g=0;g<f.fNpoints;++g){h.xmin=Math.min(h.xmin,f.fX[g]);h.xmax=Math.max(h.xmax,f.fX[g]);h.ymin=Math.min(h.ymin,f.fY[g]);h.ymax=Math.max(h.ymax,f.fY[g])}
return h};
this[
"padtoX"]=
function(g,f){
if(g.fLogx&&(f<50)){
return Math.exp(2.302585092994*f)}
return f};this.ScanGraphsRange=
function(o,l,h){var j=this.GetObject(),k,p,u,t,s=0,g=0,r=
false,q=
false,f={xmin:0,xmax:0,ymin:0,ymax:0,first:
true};
if(h!=null){r=h.fLogx;q=h.fLogy;f.xmin=h.fUxmin;f.xmax=h.fUxmax;f.ymin=h.fUymin;f.ymax=h.fUymax;f.first=
false}
if(l!=null){p=l.fYaxis.fXmin;k=l.fYaxis.fXmax;
if(h!=null){s=this.padtoX(h,f.xmin);g=this.padtoX(h,f.xmax)}}
else{this.autorange=
true;
for(var m=0;m<o.arr.length;++m){this.ComputeGraphRange(f,o.arr[m])}
if(f.xmin==f.xmax){f.xmax+=1}
if(f.ymin==f.ymax){f.ymax+=1}u=0.05*(f.xmax-f.xmin);t=0.05*(f.ymax-f.ymin);s=f.xmin-u;g=f.xmax+u;
if(q){
if(f.ymin<=0){f.ymin=0.001*f.ymax}p=f.ymin/(1+0.5*a.log10(f.ymax/f.ymin));k=f.ymax*(1+0.2*a.log10(f.ymax/f.ymin))}
else{p=f.ymin-t;k=f.ymax+t}
if(p<0&&f.ymin>=0){p=0}
if(k>0&&f.ymax<=0){k=0}}
if(s<0&&f.xmin>=0){
if(r){s=0.9*f.xmin}
else{s=0}}
if(g>0&&f.xmax<=0){
if(r){g=1.1*f.xmax}
else{g=0}}
if(j.fMinimum!=-1111){f.ymin=p=j.fMinimum}
if(j.fMaximum!=-1111){f.ymax=k=j.fMaximum}
if(p<0&&f.ymin>=0){
if(q){p=0.9*f.ymin}}
if(k>0&&f.ymax<=0){
if(q){k=1.1*f.ymax}}
if(p<=0&&q){p=0.001*k}
if(s<=0&&r){
if(g>1000){s=1}
else{s=0.001*g}}
if(!l){l=a.Create(
"TH1I");l.fTitle=j.fTitle;l.fXaxis.fXmin=s;l.fXaxis.fXmax=g}l.fYaxis.fXmin=p;l.fYaxis.fXmax=k;
return l};this.DrawAxis=
function(){var g=this.GetObject();var f=this.ScanGraphsRange(g.fGraphs,g.fHistogram,
this.root_pad());this.firstpainter=a.Painter.drawHistogram1D(this.divid,f,
"AXIS")};this.DrawNextFunction=
function(i,k){var j=this.GetObject();
if((j.fFunctions==null)||(i>=j.fFunctions.arr.length)){
return a.CallBack(k)}var h=j.fFunctions.arr[i];var g=j.fFunctions.opt[i];var f=a.draw(this.divid,h,g);
if(f){
return f.WhenReady(this.DrawNextFunction.bind(
this,i+1,k))}this.DrawNextFunction(i+1,k)};this.DrawNextGraph=
function(i,h){var f=this.GetObject().fGraphs;
if(i>=f.arr.length){
return this.DrawNextFunction(0,this.DrawingReady.bind(
this))}var g=f.opt[i];
if((g==null)||(g==
"")){g=h}var j=a.draw(this.divid,f.arr[i],g);this.painters.push(j);j.WhenReady(this.DrawNextGraph.bind(
this,i+1,h))};
if(c==null){c=
""}c=c.toUpperCase().replace(
"3D",
"").replace(
"FB",
"");
if((c.indexOf(
"A")>=0)||(this.main_painter()==null)){c=c.replace(
"A",
"");this.DrawAxis()}this.SetDivId(e);this.DrawNextGraph(0,c);
return this};a.Painter.drawLegend=
function(e,d,c){a.extend(
this,
new a.TPavePainter(d));this.SetDivId(e);this.DrawLegendItems=
function(t,D){var j=this.GetObject(),x=j.fPrimitives.arr.length,q=j.fNColumns,o=x;
if(q<2){q=1}
else{
while((o-1)*q>=x){o--}}this.StartTextDrawing(j.fTextFont,D/(x*1.2));var M=a.Painter.root_colors[j.fTextColor],r=Math.round(t/q),v=Math.round(0.03*t/q),u=Math.round(0.03*D),s=(D-2*u)/o,k=
false;
for(var C=0;C<x;++C){var H=j.fPrimitives.arr[C];var l=H.fOption.toLowerCase();var F=C%q,J=(C-F)/q;var E=F*r;var m=E+Math.round(j.fMargin*r);var f=Math.round(u+J*s);var L=Math.round(u+(J+0.5)*s);var K=H,y=H,A=H;var B=H.fObject;var G=null;
if((B!==null)&&(typeof B==
"object")){
if(
"fLineColor" in B){A=B}
if(
"fFillColor" in B){K=B}
if(
"fMarkerColor" in B){y=B}G=this.FindPainterFor(B)}
if(l.indexOf(
"f")!=-1){var z=(G&&G.fillatt)?G.fillatt:
this.createAttFill(K);this.draw_g.append(
"svg:rect").attr(
"x",E+v).attr(
"y",Math.round(f+s*0.1)).attr(
"width",m-2*v-E).attr(
"height",Math.round(s*0.8)).call(z.func)}
if(l.indexOf(
"l")!=-1){var I=(G&&G.lineatt)?G.lineatt:a.Painter.createAttLine(A);this.draw_g.append(
"svg:line").attr(
"x1",E+v).attr(
"y1",L).attr(
"x2",m-v).attr(
"y2",L).call(I.func)}
if(l.indexOf(
"e")!=-1&&(l.indexOf(
"l")==-1||l.indexOf(
"f")!=-1)){}
if(l.indexOf(
"p")!=-1){var p=(G&&G.markeratt)?G.markeratt:a.Painter.createAttMarker(y);this.draw_g.append(
"svg:path").attr(
"d",p.create((E+m)/2,L)).call(p.func)}var g=m;
if(l.length>0){k=
true}
else{
if(!k){g=E+v}}this.DrawText(
"start",g,f,E+r-g-v,s,H.fLabel,M)}this.FinishTextDrawing()};this.PaveDrawFunc=this.DrawLegendItems;this.Redraw();
return this.DrawingReady()};a.Painter.drawPaletteAxis=
function(e,c,d){c.fBorderSize=1;c.fShadowColor=0;a.extend(
this,
new a.TPavePainter(c));this.SetDivId(e);this.z_handle=
new a.TAxisPainter(c.fAxis,
true);this.z_handle.SetDivId(e,-1);
this[
"MakeIcon"]=
function(m,s){var q=this.frame_height();var r=
"";var k={x:-1,y:-1,width:0,height:0,fill:
""};
for(var o=0;o<m.length-1;++o){var p=s(m[o]);var l=s(m[o+1]);var g=this.main_painter().getValueColor(m[o]);var f={x:128,width:256,y:Math.round(l/q*512),height:Math.round((p-l)/q*512),fill:g};
if(r.length==0){r=
"["}
else{r+=
","}var j=
"{";
if(f.x!=k.x){r+=j+
"x:"+Math.round(f.x);j=
","}
if(f.y!=k.y){r+=j+
"y:"+Math.round(f.y);j=
","}
if(f.width!=k.width){r+=j+
"w:"+Math.round(f.width);j=
","}
if(f.height!=k.height){r+=j+
"h:"+Math.round(f.height);j=
","}
if(f.fill!=k.fill){r+=j+
"f:'"+f.fill+
"'";j=
","}r+=
"}";k=f}r+=
"]"};this.DrawAxisPalette=
function(s,J){var o=
this,I=this.GetObject(),l=I.fAxis;var t=l.fNdiv%100;
if(t<=0){t=8}var h=parseInt(this.draw_g.attr(
"x")),g=parseInt(this.draw_g.attr(
"y")),B=this.pad_width(),A=this.pad_height(),m=l.fLabelOffset*B,C=this.main_painter().fContour,K=0,M=this.main_painter().gmaxbin;
if(C!==null){K=C[0];M=C[C.length-1]}var u=null,N=
"normal";
if(this.main_painter().options.Logz){u=b.scale.log();N=
"log"}
else{u=b.scale.linear()}u.domain([K,M]).range([J,0]);
if((C==null)||this._can_move){this.draw_g.append(
"svg:rect").attr(
"x",0).attr(
"y",0).attr(
"width",s).attr(
"height",J).attr(
"fill",
"white")}
else{
for(var G=0;G<C.length-1;++G){var x=u(C[G]),w=u(C[G+1]),p=this.main_painter().getValueColor(C[G]);var y=this.draw_g.append(
"svg:rect").attr(
"x",0).attr(
"y",w.toFixed(1)).attr(
"width",s).attr(
"height",(x-w).toFixed(1)).style(
"fill",p).style(
"stroke",p);
if(a.gStyle.Tooltip>0){y.on(
"mouseover",
function(){b.select(
this).transition().duration(100).style(
"stroke",
"black").style(
"stroke-width",
"2")}).on(
"mouseout",
function(){b.select(
this).transition().duration(100).style(
"stroke",b.select(
this).style(
"fill")).style(
"stroke-width",
"")}).append(
"svg:title").text(C[G].toFixed(2)+
" - "+C[G+1].toFixed(2))}
if(a.gStyle.Zooming){y.on(
"dblclick",
function(){o.main_painter().Unzoom(
"z")})}}}this.z_handle.SetAxisConfig(
"zaxis",N,u,K,M,K,M);this.z_handle.DrawAxis(this.draw_g,s,J,
"translate("+s+
", 0)");
if(this._can_move&&(
"getBoundingClientRect" in this.draw_g.node())){this._can_move=
false;var k=this.draw_g.node().getBoundingClientRect();var H=(h+parseInt(k.width))-Math.round(0.995*B)+3;
if(H>0){this.draw_g.attr(
"x",h-H).attr(
"y",g).attr(
"transform",
"translate("+(h-H)+
", "+g+
")");I.fX1NDC-=H/B;I.fX2NDC-=H/B;
return}}
if(!a.gStyle.Zooming){
return}var q=null,L=
false,E=0,D=0,f=null;
function v(){
if(!L){
return}b.event.preventDefault();var i=b.mouse(q);
if(i[1]<E){E=i[1]}
else{D=i[1]}f.attr(
"y",E).attr(
"height",Math.abs(D-E))}
function j(){
if(!L){
return}b.event.preventDefault();b.select(window).on(
"mousemove.colzoomRect",null).on(
"mouseup.colzoomRect",null);f.remove();f=null;L=
false;var i=Math.min(u.invert(E),u.invert(D));var r=Math.max(u.invert(E),u.invert(D));o.main_painter().Zoom(undefined,undefined,undefined,undefined,i,r)}
function F(){
if(L){
return}L=
true;b.event.preventDefault();q=
this;var i=b.mouse(q);E=D=i[1];f=o.draw_g.append(
"svg:rect").attr(
"class",
"zoom").attr(
"id",
"colzoomRect").attr(
"x",
"0").attr(
"width",s).attr(
"y",E).attr(
"height",5);b.select(window).on(
"mousemove.colzoomRect",v).on(
"mouseup.colzoomRect",j,
true);b.event.stopPropagation()}this.draw_g.select(
".axis_zoom").on(
"mousedown",F).on(
"dblclick",
function(){o.main_painter().Unzoom(
"z")})};this.ShowContextMenu=
function(f){this.main_painter().ShowContextMenu(
"z",f,this.GetObject().fAxis)};this.Redraw=
function(){this.Enabled=
true;var f=this.main_painter();this.UseContextMenu=(f!==null);
if((f!==null)&&f.options){this.Enabled=(f.options.Zscale>0)&&(f.options.Color>0)&&(f.options.Lego===0)}this.DrawPave()};this.PaveDrawFunc=this.DrawAxisPalette;this.CompleteDraw=this.Redraw;this._can_move=(d===
"canmove");this.Redraw();
return this.DrawingReady()};a.TH2Painter=
function(c){a.THistPainter.call(
this,c);this.fContour=null;this.fUserContour=
false;this.fPalette=null};a.TH2Painter.prototype=Object.create(a.THistPainter.prototype);a.TH2Painter.prototype.FillHistContextMenu=
function(c){
if(!this.draw_content){
return}c.add(
"Auto zoom-in",this.AutoZoom);c.addDrawMenu(
"Draw with",[
"col",
"colz",
"scat",
"box",
"text",
"lego"],
function(d){this.options=this.DecodeOptions(d);
if(this.options.Zscale>0){this.DrawNewPalette(
true)}this.RedrawPad();
if(this.options.Lego==0){this.AddInteractive()}})};a.TH2Painter.prototype.ButtonClick=
function(c){
if(a.THistPainter.prototype.ButtonClick.call(
this,c)){
return true}
if(
this!==this.main_painter()){
return false}
switch(c){
case"ToggleColor":this.ToggleColor();
break;
case"ToggleColorZ":
if(this.options.Lego==0&&
this.options.Color>0){this.ToggleColz()}
break;
case"Toggle3D":this.options.Lego=this.options.Lego>0?0:1;this.RedrawPad();
break;
default:
return false}
return true};a.TH2Painter.prototype.FillToolbar=
function(){a.THistPainter.prototype.FillToolbar.call(
this);var c=this.pad_painter(
true);
if(c===null){
return}c.AddButton(a.ToolbarIcons.th2color,
"Toggle color",
"ToggleColor");c.AddButton(a.ToolbarIcons.th2colorz,
"Toggle color palette",
"ToggleColorZ");c.AddButton(a.ToolbarIcons.th2draw3d,
"Toggle 3D mode",
"Toggle3D")};a.TH2Painter.prototype.ToggleColor=
function(){var c=
true;
if(this.options.Lego>0){this.options.Lego=0;c=
false}
if(this.options.Color==0){this.options.Color=(
"LastColor" in this.options)?this.options.LastColor:1}
else{
if(c){this.options.LastColor=this.options.Color;this.options.Color=0}}
if((this.options.Color>0)&&(this.options.Zscale>0)){this.DrawNewPalette(
true)}this.RedrawPad()};a.TH2Painter.prototype.FindPalette=
function(c){var d=this.GetObject().fFunctions;
if(d===null){
return null}
for(var e=0;e<d.arr.length;++e){var f=d.arr[e];
if(f._typename!==
"TPaletteAxis"){
continue}
if(c){d.RemoveAt(e);
if(this.pad_painter()){this.pad_painter().RemovePrimitive(f)}
return null}
return f}
return null};a.TH2Painter.prototype.DrawNewPalette=
function(g){var c=this.FindPalette(),e=this.GetObject();
if((c!==null)&&!g){
return}
if(c===null){c=a.Create(
"TPave");a.extend(c,{_typename:
"TPaletteAxis",fName:
"TPave",fH:null,fAxis:null,fX1NDC:0.91,fX2NDC:0.95,fY1NDC:0.1,fY2NDC:0.9,fInit:1});c.fAxis=a.Create(
"TGaxis");a.extend(c.fAxis,{fTitle:e.fZaxis.fTitle,fLineColor:1,fLineSyle:1,fLineWidth:1,fTextAngle:0,fTextSize:0.04,fTextAlign:11,fTextColor:1,fTextFont:42});
if(e.fFunctions==null){e.fFunctions=a.Create(
"TList")}e.fFunctions.AddFirst(c)}var d=this.frame_painter();c.fX2NDC=d.fX2NDC+0.01+(c.fX2NDC-c.fX1NDC);c.fX1NDC=d.fX2NDC+0.01;c.fY1NDC=d.fY1NDC;c.fY2NDC=d.fY2NDC;var f=this.FindPainterFor(c);
if(f===null){this.svg_canvas().property(
"current_pad",this.pad_name);f=a.draw(this.divid,c,
"canmove");this.svg_canvas().property(
"current_pad",
"")}
else{f._can_move=
true;f.Redraw()}
if(c.fX1NDC<d.fX2NDC){d.fX2NDC=c.fX1NDC-0.01;d.Redraw()}};a.TH2Painter.prototype.ToggleColz=
function(){
if(this.options.Zscale>0){this.options.Zscale=0}
else{this.options.Zscale=1;this.DrawNewPalette(
true)}this.RedrawPad()};a.TH2Painter.prototype.AutoZoom=
function(){var k=this.GetSelectIndex(
"x",
"left",-1),h=this.GetSelectIndex(
"x",
"right",1),v=this.GetSelectIndex(
"y",
"left",-1),u=this.GetSelectIndex(
"y",
"right",1),s,o,p=this.GetObject();
if((k==h)||(v==u)){
return}var m=p.getBinContent(k+1,v+1);
for(s=k;s<h;++s){
for(o=v;o<u;++o){
if(p.getBinContent(s+1,o+1)<m){m=p.getBinContent(s+1,o+1)}}}
if(m>0){
return}var f=h,e=k,c=u,l=v;
for(s=k;s<h;++s){
for(o=v;o<u;++o){
if(p.getBinContent(s+1,o+1)>m){
if(s<f){f=s}
if(s>=e){e=s+1}
if(o<c){c=o}
if(o>=l){l=o+1}}}}var d,r,t,g,q=
false;
if((f>k||e<h)&&(f<e-1)){d=this.GetBinX(f);r=this.GetBinX(e);q=
true}
if((c>v||l<u)&&(c<l-1)){t=this.GetBinY(c);g=this.GetBinY(l);q=
true}
if(q){this.Zoom(d,r,t,g)}};a.TH2Painter.prototype.ScanContent=
function(){var e,d,c=this.GetObject();this.nbinsx=c.fXaxis.fNbins;this.nbinsy=c.fYaxis.fNbins;this.CreateAxisFuncs(
true);this.gminbin=this.gmaxbin=c.getBinContent(1,1);this.gmin0bin=null;
for(e=0;e<this.nbinsx;++e){
for(d=0;d<this.nbinsy;++d){var f=c.getBinContent(e+1,d+1);
if(f<this.gminbin){this.gminbin=f}
else{
if(f>this.gmaxbin){this.gmaxbin=f}}
if(f>0){
if((this.gmin0bin===null)||(this.gmin0bin>f)){this.gmin0bin=f}}}}
if(this.gmin0bin===null){this.gmin0bin=this.gmaxbin*0.0001}this.draw_content=this.gmaxbin>0;
if(this.is_main_painter()&&(this.zoom_xmin===this.zoom_xmax)&&this.histo.fXaxis.TestBit(a.EAxisBits.kAxisRange)&&(this.histo.fXaxis.fFirst!==this.histo.fXaxis.fLast)&&((this.histo.fXaxis.fFirst>1)||(this.histo.fXaxis.fLast<=this.nbinsx))){this.zoom_xmin=this.histo.fXaxis.fFirst>1?this.GetBinX(this.histo.fXaxis.fFirst-1):this.xmin;this.zoom_xmax=this.histo.fXaxis.fLast<=this.nbinsx?this.GetBinX(this.histo.fXaxis.fLast):this.xmax}if(this.is_main_painter()&&(this.zoom_ymin===this.zoom_ymax)&&this.histo.fYaxis.TestBit(a.EAxisBits.kAxisRange)&&(this.histo.fYaxis.fFirst!==this.histo.fYaxis.fLast)&&((this.histo.fYaxis.fFirst>1)||(this.histo.fYaxis.fLast<=this.nbinsy))){this.zoom_ymin=this.histo.fYaxis.fFirst>1?this.GetBinY(this.histo.fYaxis.fFirst-1):this.ymin;this.zoom_ymax=this.histo.fYaxis.fLast<=this.nbinsy?this.GetBinY(this.histo.fYaxis.fLast):this.ymax}};a.TH2Painter.prototype.CountStat=
function(i){var j=this.GetObject(),e=0,h=0,p=0,g=0,o=0,s=0,d=this.GetSelectIndex(
"x",
"left"),m=this.GetSelectIndex(
"x",
"right"),t=this.GetSelectIndex(
"y",
"left"),r=this.GetSelectIndex(
"y",
"right"),l,c,f,v,q,k,u,w={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};
for(l=0;l<=this.nbinsx+1;++l){c=(l<=d)?0:(l>m?2:1);f=this.GetBinX(l-0.5);
for(v=0;v<=this.nbinsy+1;++v){q=(v<=t)?0:(v>r?2:1);k=this.GetBinY(v-0.5);u=j.getBinContent(l,v);w.entries+=u;w.matrix[q*3+c]+=u;
if((c!=1)||(q!=1)){
continue}
if((i!=null)&&!i(f,k)){
continue}
if((w.wmax==null)||(u>w.wmax)){w.wmax=u;w.xmax=f;w.ymax=k}e+=u;h+=f*u;p+=k*u;g+=f*f*u;o+=k*k*u;s+=f*k*u}}
if(!this.IsAxisZoomed(
"x")&&!this.IsAxisZoomed(
"y")&&(j.fTsumw>0)){e=j.fTsumw;h=j.fTsumwx;g=j.fTsumwx2;p=j.fTsumwy;o=j.fTsumwy2;s=j.fTsumwxy}
if(e>0){w.meanx=h/e;w.meany=p/e;w.rmsx=Math.sqrt(g/e-w.meanx*w.meanx);w.rmsy=Math.sqrt(o/e-w.meany*w.meany)}
if(w.wmax===null){w.wmax=0}w.integral=e;
if(j.fEntries>1){w.entries=j.fEntries}
return w};a.TH2Painter.prototype.FillStatistic=
function(i,k,u){
if(this.GetObject()===null){
return false}var j=i.GetObject(),h=this.CountStat(),p=Math.floor(k%10),s=Math.floor(k/10)%10,o=Math.floor(k/100)%10,r=Math.floor(k/1000)%10,c=Math.floor(k/10000)%10,d=Math.floor(k/100000)%10,f=Math.floor(k/1000000)%10,l=Math.floor(k/10000000)%10,g=Math.floor(k/100000000)%10;
if(p>0){j.AddText(this.GetObject().fName)}
if(s>0){j.AddText(
"Entries = "+i.Format(h.entries,
"entries"))}
if(o>0){j.AddText(
"Mean x = "+i.Format(h.meanx));j.AddText(
"Mean y = "+i.Format(h.meany))}
if(r>0){j.AddText(
"Std Dev x = "+i.Format(h.rmsx));j.AddText(
"Std Dev y = "+i.Format(h.rmsy))}
if(f>0){j.AddText(
"Integral = "+i.Format(h.matrix[4],
"entries"))}
if(l>0){j.AddText(
"Skewness x = <undef>");j.AddText(
"Skewness y = <undef>")}
if(g>0){j.AddText(
"Kurt = <undef>")}
if((c>0)||(d>0)){var e=h.matrix;j.AddText(
""+e[6].toFixed(0)+
" | "+e[7].toFixed(0)+
" | "+e[7].toFixed(0));j.AddText(
""+e[3].toFixed(0)+
" | "+e[4].toFixed(0)+
" | "+e[5].toFixed(0));j.AddText(
""+e[0].toFixed(0)+
" | "+e[1].toFixed(0)+
" | "+e[2].toFixed(0))}var q=j.fLines.arr.length,t=q*a.gStyle.StatFontSize;
if(t<=0||3==(a.gStyle.StatFont%10)){t=0.25*q*a.gStyle.StatH;j.fY1NDC=0.93-t;j.fY2NDC=0.93}
return true};a.TH2Painter.prototype.CreateContour=
function(i,d,g,f){
if(i<1){i=20}this.fContour=[];this.zmin=d;this.zmax=g;
if(this.options.Logz){
if(this.zmax<=0){this.zmax=1}
if(this.zmin<=0){this.zmin=(f>0)?0.3*f:0.0001*this.zmax}
if(this.zmin>=this.zmax){this.zmin=0.0001*this.zmax}var e=Math.log(this.zmin)/Math.log(10);var h=Math.log(this.zmax)/Math.log(10);var c=(h-e)/i;this.fContour.push(this.zmin);
for(var j=1;j<i;j++){this.fContour.push(Math.exp((e+c*j)*Math.log(10)))}this.fContour.push(this.zmax)}
else{
if((this.zmin==this.zmax)&&(this.zmin!=0)){this.zmax+=0.01*Math.abs(this.zmax);this.zmin-=0.01*Math.abs(this.zmin)}var c=(this.zmax-this.zmin)/i;
for(var j=0;j<=i;j++){this.fContour.push(this.zmin+c*j)}}};a.TH2Painter.prototype.getContourIndex=
function(d){
if(this.fContour==null){var f=this.GetObject();this.fUserContour=
false;
if((f.fContour!=null)&&(f.fContour.length>1)&&f.TestBit(a.TH1StatusBits.kUserContour)){this.fContour=a.clone(f.fContour);this.fUserContour=
true}
else{var g=20,h=this.minbin,k=this.maxbin;
if(f.fContour!=null){g=f.fContour.length}
if(this.zoom_zmin!=this.zoom_zmax){h=this.zoom_zmin;k=this.zoom_zmax}this.CreateContour(g,h,k,this.minposbin)}}
if(this.fUserContour||this.options.Logz){var i=this.fContour,e=0,c=this.fContour.length-1,j;
if(d<i[0]){
return -1}
if(d>=i[c]){
return c}
while(e<c-1){j=Math.round((e+c)/2);
if(i[j]>d){c=j}
else{e=j}}
return e}
return Math.floor(0.01+(d-this.zmin)*(this.fContour.length-1)/(
this.zmax-
this.zmin))};a.TH2Painter.prototype.getValueColor=
function(c,f){var d=this.getContourIndex(c);
if(d<0){
if(this.options.Color!==111){
return null}d=0}
if(this.fPalette==null){this.fPalette=a.Painter.GetColorPalette(this.options.Palette)}var e=Math.floor((d+0.99)*this.fPalette.length/(
this.fContour.length-1));
if(e>this.fPalette.length-1){e=this.fPalette.length-1}
return f?e:this.fPalette[e]};a.TH2Painter.prototype.CompressAxis=
function(j,e,c){
if(j.length<=e){
return}var d=0,p=j.length-2;
while((d<p)&&(j[d].cnt===0)){++d}
while((d<p)&&(j[p].cnt===0)){--p}
if(p-d<e){
return}
function o(){var i=p;
while(i>=d){
while((i>=d)&&(j[i]!==null)){--i}var k=i;
while((i>=0)&&(j[i]===null)){--i}
if(i<k){j.splice(i+1,k-i);p-=(k-i)}--i}}
if(!c){var g=Math.abs(j[p+1].gr-j[d].gr)/e;var h=d;
while(h<=p){var l=j[h++].gr;
while((h<=p)&&(Math.abs(j[h+1].gr-l)<g)){j[h++]=null}}o()}
if(c||((p-d)>1.5*e)){var m=Math.floor((p-d)/e);
if(m<2){m=2}var h=d;
while(++h<=p){
for(var f=1;f<m;++f){
if(++h<=p){j[h]=null}}}o()}};a.TH2Painter.prototype.CreateDrawBins=
function(m,E){var q=this.GetObject(),A=this.GetSelectIndex(
"x",
"left",0),v=this.GetSelectIndex(
"x",
"right",1),d=this.GetSelectIndex(
"y",
"left",0),c=this.GetSelectIndex(
"y",
"right",1),F=this.GetTipName(
"\n"),e=[],r=[],C,B,l,k,p=0,o=0,g=0;
for(C=A;C<=v;++C){l=this.GetBinX(C);
if(this.options.Logx&&(l<=0)){A=C+1;
continue}e.push({indx:C,axis:l,gr:this.grx(l),cnt:0})}
for(B=d;B<=c;++B){k=this.GetBinY(B);
if(this.options.Logy&&(k<=0)){d=B+1;
continue}r.push({indx:B,axis:k,gr:this.gry(k),cnt:0})}this.maxbin=this.minbin=q.getBinContent(A+1,d+1);
for(C=A;C<v;++C){
for(B=d;B<c;++B){o=q.getBinContent(C+1,B+1);
if(o!=0){p++}
if(o>this.maxbin){this.maxbin=o}
else{
if(o<this.minbin){this.minbin=o}}}}
if(((this.options.Optimize>0)&&(p>1000))||(
this.options.Optimize>10)){p=0;
for(C=A;C<v;++C){
for(B=d;B<c;++B){o=q.getBinContent(C+1,B+1);
if((o==0)||(o<this.minbin)){
continue}p++;e[C-A].cnt+=1;r[B-d].cnt+=1}}}
if(((this.options.Optimize>0)&&(p>1000))||(
this.options.Optimize>10)){var u=this.options.Optimize>10?10:40;var t=u;var f=Math.abs(e[0].gr-e[e.length-1].gr)/Math.abs(r[0].gr-r[r.length-1].gr);
if(f>1){t=Math.max(10,Math.round(u/f))}
else{u=Math.max(10,Math.round(t*f))}
if((this.options.Optimize>1)||(e.length>50)){this.CompressAxis(e,u,!this.options.Logx&&
this.regularx)}
if((this.options.Optimize>1)||(r.length>50)){this.CompressAxis(r,t,!this.options.Logy&&
this.regulary)}}var D=[];
for(C=0;C<e.length-1;++C){
for(B=0;B<r.length-1;++B){g=o=q.getBinContent(e[C].indx+1,r[B].indx+1);
if((e[C+1].indx>e[C].indx+1)||(r[B+1].indx>r[B].indx+1)){g=0;
for(var A=e[C].indx;A<e[C+1].indx;++A){
for(var d=r[B].indx;d<r[B+1].indx;++d){var s=q.getBinContent(A+1,d+1);o=Math.max(o,s);g+=s}}}
if((o==0)||(o<this.minbin)){
continue}var z={x1:e[C].axis,x2:e[C+1].axis,y1:r[B].axis,y2:r[B+1].axis,z:o};
if(a.gStyle.Tooltip>0){
if(this.x_kind==
"labels"){z.tip=F+
"x = "+this.AxisAsText(
"x",e[C].axis)+
"<br/>"}
else{z.tip=F+
"x = ["+this.AxisAsText(
"x",e[C].axis)+
", "+this.AxisAsText(
"x",e[C+1].axis)+
")";
if(e[C].indx+1==e[C+1].indx){z.tip+=
" bin="+e[C].indx+
"<br/>"}
else{z.tip+=
" bins=["+e[C].indx+
","+(e[C+1].indx-1)+
"]<br/>"}}
if(this.y_kind==
"labels"){z.tip+=
"y = "+this.AxisAsText(
"y",r[B].axis)+
"<br/>"}
else{z.tip+=
"y = ["+this.AxisAsText(
"y",r[B].axis)+
", "+this.AxisAsText(
"y",r[B+1].axis)+
")";
if(r[B].indx+1==r[B+1].indx){z.tip+=
" bin="+r[B].indx+
"<br/>"}
else{z.tip+=
" bins=["+r[B].indx+
","+(r[B+1].indx-1)+
"]<br/>"}}
if(g==o){z.tip+=
"entries = "+a.FFormat(g,a.gStyle.StatFormat)}
else{z.tip+=
"sum = "+a.FFormat(g,a.gStyle.StatFormat)+
" max = "+a.FFormat(o,a.gStyle.StatFormat)}}D.push(z)}}
return D};a.TH2Painter.prototype.PrepareColorDraw=
function(c,d){var f=this.GetObject(),g,e,m,l,k,o,h={i1:this.GetSelectIndex(
"x",
"left",0),i2:this.GetSelectIndex(
"x",
"right",1),j1:this.GetSelectIndex(
"y",
"left",0),j2:this.GetSelectIndex(
"y",
"right",1),grx:[],gry:[],min:0,max:0};
if(d){c=
true}
for(g=h.i1;g<=h.i2;++g){m=this.GetBinX(g);
if(this.options.Logx&&(m<=0)){h.i1=g+1;
continue}h.grx[g]=this.grx(m);
if(c){h.grx[g]=Math.round(h.grx[g])}}
for(e=h.j1;e<=h.j2;++e){l=this.GetBinY(e);
if(this.options.Logy&&(l<=0)){h.j1=e+1;
continue}h.gry[e]=this.gry(l);
if(c){h.gry[e]=Math.round(h.gry[e])}}k=f.getBinContent(h.i1+1,h.j1+1);this.maxbin=this.minbin=this.minposbin=null;
for(g=h.i1;g<h.i2;++g){
for(e=h.j1;e<h.j2;++e){k=f.getBinContent(g+1,e+1);
if(d){o=(h.grx[g+1]-h.grx[g])*(h.gry[e]-h.gry[e+1]);
if(o<=0){
continue}h.max=Math.max(h.max,k);
if((k>0)&&((k<h.min)||(h.min===0))){h.min=k}k=k/o}
if(this.maxbin===null){this.maxbin=this.minbin=k}
else{this.maxbin=Math.max(this.maxbin,k);this.minbin=Math.min(this.minbin,k)}
if(k>0){
if((this.minposbin===null)||(k<this.minposbin)){this.minposbin=k}}}}this.fContour=null;this.fUserContour=
false;
return h};a.TH2Painter.prototype.DrawBinsColor=
function(p,g){var e=this.GetObject(),k=this.PrepareColorDraw(
true),c=[],o=[],m=[],r,s,q,f,d,l;
for(f=k.i1;f<k.i2;++f){
for(d=k.j1;d<k.j2;++d){l=e.getBinContent(f+1,d+1);
if((l==0)||(l<this.minbin)){
continue}r=this.getValueColor(l,
true);
if(r===null){
continue}s=
"M"+k.grx[f]+
","+k.gry[d+1];
if(c[r]===undefined){c[r]=s}
else{q=
"m"+(k.grx[f]-o[r])+
","+(k.gry[d+1]-m[r]);c[r]+=(q.length<s.length)?q:s}o[r]=k.grx[f];m[r]=k.gry[d+1];c[r]+=
"v"+(k.gry[d]-k.gry[d+1])+
"h"+(k.grx[f+1]-k.grx[f])+
"v"+(k.gry[d+1]-k.gry[d])+
"z"}}
for(r=0;r<c.length;++r){
if(c[r]!==undefined){this.draw_g.append(
"svg:path").attr(
"palette-index",r).attr(
"fill",this.fPalette[r]).attr(
"d",c[r])}}
return k};a.TH2Painter.prototype.DrawBinsText=
function(q,k,l){var e=this.GetObject(),f,d,o,r,p,g,m;
if(l===null){l=this.PrepareColorDraw(
false)}var c=this.draw_g.append(
"svg:g").attr(
"class",
"th2_text");this.StartTextDrawing(42,20,c);
for(f=l.i1;f<l.i2;++f){
for(d=l.j1;d<l.j2;++d){o=e.getBinContent(f+1,d+1);
if((o==0)||(o<this.minbin)){
continue}r=this.getValueColor(o,
true);
if(r===null){
continue}p=l.grx[f+1]-l.grx[f];g=l.gry[d]-l.gry[d+1];m=Math.round(o);
if(m===o){m=o.toString()}
else{m=a.FFormat(o,a.gStyle.StatFormat)}this.DrawText(22,Math.round(l.grx[f]+p*0.1),Math.round(l.gry[d+1]+g*0.1),Math.round(p*0.8),Math.round(g*0.8),m,
"black",0,c)}}this.FinishTextDrawing(c);
return l};a.TH2Painter.prototype.DrawBinsBox=
function(m,u){var p=this.GetObject(),B=this.PrepareColorDraw(
false),s,q,o,C=[],z=[],v=[],k,x,f,e,D,g,d,c;var l=1,t=1,A=
false,r=0,y=1;
if(this.options.Logz&&(
this.maxbin>0)){A=
true;y=Math.log(this.maxbin);r=(this.minbin>0)?Math.log(
this.minbin):y-10;
if(r>=y){r=y-10}l=0.5/(y-r);t=0.5/(y-r)}
else{l=0.5/(this.maxbin-this.minbin);t=0.5/(this.maxbin-this.minbin)}
for(s=B.i1;s<B.i2;++s){
for(q=B.j1;q<B.j2;++q){o=p.getBinContent(s+1,q+1);
if((o==0)||(o<this.minbin)){
continue}x=A?(y-((o>0)?Math.log(o):r)):this.maxbin-o;D=B.grx[s+1]-B.grx[s];g=B.gry[q]-B.gry[q+1];f=x*l*D;e=x*t*g;D=Math.max(Math.round(D-2*f),1);g=Math.max(Math.round(g-2*e),1);
if(C[s]===undefined){C[s]=
""}C[s]+=
"M"+Math.round(B.grx[s]+f)+
","+Math.round(B.gry[q+1]+e)+
"v"+g+
"h"+D+
"v-"+g+
"z"}}
for(s=0;s<C.length;++s){
if(C[s]!==undefined){this.draw_g.append(
"svg:path").attr(
"hist-column",s).attr(
"d",C[s]).call(this.lineatt.func).call(this.fillatt.func)}}
return B};a.TH2Painter.prototype.DrawBinsScatter=
function(m,C){var r=this.GetObject(),G=this.PrepareColorDraw(
true,
true),H=[],F=[],E=[],f=[],l=[],k,e,c,B,z,q,g,o,s=1;
if(this.maxbin>0.7){s=0.7/this.maxbin}var y=Math.round(G.max-G.min);this.CreateContour((y>50)?50:y,this.minposbin,this.maxbin,this.minposbin);
for(B=G.i1;B<G.i2;++B){
for(z=G.j1;z<G.j2;++z){q=r.getBinContent(B+1,z+1);
if((q==0)||(q<this.minbin)){
continue}g=G.grx[B+1]-G.grx[B];o=G.gry[z]-G.gry[z+1];
if(g*o<=0){
continue}k=this.getContourIndex(q/g/o);
if(k<0){
continue}e=
"M"+G.grx[B]+
","+G.gry[z+1];
if(H[k]===undefined){H[k]=e;f[k]=g;l[k]=o}
else{c=
"m"+(G.grx[B]-F[k])+
","+(G.gry[z+1]-E[k]);H[k]+=(c.length<e.length)?c:e;f[k]=Math.max(f[k],g);l[k]=Math.max(l[k],o)}F[k]=G.grx[B];E[k]=G.gry[z+1];H[k]+=
"v"+o+
"h"+g+
"v-"+o+
"z"}}var I=this.svg_frame().select(
".main_layer");var d=I.select(
"defs");
if(d.empty()&&(H.length>0)){d=I.insert(
"svg:defs",
":first-child")}
if(!this.markeratt){this.markeratt=a.Painter.createAttMarker(r)}
for(k=0;k<H.length;++k){
if((H[k]!==undefined)&&(k<this.fContour.length)){var x=
"scatter_"+k;var D=d.select(
"."+x);
if(D.empty()){D=d.append(
"svg:pattern").attr(
"class",x).attr(
"id",
"jsroot_scatter_pattern_"+a.id_counter++).attr(
"patternUnits",
"userSpaceOnUse")}
else{D.selectAll(
"*").remove()}var p=Math.round(s*this.fContour[k]*f[k]*l[k]);
if(p<1){p=1}var A=
new Float32Array(p),v=
new Float32Array(p);
if(p===1){A[0]=v[0]=0.5}
else{
for(var u=0;u<p;++u){A[u]=Math.random();v[u]=Math.random()}}this.markeratt.reset_pos();var t=
"";
for(var u=0;u<p;++u){t+=this.markeratt.create(A[u]*f[k],v[u]*l[k])}D.attr(
"width",f[k]).attr(
"height",l[k]).append(
"svg:path").attr(
"d",t).call(this.markeratt.func);this.draw_g.append(
"svg:path").attr(
"scatter-index",k).attr(
"fill",
"url(#"+D.attr(
"id")+
")").attr(
"d",H[k])}}
return G};a.TH2Painter.prototype.DrawBins=
function(){this.RecreateDrawG(
false,
"main_layer");var c=this.frame_width(),d=this.frame_height();var e=null;
if(this.options.Color+
this.options.Box+
this.options.Scat+
this.options.Text==0){this.options.Scat=1}
if(this.options.Color>0){e=this.DrawBinsColor(c,d)}
else{
if(this.options.Scat>0){e=this.DrawBinsScatter(c,d)}
else{
if(this.options.Box>0){e=this.DrawBinsBox(c,d)}}}
if(this.options.Text>0){e=this.DrawBinsText(c,d,e)}this.tt_handle=e};a.TH2Painter.prototype.GetBinTips=
function(e,d){var c=[];c.push(this.GetTipName());
if(this.x_kind==
"labels"){c.push(
"x = "+this.AxisAsText(
"x",this.GetBinX(e)))}
else{c.push(
"x = ["+this.AxisAsText(
"x",this.GetBinX(e))+
", "+this.AxisAsText(
"x",this.GetBinX(e+1))+
")")}
if(this.y_kind==
"labels"){c.push(
"y = "+this.AxisAsText(
"y",this.GetBinY(d)))}
else{c.push(
"y = ["+this.AxisAsText(
"y",this.GetBinY(d))+
", "+this.AxisAsText(
"y",this.GetBinY(d+1))+
")")}c.push(
"bin = "+e+
", "+d);var f=this.GetObject().getBinContent(e+1,d+1);
if(f===Math.round(f)){c.push(
"entries = "+f)}
else{c.push(
"entries = "+a.FFormat(f,a.gStyle.StatFormat))}
return c};a.TH2Painter.prototype.ProcessTooltip=
function(c){
if(c==null){
if(this.draw_g!==null){this.draw_g.select(
".tooltip_bin").remove()}this.ProvideUserTooltip(null);
return null}var f=this.GetObject(),k=this.tt_handle,g,e,l=0;
for(g=k.i1;g<k.i2;++g){
if((c.x>=k.grx[g])&&(c.x<=k.grx[g+1])){++l;
break}}
for(e=k.j1;e<=k.j2;++e){
if((c.y>=k.gry[e+1])&&(c.y<=k.gry[e])){++l;
break}}var d=this.draw_g.select(
".tooltip_bin");var o=(l===2)?f.getBinContent(g+1,e+1):-100;
if((l!==2)||(o===0)||(o<this.minbin)){d.remove();this.ProvideUserTooltip(null);
return null}var m={x:c.x,y:c.y,color1:this.lineatt.color,color2:this.fillatt.color,lines:this.GetBinTips(g,e),exact:
true,menu:
true};
if(this.options.Color>0){m.color2=this.getValueColor(o)}
if(d.empty()){d=this.draw_g.append(
"svg:rect").attr(
"class",
"tooltip_bin h1bin").style(
"pointer-events",
"none")}m.changed=d.property(
"current_bin")!==g*10000+e;
if(m.changed){d.attr(
"x",k.grx[g]).attr(
"width",k.grx[g+1]-k.grx[g]).attr(
"y",k.gry[e+1]).attr(
"height",k.gry[e]-k.gry[e+1]).style(
"opacity",
"0.7").property(
"current_bin",g*10000+e)}
if(this.IsUserTooltipCallback()&&m.changed){this.ProvideUserTooltip({obj:f,name:f.fName,bin:f.getBin(g+1,e+1),cont:o,binx:g+1,biny:e+1,grx:c.x,gry:c.y})}
return m};a.TH2Painter.prototype.CanZoomIn=
function(e,d,c){
if((e==
"x")&&(this.GetIndexX(c,0.5)-this.GetIndexX(d,0)>1)){
return true}
if((e==
"y")&&(this.GetIndexY(c,0.5)-this.GetIndexY(d,0)>1)){
return true}
if(e==
"z"){
return true}
return false};a.TH2Painter.prototype.Draw2D=
function(c){
if(typeof
this[
"Create3DScene"]==
"function"){this.Create3DScene(-1)}this.DrawAxes();this.DrawGrids();this.DrawBins();this.DrawTitle();a.CallBack(c)};a.TH2Painter.prototype.CheckResize=
function(c){var e=this.pad_painter();var f=
true,d=(this.options.Lego>0)&&!a.browser.isFirefox;
if(e){f=e.CheckCanvasResize(c,d)}
if(f&&(this.options.Lego>0)&&(typeof
this[
"Resize3D"]==
"function")){this.Resize3D()}
return f};a.TH2Painter.prototype.Draw3D=
function(c){a.AssertPrerequisites(
"3d",
function(){
this[
"Create3DScene"]=a.Painter.HPainter_Create3DScene;
this[
"Draw3DBins"]=a.Painter.TH2Painter_Draw3DBins;
this[
"Draw3D"]=a.Painter.TH2Painter_Draw3D;
this[
"Draw3D"](c)}.bind(
this))};a.TH2Painter.prototype.Redraw=
function(){this.CreateXY();var c=(this.options.Lego>0)?
"Draw3D":
"Draw2D";
this[c]()};a.Painter.drawHistogram2D=
function(f,d,e){a.extend(
this,
new a.TH2Painter(d));this.SetDivId(f,1);this.options=this.DecodeOptions(e);this.CheckPadOptions();this.ScanContent();
if(this.create_canvas&&(this.options.Zscale>0)){this.DrawNewPalette(
true)}this.CreateXY();
if(a.gStyle.AutoStat&&
this.create_canvas){this.CreateStat()}var c=this.options.Lego>0?
"Draw3D":
"Draw2D";
this[c](
function(){this.DrawNextFunction(0,
function(){
if(this.options.Lego==0){
this.AddInteractive();
if(this.options.AutoZoom){this.AutoZoom()}}this.FillToolbar();this.DrawingReady()}.bind(
this))}.bind(
this));
return this};
return a.Painter}));