Multiple output files

Hi @mkelsey ,

I am also working with Trajectories at the moment. I am taking a cylindrical tank in Geant4 filled with Gd+Water and shooting a neutrons from all sides of the wall of tank and i want to see how deep into the water one particular neutron can go until it gets captured. So, basically i want to find the distance of one particular neutron when it created until it gets captured. I decided to do it with trajectories. Now i have a container of trajectories and i want to save the distance or at least position of starting and end point of neutron track. I am attaching this screenshot of my code so far.

I was wondering if i could use PreUserTrackingAction() and PostUserTrackingAction() inside container to get the track length of neutron.

I would really appreciate your help!

Hello @mkelsey ,

I also tried using PostUserTrackingAction() and save “track->GetTrackLength()” but i noticed that it only give me the distance of last step when neutron get captured (can be seen in the screenshot below) but what i need is the distance of whole path i.e. from creation from wall until it get captured in water.

In this screenshot, in the second last line you can see “track in post = 231.6” which in the table is the distance of only last step (third-last column) called “TrackLeng”.

That’s weird. The G4Track::GetTrackLength() function returns G4Track::fTrackLength, which is documented in G4Track.hh as “Accumulated track length”. There is a separate G4Track::GetStepLength() function which returns the intermediate step length.

Are you sure you’re calling the right function in your PostUserTrackingActon? I see from your /tracking/verbose that your neutron had 26 total step, all of them hadElastic, so you should have gotten a total track length of several meters.