Penetration Depth of Particles Inside a Volume

Greetings,

I intend to calculate the penetration depth of electrons in a logical volume. The scenario is that there is a mother volume made out of air with lots of other geometries inside of this mother volume. I want to have some kind of a histogram of penetration depth of these electrons.

Please do not suggest to get the z position of each electrons because the target is located in a place where some electrons pass through the target until they reach the end of my main mother volume. So, getting the z position is not a good idea because I would like to have the measurement only inside the target.

The Idea I have in mind is to define some scorer bins (like 1000 bins) and attach it to the target. Then tell each bin to record the number of electrons passed through it. And tell it to save it in a file so I can extract a histogram out of it but I have no I idea how I can do that.

It would be much appreciated if you could help me in this issue.

Hello,

What you’re describing sounds like one of the command-based scorers, particularly the nOfTerminatedTrack option. Alternatively, you could add an if-statement to check the volume of a particle before you score the z coordinate. In a PostUserTrackingAction:

if ( ( track->GetVolume()->GetName()=="myPhysicalVolume" ) && ( track->GetTrackStatus()==fStopAndKill ) )
{
    '''
     Use your preferred method of scoring position here.
    '''
}

Are you wanting the penetration depth in the mother volume, or in the individual daughter volumes? Said differently, which volume is “the target”?

If “the target” is one of the things placed as a daughter in Air, then you can attach either a command based scorer, or write a SensitiveDetector, for that volume. If the target is the Air itself, then you’ll want to use a scorer volume to get the travel distance through the mother, including the case where the electron stops in one of the daughters.

Hi mkelsey,

Actually I have a container made out of air and inside of the air there are lots of daughter volumes inside. The targets are the daughter volumes but I need the penetration depth of the ‘container’ as a whole. In case of a command-based scorer, I was wondering which option is better to get something like a histogram of electron penetration?

Although I like to use Sensitive Detector option but the coding is very hard for me since I am new to Geant4.

Do you only care about the primary particles or any of the potential secondaries? If it is just the primaries than you can align the “depth” dimension of your geometry to one of the cartesian axes. But is also important to distinguish between where the particle stops and the deepest “depth” aka range vs penetration. For electrons, these are two different quantities. For ions, they are nearly the same.

If it is just the range that you care about than you can use @afish58’s idea since PostUserTrackingAction is called once and only once at the end of life of a particle: exits world, reacts, or stops. So by polling the particles position you are getting its final position which you can histogram very quickly.

If it is depth that matters you would add a variable for the particle in the PreUserTrackingAction called “max depth” that you initialize to some very negative value (if the particle is moving in the positive direction). Then poll the position and update this variable in the SteppingAction and histogram this variable inside PostUserTrackingAction. This would require creating a simple TrackingInfo class with just that one value (so that it can be passed to the stepping action as needed).

I think this is a flexible approach that should be straightforward for a beginner. RE01 has a lot of insight to use. B4a (and b) has some of the template for the histogramming.