subroutine hec_beam_xymwpc(idata,n_cha,i_xy,coor,ch_width) c c decode mwpc data word idata c and returns : n_cha = chamber number (1 .. 5) c i_xy = 1 if x-coordinate plane c =-1 if y-coordiante plane c coor = cluster coordinate in cm c ch_width = cluster half width c c modified 27-jun-1997 A.Minaenko c modified 02-nov-1997 A.Minaenko c implicit none integer idata, n_cha, i_xy real coor, ch_width c include 'hec_par.inc' ! shared parameters include 'hec_datacard.inc' include 'hec_beam_sys_config.inc' c integer maskad,masknw,maskpl,maskwi c 12 bits wire address (center of cluster) parameter (maskad=4095) c 4 bits cluster size parameter (masknw=15) c 4 bits for plane number (0-15) (octal 3600) parameter (maskpl=1920) c 7 bits cluster number (center wire number) parameter (maskwi=127) integer ncent, nplane, nwires c logical w_even c coor=0.0 n_cha=0 if (idata.eq.0) return ncent =iand(idata,maskad) c=== get plane number nplane = iand(ncent,maskpl) nplane = ishft(nplane,-7)+1 if (nplane.lt.1.or.nplane.gt.10) then write(*,4444)nplane,ncent 4444 format(2x,'unknown plane #',i2,' ncent=',i3) c c avoid too many stops on muon runs for online mode ML 14/05/98 c to be verified by A.M. c if (run_mode .eq. 1) then stop 'unknown mwpc plane' else print *, 'unknown mwpc plane', nplane endif endif c=== get wire number of cluster center ncent = iand(ncent,maskwi) nwires=iand(ishft(idata,-12),masknw) C=== C=== Correct MWPC number at Oct97 and after if (irunpd.ge.6) nplane=nplane+2 C=== Correct the data for the upstream 2mm chamber !!!!!!! if (irunpd.ge.3.and.nplane.eq.9) then if (ncent.ge.64) then nplane=nplane+1 ncent=ncent-64 endif endif C=== c c w_even=mod(nwires,2).eq.0 c=== set: n_cha - chamber # c=== i_xy = 1 if x coordinate plane , -1 if y cordinate plane c=== coor - coordinate in cm c=== ch_width - cluster half width n_cha=((nplane-1)/2)+1 coor=-hsize(n_cha)+step(n_cha)*float(ncent) if (mod(nwires,2).eq.0) coor=coor+0.5*step(n_cha) if (mod(nplane,2).eq.1) then i_xy=1 coor=xinv(n_cha)*coor else i_xy=-1 coor=yinv(n_cha)*coor endif ch_width=0.5*float(nwires)*step(n_cha) ccc print *, 'n_cha, ixy,ncent, nwires, coor ->' ccc + ,n_cha, i_xy, ncent,nwires,coor return end