- Table of contents
- G4Helper ( G4Helper )
- UserAction and friends
G4Base is the interface between code that is based on the ART framework and Geant4. It has several components to it that are described below. Note that many of the section headings are links to the header files for the described objects and those files have a detailed description of the objects in question.
This is the direct interface between Geant4 and the experiment's code. The G4Helper provides all the initialization needed to run Geant4 and a link to the G4RunManager that controls the execution of tracking particles through the detector.
PhysicsList (and physics processes)¶
The G4Helper provides a means for setting the physics list used by G4, and a hook for adding in additional physics processes and configuring them:
physics.producers.geantgen.G4AlgPSet.G4PhysListName: " QGSP_BERT ; g4n::NovaG4MonopolePhysics ( /monopole/setup 1. 0. 1.0e5 GeV , /monopole/magCharge 1 , /monopole/elCharge 0 ) "
The first field (split using a semi-colon as a separator) is always the base physics list, here
QGSP_BERT. Subsequent fields start with a physics process derived from
G4VPhysicsConstructorand registered with the
G4Base/G4PhysicsProcessFactorySingleton. Comma separated commands given in ()'s are passed via the G4UI (user interface) to configure the process at the appropriate time.
This object produces Geant4 physics lists based on a string. It is called by the
G4Helper object and the contents of the physics list can be specified through the use of fhicl parameter sets as shown above.
To allow extensibility of they physics list to provide for adding additional physics processes as show above,
G4Helper uses this class. Physics processes can be registered by using the following two lines (
g4n is a namespace) in an implementation (i.e. non-header) file:
#include "G4Base/G4PhysicsProcessFactorySingleton.hh" PHYSPROCREG3(g4n,NovaG4MonopolePhysics,g4n::NovaG4MonopolePhysics);
UserAction and friends¶
This is an abstract class that provides hooks that Geant4 uses to perform user specified tasks during execution. For example, one could make a derived class that collects the secondary particles from a primary interaction.The
UserActionclass supports all the standard actions (other than the primary generator):
Users can implement any of these as needed (default null actions exist in the base class) for a coherent whole. The latter three methods are stacking actions that allow the user to prioritize when particles get tracked, to kill them, or to defer them to the next event. Classes that implement any of the three the stacking actions also need to override
ProvidesStacking() to return
This object provides functionality for a user to make and manage a collection of UserActions defined for the job. It must be configured between calling the
SetUserAction methods of
This singleton class allows
UserAction classes to self-register with it. It can then create any registered class upon demand based on the class name. The
ExampleAction in the
altns namespaces, class registers by adding to the implementation file the lines:
#include "G4Base/UserActionFactory.h" USERACTIONREG3(altns,ExampleAction,altns::ExampleAction)
Using them all together¶
UserAction needs configuration parameters is should implement the
Config(fhicl::ParameterSet const& pset) method as well as the
fG4Help->InitPhysics(); // UserActionManager and UserActionFactory are singletons, so get their handles g4b::UserActionManager* uam = g4b::UserActionManager::Instance(); g4b::UserActionFactory& uafactory = g4b::UserActionFactory::Instance(); // get the UserAction by name, configure it (w/ an appropriate pset), hand it to the manager std::string uaname = "altns::ExampleAction"; fhicl::ParameterSet uapset = ... // fetch correct parameter set for this user action g4b::UserAction* ua = uafactory.GetUserAction(uaname); ua->Config(uapset); uam->AddAndAdoptAction(ua); // add to the list of managed actions // print the state of the UserActionManager (and actions if they know how) uam->PrintActionList("config"); fG4Help->SetUserAction();
This object looks for the gdml file of the detector geometry using the Geometry service. It is assumed that the user has a Geometry service defined that is located in a Geometry package. The object also provides hooks to register parallel worlds, if necessary, and return the any magnetic field or the world volume.
This object provides a mechanism to take the primary particles generated by an external event generator, such as GENIE or CRY, and turn them into Geant4 primary particles.
This object provides access to the MCTruth object for each G4 tracked event.