

from hep.aida import IAnalysisFactory
from java.util import Random
from jhplot  import * 

h1 = H1D("1D  histogram",100, -2, 2.0)
p1=P1D("data with errors")

rand = Random()
for i in range(600):
      h1.fill(rand.nextGaussian())     
p0=P0D("Normal distribution")
p0.randomNormal(1000,0.0,10.0)
p1.add(1,10,3)
p1.add(2,5,1)
p1.add(3,12,2)

aFactory = IAnalysisFactory.create()
tFactory = aFactory.createTreeFactory()
tree = tFactory.create();
fFactory = aFactory.createFunctionFactory(tree)
gauss=fFactory.createFunctionFromScript("gauss", 1, "a*exp(-(x[0]-mean)*(x[0]-mean)/sigma/sigma)","a,mean,sigma","NewGaussian")
parabola=fFactory.createFunctionFromScript("parabola",1,"background + (a*x[0]*x[0]+b*x[0]+c)","a,b,c,background","Parabola")
 
from  java.util import ArrayList
a=ArrayList([h1,p1,p0])
# c=HPlotJas("JAS",ArrayList([h1,p1,p0]))
c=HPlotJas("JAS",ArrayList([h1,p1,p0,gauss,parabola]))

