Geant4 Version: geant4-11-01-patch-02
Operating System: Linux/Windows
Compiler/Version: VS
CMake Version: 3.27
Hi All,
Is it possible to write the trajectory of the beam along the transverse direction to an external file using vis commands? I want to plot sigma x and sigma y along the z-direction of a beam due to the change expected due to the applied magnetic field. Please also let me know if any examples that can help me. Please see picture.

Thanks & Regards,
Raja
Hi Raja
Not quite sure what you mean. The short answer is, no, there are no vis commands for dumping the trajectory coordinates. The trajectory base class, G4VTrajectory
, has ShowTrajectory
, so in your end of event action you could invoke it. Something like:
G4TrajectoryContainer* TC = event -> GetTrajectoryContainer ();
for (std::size_t iT = 0; iT < TC->entries(); ++iT) {
(*TC)[iT]->ShowTrajectory();
}
ShowTrajectory
can take an output file stream argument.
Alternatively, you could issue /tracking/verbose 2
, and see if that tells you what you want to know.
John
Thank you Allison for your kind reply. I will try it.