Problem 2611

Summary: Anisotropic angle distribution in isotropic flux
Product: Geant4 Reporter: Yaroslav Strilchuk <ditegen>
Component: eventAssignee: Makoto Asai <asai>
Status: CLOSED INVALID    
Severity: minor    
Priority: P4    
Version: 11.2   
Hardware: All   
OS: All   

Description Yaroslav Strilchuk 2024-05-01 20:53:21 CEST
In G4SPSAngDistribution::GenerateIsotropicFlux(), cosine of a uniformly distributed random angle is not calculated in the proper way:

https://github.com/Geant4/geant4/blob/master/source/event/src/G4SPSAngDistribution.cc#L348

costheta = std::cos(MinTheta) - rndm * (std::cos(MinTheta) - std::cos(MaxTheta));

Suggested fix:

Theta = MinTheta - rndm * (MinTheta - MaxTheta);
costheta = std::cos(Theta);

The bug affects at least GPS's sources with angular distribution set to "iso" and results in primaries of the expected isotropic flux being less likely oriented towards the poles.
Comment 1 Makoto Asai 2024-05-01 21:17:29 CEST
Theta is azimuth angle. If it is not biased, it should distribute between 0 to pi/2, not evenly but in cosine shape. 

The current implementation is correct. If theta distributes evenly as you suggest, tracks would concentrate to the polar region.
Comment 2 Makoto Asai 2024-05-01 21:20:49 CEST
Sorry, "0 to pi/2" should read "0 to pi".
Comment 3 Yaroslav Strilchuk 2024-05-01 23:49:29 CEST
Thank you, my bad.