anchor.diff:    return
   end function checkCR
   
  -logical function checkTR( x, y, aprx, apry, apex, apey, apxx, apyy, apxy, m, q, aptx, apty )
  +logical function checkTR( x, y, aprx, apry, apex, apey, apxx, apyy, apxy, aptx, apty, m, q )
   !-----------------------------------------------------------------------
   !     A.Mereghetti (CERN, BE/ABP-HSS)
   !     last modified: 16-01-2019
  
positive.code:      do i=1,nAzim
          thetaRay=(i/real(nAzim))*(two*pi) ! radians
          ! call (angle to aperture ref sys)
          call intersectRE(xRay,yRay,thetaRay-tmpape(7),tmpape(1),tmpape(2),xChk,yChk,nChk)
          ! go back to machine reference system
          if(tmpOffTlt) call roffpos_inv(xChk,yChk,xChk,yChk,tmpape(7),tmpape(8),tmpape(9))
          ! echo result of scan
          write(iunit,1982) thetaRay/rad,sqrt(xChk**2+yChk**2),xChk,yChk
       end do
  
negative.code:      do i=1,nAzim
          thetaRay=(i/real(nAzim))*(two*pi) ! radians
          ! call (angle to aperture ref sys)
          call intersectOC(xRay,yRay,thetaRay-tmpape(9),tmpape(1),tmpape(2),tmpape(7),tmpape(8),xChk,yChk,nChk)
          ! go back to machine reference system
          if(tmpOffTlt) call roffpos_inv(xChk,yChk,xChk,yChk,tmpape(9),tmpape(10),tmpape(11))
          ! echo result of scan
          write(iunit,1982) thetaRay/rad,sqrt(xChk**2+yChk**2),xChk,yChk
       end do
  