source: trunk/source/processes/electromagnetic/lowenergy/test/fluoTest/fit.py @ 1228

Last change on this file since 1228 was 1199, checked in by garnier, 15 years ago

nvx fichiers dans CVS

File size: 1.8 KB
Line 
1hm.selectStore("xrayfluo.his")
2histoGamDet     = hm.load1D(1)
3
4# prepare to fit the histo h1
5# creating a vector from a histogram
6v1=vm.from1D(histoGamDet)
7
8vm.list()
9
10# create a new fitter:
11fit=Fitter()
12# perform fit using the histogram               
13fit.setData(v1) 
14v1.toAscii("EnergyDep.dat")     
15# set the model to "gaussian"   
16fit.setModel("G")       
17# define (and init) parameters for fit function         
18fit.setParameter("amp"  ,653.)
19amp = fit.fitParameter ("amp")
20amp.setStart(653.)
21amp.setStep(1.)
22amp.setBounds(500.,700.)
23# ... for these the order is relevant
24fit.setParameter("mean" ,1.72)
25mean = fit.fitParameter ("mean")
26mean.setStart(1.72)
27mean.setStep(0.01)
28mean.setBounds(1.62,1.82)
29
30# ... as there is no "intelligent parsing" possible :-(
31fit.setParameter("sigma",.1)
32sigma = fit.fitParameter ("sigma")
33sigma.setStart(0.1)
34sigma.setStep(0.005)
35sigma.setBounds(0.01,0.3)
36# perform fit using the histogram
37fit.chiSquareFit()     
38fit.printResult()               
39# get vector wiht fitted function for overlay
40
41vfit=fit.fittedVector(vm)                       
42
43# comment this if you want to have a look at the resource file for NAG
44shell("rm -f e04ucc.r")
45
46#pl.zoneOption("mirrorAxis","yes")
47pl.xAxisOption("title","energy release in the detector")
48pl.yAxisOption("label","counts")
49# set error bars (full version)
50#pl.dataOption("Representation","Error")
51# plot data with overlayed fit-result
52pl.textStyle("fontsize","10.")
53pl.dataStyle("linecolor", "green")
54pl.dataOption("legend","fit")
55#pl.dataStyle("lineshape","dashdot")
56pl.plot(vfit)
57
58wait()
59pl.psPrint("fitEnegyDep.ps")   
60pl.reset()
61
62pl.textStyle("fontsize","10.")
63pl.dataStyle("linecolor", "red")
64pl.dataOption("legend","energyDeposit")
65pl.plot(v1)
66wait()
67
68pl.dataStyle("linecolor", "green")
69pl.dataOption("legend","fit")
70pl.dataStyle("lineshape","dashdot")
71pl.overlay(vfit)
72
73pl.psPrint("fitEnegyOverl.ps")         
74pl.reset()
75del fit
76
77
Note: See TracBrowser for help on using the repository browser.