DNAPhysics - illegal application state -- command refused

Hi guys,
I am new in Geant4 and I could use some help.
I am trying to use Dnaphysics to simulate radiation exposure of 98.85 kev 195Pt in a World Volume of Water but everytime I use for example the command /process/em/addDNARegion World DNA_opt6 or for example dna/test/addPhysics raddecay I get the error message below:
illegal application state – command refused:“/process/em/AddDNARegion World DNA_opt6”
illegal application state – command refused:" /dna/test/addPhysics raddecay "

I have tried to use the command before and after /run/initialize but I get the same error.

Do you have any ideas why or how I can fix it ?
Many Thanks in advance

It’s probable that the initialization is happening in the C++ code before the commands here are executed. Check the code for lines like:


That can generally be removed and the initialization deferred to commands, but see the main() programs and command macros in the basic examples for the correct structure.

Thanks for your answer. I searched for a line like this but I don´t seem to find anything that indicates the initialization of the runManager. Below you can find a snippet of my main().

int main(int argc, char **argv) {

  // Detect interactive mode (if no arguments) and define UI session
  G4UIExecutive* ui = nullptr;
  if ( argc == 1 ) {
    ui = new G4UIExecutive(argc, argv);

  // Construct the default run manager
  auto* runManager = G4RunManagerFactory::CreateRunManager();
  if(argc==3) runManager->SetNumberOfThreads(atoi(argv[2]));
  else runManager->SetNumberOfThreads(2);

  // Set mandatory user initialization classes
  auto physlist = new PhysicsList();
  runManager->SetUserInitialization(new DetectorConstruction(physlist));

  // User action initialization
  runManager->SetUserInitialization(new ActionInitialization());

Could you post your macro file, and show where you’re inserting the above two commands? You might have a /run/initialize command in your macro file, and you’re putting those commands after it, rather than before (or vice versa).

Thanks for your answer!

Sure. Below you can find the macro file, but as I said I tried to put the commands before and after /run/initialize but I got the same error.

My macro file:

/process/em/auger true
/process/em/augerCascade true
/process/em/deexcitationIgnoreCut true 

/process/em/AddDNARegion World DNA_Opt6 

/dna/test/setMat G4_Water

/gps/particle ion
/gps/ion 78 195 0 98.85 keV

/gps/energy 0 keV

/gps/pos/type Point

/gps/ang/type iso
/gps/pos/centre 0. 0. 0. mm

/run/beamOn 100000

I see that you have two occurrences of /run/initialize in your macro file. I’m pretty confident that you need the setMat command before, because that command it changing how the geometry should be built (and /run/initialize triggers building the geometry however it’s configure at that moment).

Conversely, I suspect that the AddDNARegion must be after /run/initialize, because regions get created or named as part of building the geometry.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.