Skip to content

Fixed bug with beam direction

Fix of issue #168 (closed). Since Geant4 Beam2d always sets the momentum direction to (0,0,-1) (Negative z-direction) I rotated the coordinate system of the single particle source such that the negative z-direction aligns with the specified beam_direction.

I got the vector idea from https://stackoverflow.com/questions/33757842/how-to-calculate-coordinate-system-from-one-vector.

Geant4 calculates the Z-axis of the source by taking the cross product of the angref1 and angref2, so I defined these in such a way that the resulting cross product will result in the negative z-direction being equal to the given direction. I logged some info so you can see what's going on. The "unit" means it's the unitary vector of the given vector. The last cross product is just to check that x cross z gives back the y-axis defined in angref2. ang_ref_info I made a screen-shot of the directions working as supposed to. beam_direction_fix

Edited by Koen Bernard Van Den Brandt

Merge request reports