[1350] | 1 | |
---|
| 2 | MACRO 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 |
---|
| 32 | nbins = 200 |
---|
| 33 | xmin = 1e-14 |
---|
| 34 | xmax = 1e5 |
---|
| 35 | |
---|
| 36 | string = basename [file] .hbk |
---|
| 37 | base = $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 | |
---|
| 49 | hi/del 0 | delete all histos |
---|
| 50 | v/del * | delete all vectors |
---|
| 51 | cut 0 - | delete all cuts |
---|
| 52 | |
---|
| 53 | opt logx |
---|
| 54 | |
---|
| 55 | opt nstat |
---|
| 56 | opt ngrid |
---|
| 57 | opt nfit |
---|
| 58 | opt grid |
---|
| 59 | |
---|
| 60 | ****************************************************************** |
---|
| 61 | ****************************************************************** |
---|
| 62 | ********************** create binning **************************** |
---|
| 63 | |
---|
| 64 | ve/cre x([nbins]) r |
---|
| 65 | ve/cre widths([nbins]) r |
---|
| 66 | ve/cre vlogdx([nbins]) r |
---|
| 67 | ve/cre xerr([nbins]) r |
---|
| 68 | ve/cre XHigh([nbins]) r |
---|
| 69 | ve/cre XLow([nbins]) r |
---|
| 70 | |
---|
| 71 | div = [xmax]/[xmin] |
---|
| 72 | |
---|
| 73 | do 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] |
---|
| 84 | enddo |
---|
| 85 | |
---|
| 86 | vscale widths 0.5 xerr |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | ****************************************************************** |
---|
| 90 | ****************************************************************** |
---|
| 91 | ********************** analyse data ****************************** |
---|
| 92 | |
---|
| 93 | |
---|
| 94 | exec checksinglesolid [file] |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | ****************************************************************** |
---|
| 98 | ****************************************************************** |
---|
| 99 | ********************** plot data ******************************** |
---|
| 100 | |
---|
| 101 | plot: |
---|
| 102 | |
---|
| 103 | * set fonts and precission |
---|
| 104 | |
---|
| 105 | set *fon -132 |
---|
| 106 | set TXFP -132 |
---|
| 107 | * set vsiz 0.45 |
---|
| 108 | set asiz 0.7 |
---|
| 109 | * margins |
---|
| 110 | set ymgl 2.5 |
---|
| 111 | set ymgu 2.0 |
---|
| 112 | set xmgl 3.0 |
---|
| 113 | set 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 | |
---|
| 118 | title = [base] | or something else to describe your data |
---|
| 119 | psfile = [base]-full.ps |
---|
| 120 | exec plot [psfile] [title] [xmin] [xmax] 0 0.15 |
---|
| 121 | |
---|
| 122 | psfile = [base]-zoom.ps |
---|
| 123 | exec plot [psfile] [title] [xmin] 1e-7 0 0.15 |
---|
| 124 | |
---|
| 125 | return |
---|
| 126 | |
---|
| 127 | ****************************************************************** |
---|
| 128 | ****************************************************************** |
---|
| 129 | ********************** macros ************************************ |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | MACRO 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 | |
---|
| 139 | nbins = $vdim(x,1) | number of bins |
---|
| 140 | m = 1 | only one solid |
---|
| 141 | |
---|
| 142 | mess [psfile] [title] |
---|
| 143 | |
---|
| 144 | * open postscript file |
---|
| 145 | for/file 70 [psfile] |
---|
| 146 | meta 70 -114 |
---|
| 147 | |
---|
| 148 | null [xmin] [xmax] [ymin] [ymax] |
---|
| 149 | atitle 'dist (mm)' 'events/bin (variable size)' |
---|
| 150 | |
---|
| 151 | do 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 | |
---|
| 166 | enddo |
---|
| 167 | |
---|
| 168 | * close postscript |
---|
| 169 | close 70 |
---|
| 170 | |
---|
| 171 | Return |
---|
| 172 | |
---|
| 173 | ****************************************************************** |
---|
| 174 | ****************************************************************** |
---|
| 175 | |
---|
| 176 | MACRO 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 |
---|
| 184 | idc = 12345 |
---|
| 185 | 1d [idc] 'counter' 1 0 1 |
---|
| 186 | |
---|
| 187 | nbins = $vdim(x,1) | number of bins |
---|
| 188 | m = 1 | number of solids |
---|
| 189 | |
---|
| 190 | |
---|
| 191 | do 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 | |
---|
| 226 | enddo |
---|
| 227 | |
---|
| 228 | hi/del [idc] | delete counter |
---|
| 229 | |
---|
| 230 | return |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | |
---|
| 234 | ****************************************************************** |
---|
| 235 | ****************************************************************** |
---|
| 236 | |
---|
| 237 | |
---|
| 238 | MACRO 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] |
---|
| 262 | Return |
---|
| 263 | |
---|