Find energy as a function of time

Hi Dear geant4 user!

What command can be used to obtain energy in two different times?!

None. You would need to write either a SensitiveDetector or SteppingAction class, and record the track’s current energy and time at each step. You could put that into an N-tuple (along with other useful information), and analyze it outside the simulation code.

Thank you for your reply…

The track’s current energy?!
Can you explain a little more?
I have two boxes, particles leave one box and enter another box. I want the particle energy when leaving the first box and the deposit energy in the second box!

I would use a SteppingAction class to access Step and Track information, and save your energy at certain positions