All of the following are based on Geant4.10.6BookForApplicationDevelopers. Sections follow the same order in the user guide.
You can begin installing Geant4 by downloading the code from the distribution page. Next, consult the Installation Guide for the instructions required to set up Geant4 in your computing environment.
On MacOS, I execute in terminal src_sh[:exports code]{sudo port install geant4}.
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "ExG4DetectorConstruction01.hh"
#include "ExG4PhysicsList00.hh"
#include "ExG4ActionInitialization01.hh"
int main()
{
// construct the default run manager
G4RunManager* runManager = new G4RunManager;
// set mandatory initialization classes
// ExG4DetectorConstruction0 is user initialization of
// detector setup, including its geometry,
// the materials used in its construction,
// a definition of its sensitive regions and
// the readout schemes of the sensitive regions.
// ExG4DetectorConstruction0 is derived from G4VUserDetectorConstruction
runManager->SetUserInitialization(new ExG4DetectorConstruction01);
// ExG4PhysicsList0 is a user class derived from G4VUserPhysicsList
//
runManager->SetUserInitialization(new ExG4PhysicsList00);
runManager->SetUserInitialization(new ExG4ActionInitialization01);
// initialize G4 kernel
runManager->Initialize();
// get the pointer to the UI manager and set verbosities
G4UImanager* UI = G4UImanager::GetUIpointer();
UI->ApplyCommand("/run/verbose 1");
UI->ApplyCommand("/event/verbose 1");
UI->ApplyCommand("/tracking/verbose 1");
// start a run
int numberOfEvent = 3; runManager->BeamOn(numberOfEvent);
// job termination
delete runManager;
return 0;
}
It must be created. It controls the flow the program and manages the event loop(s) within a run. It cannot be used multi-threadedly. Use G4MTRunManager instead
I checked Geant4 Course at XX Seminar on Software for Nuclear, Sub-nuclear and Applied Physics.
The link to the course is here.
Geant4 is a toolkit (= a collection of tools), i.e., you cannot run it out of the box. You must write an application, which uses Geant4 tools.
See Documentation.
Decay for some particles may be switched on or off by using
G4ParticleDefinition::SetPDGStable()
as well asActivateProcess()
andInActivateProcess()
methods ofG4ProcessManager
.
An example I tried is:
G4ParticleDefinition *pionDef = particleTable->FindParticle("pi+");
// a setup for electron, https://apc.u-paris.fr/~franco/g4doxy/html/classG4Electron.html
pionDef->SetPDGStable(true);
pionDef->SetPDGLifeTime(-1);
pionDef->SetDecayTable(NULL);
G4ProcessManager *manager = pionDef->GetProcessManager();
// maybe other decay type, G4DecayProcessType.hh
// https://apc.u-paris.fr/~franco/g4doxy/html/G4DecayProcessType_8hh-source.html#l00043
manager->SetProcessActivation(static_cast<int>(DECAY), false);
Reference is here.
The macro command (UI command) is /run/particle/dumpOrderingParam
. No
matter the it is defined in user physics lists, built-in processes
known by GEANT4 are dumped. User defined custom processes are not
included. The type and subtype of the processes are also given.
The macro commands are
/paritcle/select e-
/particle/process/dump
It will not tell you the subtype assignment but the name and the type as a string.
Reference is here.
Given a instance of G4Step
, step
, try
const G4String& procName =
step->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName();
G4cout << "ProcName: " << procName << G4endl;
Before dereferencing a pointer, it is better to try if it is null. In
this case, it is checking
step->GetPreStepPoint()->GetProcessDefinedStep()
.