Distance travel by neutron from the wall of cylinder until it get captured

Hello Everyone!

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. Now i have x,y,z coordinates of neutrons inside the water but i am not sure how will i find it’s distance from the wall.

My idea was to save the position coordinates of the neutron when i was at the wall of the tank and then subtract them form the coordinates of neutrons inside the water tank when it get captured and calculate the distance between them.

So, to save the position of neutron at the wall what i tried so far is to check the first step in water volume i.e. step->IsFirstStepInVolume() and then i saved position from its PrestepPoint as can be seen in the figure. I am saving these x,y,z coordinates as vectors of float.

But the problem is that i can’t subtract “neu_xposAtWall” from “neu_xpos”(Neutron-X position in water) because neu_xpos is the vector of values whereas neu_xposAtWall is saving only one value. You can see its Screenshot below.

Now I am also wondering if i am using correct approach to track one particular neutron from start to until it gets captured. It would be really appreciated if someone can help me with this problem or have a better idea for it. I shall be very thankfull.

Have a nice day!

Cheers,
Khushbakht

I also tried to save position of only those neutrons that are captured in water but arrays of captured and neutrons at the wall also don’t match as obviously not all the neutrons are captured.

did you consider using the TrackLength scorer?

https://geant4-userdoc.web.cern.ch/UsersGuides/ForApplicationDeveloper/html/Detector/hit.html#track-length-scorers

attach it to your water volume and also filter for neutrons, if this scorer is indeed suitable!

besides: I think you can have a vector of g4threevectors, or not? this way you don’t need to reassemble a 3vector to be able to subtract another

Hi Weller,

Thanks alot for your reply. I like the idea of Track Length. Could you tell me a little bit more about it. According to the link you mentioned TrackLength saves the sum of step lengths of the particles inside the cell. Would this in my case saves the distance that neutron travel until in gets captured?

I saw example of Geant4 /extended/biasing/B01. In this example they used

G4PSTrackLength* scorer4 = new G4PSTrackLength(psName=“SL”);
MFDet->RegisterPrimitive(scorer4);

I am not sure what this psName suggests? Is it volume name?

sorry, I have no experience yet in using this scorer, I just remembered from reading the nice documentation :wink:
also, not firm in neutron physics, but in principle I would interpret the scorer as the distance traveled in the cell in general. if capture is the only way a neutron is “killed” in, then yes. otherwise it will be all types of track termination.
leaving the volume again is always an option, but you could additionally score the G4PSPassageTrackLength and adjust the data accordingly!?

psName is probably just a name for the scorer, the scorer is attached to the volumes in the example you mentioned in this loop.

Try from the command line, think this is much easier (adjust histogram numbers & dimensions as necessary!):

# attach scorer to volume
/score/create/realWorldLogVol logVolName
/score/quantity/trackLength trackLength
/score/filter/particle neutron neutron
/score/quantity/passageTrackLength passageTrackLength 
/score/filter/particle neutron neutron
/score/close

#define histograms
/analysis/h1/create TrackLength TrackLength 101 0 100 mm
/analysis/h1/create PassageTrackLength PassageTrackLength 101 0 100 mm
/score/fill1D 0 logVolName TrackLength
/score/fill1D 1 logVolName PassageTrackLength

read Command-based scoring — Book For Application Developers 11.0 documentation how to enable histogram filling from command line