Importance sampling multiple particle types


I’m having an issue assigning/registering importance bias to two particles. Infact, the assigning only works with whatever I register first.

B01DetectorConstruction* detector = new B01DetectorConstruction();
G4GeometrySampler gamma_bias(detector->GetWorldVolume(),“gamma”);
physicsList->RegisterPhysics(new G4ImportanceBiasing(&gamma_bias));
G4GeometrySampler electron_bias(detector->GetWorldVolume(),“e-”);
physicsList->RegisterPhysics(new G4ImportanceBiasing(&electron_bias));

In this case the gammas will be biased.

I also found a similar question from 2016 with the same problem and no solution,

Any suggestions?



I don’t think this works. There is a bug report from a couple of years ago:

Did you try generic biasing (see examples extended/biasing/GB01 to GB06)? These use the generic biasing physics lists (source/physics_lists/constructors/limiters/include/G4GenericBiasingPhysics.hh) which appear to allow multiple particles.