24#include <G4AutoLock.hh>
25#include <G4Electron.hh>
26#include <G4Positron.hh>
28#include <G4SystemOfUnits.hh>
29#include <G4Threading.hh>
30#include <G4Transportation.hh>
32#include <G4UImanager.hh>
33#include <Randomize.hh>
44G4Mutex mergeMutex = G4MUTEX_INITIALIZER;
47G4Transportation* FindTransportation(
50 const auto* processManager = particleDefinition->GetProcessManager();
51 return dynamic_cast<G4Transportation*
>(
52 processManager->GetProcess(
"Transportation"));
64 fCrossSectionManager(),
67 fSaveRandomStatus(false),
68 fReadRandomStatus(false),
69 fRandomStatusFile(fgkDefaultRandomStatusFile),
70 fThresholdWarningEnergy(-1.0),
71 fThresholdImportantEnergy(-1.0),
72 fNumberOfThresholdTrials(0)
77 G4cout <<
"TG4RunAction::TG4RunAction " <<
this << G4endl;
88 G4cout <<
"TG4RunAction::~TG4RunAction " <<
this << G4endl;
107 auto* transportation = FindTransportation(particleDefinition);
108 if (!transportation) {
110 "Cannot set parameters. Transportation process not found.");
116 G4cout <<
"ChangeLooperParameters: ThresholdWarningEnergy [keV] = "
124 G4cout <<
"ChangeLooperParameters: ThresholdImportantEnergy [keV] = "
132 G4cout <<
"ChangeLooperParameters: NumberOfThresholdTrials = "
144 auto transportation = FindTransportation(G4Electron::Definition());
145 if (transportation) {
146 G4cout <<
"ThresholdWarningEnergy [MeV] = "
147 << transportation->GetThresholdWarningEnergy() / MeV << G4endl;
148 G4cout <<
"ThresholdImportantEnergy [MeV] = "
149 << transportation->GetThresholdImportantEnergy() / MeV << G4endl;
150 G4cout <<
"NumberOfThresholdTrials = "
151 << transportation->GetThresholdTrials() << G4endl;
167 G4cout <<
"### Run " << run->GetRunID() <<
" start." << G4endl;
171 if (regionsManager !=
nullptr) {
172 if (regionsManager->IsCheck()) {
173 regionsManager->CheckRegions();
175 if (regionsManager->IsPrint()) {
176 regionsManager->PrintRegions(G4cout);
178 if (regionsManager->IsSave()) {
179 regionsManager->SaveRegions();
185 G4UImanager::GetUIpointer()->ApplyCommand(
"/random/setSavingFlag true");
187 G4cout <<
"Activated saving random status " << G4endl;
188 CLHEP::HepRandom::showEngineStatus();
194 CLHEP::HepRandom::showEngineStatus();
195 G4String command(
"/random/resetEngineFrom ");
197 G4UImanager::GetUIpointer()->ApplyCommand(command.data());
200 CLHEP::HepRandom::showEngineStatus();
223#ifdef G4MULTITHREADED
226 G4AutoLock lm(&mergeMutex);
228 TVirtualMCApplication::Instance());
240 G4cout <<
"Time of this run: " << *
fTimer << G4endl;
241 G4cout <<
"Number of events processed: " << run->GetNumberOfEvent()
Definition of the TG4Globals class and basic container types.
Definition of the TG4RunAction class.
Definition of the TG4VRegionsManager class.
Definition of the TGeant4 class.
TObjArray * MakeHistograms()
G4bool IsMakeHistograms() const
static void Warning(const TString &className, const TString &methodName, const TString &text)
virtual void BeginOfRunAction(const G4Run *run)
G4String fRandomStatusFile
random engine status file name
G4bool fReadRandomStatus
control for reading random engine status
G4int fNumberOfThresholdTrials
Number of trials to propagate a looping track.
G4double fThresholdWarningEnergy
Energy threshold for warnings about killing looping tracks.
TG4CrossSectionManager fCrossSectionManager
cross section manager
G4double fThresholdImportantEnergy
virtual void EndOfRunAction(const G4Run *run)
G4bool fSaveRandomStatus
control for saving random engine status
void PrintLooperParameters() const
void ChangeLooperParameters(const G4ParticleDefinition *particleDefinition)
static const G4String fgkDefaultRandomStatusFile
default name of the random engine status file to be read in
static TG4VRegionsManager * Instance()
Return the singleton instance.
Base class for defining the verbose level and a common messenger.
virtual G4int VerboseLevel() const
static TVirtualMCApplication * MasterApplicationInstance()