Skip the step of sampling for secondary electron

Nice to meet u guys,

I used RE02 example to construct phantom with a repetitive structrue, and just pure tissue material inside it.
I tried to know how the neutron and photon flux are distributed inside this phantom hitting by 10keV neutron source, and also comparing it with result in MCNP with same geometry and same source.

However, I found that I need to use G4ThermalNeutrons library to get the answer that match with MCNP result.
But using this library made the whole simulation time much longer (about 2~3 times longer compute time)

Since I don’t need dose distribution by now, I tried to kill all the secondary(especially e-) except for neutron and photon with StackingAction(as below) to reduce the computational time:

StackingAction::ClassifyNewTrack(const G4Track* track)

if (track->GetParentID() == 0) return fUrgent; //Primaries
if (track->GetDefinition() == G4Neutron::Neutron()) return fUrgent;
if (track->GetDefinition() == G4Gamma::Gamma()) return fUrgent;

return fKill;

But this seems not having much help , total computational time didnt change much,
so i guess it’s because in this way we still have to check the table for sampling the energy and momentum of secondary electron, so what i want to know is: Can i just skip the step of sampling electron energy and tell Geant4 that whenever a electron producing process are encountered(such as Compton scatter or pair production), just directly dump that electron and don’t waste time on looking up the library?

My objective is to increase the computation efficiency and also maintain the correctness of simulation, so if there are any other ways to attain this, i’ll be also glad to know!
(Geant4 version:geant4-v11.1.1)

Hope someone can help me, thanks in advance!

In example Hadr04, electromagnetic interactions are not registered.

Maire, thanks for your reply!

But in this case I also need to know the distrubution of secondary photon, so I think we can’t just not registering the EM interaction?

Here an electromagnetic physics constructor which includes only Gamma processes.
I have tested it in the context of Hadr04. (3.3 KB)

I have forgotten to join the corresponding header file.
ElectromagneticPhysics.hh.txt (2.7 KB)