# Multiple output files

**URL:** <https://geant4-forum.web.cern.ch/t/multiple-output-files/1780>\
**Category:** Getting Started\
**Created:** [January 29, 2020, 8:07pm UTC](https://geant4-forum.web.cern.ch/t/multiple-output-files/1780 "2020-01-29T20:07:58Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![khushbakht123](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/khushbakht123/32/3509_2.png) [@khushbakht123](https://geant4-forum.web.cern.ch/u/khushbakht123)\
**Post date:** [February 18, 2022, 10:13am UTC](https://geant4-forum.web.cern.ch/t/multiple-output-files/1780/21 "2022-02-18T10:13:30Z")

</div>

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.

 ![1](https://geant4-forum.web.cern.ch/uploads/default/original/2X/3/3d4fc421ada633336c66b6ad8b01352c4fdb0660.png)

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!

---

<div class="post-metadata">

**Author:** ![khushbakht123](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/khushbakht123/32/3509_2.png) [@khushbakht123](https://geant4-forum.web.cern.ch/u/khushbakht123)\
**Post date:** [February 19, 2022, 6:41pm UTC](https://geant4-forum.web.cern.ch/t/multiple-output-files/1780/22 "2022-02-19T18:41:08Z")

</div>

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.

 ![track](https://geant4-forum.web.cern.ch/uploads/default/original/2X/2/29650afcaef42e13e0798b67fbc470df1075cdc1.png)

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”.

---

<div class="post-metadata">

**Author:** ![mkelsey](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/mkelsey/32/49_2.png) [@mkelsey](https://geant4-forum.web.cern.ch/u/mkelsey)\
**Post date:** [February 22, 2022, 4:04am UTC](https://geant4-forum.web.cern.ch/t/multiple-output-files/1780/23 "2022-02-22T04:04:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bmorgan](https://geant4-forum.web.cern.ch/user_avatar/geant4-forum.web.cern.ch/bmorgan/32/7_2.png) [@bmorgan](https://geant4-forum.web.cern.ch/u/bmorgan)\
**Post date:** [July 2, 2022, 4:54pm UTC](https://geant4-forum.web.cern.ch/t/multiple-output-files/1780/24 "2022-07-02T16:54:51Z")

</div>

Closed on July 2, 2022, 4:54pm UTC



[Previous page](https://geant4-forum.web.cern.ch/t/multiple-output-files/1780.md?page=1)
