Skip to content

Latest commit

 

History

History
135 lines (122 loc) · 5.32 KB

geant4.10.6.org

File metadata and controls

135 lines (122 loc) · 5.32 KB

Knowledge from Developer user-guide

All of the following are based on Geant4.10.6BookForApplicationDevelopers. Sections follow the same order in the user guide.

Installation

Instructions from official website

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.

What I did

MacOS

On MacOS, I execute in terminal src_sh[:exports code]{sudo port install geant4}.

Debian

An example

A main() program

Source code

#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;
}

G4RunManager

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

Knowledge from summer school

I checked Geant4 Course at XX Seminar on Software for Nuclear, Sub-nuclear and Applied Physics.

Introduction and concepts

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.

Required

Optional

The main() program

Required

Optional

Build an application

Materials and geometry

Generation of a primary event

Physics processes

Knowledge from the attempts

Miscellaneous

Disable Decay

See Documentation.

Decay for some particles may be switched on or off by using G4ParticleDefinition::SetPDGStable() as well as ActivateProcess() and InActivateProcess() methods of G4ProcessManager.

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);

Knowledge from forum posts

Dump available GEANT4 built-in physics processes

Reference is here.

Dump all built-in processes along with their type and subtype tables

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.

Dump all processes for a given particle

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.

Get the step’s process name

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().