However, the direction is always the same, whether I use G4double cosTheta = 1, G4double cosTheta = 20 or G4double cosTheta = 70.
Just realized that when I use values between [-1, 1] it’s changing then. But the angle is turning with the red-blue plane. I need an angle that is rotating on the green axis. It also seems that the angle is always fixed. Do I have to lay a random function over it to get an angle range?
G4RandomDirection(cosTheta) generates a random unit vector inside a cone around Z axis. Theta is the angle between Z axis and the surface of the cone. cosTheta should be in a range between [-1,1]. If to set cosTheta = 1, then all generated vectors will be directed alone Z.
C:\geant4\sim\generator.cc(74,62): error C2664: ‘void G4ParticleGun::SetParticleMomentumDirection(G4ParticleMomentum)’: cannot convert argument 1 from ‘overloaded-function’ to ‘G4ParticleMomentum’ [C:\geant4\bu
C:\geant4\sim\generator.cc(74,62): message : No constructor could take the source type, or constructor overload resolution was ambiguous [C:\geant4\build\project.vcxproj]
C:\Program Files\Geant4-11.0\include\Geant4\G4ParticleGun.hh(96,17): message : see declaration of ‘G4ParticleGun::SetParticleMomentumDirection’ [C:\geant4\build\project.vcxproj]
I fully agree with the comment above. If you want to change the particle direction, then, in general case, you should apply a rotation transformation. But in case of simple change between axes, then it can be done by circular shift of the vector components:
(x,y,z) -> (z,x,y) -> (y,z,x)
BTW, a more clear way to specify the angle of the cone is:
thank you, changing the axis works now. Means, the beam cone refers to the y-axis now.
Next, I “only” need to rotate the cone itself such that 0° refers to the y-axis and e.g. 70° would be the angle segment beginning at this axis.
Is there a convenient command to do so?
edit: I figured it out. It would simply be:
I’m having such a hard time to find solutions for all my problems because I still couldn’t figure out where to read up those things. I’m always googling around a lot and by coincidence I stumble over some things. But mostly I have to rely on this forum. I appreciate, a lot! But I would also like to become independent
How do you guys do it? Where would have you looked up this command?
I figured out something else (resp. I wasn’t aware of before): The angle refers to the angle cone.
Is it doable to have no angle in z-direction? I only need a two-dimensional plane in xy with an angle of 70 °, not a three-dimensional cone of 70 °.