macro addstat text=* number relline=1 nfitpar=0 absline=0 chopt='' if [text]='*' then mess '* ' mess '* Macro : addstat text number relline=1 nfitpar=0 absline=0 chopt=''' mess '* Author: Mark Lakata ' mess '* Version: 1.1' mess '* ' mess '* text C Field name' mess '* number C Field value (need not be numeric)' mess '* relline I Line to write additional statistic. Counts from 1. ' mess '* (ignored if absline>0 or chopt=s)' mess '* nfitpar I Number of fit parameters used in histogram fit.' mess '* (ignored if absline>0)' mess '* absline I Absolute line to write additional statistic. First line is 1.' mess '* If <=0, then append to end using relline and nfitpar.' mess '* chopt C options.' mess '* S = add another statistic line (calculate relline automatially)' mess '* ' mess '* Draw an additional statistic, similar to those drawn with the STAT or' mess '* FIT options, i.e. ID, Entries, Mean, RMS.' mess '* ' mess '* Example:' mess '* h/pl 10 ' mess '* exec addstat Ngamma 3 ' mess '* exec addstat Ntrack 4 chopt=s ' mess '* exec addstat Nmuon 2 chopt=s ' mess '* ' mess '* h/fit 10 g ! fit with a gaussian' mess '* exec addstat method 17 nfitpar=3 ! use nfitpar=3 for a Gaussian fit' mess '* exec addstat beam '600 MeV/c' nfitpar=3 chopt=s !' exitm endif if $index([chopt],'s')>0 then relline = savedrelline + 1 endif if [absline]<=0 then stat = $grafinfo('?STAT') fit = $grafinfo('?FIT') statcount = $exec('countones '//[stat]) fitcount1 = $exec('countones '//[fit]//' mask=00000001') fitcount2 = $exec('countones '//[fit]//' mask=11111110') statlines = [statcount] * $option('stat') fitlines = (([fitcount2] * [nfitpar]) + [fitcount1]) * $option('fit') * mess fitlines = (([fitcount1] * [nfitpar]) + [fitcount2]) * $option('fit') absline = [statlines] + [fitlines] + [relline] endif exec resetnt1 origin=ur chhe = $grafinfo('?csiz') / $grafinfo('xzones') x0 = -20*[chhe] x1 = -19*[chhe] x2 = -[chhe] y = - 2 * [chhe] * ([absline] - 0.25) y1 = - 2 * [chhe] * ([absline] + 0.0) oldtxfp = $grafinfo('?txfp') oldchhe = $grafinfo('?chhe') oldtxal = $grafinfo('?txal') igset txfp $grafinfo('?cfon') igset chhe [chhe] igset txal 10 itx [x1] [y] [text] igset txal 30 itx [x2] [y] [number] line [x0] 0 [x0] [y1] line [x0] [y1] 0 [y1] igset txfp [oldtxfp] igset chhe [oldchhe] igset txal [oldtxal] alias/create savedrelline [relline] return macro countones bitpattern mask=1111111111111111 * mess pased [mask] [bitpattern] lenpat = $len([bitpattern]) if [lenpat]>16 then mess 'bitpattern too long' exitm 0 endif lenmask = $len([mask]) if [lenmask]>16 then mess 'bitpattern too long' exitm 0 endif if [lenmask]>[lenpat] then mask = $substring([mask],[lenmask]-[lenpat]+1,[lenpat]) elseif [lenmask]<[lenpat] then bitpattern = $substring([bitpattern],[lenpat]-[lenmask]+1,[lenmask]) endif * mess fixed [mask] [bitpattern] count = 0 do i=1,[lenpat] if ($substring([bitpattern],[i],1)=1.and.$substring([mask],[i],1)=1) then count = [count] + 1 endif * mess [i] $substring([bitpattern],[i],1) $substring([mask],[i],1) c=[count] enddo exitm [count] return * macro resetnt1 ymax = 0 ymin = -1*($grafinfo('vpymax')-$grafinfo('vpymin'))*$grafinfo('?ysiz') xmax = 0 xmin = -1* ($grafinfo('vpxmax')-$grafinfo('vpxmin'))*$grafinfo('?xsiz') null [xmin] [xmax] [ymin] [ymax] sab return