How can I store the global time for each step of a trajectory in a HepRep file?

Dear Geant4 experts,
How can I store the global time for each step of a trajectory in a HepRep file? I see that the positions of the steps are saved and some information about the trajectory when I use “/vis/scene/add/trajectories rich”. Also there is the possibility to add attributes but I don’t see how to do this for a step.

Thanks in advance,
Dittmar

Hi Dittmar

If you use /vis/scene/add/trajectories rich you get attributes as shown below (you should see this printing, but maybe you need /vis/verbose confirmations too). So global time is available for each step of the trajectory. (If you are in a magnetic field, you may miss some steps unless you /vis/scene/add/trajectories smooth rich.)

So global time should be available in HepRepFile (not HepRep nor HepRepXML). HepRepFile output is browsable with HepRApp - see documentation. The global time is certainly available to trajectory filtering commands and is used in “time slicing” - see documentation.

If you wish to add your own attributes, it can be done. It’s quite tricky so get back to me on that one.

Good luck
John

G4TrajectoriesModel:
  Event ID (EventID): G4int
  Run ID (RunID): G4int
G4RichTrajectory:
  Creator Model ID (CMID): G4int
  Creator Model Name (CMN): G4String
  Creator Process Name (CPN): G4String
  Creator Process Type Name (CPTN): G4String
  Charge (Ch): unit: e+ (G4double)
  Ending Process Name (EPN): G4String
  Ending Process Type Name (EPTN): G4String
  Final kinetic energy (FKE): G4BestUnit (G4double)
  Final Next Volume Path (FNVPath): G4String
  Final Volume Path (FVPath): G4String
  Track ID (ID): G4int
  Initial kinetic energy (IKE): G4BestUnit (G4double)
  Initial momentum magnitude (IMag): G4BestUnit (G4double)
  Initial momentum (IMom): G4BestUnit (G4ThreeVector)
  Initial Next Volume Path (INVPath): G4String
  Initial Volume Path (IVPath): G4String
  No. of points (NTP): G4int
  PDG Encoding (PDG): G4int
  Parent ID (PID): G4int
  Particle Name (PN): G4String
G4RichTrajectoryPoint:
  Auxiliary Point Position (Aux): G4BestUnit (G4ThreeVector)
  Process Defined Step (PDS): G4String
  Process Type Defined Step (PTDS): G4String
  Position (Pos): G4BestUnit (G4ThreeVector)
  Post-step-point status (PostStatus): G4String
  Post-step-point global time (PostT): G4BestUnit (G4double)
  Post-step Volume Path (PostVPath): G4String
  Post-step-point weight (PostW): G4double
  Pre-step-point status (PreStatus): G4String
  Pre-step-point global time (PreT): G4BestUnit (G4double)
  Pre-step Volume Path (PreVPath): G4String
  Pre-step-point weight (PreW): G4double
  Remaining Energy (RE): G4BestUnit (G4double)
  Total Energy Deposit (TED): G4BestUnit (G4double)

Hello John,
Thank you very much for your answer. I don’t quite understand how I can save the global time for each step in a HepRep file by applying filters. I can filter by charge and plot/save a specific one but how do I do that with the global time? I don’t want to filter out a trajectory just save the time in addition to the location. Could you tell me what commands to use or where to find them?

Thanks in advance,
Clemens

Hi Clemens

Maybe using trajectory attributes is not the way to go for you.

You can intercept every step in your stepping action. Even examples/basic/B1 has a stepping action. At each step you can get everything that Geant4 has to offer. Have a look at Tracks and steps — FrequentlyAskedQuestions 11.0 documentation.

John

Hello John,
I basically just need an xml or txt file with x,y,z position, time, type of particle and its energy. It needs to be a file as I will then pass it on to another programme running on a different operating system. There the event should be visualized in a slow motion sequence. For this visualization I need a simple xml or txt file. I had hoped that the HepRep format might offer this directly.
Could I ask you if you know of an example where such information is stored in an xml or txt format?
With kind regards
Clemens

Hi Clemens

Have you had a look at Making a Movie — Book For Application Developers 11.0 documentation? In particular, Using /vis/viewer/interpolate? Have a look at examples/extended/visualization/movies.

If you want to do it yourself, making a file as you propose can get quite tricky, especially in multithreaded mode. Come back to me on that one.

John

Hello John,
I have found a suitable solution for me. Using these three commands in vis.mac, the global time per step for each particle is also stored in a HepRep file.

/vis/scene/add/trajectories rich
/vis/modeling/trajectories/create/drawByParticleID
/vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true

Thank you very much for your help,
Clemens

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