12#include "G4DarkBreM/G4DarkBremsstrahlung.h"
14#include "SimCore/DetectorConstruction.h"
17#include "SimCore/G4User/RunAction.h"
18#include "SimCore/G4User/StackingAction.h"
19#include "SimCore/G4User/SteppingAction.h"
22#include "SimCore/ParallelWorld.h"
23#include "SimCore/XsecBiasingOperator.h"
28#include "FTFP_BERT.hh"
29#include "G4GDMLParser.hh"
30#include "G4GenericBiasingPhysics.hh"
31#include "G4ParallelWorldPhysics.hh"
32#include "G4ProcessTable.hh"
33#include "G4VModularPhysicsList.hh"
42 auto rootPrimaryGenUseSeed{
56 <<
"[ RunManager ]: Parallel worlds physics list has been registered."
58 pList->RegisterPhysics(
new G4ParallelWorldPhysics(
"ldmxParallelWorld"));
68 auto biasing_operators{
70 "biasing_operators", {})};
71 if (!biasing_operators.empty()) {
72 std::cout <<
"[ RunManager ]: Biasing enabled with "
73 << biasing_operators.size() <<
" operator(s)." << std::endl;
78 bop.getParameter<std::string>(
"class_name"),
79 bop.getParameter<std::string>(
"instance_name"), bop);
83 G4GenericBiasingPhysics* biasingPhysics =
new G4GenericBiasingPhysics();
90 std::cout <<
"[ RunManager ]: Biasing operator '" << bop->GetName()
91 <<
"' set to bias " << bop->getParticleToBias() << std::endl;
92 biasingPhysics->Bias(bop->getParticleToBias());
96 pList->RegisterPhysics(biasingPhysics);
99 this->SetUserInitialization(pList);
108 std::cout <<
"[ RunManager ]: Parallel worlds have been enabled."
112 G4GDMLParser* pwParser =
new G4GDMLParser();
122 G4RunManager::Initialize();
132 SetUserAction(primary_action);
133 SetUserAction(run_action);
134 SetUserAction(event_action);
135 SetUserAction(tracking_action);
136 SetUserAction(stepping_action);
137 SetUserAction(stacking_action);
143 for (
auto& user_action : user_actions) {
145 user_action.getParameter<std::string>(
"class_name"),
146 user_action.getParameter<std::string>(
"instance_name"), user_action);
147 for (
auto& type : ua->getTypes()) {
148 if (type == simcore::TYPE::RUN) {
149 run_action->registerAction(ua.get());
150 }
else if (type == simcore::TYPE::EVENT) {
151 event_action->registerAction(ua.get());
152 }
else if (type == simcore::TYPE::TRACKING) {
153 tracking_action->registerAction(ua.get());
154 }
else if (type == simcore::TYPE::STEPPING) {
155 stepping_action->registerAction(ua.get());
156 }
else if (type == simcore::TYPE::STACKING) {
157 stacking_action->registerAction(ua.get());
159 EXCEPTION_RAISE(
"ActionType",
"Action type does not exist.");
167 G4RunManager::TerminateOneEvent();
172 static auto reactivate_dark_brem = [](G4ProcessManager* pman) {
173 for (
int i_proc{0}; i_proc < pman->GetProcessList()->size(); i_proc++) {
174 G4VProcess* p{(*(pman->GetProcessList()))[i_proc]};
175 if (p->GetProcessName().contains(G4DarkBremsstrahlung::PROCESS_NAME)) {
176 pman->SetProcessActivation(p,
true);
182 reactivate_dark_brem(G4Electron::Definition()->GetProcessManager());
184 if (this->GetVerboseLevel() > 1) {
185 std::cout <<
"[ RunManager ] : "
186 <<
"Reset the dark brem process (if it was activated)."
Class which defines basic APrime physics.
Class which implements the Geant4 user event action.
Class used to enhanced the gamma physics list.
Class implementing the Geant4 primary generator action.
Class providing a Geant4 run manager implementation.
Class which implements the user tracking action.
Class encapsulating parameters for configuring a processor.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Defines basic APrime physics.
Handle to the conditions system, provided at construction to classes which require it.
Implements the Geant4 detector construction.
void apply(UnaryFunction f) const
Apply the input UnaryFunction to each entry in the inventory.
static Factory & get()
get the factory instance
PrototypePtr make(const std::string &full_name, PrototypeConstructorArgs... maker_args)
make a new object by name
extra gamma particle physics for simulation and sets up the photonuclear model to use from the config...
Allows the configuration of properties of kaons produced in the simulation, in particular setting the...
std::string parallelWorldPath_
Path to GDML description of parallel world.
framework::config::Parameters parameters_
The set of parameters used to configure the RunManager.
bool isPWEnabled_
Flag indicating whether a parallel world should be registered.
void TerminateOneEvent()
Called at the end of each event.
void setupPhysics()
Initialize physics.
void setUseRootSeed(bool useIt=true)
Tell RunManager to use the seed from the root file.
void Initialize()
Perform application initialization.
DetectorConstruction * getDetectorConstruction()
Get the user detector construction cast to a specific type.
G4PhysListFactory physicsListFactory_
Factory class for instantiating the physics list.
RunManager(framework::config::Parameters ¶meters, ConditionsInterface &)
Class constructor.
Implementation of user event action hook.
Implementation of Geant4 primary generator action.
Implementation of user run action hook.
Class implementing a user stacking action.
Implements the Geant4 user stepping action.
Implementation of user tracking action.