Different physics list per G4Region?

I need to write a simulation combining G4 with G4-DNA. Specifically I want to have a water phantom with a higher production threshold, where only one of the standard EM physics list is used, and an inner water region where the DNA extension is used and the production threshold is much lower.

Changing the threshold in the inner G4Region is obviously not a problem, however I’m not sure how could I also select different physics processes.

Actually, the example extended/medical/dna/microdosimetry describes exactly that scenario, however it builds the physics list by calling individually each particle and process, which is too complicated for my current capabilities. Instead, I wanted to use G4VModularPhysicsList to make my job easier (and because a paper I need to replicate does that) by mimicking what extended/medical/dna/dnaphysics does:

PhysicsList::PhysicsList() 
: G4VModularPhysicsList()
{
  // ...
  
  RegisterPhysics(new G4EmStandardPhysics_option4());
  
  RegisterPhysics(new G4EmDNAPhysicsActivator());

  // RegisterPhysics(new SomeHadronPhysicsList());

 // ... 
}

Is there a way to make it so that G4EmDNAPhysicsActivator is only applied to the inner G4Region?

Hi Jacopo,

For the case you have described you have to manually activate Geant4-DNA at runtime / in a macro file so that it is only applied to a certain region. You can do this with the command “/process/em/AddDNARegion <PHYSICAL_VOLUME_NAME> DNA_Opt0”. EM Standard Physics only will be invoked in all other regions.

If calling this command leads to an error re: “illegal application state” see my post here.

Joseph

Thank you! Out of curiosity, is there any particular reason why this can’t be done directly via c++?

Happy to help.

Sorry, I see how the language I used implies that it can’t be done manually through C++, I didn’t mean to communicate that. Fundamentally all of the UI / macro commands are interacting with C++ so anything done with a UI command can be done in user code as well.

The answer to your question is that the G4EmDNAPhysicsActivator class was made to be a user friendly way of activating DNA physics, and this class in particular was made to be interacted with through UI commands. You can see how to activate DNA Physics in a region using C++ by inspecting the G4EmDNAPhysicsActivator.cc source code at:

<geant_dir>/source/physics_lists/constructors/electromagnetic/src

You will see what looks a lot like the code you referred to in the microdosimetry example where each particle and physics process is iterated over, except with an additional argument for the region to which the process should apply. For example, activating G4-DNA elastic scattering of electrons in region “reg”:

mod = new G4DNAChampionElasticModel();
em_config->SetExtraEmModel(“e-”, “e-_G4DNAElastic”, mod, reg, 0.0, elimel); //elimel = 1 MeV

The G4EmDNAPhysicsActivator class gets the “reg” string from G4EmParameters which is the class which receives the information entered in the UI command. If you wanted to implement G4DNA in only certain regions using C++, you could essentially copy and paste the G4EmDNAPhysicsActivator in to your physics list, but redefine reg locally. Something like G4String reg = {“<DNA region 1>”, “<DNA region 2”>}.

TL;DR: All of this is to say if you look at the G4EmDNAPhysicsActivator source code you should be able to make your own implementation in C++, but it will be similar to the implementation you saw in the microdosimetry example.

Ah, that makes sense. It looks like something I might want to look into once I get more experienced with Geant4.