         subroutine get_offsets(name)
         include 'inplane.cmm'
         character*16 name
         character*40 namex
         character*40 namey
         ipass=1

         if (name.eq.'A+NW') then
              namex='xpars.a+nw'
              namey='ypars.a+nw'
              rott(1)=-1. ! SWAP X
              rott(2)=-1. ! swap y
              rott(3)=1.  ! swap rotz
              rott(4)=-4.8  ! rotz tower
         elseif (name.eq.'A+NE') then
              namex='xpars.a+ne'
              namey='ypars.a+ne'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'A+SW') then
              namex='xpars.a+sw'
              namey='ypars.a+sw'
              rott(1)=-1.
              rott(2)=-1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'A+SE') then
              namex='xpars.a+se'
              namey='ypars.a+se'
              rott(1)=1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=28.96
         elseif (name.eq.'A-NW') then
              namex='xpars.a-nw'
              namey='ypars.a-nw'
              rott(1)=-1. ! SWAP X
              rott(2)=1. ! swap y
              rott(3)=1.  ! swap rotz
              rott(4)=-4.8  ! rotz tower
         elseif (name.eq.'A-NE') then
              namex='xpars.a-ne'
              namey='ypars.a-ne'
              rott(1)=1.
              rott(2)=-1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'A-SW') then
              namex='xpars.a-sw'
              namey='ypars.a-sw'
              rott(1)=-1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'A-SE') then
              namex='xpars.a-se'
              namey='ypars.a-se'
              rott(1)=1.
              rott(2)=-1.
              rott(3)=-1.
              rott(4)=28.96
         elseif (name.eq.'C-NW') then
              namex='xpars.c-nw'
              namey='ypars.c-nw'
              rott(1)=-1. ! SWAP X
              rott(2)=-1. ! swap y
              rott(3)=1.  ! swap rotz
              rott(4)=-4.8  ! rotz tower
         elseif (name.eq.'C-NE') then
              namex='xpars.c-ne'
              namey='ypars.c-ne'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'C-SW') then
              namex='xpars.c-sw'
              namey='ypars.c-sw'
              rott(1)=-1.
              rott(2)=-1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'C-SE') then
              namex='xpars.c-se'
              namey='ypars.c-se'
              rott(1)=1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=28.96
         elseif (name.eq.'B-NW') then
              namex='xpars.b-nw'
              namey='ypars.b-nw'
              rott(1)=-1. ! SWAP X
              rott(2)=1. ! swap y
              rott(3)=1.  ! swap rotz
              rott(4)=-4.8  ! rotz tower
         elseif (name.eq.'B-NE') then
              namex='xpars.b-ne'
              namey='ypars.b-ne'
              rott(1)=1.
              rott(2)=-1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'B-SW') then
              namex='xpars.b-sw'
              namey='ypars.b-sw'
              rott(1)=-1.
              rott(2)=-1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'B-SE') then
              namex='xpars.b-se'
              namey='ypars.b-se'
              rott(1)=1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=28.96
         elseif (name.eq.'B+NW') then
              namex='xpars.b+nw'
              namey='ypars.b+nw'
              rott(1)=-1. ! SWAP X
              rott(2)=1. ! swap y
              rott(3)=1.  ! swap rotz
              rott(4)=-4.8  ! rotz tower
         elseif (name.eq.'B+NE') then
              namex='xpars.b+ne'
              namey='ypars.b+ne'
              rott(1)=1.
              rott(2)=-1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'B+SW') then
              namex='xpars.b+sw'
              namey='ypars.b+sw'
              rott(1)=-1.
              rott(2)=-1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'B+SE') then
              namex='xpars.b+se'
              namey='ypars.b+se'
              rott(1)=1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=28.96
         elseif (name.eq.'C+NW') then
              namex='xpars.c+nw'
              namey='ypars.c+nw'
              rott(1)=-1. ! SWAP X
              rott(2)=-1. ! swap y
              rott(3)=1.  ! swap rotz
              rott(4)=-4.8  ! rotz tower
         elseif (name.eq.'C+NE') then
              namex='xpars.c+ne'
              namey='ypars.c+ne'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'C+SW') then
              namex='xpars.c+sw'
              namey='ypars.c+sw'
              rott(1)=-1.
              rott(2)=-1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'C+SE') then
              namex='xpars.c+se'
              namey='ypars.c+se'
              rott(1)=1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=28.96
         elseif (name.eq.'B_NW_PW') then
              namex='xpars.bnwpw'
              namey='ypars.bnwpw'
	      rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
         elseif (name.eq.'D_NW_PW') then
              namex='xpars.dnwpw'
              namey='ypars.dnwpw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
         elseif (name.eq.'B_SW-PW') then
              namex='xpars.bswpw'
              namey='ypars.bswpw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
         elseif (name.eq.'D_SW_PW') then
              namex='xpars.dswpw'
              namey='ypars.dswpw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
         elseif (name.eq.'B_NE_QW') then
              namex='xpars.bneqw'
              namey='ypars.bneqw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
         elseif (name.eq.'D_NE_QW') then
              namex='xpars.dneqw'
              namey='ypars.dneqw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
         elseif (name.eq.'B_SE_QW') then
              namex='xpars.bseqw'
              namey='ypars.bseqw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
         elseif (name.eq.'D_SE_QW') then
              namex='xpars.dseqw'
              namey='ypars.dseqw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
         else
            ipass=0
	    print *,'WARNING -- no predefined offsets for ',name
            do i=1,3
		xpar(i)=0.
		ypar(i)=0.
	    enddo
            rott(1)=1.
            rott(2)=1.
            rott(3)=1.
            rott(4)=0.
         endif
        if (ipass.eq.1) then
	   call readoff(namex,xpar)
	   call readoff(namey,ypar)
        endif
	end
	
	subroutine readoff(name,par)
	real par(3)
	character*40 name
	character*80 dname
        dname='../'//name
	par(1)=0.
	par(2)=0.
        par(3)=0.
	open(68,file=dname)
	read(68,*,END=69,ERR=69)par(1)
	read(68,*,END=69,ERR=69)par(2)
	read(68,*,END=69,ERR=69)par(3)
 69	continue
        close(68)
	end
	


        subroutine get_correction(x,y,scale,rotz)
        include 'inplane.cmm'
        real zz
        zz=0
	if (scale.gt.0) zz=1./scale
        x= rott(1)*(x-xpar(1)-xpar(2)*zz)
        y= rott(2)*(y-ypar(1)-ypar(2)*zz)
        xr=x
	yr=y
        rotz=rotz-rott(4)
        rotz=rott(3)*rotz
        x=xr+yr*rotz/1000.
        y=yr-xr*rotz/1000.
        end

           












*	subroutine get_offsets(name)
*        include 'inplane.cmm'
*        character*16 name
*        real aap
*        open (8,file='steer',STATUS='OLD')
*        call ffinit(0)
*        call ffset('LINP',8)
*        call ffset('SIZE',16)
*        print *,' search for name ',name
************* C+ SE ****************************************
*         if (name.eq.'C+SE') then
*            call FFKEY('CpSE            ',offcpse,6,'REAL')
*         endif
************************************************************
*        call ffgo
*        close(8)
*        end


