Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!
—Dear experts,
I’m currently trying to kill the particles in my simulation created by Bremsstrahlung process. I try to kill such tracks by using if (process && process->GetProcessName() == “eBrem” && particleName == “gamma”) {
const_cast<G4Track*>(track)->SetTrackStatus(fKillTrackAndSecondaries);
}, I wonder if my code killed such particles and their secondaries properly? Thank you so much!
Didn’t tried it from Tracking Action, but you can do it similar in SteppingAction and it will kill for sure. But i personally follow more simple way: just comment the process in physics list.
You will not be able to deactivate eBrem on a volume level at least not directly. I can think of two methods to do what you want. One way to do this is in tracking action, specifically PreUserTrackingAction.
That will allow killing of the track before it has any chance to create secondaries in the first place. The other probably better method if you think carefully on it is to use very aggressive region cuts on electrons/positrons in a region that contains all volumes that you don’t want eBrem.
Suppose you create a region called “bkgLogReg” in detector construction or in your physics list:
G4ProductionCuts *brem_cut = new G4ProductionCuts();
brem_cut->SetProductionCut(defaultCutValue,"gamma");
brem_cut->SetProductionCut(1*kilometer,"e-");
brem_cut->SetProductionCut(1*kilometer,"e+");
# Below line necessary if not in same file as the region definition
G4Region* bkgLogReg = (G4RegionStore::GetInstance())->GetRegion("bkgLogReg");
bkgLogReg->SetProductionCuts(brem_cut);
This would effectively prevent all positrons and electrons being produced in the region even with different materials. So if you don’t care about them this will work best. And, it will be much faster than killing tracks since this will prevent the production of them in the first place.