How to add hadronic physics to a simulation?

Hello! I am trying to add hadronic physics to my simulation, but it doesn’t seem to work.

I have added G4EmStandardPhysics and G4OpticalPhysics via adding the header files and RegisterPhysics (new G4OpticalPhysics());
commands.

But when trying to do the same with G4VHadronicPhysics - #include “G4VHadronPhysics.hh”, RegisterPhysics (new G4VHadronPhysics()); and error gets shown -

In constructor ‘MyPhysicsList::MyPhysicsList()’:
/home/ginger/Desktop/sim/physics.cc:6:40: error: invalid new-expression of abstract class type ‘G4VHadronPhysics’
6 | RegisterPhysics (new G4VHadronPhysics());
| ^
In file included from /home/ginger/Desktop/sim/physics.hh:6,
from /home/ginger/Desktop/sim/physics.cc:1:
/home/ginger/Desktop/software/geant4/geant4-v11.1.1-install/include/Geant4/G4VHadronPhysics.hh:49:7: note: because the following virtual functions are pure within ‘G4VHadronPhysics’:
49 | class G4VHadronPhysics : public G4VPhysicsConstructor
| ^~~~~~~~~~~~~~~~
In file included from /home/ginger/Desktop/software/geant4/geant4-v11.1.1-install/include/Geant4/G4VModularPhysicsList.hh:50,
from /home/ginger/Desktop/sim/physics.hh:3,
from /home/ginger/Desktop/sim/physics.cc:1:
/home/ginger/Desktop/software/geant4/geant4-v11.1.1-install/include/Geant4/G4VPhysicsConstructor.hh:120:18: note: ‘virtual void G4VPhysicsConstructor::ConstructProcess()’
120 | virtual void ConstructProcess() = 0;
| ^~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/sim.dir/build.make:141: CMakeFiles/sim.dir/physics.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:77: CMakeFiles/sim.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

My suggestion is to create a modularised physics list of Geant4. Add the constructors for EM physics, Optical Physics, Hadronic physics (e.g. elastic scattering, inelastic scattering, radioactive decay, etc). You may look at the Hadrontherapy physics list to see how the various physics components are added. Note that the optical physics is not added in that example but the example should give you an idea on how to solve your issue.

Susanna

Hello,

please, have a look into $G4INSTALL/examples/extended/hadronic/Hadr01.cc

you will see how to use Geant4 reference physics lists, in most cases it is enough. Of course, combining from components as Susanna described is also a solution, especially if your task is a specific one.

VI