Problem 1899

Summary: General Particle Source -- unexpected angular distribution when using iso and cos
Product: Geant4 Reporter: Emilia <emilia.leogrande>
Component: eventAssignee: Andrea Dotti <andrea.dotti>
Status: RESOLVED INVALID    
Severity: minor    
Priority: P4    
Version: 10.2   
Hardware: All   
OS: All   
Attachments: Theta distribution obtained with the option /gps/ang/type cos

Description Emilia 2016-10-06 18:24:16 CEST
Created attachment 419 [details]
Theta distribution obtained with the option /gps/ang/type cos

When using the General Particle Source, I find problems in the angular distributions Iso and Cos.

In particular:

a) with gps/ang/type iso
I get a flat distribution in cos(theta) instead of in theta

b) with gps/ang/type cos
I get a cos-like distribution for theta, restricted somehow only in the range 1.6 - 3.2 [in attachment]
I get a linear distribution for cos(theta)

The used mac file is the following:

/gps/verbose 1
/gps/particle mu-
/gps/direction 0 0 1
/gps/pos/type Plane
/gps/pos/shape Square
/gps/pos/centre 0 0 0  cm
/gps/pos/halfx 1 cm
/gps/pos/halfy 1 cm
/gps/ang/type cos
/gps/ene/type Lin
/gps/ene/min 5 GeV
/gps/ene/max 15 GeV
/gps/ene/gradient 1
/gps/ene/intercept 1
/run/beamOn 1000
Comment 1 Andrea Dotti 2016-12-12 23:11:07 CET
Hello,

I am sorry for the late answer to this request. This is not a bug and the results are indeed the expected behavior.

a) For "iso" it is correct that the cos(theta) is uniform and not theta. You can easily convince yourself plotting on a sphere random points in which theta is generated flat between (0,pi), the density of points will not be uniform but more points will be present at the north/south pole of the sphere. 

b) For "cos" I think the problem is that you need to rotate the plane on which the points are generated. As explained in our manuals (cfr. Section 2.7 of the Application Developer's manual), when using a plane direction of primaries is rotated according to the plane. I realize this is confusing but the UI command: 
/gps/pos/shape Square
creates a plane with the "reference" vector along x = (1,0,0). This vector is not the normal to the surface, but it lays on the plane (along the "x" component of the square). In this case the normal is along the -z direction: (0,0,-1).
I imagine the confusion comes from the fact that you want to shoot along the +z direction, and thus you should rotate the plane to have the reference vector along -x:
/gps/pos/shape Square
/gps/pos/rot1 -1 0 0 
Again you can refer to the Application Developers' manual section 2.7:
https://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch02s07.html

Regards,
Andrea