source: trunk/source/geometry/solids/test/SurfaceChecker/solid.kumac

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

update to last version 4.9.4

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