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