Can anyone please explain why the angular distribution for a specific energy in Geant4 appears to be uniform without using the rotateUz() function, but changes after applying the function? and what is the purpose of rotateUz in SampleSecondaries in the physics model class? how does this function affect the angular distribution of particles?

RotateUz() method is used in many Geant4 models, because formulas inside these models are bases on assumption that projectile particle has direction along Z axis. After interaction all products directions should be rotated to the laboratory system.

Does it make sense that the distribution is uniform when not using rotateUz and non-uniform after using it?

In Geant4 the ejected electron angle is chosen according to a uniform distribution that depends on its ejection energy. I am trying to simulate the distribution of the ejected angle using a different method than the one used in Geant4.
Without rotateUz, the two distributions (using my method and using Geant4’s method) are different, but after using rotateUz, the two distributions become similar. So, I don’t understand how two different distributions in a frame (particle frame) become the same in another frame (world frame).