@weller Why do you set u = G4UniformRand()+G4UniformRand() rather than simply u = 2*G4UniformRand()? I don’t think it fundamentally matters for the distribution, but I’m curious.
Thanks, @weller ! From the StackOverflow comments:
Try using both schemes to generate random numbers and see what you get. 2*random() gives numbers uniformly distributed in the range 0 to 2. random()+random() gives you numbers in the range 0 to 2 but there will (usually) be more numbers near 1.0 than near 0.0 or 2.0. It’s like how rolling two dice and summing is more likely to give 7 than any other number.
I need to think about this. We do something entirely different, generating differential area elements:
maybe the performance (Sqrt vs. 2nd random throw) is the difference then?
edit: depends on the generator, for the ones available in matlab sqrt is faster.
to finally come back to the topic: if you want to avoid introducing macro files to your simulation, you can also issue commands in source code like this:
How to rotate the circular plane source 30 degrees to axes X and 60 degrees to axes Z ?
(I mean the particles must interact with material by the form of circle not a elliptic which we see on the picture).