Reducing verbosity in output messages for cross sections and physics list

Dear all,

I’m trying to decrease the level of verbosity of my program, related to the the following output messages about the physics list used by my model (G4HadronElasticPhysicsHP, G4HadronPhysicsQGSP_BERT_HP, G4EmStandardPhysics, G4EmExtraPhysics, G4DecayPhysics, G4StoppingPhysics, G4IonPhysics, G4RadioactiveDecayPhysics):

I tried to decrease the level of verbosity by using the solution suggested in Reducing Physics Verbosity and by setting the verbosity level to 0:

int verb = 0;

  // EM Physics
  RegisterPhysics( new G4EmStandardPhysics(verb) );

  // Synchroton Radiation & Gamma Nuclear Physics
  RegisterPhysics( new G4EmExtraPhysics(verb) );

  // Decays
  RegisterPhysics( new G4DecayPhysics(verb) );

  // Hadron Elastic scattering
  RegisterPhysics( new G4HadronElasticPhysicsHP(verb) );

  // Hadron Physics
  RegisterPhysics( new G4HadronPhysicsQGSP_BERT_HP(verb));

  // Stopping Physics
  RegisterPhysics( new G4StoppingPhysics(verb) );

  // Ion Physics
  RegisterPhysics( new G4IonPhysics(verb));

  // Radioactive decay
  RegisterPhysics( new G4RadioactiveDecayPhysics(verb) );

My program is still printing the output messages as above. Any suggestion, please?


1 Like

Thank you very much! I used your function and it works well. The problem is that I noticed that the time spent by the simulation is the same in both cases, enabled or disabled stdout. Indeed, I want to reduce the time of the simulation lost by the verbosity.


In that case, you should compile Geant4 with -DGEANT4_BUILD_VERBOSE_CODE=OFF as suggested in the other Forum post (maybe also -DGEANT4_BUILD_STORE_TRAJECTORY if that’s enabled for you). Although for the initialization part, the options above will not change much. If you want to turn off most output from that, you can try adding this to your code (right after you create your run manager):

  G4UImanager* UI = G4UImanager::GetUIpointer();

  UI->ApplyCommand(G4String("/process/verbose       0"));
  UI->ApplyCommand(G4String("/process/em/verbose    0"));
  UI->ApplyCommand(G4String("/process/had/verbose   0"));
  UI->ApplyCommand(G4String("/process/eLoss/verbose 0"));

  UI->ApplyCommand(G4String("/control/verbose  0"));
  UI->ApplyCommand(G4String("/run/verbose      0"));
  UI->ApplyCommand(G4String("/event/verbose    0"));
  UI->ApplyCommand(G4String("/hits/verbose     0"));
  UI->ApplyCommand(G4String("/tracking/verbose 0"));
  UI->ApplyCommand(G4String("/stepping/verbose 0"));
1 Like

Ok thanks for your suggestion! I tried all the solutions provided, but Geant4 still works at the same speed with or without verbosity. At this point, I think it is a problem that should be fixed in the next versions of the code.



In recent versions of Geant4 it is needed to set to zero “em” and “had” verbosity.