anchor.diff:    angrad = (cheby_angle(icheby(ix))/c180e0)*pi
   
     if (st_debug) then
  -    write(lout,'(a)')'CHEBY> CHEBY_KICK_FOX closed orbit BEFORE cheby map:'
  +    write(lout,'(3(a,i0))')'CHEBY> CHEBY_KICK_FOX for i= ',i,' - ix= ',ix, ' - icheby(ix)= ',icheby(ix)
  +    write(lout,'(a)')      'CHEBY> CHEBY_KICK_FOX closed orbit BEFORE cheby map:'
       call dapri(XX(1),6)
       call dapri(XX(2),6)
       call dapri(YY(1),6)
  
positive.code: subroutine cheby_kick_fox(i,ix)
  
    ! A. Mereghetti (CERN, BE-ABP-HSS)
    ! last modified: 02-04-2020
    ! apply kick of Chebyshev lenses (FOX)
  
    use mod_common, only : beta0, mtcda, brho
  
negative.code:     ! apply offset
      xx=xv1(jj)-cheby_offset_x(icheby(ix))
      yy=xv2(jj)-cheby_offset_y(icheby(ix))
      if (abs(xx)<epsilon) xx=zero
      if (abs(yy)<epsilon) yy=zero
  
      ! in case of non-zero tilt angle, rotate coordinates
      if (lrotate) then
        ! rr = sqrt(xx**2+yy**2)
        rr=sqrt((xx+yy)*(xx+yy)-two*(xx*yy))
        if (abs(rr)<epsilon) then
          xx=zero
          yy=zero
        else
          theta = atan2_mb(yy, xx)-angle_rad
          xx = rr * cos_mb(theta)
          yy = rr * sin_mb(theta)
        end if
      end if
     
      ! check that particle is within the domain of chebyshev polynomials
  