
         subroutine get_off0804(name)
*        ---------- ----------------

         include 'Online.cmm'
         character*16 name,myname
         character*40 namex
         character*40 namey
C FINAL dx, dy
         real dyapnw(3),dxapnw(3)
         real dyapne(3),dxapne(3)
         real dyapse(3),dxapse(3)
         real dyapsw(3),dxapsw(3)
         real dyamnw(3),dxamnw(3)
         real dyamne(3),dxamne(3)
         real dyamse(3),dxamse(3)
         real dyamsw(3),dxamsw(3)

	 real dxapinp0,dyapinp0
	 real dxapinp1,dyapinp1
	 real dxapinp2,dyapinp2
	 real dxapinp3,dyapinp3

         real dycpnw(3),dxcpnw(3)
         real dycpne(3),dxcpne(3)
         real dycpse(3),dxcpse(3)
         real dycpsw(3),dxcpsw(3)

         real dycmnw(3),dxcmnw(3)
         real dycmne(3),dxcmne(3)
         real dycmse(3),dxcmse(3)
         real dycmsw(3),dxcmsw(3)



         data dycpnw/-1,0,7/
         data dxcpnw/5,	0,4/
         data dycpne/-10,0,-2/
         data dxcpne/-6,0,10/
         data dycpse/-9,0,-20/
         data dxcpse/-8,1,7/
         data dycpsw/-3,0,1/
         data dxcpsw/-10,0,4/


         data dycmnw/3,0,10/
         data dxcmnw/10,0,-5/
         data dycmne/-5,0,0/
         data dxcmne/0,0,6/
         data dycmse/-5,0,0/
         data dxcmse/-4,0,-4/
         data dycmsw/0,0,3/
         data dxcmsw/0,0,0/




C A+ constants taken from 20000626
         data dyapnw/-1,0,6/
         data dxapnw/5,0,1/
         data dyapne/-5,1,3/
         data dxapne/5,-1,-1/
         data dyapse/-9,0,-2/
         data dxapse/-5,-1,1/
         data dyapsw/3,0,6/
         data dxapsw/2,0,-4/
	 data dxaphvlo/-3.47/
	 data dyaphvlo/22.860/
         data dxaphvsh/79.560/
         data dyaphvsh/7.100/
         data dxaprolo/38.270/
         data dyaprolo/-0.940/
         data dxaprosh/38.575/
         data dyaprosh/22.610/

	 data dxapinp0/33.114/
	 data dxapinp1/73.196/
	 data dxapinp2/52.713/
	 data dxapinp3/35.168/

         data dyapinp0/25.175/
         data dyapinp1/44.311/
         data dyapinp2/29.250/
         data dyapinp3/46.301/

C.. Cal taken A- 17 july
	data dyamnw/-2,0,4/
        data dxamnw/0,0,6/
        data dyamne/-8,0,0/
        data dxamne/0,0,8/
        data dyamse/-10,0,-4/
        data dxamse/-10,0,10/
        data dyamsw/-8,0,-4/
        data dxamsw/-4,0,2/
	common/rewsa/first
	logical first
        data first/.true./


	


         ipass=1
         ierror(2)=0
C--
C default
C--
            id=100
            do i=1,3
                xpar(i)=0.
                ypar(i)=0.
            enddo
            rott(1)=1.
            rott(2)=1.
            rott(3)=1.
            rott(4)=0.
            rott(5)=0.00001 
C FIX rotation rotz for the following RASASS systems
         aznw=-3.98
	 azne=-3.95
         azse=-1.48
         azsw=-0.7


	do i=1,3
		dyfin(i)=0.
		dxfin(i)=0.
	enddo










C---

         xplate=-1
         txplate_cal(-1)=20.2
         lxplate=0.
         tsens(1)=8+40 ! wall
         tsens(2)=7+40 ! airo
         tsens(3)=9+40 ! airt
         tsens(4)=-1

C RASASS
C    xplate=0 or 1  for RO=0 HV=1
	if (name(1:2).eq.'A+' .and.
     +         name(3:3).eq.'N') xplate=1
        if (name(1:2).eq.'A+' .and.
     +         name(3:3).eq.'S') xplate=0
        if (name(1:2).eq.'C+' .and.
     +         name(3:3).eq.'S') xplate=1
        if (name(1:2).eq.'C+' .and.
     +         name(3:3).eq.'N') xplate=0
        if (name(1:2).eq.'A-' .and.
     +         name(3:3).eq.'N') xplate=0
        if (name(1:2).eq.'A-' .and.
     +         name(3:3).eq.'S') xplate=1
        if (name(1:2).eq.'C-' .and.
     +         name(3:3).eq.'S') xplate=0
        if (name(1:2).eq.'C-' .and.
     +         name(3:3).eq.'N') xplate=1
C Xplate rasniks
        if (name(3:4).eq.'RO') xplate=0
        if (name(3:4).eq.'HV') xplate=1

	side=xplate
	if (name(3:3).eq.'N') side=1
	if (name(3:3).eq.'S') side=0

C calibrated from 0626/2000 at 14:30
         tgrancal=20.5036259
         tgrascal=20.2929993
         tfrascal=20.0769997
         tfrancal=20.3600006
	
	if (side.eq.0) then
* get T_Gra_S
         tsens_gra(1)=42
         tsens_gra(2)=48
         tsens_gra(3)=49
         tsens_gra(4)=51
	 tgracal=tgrascal
* get T_Fra_S
         tsens_fra(1)=55
         tsens_fra(2)=55
         tsens_fra(3)=50
         tsens_fra(4)=50
         tfracal=tfrascal
        elseif (side.eq.1) then
* get T_Gra_N
         tsens_gra(1)=41
         tsens_gra(2)=44
         tsens_gra(3)=52
         tsens_gra(4)=52
	 tgracal=tgrancal
* get T_Fra_N
         tsens_fra(1)=43
         tsens_fra(2)=43
         tsens_fra(3)=53
         tsens_fra(4)=53
         tfracal=tfrancal
	endif


	if (xplate.eq.0) then ! READOUT
	   tsens(1)=0
           tsens(2)=1
           tsens(3)=2
           tsens(4)=3
           lxplate=40.
           txplate_cal(0)=19.95
           if (name(1:2).eq.'A-') txplate_cal(0)=20.044
           if (name(1:2).eq.'C+') txplate_cal(0)=20.1061249
           if (name(1:2).eq.'C-') txplate_cal(0)=20.25375
           if (name(4:4).eq.'E') lxplate=2600.
	elseif (xplate.eq.1) then ! HV
	   tsens(1)=8
	   tsens(2)=9
	   tsens(3)=10
           tsens(4)=11
           lxplate=40.
           if (name(4:4).eq.'E') lxplate=2600.
           txplate_cal(1)=20.1
           if (name(1:2).eq.'A-') txplate_cal(1)=20.2355-0.15
           if (name(1:2).eq.'C+') txplate_cal(1)=20.0816994
           if (name(1:2).eq.'C-') txplate_cal(1)=19.9815
        endif
C Xplate rasniks
        if (name(1:2).eq.'RO') lxplate=0.
        if (name(1:2).eq.'HV') lxplate=0.

C granite
        if (name(1:3).eq.'Gra') then
	   tsens(1)=2+40
           tsens(2)=4+40
           tsens(3)=9+40
           tsens(4)=1+40
           lxplate=0.
	endif

C Inplane
        if (name(3:6).eq.'InPl') then
           tsens(1)=4
           tsens(2)=5
           tsens(3)=6
           tsens(4)=7
           lxplate=0.
        endif


	 if (name.eq.'A+NW') rott(5)=aznw
	 if (name.eq.'A+NE') rott(5)=azne
	 if (name.eq.'A+SE') rott(5)=azse
	 if (name.eq.'A+SW') rott(5)=azsw



         if (name.eq.'C+NW') rott(5)=-azse
         if (name.eq.'C+NE') rott(5)=-azsw
         if (name.eq.'C+SE') rott(5)=-aznw
         if (name.eq.'C+SW') rott(5)=-azne


         if (name.eq.'A-NW') rott(5)=-azsw
         if (name.eq.'A-NE') rott(5)=-azse
         if (name.eq.'A-SE') rott(5)=-azne
         if (name.eq.'A-SW') rott(5)=-aznw

         if (name.eq.'C-NW') rott(5)=azne
         if (name.eq.'C-NE') rott(5)=aznw
         if (name.eq.'C-SE') rott(5)=azsw
         if (name.eq.'C-SW') rott(5)=azse

	if (name(3:6).eq.'InPl') then
        if (name(8:8).eq.'0') then
          dxfin(2)=dxapinp0
          dyfin(2)=dyapinp0
        elseif (name(8:8).eq.'1') then
          dxfin(2)=dxapinp1
          dyfin(2)=dyapinp1
        elseif (name(8:8).eq.'2') then
          dxfin(2)=dxapinp2
          dyfin(2)=dyapinp2
        elseif (name(8:8).eq.'3') then
          dxfin(2)=dxapinp3
          dyfin(2)=dyapinp3
        endif
        endif


	if (name(3:6).eq.'ROSH') then
	  dxfin(2)=dxaprosh
          dyfin(2)=dyaprosh
	elseif (name(3:6).eq.'ROLO') then
          dxfin(2)=dxaprolo
          dyfin(2)=dyaprolo
	elseif (name(3:6).eq.'HVSH') then
          dxfin(2)=dxaphvsh
          dyfin(2)=dyaphvsh
        elseif (name(3:6).eq.'HVLO') then
          dxfin(2)=dxaphvlo
          dyfin(2)=dyaphvlo
        endif


	dxfin(1)=dxfin(2)
	dxfin(3)=dxfin(2)
	dyfin(3)=dyfin(2)
	dyfin(1)=dyfin(2)




C--
C find channels
C--

         if (name.eq.'A+NW') then
              id=1
              namex='xpars.a+nw'
              namey='ypars.a+nw'
              do i=1,3
		dxfin(i)=dxapnw(i)/1000.
		dyfin(i)=dyapnw(i)/1000.
              enddo
              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
              id=2
              namex='xpars.a+ne'
              namey='ypars.a+ne'
              do i=1,3
                dxfin(i)=dxapne(i)/1000.
                dyfin(i)=dyapne(i)/1000.
              enddo
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'A+SW') then
              id=3
              namex='xpars.a+sw'
              namey='ypars.a+sw'
              do i=1,3
                dxfin(i)=dxapsw(i)/1000.
                dyfin(i)=dyapsw(i)/1000.
              enddo
              rott(1)=-1.
              rott(2)=-1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'A+SE') then
              id=4
              namex='xpars.a+se'
              namey='ypars.a+se'
              do i=1,3
                dxfin(i)=dxapse(i)/1000.
                dyfin(i)=dyapse(i)/1000.
              enddo
              rott(1)=1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=28.96
         elseif (name.eq.'A-NW') then
              id=5
              namex='xpars.a-nw'
              namey='ypars.a-nw'
              do i=1,3
                dxfin(i)=dxamnw(i)/1000.
                dyfin(i)=dyamnw(i)/1000.
              enddo
              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
              id=6
              namex='xpars.a-ne'
              namey='ypars.a-ne'
              do i=1,3
                dxfin(i)=dxamne(i)/1000.
                dyfin(i)=dyamne(i)/1000.
              enddo
              rott(1)=1.
              rott(2)=-1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'A-SW') then
              id=7
              namex='xpars.a-sw'
              namey='ypars.a-sw'
              do i=1,3
                dxfin(i)=dxamsw(i)/1000.
                dyfin(i)=dyamsw(i)/1000.
              enddo
              rott(1)=-1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'A-SE') then
              id=8
              do i=1,3
                dxfin(i)=dxamse(i)/1000.
                dyfin(i)=dyamse(i)/1000.
              enddo
              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
              id=9
              do i=1,3
                dxfin(i)=dxcmnw(i)/1000.
                dyfin(i)=dycmnw(i)/1000.
              enddo
              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
              id=10
              do i=1,3
                dxfin(i)=dxcmne(i)/1000.
                dyfin(i)=dycmne(i)/1000.
              enddo
              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
              id=11
              do i=1,3
                dxfin(i)=dxcmsw(i)/1000.
                dyfin(i)=dycmsw(i)/1000.
              enddo
              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
              id=12
              do i=1,3
                dxfin(i)=dxcmse(i)/1000.
                dyfin(i)=dycmse(i)/1000.
              enddo
              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
              id=13
              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
              id=14
              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
              id=15
              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
              id=16
              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
              id=17
              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
              id=18
              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
              id=19
              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
              id=20
              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
              id=21
              namex='xpars.c+nw'
              namey='ypars.c+nw'
              do i=1,3
                dxfin(i)=dxcpnw(i)/1000.
                dyfin(i)=dycpnw(i)/1000.
              enddo
              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
              id=22
              namex='xpars.c+ne'
              namey='ypars.c+ne'
              do i=1,3
                dxfin(i)=dxcpne(i)/1000.
                dyfin(i)=dycpne(i)/1000.
              enddo
              rott(1)=1.
              rott(2)=-1.
              rott(3)=1.
              rott(4)=17.37
         elseif (name.eq.'C+SW') then
              id=23
              namex='xpars.c+sw'
              namey='ypars.c+sw'
              do i=1,3
                dxfin(i)=dxcpsw(i)/1000.
                dyfin(i)=dycpsw(i)/1000.
              enddo
              rott(1)=-1.
              rott(2)=1.
              rott(3)=-1.
              rott(4)=6.28
         elseif (name.eq.'C+SE') then
              id=24
              namex='xpars.c+se'
              namey='ypars.c+se'
              do i=1,3
                dxfin(i)=dxcpse(i)/1000.
                dyfin(i)=dycpse(i)/1000.
              enddo
              rott(1)=1.
              rott(2)=-1.
              rott(3)=-1.
              rott(4)=28.96
         elseif (name.eq.'B_NW_PW') then
              id=25
              namex='xpars.bnwpw'
              namey='ypars.bnwpw'
	      rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.
         elseif (name.eq.'D_NW_PW') then
              id=26
              namex='xpars.dnwpw'
              namey='ypars.dnwpw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.
         elseif (name.eq.'B_SW-PW') then
              id=27
              namex='xpars.bswpw'
              namey='ypars.bswpw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.
         elseif (name.eq.'D_SW_PW') then
              id=28
              namex='xpars.dswpw'
              namey='ypars.dswpw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.
         elseif (name.eq.'B_NE_QW') then
              id=29
              namex='xpars.bneqw'
              namey='ypars.bneqw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.
         elseif (name.eq.'D_NE_QW') then
              id=30
              namex='xpars.dneqw'
              namey='ypars.dneqw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.
         elseif (name.eq.'B_SE_QW') then
              id=31
              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
              id=32
              namex='xpars.dseqw'
              namey='ypars.dseqw'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.
         elseif (name.eq.'Gra0') then
              id=33
              namex='xpars.gra0'
              namey='ypars.gra0'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.00001
         elseif (name.eq.'Gra1') then
              id=34
              namex='xpars.gra1'
              namey='ypars.gra1'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.00001
         elseif (name.eq.'Gra2') then
              id=35
              namex='xpars.gra2'
              namey='ypars.gra2'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.00001
         elseif (name.eq.'Gra3') then
              id=36
              namex='xpars.gra3'
              namey='ypars.gra3'
              rott(1)=1.
              rott(2)=1.
              rott(3)=1.
              rott(4)=0.
              rott(5)=0.00001
	elseif (name(3:8).eq.'InPl_0') then
              id=37
              ipass=0
        elseif (name(3:8).eq.'InPl_1') then
              id=38
              ipass=0
        elseif (name(3:8).eq.'InPl_2') then
              id=39
              ipass=0
        elseif (name(3:8).eq.'InPl_3') then
              id=40
              ipass=0
        elseif (name(3:6).eq.'ROSH') then
              id=41
              ipass=0
        elseif (name(3:6).eq.'ROLO') then
              id=42
              ipass=0
        elseif (name(3:6).eq.'HVSH') then
              id=43
              ipass=0
        elseif (name(3:6).eq.'HVLO') then
              id=44
              ipass=0
        else
            id=100
            ipass=0
c	    print *,'WARNING -- no predefined offsets for ',name
            ierror(2)=1
            do i=1,3
		xpar(i)=0.
		ypar(i)=0.
	    enddo
            rott(1)=1.
            rott(2)=1.
            rott(3)=1.
            rott(4)=0.
            rott(5)=0.000001
         endif
C
	if (id.ne.100) then
           idch=id ! store the channels id
           namech(id)=name
           if (name(3:6).eq.'InPl') namech(id)=name(3:8)
           if (name(3:4).eq.'RO' .or.
     +           name(3:4).eq.'HV') namech(id)=name(3:6)
	endif

        if (ipass.eq.1) then ! for channels with parameter file
	   call readoff(namex,xpar)
	   call readoff(namey,ypar)
        endif
        
        if (id.eq.100) then
C make a name slot for this channel
           iname=0
           ifree=0
	   do i=50,100
	    if (namech(i).eq.name) then
		iname=i
	    elseif (ifree.eq.0 .and. namech(i).eq.'empty') then
                ifree=i
	    endif ! found name or found first free
	   enddo ! i for channels
          
           if (iname.gt.0) then
		idch=iname
	   elseif (iname.eq.0 .and. ifree.gt.0) then
		idch=ifree
		namech(idch)=name
	   endif ! iname or new name
        endif ! id=100, so no predefined channel
        end

