anchor.diff:        end if
   
         p_in(j) = (one + dpop) * p0
  -!     SR, 30-08-2005: add the initial position of the slice
         s_in(j) = sp + (real(j_slices,fPrec)-one) * c_length
  -
       else
         x_in(j) = x
         y_in(j) = z
  -    end if !if(x.lt.99.0d-3) then
  -
  +    end if
     end do ! End of loop over all particles
   
   end subroutine k2coll_collimate
  
positive.code:             call h5_finaliseWrite(coll_hdf5_fstImpacts)
            else
  #endif
              write(coll_fstImpactUnit,'(i5,1x,i7,1x,i2,1x,i1,2(1x,f5.3),8(1x,e17.9))') &
                partID(j),iturn,icoll,nabs,                             &
                s_impact + (real(j_slices,fPrec)-one) * c_length,       &
                s+sp + (real(j_slices,fPrec)-one) * c_length,           &
  
negative.code:       lint(j) = zlm - drift_length
      end if
  
      !++  Transform back to particle coordinates with opening and offset
      if(x < 99.0d-3) then
        ! Include collimator tilt
        if(tiltangle > zero) then
          x  = x  + tiltangle*c_length
          xp = xp + tiltangle
        else if(tiltangle < zero) then
          x  = x + tiltangle*c_length
          xp = xp + tiltangle
          x  = x - sin_mb(tiltangle) * c_length
        end if
  
        ! Transform back to particle coordinates with opening and offset
        z00 = z
        x00 = x + mirror*c_offset
        x = (x + c_aperture/two) + mirror*c_offset
  
        ! Now mirror at the horizontal axis for negative X offset
        x  = mirror * x
        xp = mirror * xp
  
        ! Last do rotation into collimator frame
        x_in(j)  =  x*cRRot +  z*sRRot
        y_in(j)  =  z*cRRot -  x*sRRot
        xp_in(j) = xp*cRRot + zp*sRRot
        yp_in(j) = zp*cRRot - xp*sRRot
  
        if(((icoll == ipencil .and. iturn == 1) .or. &
           (iturn == 1 .and. ipencil == 999 .and. icoll <= nprim .and. (j >= (icoll-1)*nev/nprim) .and. &
           (j <= (icoll)*nev/nprim))) .and.(pencil_distr /= 3)) then
          ! RB: adding condition that this shouldn't be done if pencil_distr=3
          x00      = mirror * x00
          x_in(j)  = x00*cRRot + z00*sRRot
          y_in(j)  = z00*cRRot - x00*sRRot
  