Measuring of secondary particles by already secondary neutrons

Dear all,

In my simulation I am shooting protons of different energies at an aluminium shielding slab (volume in white), which produces a whole range of secondary particles (including neutrons), which are detected by a water cube sensitive detector (volume in blue), as showed in the following image:


I am interested in measuring the energy deposited only by the neutrons and their secondaries in the water cube.

So far, I have been able to measure the total energy deposition in the water cube (with no particle discrimination), as well as the energy deposited only by neutrons. Unfortunately, I have not been able to measure the secondary particles created by the neutrons within the water cube.

This is the code that I’m using under ProcessHits:

CubeHit* newHit = new CubeHit();
//
// Total energy deposit (no particle restrictions)
//
G4double edep = step->GetTotalEnergyDeposit();
if ( edep==0. ) return false;
// Add values
newHit->AddTotalEdep(edep);
//
//Energy deposited by neutrons
//
if ( step->GetTrack()->GetDefinition()==G4Neutron::Neutron() ) {
G4double neutronEdep = step->GetTotalEnergyDeposit();
if ( neutronEdep==0. ) return false;
// Add values
newHit->AddNeutronEdep(neutronEdep);
// Fill histogram
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(1, neutronEdep/keV);
}
// Add hit in the collection
fHitsCollection->insert(newHit);
// Add hits properties in the histogram
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(0, edep/MeV);
return false;

Any help with this matter would be greatly appreciated.

Thank you in advance!

1 Like

To collect the secondaries, you need to know what they are. You can find that out in your setpping action (or SD) here by querying the step inside your “if neutron” block, instead of abandoning things if neutronEdep is zero.

That can give you a list of all the true tracks the neutron created, with their kinetic energies (KE). If your detector is big enough, you could assume those secondaries are fully absorbed and just include their KE in your energy total.

If you actually want to wait for those secondaries to see if they deposit energy, then you need to store the neutron’s track ID in a local (data member) buffer. On subsequent calls into ProcessHits, you check to see if the new track’s ParentID() was the neutron, and if so you accumulate the Edep appropriately.

1 Like

Another idea could be to create to create a G4UserTrackInformation class that keeps a flag for every neutron that enters your water volume and then it is copied to every secondary (and their secondaries, …) produced in the water volume.

1 Like

Thank you for your recommendations, Michael! I followed your advice and modified my code like this:

//
//Energy deposited by neutrons (primaries)
//
if ( step->GetTrack()->GetDefinition()==G4Neutron::Neutron() ) {
ntrackID = step->GetTrack()->GetTrackID();
G4double neutronEdep = step->GetTotalEnergyDeposit();
// Add values
newHit->AddNeutronEdep(neutronEdep);
// Fill histogram
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(1, neutronEdep/keV);
}
//
//Energy deposited by neutrons (secondaries)
//
parentID = step->GetTrack()->GetParentID();
if ( parentID == ntrackID){
G4double neutronSecondaries = step->GetTotalEnergyDeposit();
// Add values
newHit->AddNeutronSecondaries(neutronSecondaries);
//Fill histogram
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(2,neutronSecondaries/MeV);
}

I tested it and indeed, I can now obtain the energy deposition by both the neutrons and their secondaries. Unfortunately, I also need the rest of the track’s energy deposition, i.e. the secondaries of the secondaries of the secondaries,… ,and so on.

I assume this can be done manually (following the same approach but with the new track IDs of the secondaries), but is there a way to do this automatically? Either with a for loop or perhaps there is a Geant4 function that gives me the entire range of a particle’s track (including secondaries of the secondaries and so on)?

Thank you once again for all your support!

1 Like

Yuck. G4 definitely doesn’t have tools like that built in. We all write them ourselves for our applications.