Analysis and Monte Carlo code for the UCNA experiment