Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4SchedulerMessenger.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
28//
29// History:
30// -----------
31//
32// -------------------------------------------------------------------
33#include <G4Scheduler.hh>
35#include "G4UIdirectory.hh"
39#include "G4UIcmdWithABool.hh"
40#include "G4UIcmdWithAString.hh"
41#include "G4UIcommand.hh"
42#include "G4UIparameter.hh"
43#include "G4ios.hh"
44
46 : fScheduler(stepMgr)
47{
48 fITDirectory = std::make_unique<G4UIdirectory>("/scheduler/");
49 fITDirectory->SetGuidance("Control commands for the time scheduler "
50 "(dna chemistry applications).");
51
52 // Set end time
53 fEndTime = std::make_unique<G4UIcmdWithADoubleAndUnit>("/scheduler/endTime", this);
54 fEndTime->SetGuidance("Set time at which the simulation must stop.");
55 fEndTime->AvailableForStates(G4State_PreInit, G4State_Idle);
56 fEndTime->SetUnitCategory("Time");
57 fEndTime->SetDefaultUnit("picosecond");
58 fEndTime->SetDefaultValue(1);
59
60 // Set time tolerance
61 fTimeTolerance = std::make_unique<G4UIcmdWithADoubleAndUnit>("/scheduler/timeTolerance", this);
62 fTimeTolerance->SetGuidance(
63 "This command aims at resolving issues related to"
64 " floating points. If two time events are separated by less than the "
65 "selected tolerance, they are assumed to belong to the same time step.");
66 fTimeTolerance->AvailableForStates(G4State_PreInit, G4State_Idle);
67 fTimeTolerance->SetUnitCategory("Time");
68 fTimeTolerance->SetDefaultUnit("picosecond");
69 fTimeTolerance->SetDefaultValue(1);
70
71 // Initialize
72 fInitCmd = std::make_unique<G4UIcmdWithoutParameter>("/scheduler/initialize", this);
73 fInitCmd->SetGuidance("Initialize G4Scheduler. This is done "
74 "for standalone application only (no physics).");
75 fInitCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
76
77 // Set Max Null time Step
78 fMaxNULLTimeSteps = std::make_unique<G4UIcmdWithAnInteger>("/scheduler/maxNullTimeSteps", this);
79 fMaxNULLTimeSteps->SetGuidance(
80 "Set maximum allowed zero time steps. After this "
81 "threshold, the simulation is stopped.");
82 fMaxNULLTimeSteps->SetParameterName("numberOfNullTimeSteps", true);
83 fMaxNULLTimeSteps->SetDefaultValue(10000);
84 fMaxNULLTimeSteps->SetRange("numberOfNullTimeSteps >=0 ");
85
86 fMaxStepNumber = std::make_unique<G4UIcmdWithAnInteger>("/scheduler/maxStepNumber", this);
87 fMaxStepNumber->SetGuidance(
88 "Set the maximum number of time steps. After this "
89 "threshold, the simulation is stopped.");
90 fMaxStepNumber->SetParameterName("maximumNumberOfSteps", true);
91 fMaxStepNumber->SetDefaultValue(-1);
92
93 // Beam On
94 fProcessCmd = std::make_unique<G4UIcmdWithoutParameter>("/scheduler/process", this);
95 fProcessCmd->SetGuidance(
96 "Process stacked tracks in G4Scheduler. This is done "
97 "for standalone application only (no physics).");
98 fProcessCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
99
100 // Verbose
101 fVerboseCmd = std::make_unique<G4UIcmdWithAnInteger>("/scheduler/verbose", this);
102 fVerboseCmd->SetGuidance("Set the Verbose level of G4Scheduler.");
103 fVerboseCmd->SetGuidance(" 0 : Silent (default)");
104 fVerboseCmd->SetGuidance(" 1 : Display reactions");
105 fVerboseCmd->SetGuidance(" 2 ");
106 fVerboseCmd->SetParameterName("level", true);
107 fVerboseCmd->SetDefaultValue(1);
108
109 fWhyDoYouStop = std::make_unique<G4UIcmdWithoutParameter>("/scheduler/whyDoYouStop", this);
110 fWhyDoYouStop->SetGuidance("Will print information on why the scheduler is "
111 "stopping the process");
112
113 fUseDefaultTimeSteps = std::make_unique<G4UIcmdWithABool>("/scheduler/useDefaultTimeSteps", this);
114 fUseDefaultTimeSteps->SetGuidance(
115 "Let the G4 processes decided for the next "
116 "time step interval. This command would be interesting if no reaction has "
117 "been set and if one will want to track down Brownian objects. "
118 "NB: This command gets in conflicts with the declaration of time steps.");
119
120 fResetScavenger = std::make_unique<G4UIcmdWithABool>("/scheduler/ResetScavengerForEachBeamOn", this);
121 fResetScavenger->SetGuidance(
122 "Reset Scavenger information apres each BeamOn.");
123 fResetScavenger->SetDefaultValue(true);
124
125}
126
128
130{
131 if(command == fProcessCmd.get())
132 {
133 fScheduler->Process();
134 }
135 else if(command == fEndTime.get())
136 {
137 fScheduler->SetEndTime(fEndTime->GetNewDoubleValue(newValue));
138 }
139 else if(command == fTimeTolerance.get())
140 {
141 fScheduler->SetTimeTolerance(fTimeTolerance->GetNewDoubleValue(newValue));
142 }
143 else if(command == fVerboseCmd.get())
144 {
145 fScheduler->SetVerbose(fVerboseCmd->GetNewIntValue(newValue));
146 }
147 else if(command == fInitCmd.get())
148 {
149 fScheduler->Initialize();
150 }
151 else if(command == fMaxNULLTimeSteps.get())
152 {
153 fScheduler->SetMaxZeroTimeAllowed(
154 fMaxNULLTimeSteps->GetNewIntValue(newValue));
155 }
156 else if(command == fMaxStepNumber.get())
157 {
158 fScheduler->SetMaxNbSteps(fMaxStepNumber->GetNewIntValue(newValue));
159 }
160 else if(command == fWhyDoYouStop.get())
161 {
162 fScheduler->WhyDoYouStop();
163 }
164 else if(command == fUseDefaultTimeSteps.get())
165 {
166 fScheduler->UseDefaultTimeSteps(
167 fUseDefaultTimeSteps->GetNewBoolValue(newValue));
168 }
169 else if(command == fResetScavenger.get())
170 {
171 fScheduler->ResetScavenger(fResetScavenger->GetNewBoolValue(newValue));
172 }
173}
174
176{
177 G4String cv;
178
179 if(command == fVerboseCmd.get())
180 {
181 cv = fVerboseCmd->ConvertToString(fScheduler->GetVerbose());
182 }
183 else if(command == fEndTime.get())
184 {
185 cv = fEndTime->ConvertToString(fScheduler->GetEndTime());
186 }
187 else if(command == fTimeTolerance.get())
188 {
189 cv = fTimeTolerance->ConvertToString(fScheduler->GetTimeTolerance());
190 }
191 else if(command == fInitCmd.get())
192 {
193 cv = fInitCmd->ConvertToString(fScheduler->IsInitialized());
194 }
195 else if(command == fMaxNULLTimeSteps.get())
196 {
197 cv =
198 fMaxNULLTimeSteps->ConvertToString(fScheduler->GetMaxZeroTimeAllowed());
199 }
200 else if(command == fMaxStepNumber.get())
201 {
202 cv = fMaxStepNumber->ConvertToString(fScheduler->GetMaxNbSteps());
203 }
204 else if(command == fUseDefaultTimeSteps.get())
205 {
206 cv = fUseDefaultTimeSteps->ConvertToString(
207 fScheduler->AreDefaultTimeStepsUsed());
208 }
209 return cv;
210}
@ G4State_Idle
@ G4State_PreInit
void SetNewValue(G4UIcommand *command, G4String newValues)
G4String GetCurrentValue(G4UIcommand *command)
G4SchedulerMessenger(G4Scheduler *runMgr)
G4int GetMaxZeroTimeAllowed() const
Definition: G4Scheduler.hh:396
void SetMaxNbSteps(G4int)
Definition: G4Scheduler.hh:334
G4bool IsInitialized()
Definition: G4Scheduler.hh:296
G4int GetMaxNbSteps() const
Definition: G4Scheduler.hh:339
void SetVerbose(G4int)
Definition: G4Scheduler.hh:380
void Process()
Definition: G4Scheduler.cc:379
G4double GetEndTime() const
Definition: G4Scheduler.hh:349
G4bool AreDefaultTimeStepsUsed()
Definition: G4Scheduler.hh:451
void WhyDoYouStop()
Definition: G4Scheduler.hh:441
void Initialize()
Definition: G4Scheduler.cc:284
void SetMaxZeroTimeAllowed(G4int)
Definition: G4Scheduler.hh:391
void SetEndTime(const G4double)
Definition: G4Scheduler.hh:306
G4double GetTimeTolerance() const
Definition: G4Scheduler.hh:406
void SetTimeTolerance(G4double)
Definition: G4Scheduler.hh:401
void ResetScavenger(bool)
Definition: G4Scheduler.hh:456
G4int GetVerbose() const
Definition: G4Scheduler.hh:385
void UseDefaultTimeSteps(G4bool)
Definition: G4Scheduler.hh:446