source: trunk/source/geometry/solids/test/SurfaceChecker/singlesolid.kumac @ 1350

Last change on this file since 1350 was 1350, checked in by garnier, 14 years ago

update to last version 4.9.4

File size: 6.5 KB
RevLine 
[1350]1
2MACRO SINGLESOLID   [FILE]
3
4* Author: Oliver Link, Oliver.Link@cern.ch
5* Description:
6*    1. Only a single hbk file [file] will be analysed and plotted.
7*    2. The user can specify the range to be analysed [xmin] [xmax]
8*        and change the number of bins [n] . See USER INPUT below
9*    3. Analyse the hbkook : checksinglesolid [file]
10*    4. Plotting data (stored in vectors).
11*       Macro: plot [psfile] [title] [xmin] [xmax] [ymin] [ymax]
12*   ->  Prepares two postscript files
13*           file  = hbk/yourfile.hbk
14*       --->   yourfile-full.ps ,  yourfile-zoom.ps
15*
16*    the macros are similar to SINGLE macro ( set m = 1 )
17*    except the plot macro  : you have to give a title
18*
19* 31.May:
20*  - added an argument in order to specifiy the name of
21*    the hbook file directly, e.g
22*        exec singlesolid hbk/yourfile.hbk
23*
24   
25******************************************************************
26******************************************************************
27***************          USER INPUT       ************************
28******************************************************************
29******************************************************************
30
31** fix the number of bins and analysis range
32nbins = 200
33xmin  = 1e-14
34xmax  = 1e5
35
36string = basename [file] .hbk
37base = $shell([string])
38
39*goto plot     | if you want to go directly to the plot section
40              | and thus skipping the checksolids macro.
41              | You have to process the checksolids macro at least once.
42
43******************************************************************
44******************************************************************
45********************** initialization  ***************************
46
47** delete old histograms and vectors,  init some paw settings
48
49hi/del 0    | delete all histos
50v/del *     | delete all vectors
51cut 0 -     | delete all cuts
52
53opt logx
54
55opt nstat
56opt ngrid
57opt nfit
58opt grid
59
60******************************************************************
61******************************************************************
62********************** create binning ****************************
63
64ve/cre x([nbins]) r
65ve/cre widths([nbins]) r
66ve/cre vlogdx([nbins]) r
67ve/cre xerr([nbins]) r
68ve/cre XHigh([nbins]) r
69ve/cre XLow([nbins]) r
70
71div = [xmax]/[xmin]
72
73do i=1,[nbins]
74  xcenter = $rsigma([xmin]*[div]**(([i]-0.5)/[nbins]))
75  dx      = $rsigma([xmin]*[div]**([i]/[nbins])*(1-[div]**(-1/[nbins])))
76  xiLow   = $rsigma([xmin]*[div]**(([i]-1)/[nbins]))
77  xiHigh  = $rsigma([xmin]*[div]**([i]/[nbins]))
78  logdx   = $rsigma(log10([xiHigh])-log10([xiLow]))
79  ve/inp x([i]) [xcenter]
80  ve/inp widths([i]) [dx]
81  ve/inp vlogdx([i]) [logdx]
82  ve/inp XLow([i])  [xiLow]
83  ve/inp XHigh([i]) [xiHigh]
84enddo
85
86vscale widths 0.5 xerr
87
88
89******************************************************************
90******************************************************************
91********************** analyse data ******************************
92
93
94exec checksinglesolid [file]
95
96
97******************************************************************
98******************************************************************
99********************** plot data  ********************************
100
101plot:
102
103* set fonts and precission
104
105set *fon -132
106set TXFP -132
107* set vsiz 0.45
108set asiz 0.7
109* margins
110set ymgl 2.5
111set ymgu 2.0
112set xmgl 3.0
113set xmgr 1.0
114
115* I'm extrating the basename of the bhook file
116* and use it as the name of the postscript file ..
117
118title   = [base]           | or something else to describe your data
119psfile  = [base]-full.ps   
120exec plot [psfile] [title] [xmin] [xmax] 0 0.15
121
122psfile = [base]-zoom.ps
123exec plot [psfile] [title] [xmin]  1e-7  0 0.15
124
125return
126
127******************************************************************
128******************************************************************
129********************** macros ************************************
130
131
132MACRO PLOT [psfile] [title] [xmin] [xmax] [ymin] [ymax]
133
134* this macro generates the plot x vs. y
135*    [xmin] [xmax] [ymin] [ymax] is the plot range
136*    [psfile] name of the postscript file
137*    [title]  a text describing the data points
138
139nbins = $vdim(x,1)                |  number of bins
140m     = 1                         |  only one solid
141
142mess [psfile] [title]
143
144* open postscript file
145for/file 70 [psfile]
146meta 70 -114
147
148null [xmin] [xmax] [ymin] [ymax]
149atitle 'dist (mm)' 'events/bin (variable size)'
150
151do j=1,[m]
152
153  icolor = $rsigma(mod([j],7)+1)
154  isym   = $rsigma(mod([j],11)+ 20)
155  posy = 97 - [j]*3
156
157  set hcol [icolor]
158  set pmci [icolor]
159  set plci [icolor]
160 
161  g/h/e x y[j] xerr e[j] [nbins] [isym] 0.2
162
163  exec logsymbol 75 [posy] [title] [isym]
164
165
166enddo
167
168* close postscript
169close 70
170
171Return
172
173******************************************************************
174******************************************************************
175
176MACRO CHECKSINGLESOLID  [file]
177* loops over all solids (hbook files in folder hbk)
178* operates on ntuple 1 in hbook [file]
179* calculates the number of events per bin
180* and stores the values in a vector y[solidnum]
181*  [solidnum] is a unique (integer) number to identify the solid
182
183* create a counter histogram
184idc = 12345
1851d [idc] 'counter' 1 0 1
186
187nbins = $vdim(x,1)                    |  number of bins
188m     = 1                             |  number of solids
189
190
191do solidnum=1,[m]
192
193* create vector for data
194  ve/cre y[solidnum]([nbins]) r
195  ve/cre e[solidnum]([nbins]) r
196
197  mess process [file]
198
199 
200  hi/file 1 [file]
201
202  hi/op/reset [idc]
203  nt/proj [idc] 1.0.5
204  norm = $hinfo([idc],'entries')
205
206  do i=1,[nbins]
207     hi/op/reset [idc]
208     nt/proj [idc] 1.0.5 XLow([i])<delta<XHigh([i])
209     entries = $hinfo([idc],'entries')
210
211*   factor = $rsigma(vlogdx([i])*x([i])*log(10)*[norm])
212*   factor =  $rsigma(vlogdx([i])*[norm])
213
214     factor =  $rsigma([norm])
215
216     count = $rsigma([entries]/[factor])
217     error = $rsigma(sqrt([entries])/[factor])
218
219     ve/inp y[solidnum]([i]) [count]
220     ve/inp e[solidnum]([i]) [error]
221
222  enddo
223
224  close 1
225
226enddo
227
228hi/del [idc]     | delete counter
229
230return
231
232
233
234******************************************************************
235******************************************************************
236
237
238MACRO LOGSYMBOL 1=100 2=100 [txt] [isym]
239* plots a symbol at position 1/2
240*  [txt]  text to display
241*  [isym] symbol number
242   X1 = $GRAFINFO('WNXMIN')
243   X2 = $GRAFINFO('WNXMAX')
244   Y1 = $GRAFINFO('WNYMIN')
245   Y2 = $GRAFINFO('WNYMAX')
246   DX = [X2]-[X1]
247   X  = [1]/100.
248   X  = [DX]*[X]
249   X  = [X]+[X1]
250   DY = [Y2]-[Y1]
251   Y  = [2]/100.
252   Y  = [DY]*[Y]
253   Y  = [Y]+[Y1]
254
255   if ( [X].gt.0 ) then
256      X  = $rsigma(10**[X])
257   else
258      X =  $rsigma(1./(10**abs([X])))
259   endif
260
261   key [X] [Y] [isym] [txt]
262Return
263
Note: See TracBrowser for help on using the repository browser.