Ultra-peripheral collisions (UPCs) of heavy ions can be used as a clean environment to study two-photon induced interactions such as dilepton pair photoproduction. Recently, precise data on lepton pair production in UPCs were obtained by the ATLAS experiment at the LHC where significant deviations, of up to 20%, from available theoretical predictions were observed. In this work, we present a Monte Carlo event generator, Upcgen, that implements a refined treatment of the photon flux allowing us to improve the agreement with ATLAS data at large dilepton rapidities. Besides, the new generator offers a possibility to study photon polarization effects and set arbitrary values of the lepton anomalous magnetic moment that can be used in the future studies of tau g−2 via ditau production measurements in UPCs. Program summaryProgram Title: UpcgenCPC Library link to program files:https://doi.org/10.17632/gbv9s729s9.1Developer's repository link:https://github.com/nburmaso/upcgenLicensing provisions: GPLv3Programming language:▪External routines/libraries: ROOT software toolkit; optionally: Pythia8 and (or) Pythia6 event generator, a compiler with OpenMP support.Nature of problem: In view of deviations between theoretical predictions and new experimental measurements of dilepton production cross sections in ultra-peripheral collisions of heavy ions, a more accurate calculation is needed. Precise predictions also become crucial for the studies related to tau anomalous magnetic moment measurements via ditau pair production in UPCs. We made an attempt to implement a dedicated Monte Carlo event generator with improved calculation of the photon flux that can be used to generate dilepton pairs in UPCs with a possibility to freely change the value of the anomalous magnetic moment.Solution method: Utilizing classes implemented in ROOT, the program calculates the dilepton pair production cross section AA→AA+ℓℓ by folding the elementary γγ→ℓℓ cross section and the two-photon luminosity. Computation of the elementary cross section with an arbitrary value of the anomalous magnetic moment is based on the generalized vertex formalism. The calculation of the two-photon luminosity is based on an improved photon flux treatment based on realistic nuclear form factors. Since the computation of the two-photon luminosity is a time-consuming operation, a corresponding 2D-histogram is cached in a ROOT-file. The dilepton pair production cross section is then used to generate lepton pairs via a Monte Carlo simulation process. For the decay of the taus, Pythia8 or Pythia6 can be used.Additional comments including restrictions and unusual features: The program is aimed on simulation of dilepton pair production in ultra-peripheral collisions of heavy ions in collider experiments. A user can set the energy of the colliding system, change species of incoming nuclei and also tune the anomalous magnetic moment of the lepton to be produced. A possibility to generate a realistic transverse momentum distribution of dilepton pairs is also taken into account.