 |
Interactive fit of H1D using Jas and a defined function
Source code name: "fit_jas_custom.py"
Programming language: Python
Topic: Data fitting/jaida
DMelt Version 1. Last modified: 12/02/2017. License: Pro
https://datamelt.org/code/cache/fit_jas_custom_7229.py
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
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]))
You see the box below because you did not login.