1 | |
---|
2 | MACRO 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 |
---|
27 | nbins = 200 |
---|
28 | xmin = 1e-14 |
---|
29 | xmax = 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 | |
---|
41 | hi/del 0 | delete all histos |
---|
42 | v/del * | delete all vectors |
---|
43 | cut 0 - | delete all cuts |
---|
44 | |
---|
45 | opt logx |
---|
46 | |
---|
47 | opt nstat |
---|
48 | opt ngrid |
---|
49 | opt nfit |
---|
50 | opt grid |
---|
51 | |
---|
52 | ****************************************************************** |
---|
53 | ****************************************************************** |
---|
54 | ********************** create binning **************************** |
---|
55 | |
---|
56 | ve/cre x([nbins]) r |
---|
57 | ve/cre widths([nbins]) r |
---|
58 | ve/cre vlogdx([nbins]) r |
---|
59 | ve/cre xerr([nbins]) r |
---|
60 | ve/cre XHigh([nbins]) r |
---|
61 | ve/cre XLow([nbins]) r |
---|
62 | |
---|
63 | div = [xmax]/[xmin] |
---|
64 | |
---|
65 | do 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] |
---|
76 | enddo |
---|
77 | |
---|
78 | vscale widths 0.5 xerr |
---|
79 | |
---|
80 | |
---|
81 | ****************************************************************** |
---|
82 | ****************************************************************** |
---|
83 | ********************** analyse data ****************************** |
---|
84 | |
---|
85 | |
---|
86 | exec checksolids |
---|
87 | |
---|
88 | |
---|
89 | ****************************************************************** |
---|
90 | ****************************************************************** |
---|
91 | ********************** plot data ******************************** |
---|
92 | |
---|
93 | plot: |
---|
94 | |
---|
95 | * set fonts and precission |
---|
96 | |
---|
97 | set *fon -132 |
---|
98 | set TXFP -132 |
---|
99 | * set vsiz 0.45 |
---|
100 | set asiz 0.7 |
---|
101 | * margins |
---|
102 | set ymgl 2.5 |
---|
103 | set ymgu 2.0 |
---|
104 | set xmgl 3.0 |
---|
105 | set xmgr 1.0 |
---|
106 | |
---|
107 | * usage: plot [psfile] [xmin] [xmax] [ymin] [ymax] |
---|
108 | exec plot 'solid-full.ps' [xmin] [xmax] 0 0.15 |
---|
109 | exec plot 'solid-zoom.ps' [xmin] 1e-7 0 0.15 |
---|
110 | |
---|
111 | return |
---|
112 | |
---|
113 | ****************************************************************** |
---|
114 | ****************************************************************** |
---|
115 | ********************** macros ************************************ |
---|
116 | |
---|
117 | |
---|
118 | MACRO 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 | |
---|
124 | nbins = $vdim(x,1) | number of bins |
---|
125 | m = $exec('NumberOfSolids') | number of solids |
---|
126 | |
---|
127 | |
---|
128 | * open postscript file |
---|
129 | for/file 70 [psfile] |
---|
130 | meta 70 -114 |
---|
131 | |
---|
132 | null [xmin] [xmax] [ymin] [ymax] |
---|
133 | atitle 'dist (mm)' 'events/bin (variable size)' |
---|
134 | |
---|
135 | do 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 | |
---|
157 | enddo |
---|
158 | |
---|
159 | * close postscript |
---|
160 | close 70 |
---|
161 | |
---|
162 | Return |
---|
163 | |
---|
164 | ****************************************************************** |
---|
165 | ****************************************************************** |
---|
166 | |
---|
167 | MACRO 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 |
---|
175 | idc = 12345 |
---|
176 | 1d [idc] 'counter' 1 0 1 |
---|
177 | |
---|
178 | nbins = $vdim(x,1) | number of bins |
---|
179 | m = $exec('NumberOfSolids') | number of solids |
---|
180 | |
---|
181 | do 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 | |
---|
215 | enddo |
---|
216 | |
---|
217 | hi/del [idc] | delete counter |
---|
218 | |
---|
219 | return |
---|
220 | |
---|
221 | |
---|
222 | |
---|
223 | ****************************************************************** |
---|
224 | ****************************************************************** |
---|
225 | |
---|
226 | |
---|
227 | MACRO 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] |
---|
251 | Return |
---|
252 | |
---|
253 | |
---|
254 | ****************************************************************** |
---|
255 | ****************************************************************** |
---|
256 | ******* determine the number of hbook files in hbk *************** |
---|
257 | |
---|
258 | Macro NUMBEROFSOLIDS |
---|
259 | |
---|
260 | m = $shell('ls -l hbk/run_*.hbk | wc -l') |
---|
261 | |
---|
262 | Return [m] |
---|