Currently, I am working on a project, involving the generation of particles in four spheres, all sharing the same center located at coordinates (0,0,0) but with different radii. My goal is to confine these particles within a precise volume defined by the spheres, for example : 1000000 particles between Rmin = 0.001 mm and Rmax = 0,002 mm
I have explored a few approaches to achieve this goal, including using the /gps/pos/confine command in a .mac file. However, I have not been able to obtain the desired results with this method.
I also tried
posx = (2*G4UniformRand()-1)Rmax;
posy = (2G4UniformRand()-1)Rmax;
posz = (2G4UniformRand()-1)*Rmax;
r = std::sqrt(pow(posx,2)+pow(posy,2)+pow(posz,2));
But, it always take random position, outside of the desired range.