Vector in csv file

Hi Dear geant4 user!

How can I save the position of the particle (x, y and z) in the csv file?
(Because it is not possible to save the vector in the csv file!)

Thanks for any answers.

If your position is in a variable G4ThreeVector pos, then you can store pos.x() in one column, pos.y() in a second, and pos.z() in a third.

1 Like

Thank you
Now I want to ask you another question!
The Source is at the origin of the coordinates, and I have the momentum direction and position of the particle in the csv file:

Pos.x() = 105.81
Pos.y() = -27.7881
Pos.z() = 15.7687

And

momentumDirection.x() = -0.843504
momentumDirection.y() = 0.512321
momentumDirection.z() = -0.16133

If the particle left the origin and stopped at the point (+ … , - … , + …), then the direction of the particle should be (+ … , - … , + …)
it’s true ?
But here it is (- … , + … , - … )
This issue has been occupying my mind for some time!

keep in mind that the momentum direction is a momentary property. a particle can travel some distance and then be scattered towards a new direction. also, secondary particles are emitted via a distribution that is absolutely not identical to the direction of the primary particle…

Yes, I got it
Thankful.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.