The overlap comes from missing unit (line 143), the default unit is mm in G4. Also, at the moment you place those cylinders next to each other (the shift, so the distance between the centre of both volumes, is 2mm along X-axis), I am not sure if you did not mean to have two cylinders behind each other (= along z-axis).
Regarding the other error, B1PrimaryGeneratorAction
wants to deduce from Envelope
volume of type G4Box
where to place the particle. You changed that volume to G4Tubs
. Anyway, I believe you do not need this generalisation, so you can set particle’s position directly in fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0))
and remove the code above it that is no longer used.