Adding hadronic interaction

Hello everyone

I am a very beginner user of Geant4 and this is my first post on the forum.
I received a ready-made macro to run the simulation.
However, it lacks the implementation of the hadronic interaction. I added the hadronic interaction in the file.
My question is: where, apart from the file, do I need to change the code so that the simulation takes into account the hadronic interaction?


I think and PhysicsList.hh are enough to implement the hadronic interaction in the simulation.

1 Like

Thank you for your response !
But the simulation still does not take into account the hadronic interaction.
In the PhysicsList.hh file I added:

#include "G4HadronPhysicsQGSP_BIC.hh"
#include "G4HadronElasticPhysics.hh"

void LiGenPhysicsList::ConstructProcess()
   // Hadronic interaction
   G4HadronPhysicsQGSP_BIC* hadronPhysics = new G4HadronPhysicsQGSP_BIC();
   G4HadronElasticPhysics* elasticPhysics = new G4HadronElasticPhysics();

in the file PhysicsList.hh

class LiGenPhysicsList : public G4VUserPhysicsList

 //these methods Construct physics processes and register them
 void ConstructDecay();
 void ConstructEM();
 void ConstructOp();
 void ConstructHadron();// Hadronic constructor


An easy and direct way to do this is directly include FTFB_BERT in your main cc file. Here is the link for your reference (FTFP_BERT β€” Geant4 Documentation 11.2 documentation)
Example B5 has implemented it, you can check that one.

auto physicsList = new FTFP_BERT;
  physicsList->RegisterPhysics(new G4StepLimiterPhysics());

1 Like

Thank you.
When trying to run the simulation, an error occurred:

------- EEEE ------- G4Exception-START -------- EEEE -------
*** G4Exception : had001
issued by : G4CrossSectionDataStore::BuildPhysicsTable
No cross section is registered for pi+

*** Fatal Exception *** core dump ***
**** Track information is not available at this moment
**** Step information is not available at this moment

-------- EEEE -------- G4Exception-END --------- EEEE -------

*** G4Exception: Aborting execution ***

Did you get this error after modifying the code as stated above ?

1 Like

My impression is that the hadronic physics data libraries are not set correctly. Or that particles are defined (e.g. pions) but no physics processes are instantiated. Could you please use a pre-built physics list of Geant4? e.g. QGSP_BIC_HP or any other one.


1 Like

I haven’t added your code yet.
I add this code in

void PhysicsList::ConstructHadron()
  auto particleIterator = GetParticleIterator();
  while ((*particleIterator)()) {
    G4ParticleDefinition *particle = particleIterator->value();
    G4ProcessManager *pmanager = particle->GetProcessManager();
    G4String particleName = particle->GetParticleName();
    if (particleName == "pi+" || particleName == "pi-") {
      // hadron interaction for pion
      G4HadronInelasticProcess *inelasticProcess = new G4HadronInelasticProcess("inelastic", particle);

When compiling, there is no error message. The error appears only when starting the simulation (simPion.mac)


Hi, did you instantiate the particles in the method ConstructParticle() of the Physics List?


Hi, are you asking about this list?

void PhysicsList::ConstructParticle()
  G4BosonConstructor bConstructor;

  G4LeptonConstructor lConstructor;

  G4MesonConstructor mConstructor;

  G4BaryonConstructor rConstructor;

  G4IonConstructor iConstructor;


I suggest to use a pre-built physics list of Geant4, to see if you get the same error.

Please tell me where I can find this list? β†’ Geant4 Documentation - Geant4 β†’ Guide for Physics Lists β€” PhysicsListGuide 11.2 documentation β†’ QGSP_BIC β€” PhysicsListGuide 11.2 documentation

1 Like

Deepachoudhary, I just added the code snippet from you mentioned to main cc. But the error message remains the same.

auto physicsList = new FTFP_BERT;
  physicsList->RegisterPhysics(new G4StepLimiterPhysics());

Guatelli and Mkelsey, thank you.
I added libraries (pions)

#include "G4HadronInelasticProcess.hh" 
#include "G4HadronPhysicsQGSP_BERT.hh"
#include "G4BGGPionInelasticXS.hh"
#include "G4BGGPionElasticXS.hh"
#include "G4PionPlus.hh"
#include "G4PionMinus.hh"
#include "G4HadronElasticProcess.hh"
#include "G4HadronElastic.hh"
#include "G4HadronElasticDataSet.hh"
#include "G4PiNuclearCrossSection.hh"
#include "G4ParticleTable.hh"
#include "G4HadronElasticPhysics.hh"
#include "G4HadronElastic.hh"

Is there any sample code for hadronic processes for pions available somewhere so I can see what it looks like?

Why are you doing this all by hand, rather than using one of the Geant4 reference physics lists?

Thank you very much. I think I understand what this list is about now. I added it to simPion.mac
/physics_list/select QGSP_BIC
before /run/initialize.
When I run the simulation I now get an error message:

/physics_list/select QGSP_BIC
***** COMMAND NOT FOUND </physics_list/select QGSP_BIC> *****

***** Batch is interrupted!! *****

-------- WWWW ------- G4Exception-START -------- WWWW -------
*** G4Exception: UIMAN0123
issued by: G4UImanager::ApplyCommand
Command aborted (100)
Error code : 100
*** This is just a warning message. ***
-------- WWWW -------- G4Exception-END --------- WWWW -------

I have to use Geant4 10.7.4 because only this version is compatible with my macro. Why the command
/physics_list/select QGSP_BIC is not correct?

Those macro commands (/physics_list/...) are associated with the G4PhysListFactory. In your main(), instantiate the factory:

   G4PhysListFactory thePLFactory;

You can choose a physics list in the code, as well as via the macro command:

  G4VModularPhysicsList* pl = thePLFactory->GetReferencePhysicsList("QGSP_BIC");

Thank you very much. I added this code in main cc.

G4PhysListFactory thePLFactory;
    G4VModularPhysicsList* pl = thePLFactory.GetReferencePhysList("QGSP_BIC");

but the message will be the same.
I had to replace GetReferencePhysicsList with GetReferencePhysList.
Maybe this command is not supported in Geant4 10.7.4?


It looks like it isn’t (my mistake in reading your earlier message). I had to go to the Geant4 sources to find out. In G4 10.7, the G4PhysListFactoryMessenger class creates a β€œ/physics_lists/” directory (note the plural), which does not include commands to select a physics list at run time.

I cannot find a /physics_list/... command directory anywhere in the G4 source, not in G4 10.* nor in G4 11.*. Did you get that from one of the Geant4 examples?

1 Like