Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // $Id: G4ITSteppingMessenger.cc 60427 2012-07-11 16:34:35Z matkara $
27 //
28 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29 //
30 // History:
31 // -----------
32 //
33 // -------------------------------------------------------------------
34 #include <G4Scheduler.hh>
35 #include <G4SchedulerMessenger.hh>
36 
37 #include "G4UIdirectory.hh"
39 #include "G4UIcmdWithAnInteger.hh"
41 #include "G4UIcmdWithABool.hh"
42 #include "G4UIcommand.hh"
43 #include "G4UIparameter.hh"
44 #include "G4UImanager.hh"
45 #include "G4ios.hh"
46 
48  fScheduler(stepMgr)
49 {
50  fITDirectory = new G4UIdirectory("/scheduler/");
51  fITDirectory->SetGuidance("Control commands for the time scheduler "
52  "(dna chemistry applications).");
53 
54  // Set end time
55  fEndTime = new G4UIcmdWithADoubleAndUnit("/scheduler/endTime", this);
56  fEndTime->SetGuidance("Set time at which the simulation must stop.");
58  fEndTime->SetUnitCategory("Time");
59  fEndTime->SetDefaultUnit("picosecond");
60  fEndTime->SetDefaultValue(1);
61 
62  // Set time tolerance
63  fTimeTolerance = new G4UIcmdWithADoubleAndUnit("/scheduler/timeTolerance",
64  this);
65  fTimeTolerance->SetGuidance("This command aims at resolving issues related to"
66  " floating points. If two time events are separated by less than the "
67  "selected tolerance, they are assumed to belong to the same time step.");
69  fTimeTolerance->SetUnitCategory("Time");
70  fTimeTolerance->SetDefaultUnit("picosecond");
71  fTimeTolerance->SetDefaultValue(1);
72 
73  // Initialize
74  fInitCmd = new G4UIcmdWithoutParameter("/scheduler/initialize", this);
75  fInitCmd->SetGuidance("Initialize G4Scheduler. This is done "
76  "for standalone application only (no physics).");
78 
79  // Set Max Null time Step
80  fMaxNULLTimeSteps = new G4UIcmdWithAnInteger("/scheduler/maxNullTimeSteps",
81  this);
82  fMaxNULLTimeSteps->SetGuidance("Set maximum allowed zero time steps. After this "
83  "threshold, the simulation is stopped.");
84  fMaxNULLTimeSteps->SetParameterName("numberOfNullTimeSteps", true);
85  fMaxNULLTimeSteps->SetDefaultValue(10);
86  fMaxNULLTimeSteps->SetRange("numberOfNullTimeSteps >=0 ");
87 
88  fMaxStepNumber = new G4UIcmdWithAnInteger("/scheduler/maxStepNumber", this);
89  fMaxStepNumber->SetGuidance("Set the maximum number of time steps. After this "
90  "threshold, the simulation is stopped.");
91  fMaxStepNumber->SetParameterName("maximumNumberOfSteps", true);
92  fMaxStepNumber->SetDefaultValue(-1);
93 
94  // Beam On
95  fProcessCmd = new G4UIcmdWithoutParameter("/scheduler/process", this);
96  fProcessCmd->SetGuidance("Process stacked tracks in G4Scheduler. This is done "
97  "for standalone application only (no physics).");
99 
100  // Verbose
101  fVerboseCmd = new 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  // fVerboseCmd->SetRange("level >=0 && level <=4");
109 
110  fWhyDoYouStop = new G4UIcmdWithoutParameter("/scheduler/whyDoYouStop",this);
111  fWhyDoYouStop->SetGuidance("Will print information on why the scheduler is "
112  "stopping the process");
113 
114  fUseDefaultTimeSteps = new G4UIcmdWithABool("/scheduler/useDefaultTimeSteps",
115  this);
116  fUseDefaultTimeSteps->SetGuidance("Let the G4 processes decided for the next "
117  "time step interval. This command would be interesting if no reaction has "
118  "been set and if one will want to track down Brownian objects. "
119  "NB: This command gets in conflicts with the declaration of time steps.");
120 }
121 
123 {
124  delete fTimeTolerance;
125  delete fITDirectory;
126  delete fInitCmd;
127  delete fEndTime;
128  delete fMaxNULLTimeSteps;
129  delete fMaxStepNumber;
130  delete fProcessCmd;
131  delete fVerboseCmd;
132  delete fWhyDoYouStop;
133  delete fUseDefaultTimeSteps;
134 }
135 
137  G4String newValue)
138 {
139  if (command == fProcessCmd)
140  {
141  fScheduler->Process();
142  }
143  else if (command == fEndTime)
144  {
145  fScheduler->SetEndTime(fEndTime->GetNewDoubleValue(newValue));
146  }
147  else if (command == fTimeTolerance)
148  {
149  fScheduler->SetTimeTolerance(
150  fTimeTolerance->GetNewDoubleValue(newValue));
151  }
152  else if (command == fVerboseCmd)
153  {
154  fScheduler->SetVerbose(fVerboseCmd->GetNewIntValue(newValue));
155  }
156  else if (command == fInitCmd)
157  {
158  fScheduler->Initialize();
159  }
160  else if (command == fMaxNULLTimeSteps)
161  {
162  fScheduler->SetMaxZeroTimeAllowed(
163  fMaxNULLTimeSteps->GetNewIntValue(newValue));
164  }
165  else if (command == fMaxStepNumber)
166  {
167  fScheduler->SetMaxNbSteps(fMaxStepNumber->GetNewIntValue(newValue));
168  }
169  else if (command == fWhyDoYouStop)
170  {
171  fScheduler->WhyDoYouStop();
172  }
173  else if (command == fUseDefaultTimeSteps)
174  {
175  fScheduler->UseDefaultTimeSteps(fUseDefaultTimeSteps->GetNewBoolValue(newValue));
176  }
177 }
178 
180 {
181  G4String cv;
182 
183  if (command == fVerboseCmd)
184  {
185  cv = fVerboseCmd->ConvertToString(fScheduler->GetVerbose());
186  }
187  else if (command == fEndTime)
188  {
189  cv = fEndTime->ConvertToString(fScheduler->GetEndTime());
190  }
191  else if (command == fTimeTolerance)
192  {
193  cv = fTimeTolerance->ConvertToString(fScheduler->GetTimeTolerance());
194  }
195  else if (command == fInitCmd)
196  {
197  cv = fInitCmd->ConvertToString(fScheduler->IsInitialized());
198  }
199  else if (command == fMaxNULLTimeSteps)
200  {
201  cv = fMaxNULLTimeSteps->ConvertToString(
202  fScheduler->GetMaxZeroTimeAllowed());
203  }
204  else if (command == fMaxStepNumber)
205  {
206  cv = fMaxStepNumber->ConvertToString(fScheduler->GetMaxNbSteps());
207  }
208  else if (command == fUseDefaultTimeSteps)
209  {
210  cv = fUseDefaultTimeSteps->ConvertToString(fScheduler->AreDefaultTimeStepsUsed());
211  }
212 
213  return cv;
214 }
215 
void Process()
Definition: G4Scheduler.cc:377
void SetNewValue(G4UIcommand *command, G4String newValues)
double GetTimeTolerance() const
Definition: G4Scheduler.hh:398
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
void SetEndTime(const double)
Definition: G4Scheduler.hh:298
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:372
void SetTimeTolerance(double)
Definition: G4Scheduler.hh:393
void SetUnitCategory(const char *unitCategory)
static G4double GetNewDoubleValue(const char *paramString)
G4SchedulerMessenger(G4Scheduler *runMgr)
static G4bool GetNewBoolValue(const char *paramString)
G4bool AreDefaultTimeStepsUsed()
Definition: G4Scheduler.hh:443
void SetVerbose(int)
Definition: G4Scheduler.hh:372
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:240
void SetMaxNbSteps(G4int)
Definition: G4Scheduler.hh:326
int GetVerbose() const
Definition: G4Scheduler.hh:377
bool IsInitialized()
Definition: G4Scheduler.hh:288
void SetDefaultUnit(const char *defUnit)
G4int GetMaxNbSteps() const
Definition: G4Scheduler.hh:331
G4double GetEndTime() const
Definition: G4Scheduler.hh:341
void SetDefaultValue(G4int defVal)
void SetMaxZeroTimeAllowed(int)
Definition: G4Scheduler.hh:383
int GetMaxZeroTimeAllowed() const
Definition: G4Scheduler.hh:388
void UseDefaultTimeSteps(G4bool)
Definition: G4Scheduler.hh:438
G4String GetCurrentValue(G4UIcommand *command)
void Initialize()
Definition: G4Scheduler.cc:282
void WhyDoYouStop()
Definition: G4Scheduler.hh:433