anchor.diff:    real(kind=fPrec) x, y, aprx, apry, apex, apey, apxx, apyy, apxy, m, q
   
     checkTR = checkRL(x,y,aprx,apry,apxx,apyy,apxy).or.checkOC(x,y,aprx,apry,m,q)
  -  if(aprx-apex.gt.zero.and.apry-apey.gt.zero) checkTR=checkTR.or.checkRT(x,y,aprx,apry,apex,apxx)
  +  if(aprx-apex.gt.zero.and.apry-apey.gt.zero) then
  +    checkTR=checkTR.or.checkRT(x,y,aprx,apry,apex,apey,apxx,apyy,apxy)
  +  end if
     return
   end function checkTR
   
  
positive.code:   kape(ix)=6
    ape(1,ix)=aprx
    ape(2,ix)=apry
    ape(3,ix)=radius
    ape(4,ix)=radius
    ape(5,ix)=-one
    ape(6,ix)=(sqrt(ape(3,ix)**2+ape(4,ix)**2)+(ape(1,ix)-ape(3,ix)))+(ape(2,ix)-ape(4,ix))
  end subroutine aperture_initRT
  
negative.code:   return
  end function checkOC
  
  logical function checkRT( x, y, aprx, apry, apex, apey, apxx, apyy, apxy )
  !-----------------------------------------------------------------------
  !     A.Mereghetti and P.Garcia Ortega, for the FLUKA Team
  !     last modified: 16-01-2019
  !     check particle position against RaceTrack aperture
  !     always in main code
  !-----------------------------------------------------------------------
    implicit none
  
  ! parameters
    real(kind=fPrec) x, y, aprx, apry, apex, apey, apxx, apyy, apxy
  
    checkRT = checkRE( x, y, aprx+apex, apry+apey ) .or. &
              checkEL( abs(x)-aprx, abs(y)-apry, apxx, apyy, apxy )
    return
  end function checkRT
  
  