Implementation problem in TH1D angularType when defining direction

REST version : v2.2.11_dev

The group in Zaragoza @luzon discovered that there are some issues on the angular definition using <angularType type="TH1D" ...>. It seems that the reference direction of the angular distribution is defined at each event using the origin position of the primary particle.

See for example following lines from PrimaryEventGenerator.cc

198     // A vector pointing to the origin (virtualSphere )
199     direction = -fParticleGun->GetParticlePosition().unit();

The result is that we are launching our particle towards the origin (0,0,0) with the particular dispersion provided in our angular distribution. And if using a virtualWall not in the direction of the normal plane vector.

This is an issue, the most suitable would be that we are able to define a direction in TH1D to be used as the main direction of the distribution defined in the TH1D.

Since the group of SJTU @nkx did also some simulations using muons, I wonder if this issue is also affecting on their simulations.

Hi, I made yesterday a commit so that, as default, the vector normal to the plane (towards the centre) is chosen as main direction for the angular distribution.

Hello,

I also recently made some contributions to the restG4 PrimaryGeneratorAction.cc file. I made a big push and merged my changes. My initial merge removed your contribution but I think I restored everything here (Sign in ยท GitLab). I write this in case there is something I have missed related to this issue.