Unexpected behavior with Cosine Angular distribution

Geant4 Version: v11.1.1
Operating System: Linux
Compiler/Version:
CMake Version: 3.22


Dear community,

A sphere (r=0.2m, G4_Galactic) is placed at the center of the world (G4_Galactic).
The source consist of 1 MeV protons with cosine distribution from a r=0.3m sphere, defined from a macro.
I score the angular distribution of the particles on the sphere.

Why is the incidence angle distribution over the sphere centered over pi/4 instead of 0 (as I expected)?

Here is a minimalistic code reproducing this effect, see README to run it:

The relevant lines are of course the macro, and the src/SBG4PSSphereSurfaceFlux.cc file, lines 130-174 where the angle distribution is calculated and printed.

Here is a plot of the distribution I got:

Kind regards,

You are not normalizing by the normal area of each polar angle. The cosine weighting is dN/dΩ → cos(θ) as the “normal” for a sphere is dΩ. And with dΩ/dθ ∝ sin(θ) (φ will be integrated as 2π for each lattitude). More precisely:

dN/dθ = (dN/dΩ) (dΩ/dθ) ∝ 2 cos(θ) sin(θ) = sin(2θ)

This is precisely your result with a maximum at pi/4.

Thank you very much for the accurate answer!

So basically it’s my verification strategy that failed.

Far from it, your verification strategy matched the expected result. The question is what distribution do you want on the sphere as a function of the polar angle. If you want a cosine weighting you will have to divide by the sin(θ) dependence either by weighting events from the simulation in that way or by making your own particle gun.

I want to generate an isotropic particle distribution from a sphere to match space conditions from galactic cosmic rays. People use to use a cosine distribution and I wanted to verify that the standard Geant4 cosine distribution fulfill this purpose (e.g.https://geant4.in2p3.fr/2007/prog/GiovanniSantin/GSantin_Geant4_Paris07_Normalisation_v07.pdf).

I might be misreading this but I think what you showed is that it gives you what you want? It only “looks” like a sin(2θ) is because you are implicitly integrating around latitudes. You have effectively a point detector where it would see this cos(θ) distribution as in those slides as well.