This study is aimed at validating the Monte Carlo Geant4.9.4 code for a 6MV Varian linac configuring a 10×10cm2 radiation field. For this purpose a user-friendly Geant4 code called G4Linac has been developed from scratch allowing an accurate modeling of a 6MV Varian linac head and performing dose calculation in a homogeneous water phantom. Discarding the other accelerator parts where electrons are created, accelerated and deviated, a virtual source of 6MeV electrons was considered. The parameters associated with this virtual source are often unknown. Those parameters are mean energy, sigma and its full width at half maximum has been adjusted by following our own methodology that has been developed in such a manner that the optimization phase will be fast and efficient, in fact, a small number of Monte Carlo simulations has been conducted simultaneously on a cluster of computers thanks to the Rocks cluster software. The calculated dosimetric functions in a 40×40×40cm3 water phantom were compared to the measured ones thanks to the Gamma Index method, where the gamma criterion was fixed within 2%–1mm accuracy. After optimization, it was observed that the proper mean energy, sigma and its full width at half maximum are 5.6MeV, 0.42MeV and 1.177mm, respectively. Furthermore, we have made some changes in an existing bremsstrahlung splitting technique, due to which we have succeeded to reduce the CPU time spent by the treatment head simulation about five times.