macro dfact field=perp ttype=h fit=data read field fittype=data fittype=data pmom=4.723 * Lower and upper region of W to match background and data fwlo=0.6 fwhi=.85 wtype=w_[fwlo]_[fwhi] message field = [field] message target = [ttype] message W region = [wtype] do ntar=1,2 if ( [ntar] .eq. 1) then name=top endif if ( [ntar] .eq. 2) then name=bot endif fname=../[name]_[field][ttype]_[pmom].out vec/del vrun,vtar,vtpol,vbpol,vcasy,ptime,ntime,pcharge,ncharge vec/read vrun,vtar,vtpol,vbpol,vcasy,ptime,ntime,pcharge,ncharge [fname] nrtot=$vlen(vrun,1) message Looping for [nrtot] runs in file [fname] * * filecase keep chain -all *do nr=1,[nrtot] btot_charge=0 btot_eff=0 first=4 last=[nrtot] diff=[last]-[first]+1 do nr=[first],[last] nrun=vrun([nr]) if ($FEXIST(t.out)) then sh rm t.out endif sh tclsh ../get_info_run.tcl [nrun] > t.out sh cat t.out vec/del ch,t,f vec/read ch,t,f t.out vec/write ch,t,f bcharge=ch(1) message charge = [bcharge] mC btime=t(1) message time = [btime] sec bcurrent=[bcharge]/[btime]*1000. message ave current = [bcurrent] nA bfideff=f(1) bfideff=[bfideff]/100. message Tracking eff = [bfideff] btot_charge=[btot_charge]+[bcharge] btot_eff=[btot_eff]+[bfideff] sh rm t.out nseg=1 dir=/work/hallc/e93026/rss/pass3 fname=[dir]/ntup/hms[nrun].[nseg].hbook message check [fname] while ($FEXIST([fname])) do message add [fname] to chain chain all [fname] nseg=[nseg]+1 fname=[dir]/ntup/hms[nrun].[nseg].hbook endwhile zone 1 2 enddo bavefideff=[btot_eff]/[diff] bcf=1./[btot_charge]/[bavefideff] message Total charge = [btot_charge] message average fideff= [bavefideff] * * calc dilution factor * ntheta=2 if ( [field] .eq. 'para') then vec/create vthlo([ntheta]) r 11.5 13.0875 vec/create vthhi([ntheta]) r 13.0875 15.0 endif if ( [field] .eq. 'perp') then vec/create vthlo([ntheta]) r 11.5 12.7625 vec/create vthhi([ntheta]) r 12.7625 16.0 endif do nth=1,[ntheta] if ([field] .eq. 'para') then if ( [fit] .eq. 'data') then if ( [fittype] .eq. 'data') then vec/read bgw,bgc,bgerr [field]_bg_43799_th[nth].dat vec/write bgw,bgc,bgerr ' ' 3(f15.5,1x) endif if ( [fittype] .eq. 'yield') then vec/read bgw,bgc,bgerr [field]_yield_bg_43799_th[nth].dat vec/write bgw,bgc,bgerr ' ' 3(f15.5,1x) endif endif endif if ([field] .eq. 'perp') then * if ( [fit] .eq. 'data') then if ( [fittype] .eq. 'data') then vec/read bgw,bgc,bgerr [field]_bg_43396_th[nth].dat vec/write bgw,bgc,bgerr ' ' 3(f15.5,1x) endif if ( [fittype] .eq. 'yield') then vec/read bgw,bgc,bgerr [field]_yield_bg_43396_th[nth].dat endif endif endif oname=[name]_[field][ttype]_[wtype]_df_[fittype]_[fit]_th[nth].dat psname=[name]_[field][ttype]_[wtype]_df_[fittype]_[fit]_th[nth].ps thlo=vthlo([nth]) thhi=vthhi([nth]) if ([field] .eq. 'perp') then ntu/cut $11 abs(hsyptar)<.04.and.abs(hsxptar+.05)<.12 endif if ([field] .eq. 'para') then ntu/cut $11 abs(hsyptar)<.04.and.abs(hsxptar)<.12 endif ntu/cut $2 $11.and.[thlo].01.and.0.8