Geant4 has three virtual classes whose methods the user must override in order to implement a simulation. They require the user to define the detector, specify the physics to be used, and describe how initial particles are to be generated.
G4VUserDetectorConstruction
Example 6.1.
G4VUserDetectorConstruction
class G4VUserDetectorConstruction { public: G4VUserDetectorConstruction(); virtual ~G4VUserDetectorConstruction(); public: virtual G4VPhysicalVolume* Construct() = 0; };
G4VUserPhysicsList
This is an abstract class for constructing particles and processes. There are several methods to define Physics List.
The user must
derive a concrete class from G4VUserPhysicsList
and implement three virtual methods:
ConstructParticle()
to instantiate each requested
particle type;
ConstructPhysics()
to instantiate the desired physics
processes and register each of them;
SetCuts(G4double aValue)
to set a cut value in range
for all particles in the particle table, which invokes the
rebuilding of the physics table.
At early stage of the initialisation of Geant4 the method
ConstructParticle()
of
G4VUserPhysicsList is invoked.
The ConstructProcess()
method must always invoke the
AddTransportation()
method in order to insure particle
transportation. AddTransportation()
must never be
overridden. This is done automatically if G4VUserPhysicsList
inherits of G4VModularPhysicsList. It is recommended for
users as the most robust interface to Physics List. Geant4 examples demonstrate
different methods how to create user Physics List.
Number of ready to use Physics Lists are available with Geant4 kernel. Below an example of instantiation of FTFP_BERT Physics List class is shown. The full set of reference Physics Lists is described in Geant4 web.
Example 6.2. Creating FTFP_BERT Physics List.
G4int verbose = 1; FTFP_BERT* physlist = new FTFP_BERT(verbose); runManager->SetUserInitialization(physlist);
Geant4 provides a class G4PhysListFactory allowing to defined Physics List by its name. The last for characters in the name defines an electromagnetic (EM) physics options. By default standard EM physics is used, "_EMV" corresponding to standard option1, "_EMX" - to standard option2, "_LIV" to EM Livermore physics, "_PEN" - to EM Penelope physics.
Example 6.3. Creating Physics List by name.
G4int verbose = 1; G4PhysListFactory factory; G4VModularPhysicsList* physlist = factory.GetReferencePhysList("FTFP_BERT_EMV"); physlist.SetVerboseLevel(verbose); runManager->SetUserInitialization(physlist);
The class G4PhysListFactory provides also another interface allowing to defined Physics List by the environment variable PHYSLIST.
Example 6.4. Creating Physics List by name.
G4int verbose = 1; G4PhysListFactory factory; G4VModularPhysicsList* physlist = factory.ReferencePhysList(); physlist.SetVerboseLevel(verbose); runManager->SetUserInitialization(physlist);
The user Physics List class may be created from components provided by Geant4 kernel and by user application. For that G4VModularPhysList should be implemented.
Example 6.5. Creating Physics List by name.
MyPhysicsList::MyPhysicsList():G4VModularPhysicsList() { G4DataQuestionaire it(photon, neutron, no, no, no, neutronxs); G4cout << "<<< Geant4 Physics List: MyPhysicsList " <<G4endl; G4cout <<G4endl; defaultCutValue = 0.7*mm; G4int ver = 1; SetVerboseLevel(ver); // EM Physics RegisterPhysics( new G4EmStandardPhysics(ver) ); // Synchroton Radiation & GN Physics RegisterPhysics( new G4EmExtraPhysics(ver) ); // Decays RegisterPhysics( new G4DecayPhysics(ver) ); // Hadron physics RegisterPhysics( new G4HadronElasticPhysicsXS(ver) ); RegisterPhysics( new G4QStoppingPhysics(ver) ); RegisterPhysics( new G4IonBinaryCascadePhysics(ver) ); RegisterPhysics( new G4HadronInelasticQBBC(ver)); // Neutron tracking cut RegisterPhysics( new G4NeutronTrackingCut(ver) ); }
G4VUserPrimaryGeneratorAction
Example 6.6.
G4VUserPrimaryGeneratorAction
class G4VUserPrimaryGeneratorAction { public: G4VUserPrimaryGeneratorAction(); virtual ~G4VUserPrimaryGeneratorAction(); public: virtual void GeneratePrimaries(G4Event* anEvent) = 0; };