anchor.diff:          c_rmstilt = c_rmstilt_sec
           c_systilt = c_systilt_sec
         end if
  -      cdb_cTilt(1,i) = c_systilt+c_rmstilt*ran_gauss2(three)
  +      cdb_cTilt(1,i) = c_systilt + c_rmstilt*ran_gauss2(three)
         if(systilt_antisymm) then
  -        cdb_cTilt(2,i) = -one*c_systilt+c_rmstilt*ran_gauss2(three)
  +        cdb_cTilt(2,i) = -one*c_systilt + c_rmstilt*ran_gauss2(three)
         else
  -        cdb_cTilt(2,i) =      c_systilt+c_rmstilt*ran_gauss2(three)
  +        cdb_cTilt(2,i) =      c_systilt + c_rmstilt*ran_gauss2(three)
         end if
         write(outlun,*) 'INFO>  Collimator ',trim(cdb_cName(i)),' jaw 1 has tilt [rad]: ',cdb_cTilt(1,i)
         write(outlun,*) 'INFO>  Collimator ',trim(cdb_cName(i)),' jaw 2 has tilt [rad]: ',cdb_cTilt(2,i)
  
positive.code:   do j=napx,1,-1
      if(llostp(j) .eqv. .false.) cycle
  
      part_hit_pos(j:tnapx)         = cshift(part_hit_pos(j:tnapx),   1)
      part_hit_turn(j:tnapx)        = cshift(part_hit_turn(j:tnapx),  1)
      part_abs_pos(j:tnapx)         = cshift(part_abs_pos(j:tnapx),   1)
      part_abs_turn(j:tnapx)        = cshift(part_abs_turn(j:tnapx),  1)
      part_select(j:tnapx)          = cshift(part_select(j:tnapx),    1)
      part_impact(j:tnapx)          = cshift(part_impact(j:tnapx),    1)
      part_indiv(j:tnapx)           = cshift(part_indiv(j:tnapx),     1)
      part_linteract(j:tnapx)       = cshift(part_linteract(j:tnapx), 1)
  
      nabs_type(j:tnapx)            = cshift(nabs_type(j:tnapx),      1)
      nhit_type(j:tnapx)            = cshift(nhit_type(j:tnapx),      1)
  
      tnapx = tnapx - 1
    end do
  
negative.code:   nsig        = nsig + gap_rms_error(icoll)
    xmax        = nsig*sqrt(bx_dist*c_emitx0_collgap)
    ymax        = nsig*sqrt(by_dist*c_emity0_collgap)
    xmax_pencil = (nsig + pencil_offset)*sqrt(bx_dist*c_emitx0_collgap)
    ymax_pencil = (nsig + pencil_offset)*sqrt(by_dist*c_emity0_collgap)
    xmax_nom    = cdb_cNSig(icoll)*sqrt(cdb_cBx(icoll)*c_emitx0_collgap)
    ymax_nom    = cdb_cNSig(icoll)*sqrt(cdb_cBy(icoll)*c_emity0_collgap)
  
    cry_proc(:) = -1
  
    calc_aperture = sqrt(    xmax**2*cRot**2 +     ymax**2*sRot**2)
    nom_aperture  = sqrt(xmax_nom**2*cRot**2 + ymax_nom**2*sRot**2)
  
    ! Get x and y offsets at collimator center point
    x_pencil(icoll) = xmax_pencil * cRot
    y_pencil(icoll) = ymax_pencil * sRot
  
    ! Get corresponding beam angles (uses xp_max)
    xp_pencil(icoll) = (((-one*sqrt(c_emitx0_collgap/tbetax(ie)))*talphax(ie))*xmax)/sqrt(c_emitx0_collgap*tbetax(ie))
    yp_pencil(icoll) = (((-one*sqrt(c_emity0_collgap/tbetay(ie)))*talphay(ie))*ymax)/sqrt(c_emity0_collgap*tbetay(ie))
    xp_pencil0 = xp_pencil(icoll)
    yp_pencil0 = yp_pencil(icoll)
  
    pencil_dx(icoll) = sqrt(xmax_pencil**2 * cRot**2 + ymax_pencil**2 * sRot**2) - calc_aperture
  
    ! Added condition that pencil_distr /= 3 in order to do the tilt
    if(icoll == ipencil .and. iturn == 1 .and. pencil_distr /= 3) then
      ! To align the jaw/pencil to the beam always use the minus regardless which
      ! orientation of the jaws was used (symmetric/antisymmetric)
      c_tilt(1) = c_tilt(1) + (xp_pencil0 * cRot + sRot * yp_pencil0)
      c_tilt(2) = c_tilt(2) - (xp_pencil0 * cRot + sRot * yp_pencil0)
      write(lout,*) "INFO> Changed tilt1  ICOLL  to  ANGLE  ", icoll, c_tilt(1)
      write(lout,*) "INFO> Changed tilt2  ICOLL  to  ANGLE  ", icoll, c_tilt(2)
    end if
  