Geant4 10.7.0
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
36#include "G4UIdirectory.hh"
40#include "G4UIcmdWithABool.hh"
41#include "G4UIcommand.hh"
42#include "G4UIparameter.hh"
43#include "G4UImanager.hh"
44#include "G4ios.hh"
45
47 fScheduler(stepMgr)
48{
49 fITDirectory = new G4UIdirectory("/scheduler/");
50 fITDirectory->SetGuidance("Control commands for the time scheduler "
51 "(dna chemistry applications).");
52
53 // Set end time
54 fEndTime = new G4UIcmdWithADoubleAndUnit("/scheduler/endTime", this);
55 fEndTime->SetGuidance("Set time at which the simulation must stop.");
57 fEndTime->SetUnitCategory("Time");
58 fEndTime->SetDefaultUnit("picosecond");
59 fEndTime->SetDefaultValue(1);
60
61 // Set time tolerance
62 fTimeTolerance = new G4UIcmdWithADoubleAndUnit("/scheduler/timeTolerance",
63 this);
64 fTimeTolerance->SetGuidance("This command aims at resolving issues related to"
65 " floating points. If two time events are separated by less than the "
66 "selected tolerance, they are assumed to belong to the same time step.");
68 fTimeTolerance->SetUnitCategory("Time");
69 fTimeTolerance->SetDefaultUnit("picosecond");
70 fTimeTolerance->SetDefaultValue(1);
71
72 // Initialize
73 fInitCmd = new G4UIcmdWithoutParameter("/scheduler/initialize", this);
74 fInitCmd->SetGuidance("Initialize G4Scheduler. This is done "
75 "for standalone application only (no physics).");
77
78 // Set Max Null time Step
79 fMaxNULLTimeSteps = new G4UIcmdWithAnInteger("/scheduler/maxNullTimeSteps",
80 this);
81 fMaxNULLTimeSteps->SetGuidance("Set maximum allowed zero time steps. After this "
82 "threshold, the simulation is stopped.");
83 fMaxNULLTimeSteps->SetParameterName("numberOfNullTimeSteps", true);
84 fMaxNULLTimeSteps->SetDefaultValue(10);
85 fMaxNULLTimeSteps->SetRange("numberOfNullTimeSteps >=0 ");
86
87 fMaxStepNumber = new G4UIcmdWithAnInteger("/scheduler/maxStepNumber", this);
88 fMaxStepNumber->SetGuidance("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 = new G4UIcmdWithoutParameter("/scheduler/process", this);
95 fProcessCmd->SetGuidance("Process stacked tracks in G4Scheduler. This is done "
96 "for standalone application only (no physics).");
98
99 // Verbose
100 fVerboseCmd = new G4UIcmdWithAnInteger("/scheduler/verbose", this);
101 fVerboseCmd->SetGuidance("Set the Verbose level of G4Scheduler.");
102 fVerboseCmd->SetGuidance(" 0 : Silent (default)");
103 fVerboseCmd->SetGuidance(" 1 : Display reactions");
104 fVerboseCmd->SetGuidance(" 2 ");
105 fVerboseCmd->SetParameterName("level", true);
106 fVerboseCmd->SetDefaultValue(1);
107 // fVerboseCmd->SetRange("level >=0 && level <=4");
108
109 fWhyDoYouStop = new G4UIcmdWithoutParameter("/scheduler/whyDoYouStop",this);
110 fWhyDoYouStop->SetGuidance("Will print information on why the scheduler is "
111 "stopping the process");
112
113 fUseDefaultTimeSteps = new G4UIcmdWithABool("/scheduler/useDefaultTimeSteps",
114 this);
115 fUseDefaultTimeSteps->SetGuidance("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
122{
123 delete fTimeTolerance;
124 delete fITDirectory;
125 delete fInitCmd;
126 delete fEndTime;
127 delete fMaxNULLTimeSteps;
128 delete fMaxStepNumber;
129 delete fProcessCmd;
130 delete fVerboseCmd;
131 delete fWhyDoYouStop;
132 delete fUseDefaultTimeSteps;
133}
134
136 G4String newValue)
137{
138 if (command == fProcessCmd)
139 {
140 fScheduler->Process();
141 }
142 else if (command == fEndTime)
143 {
144 fScheduler->SetEndTime(fEndTime->GetNewDoubleValue(newValue));
145 }
146 else if (command == fTimeTolerance)
147 {
148 fScheduler->SetTimeTolerance(
149 fTimeTolerance->GetNewDoubleValue(newValue));
150 }
151 else if (command == fVerboseCmd)
152 {
153 fScheduler->SetVerbose(fVerboseCmd->GetNewIntValue(newValue));
154 }
155 else if (command == fInitCmd)
156 {
157 fScheduler->Initialize();
158 }
159 else if (command == fMaxNULLTimeSteps)
160 {
161 fScheduler->SetMaxZeroTimeAllowed(
162 fMaxNULLTimeSteps->GetNewIntValue(newValue));
163 }
164 else if (command == fMaxStepNumber)
165 {
166 fScheduler->SetMaxNbSteps(fMaxStepNumber->GetNewIntValue(newValue));
167 }
168 else if (command == fWhyDoYouStop)
169 {
170 fScheduler->WhyDoYouStop();
171 }
172 else if (command == fUseDefaultTimeSteps)
173 {
174 fScheduler->UseDefaultTimeSteps(fUseDefaultTimeSteps->GetNewBoolValue(newValue));
175 }
176}
177
179{
180 G4String cv;
181
182 if (command == fVerboseCmd)
183 {
184 cv = fVerboseCmd->ConvertToString(fScheduler->GetVerbose());
185 }
186 else if (command == fEndTime)
187 {
188 cv = fEndTime->ConvertToString(fScheduler->GetEndTime());
189 }
190 else if (command == fTimeTolerance)
191 {
192 cv = fTimeTolerance->ConvertToString(fScheduler->GetTimeTolerance());
193 }
194 else if (command == fInitCmd)
195 {
196 cv = fInitCmd->ConvertToString(fScheduler->IsInitialized());
197 }
198 else if (command == fMaxNULLTimeSteps)
199 {
200 cv = fMaxNULLTimeSteps->ConvertToString(
201 fScheduler->GetMaxZeroTimeAllowed());
202 }
203 else if (command == fMaxStepNumber)
204 {
205 cv = fMaxStepNumber->ConvertToString(fScheduler->GetMaxNbSteps());
206 }
207 else if (command == fUseDefaultTimeSteps)
208 {
209 cv = fUseDefaultTimeSteps->ConvertToString(fScheduler->AreDefaultTimeStepsUsed());
210 }
211
212 return cv;
213}
214
@ G4State_Idle
@ G4State_PreInit
void SetNewValue(G4UIcommand *command, G4String newValues)
G4String GetCurrentValue(G4UIcommand *command)
G4SchedulerMessenger(G4Scheduler *runMgr)
void SetTimeTolerance(double)
Definition: G4Scheduler.hh:387
void SetEndTime(const double)
Definition: G4Scheduler.hh:292
void SetMaxZeroTimeAllowed(int)
Definition: G4Scheduler.hh:377
int GetMaxZeroTimeAllowed() const
Definition: G4Scheduler.hh:382
void SetMaxNbSteps(G4int)
Definition: G4Scheduler.hh:320
int GetVerbose() const
Definition: G4Scheduler.hh:371
G4int GetMaxNbSteps() const
Definition: G4Scheduler.hh:325
void Process()
Definition: G4Scheduler.cc:376
G4double GetEndTime() const
Definition: G4Scheduler.hh:335
G4bool AreDefaultTimeStepsUsed()
Definition: G4Scheduler.hh:437
void WhyDoYouStop()
Definition: G4Scheduler.hh:427
void SetVerbose(int)
Definition: G4Scheduler.hh:366
bool IsInitialized()
Definition: G4Scheduler.hh:282
void Initialize()
Definition: G4Scheduler.cc:281
double GetTimeTolerance() const
Definition: G4Scheduler.hh:392
void UseDefaultTimeSteps(G4bool)
Definition: G4Scheduler.hh:432
static G4bool GetNewBoolValue(const char *paramString)
void SetUnitCategory(const char *unitCategory)
void SetDefaultUnit(const char *defUnit)
static G4double GetNewDoubleValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetDefaultValue(G4int defVal)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:430
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:273