Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UserPhysicsListMessenger Class Reference

#include <G4UserPhysicsListMessenger.hh>

+ Inheritance diagram for G4UserPhysicsListMessenger:

Public Member Functions

 G4UserPhysicsListMessenger (G4VUserPhysicsList *pParticleList)
 
virtual ~G4UserPhysicsListMessenger ()
 
virtual void SetNewValue (G4UIcommand *command, G4String newValues)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Protected Attributes

G4VUserPhysicsListthePhysicsList = nullptr
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 

Detailed Description

Definition at line 63 of file G4UserPhysicsListMessenger.hh.

Constructor & Destructor Documentation

◆ G4UserPhysicsListMessenger()

G4UserPhysicsListMessenger::G4UserPhysicsListMessenger ( G4VUserPhysicsList pParticleList)

Definition at line 48 of file G4UserPhysicsListMessenger.cc.

50 : thePhysicsList(pParticleList)
51{
52 G4UIparameter* param = nullptr;
53 // /run/particle directory
54 theDirectory = new G4UIdirectory("/run/particle/");
55 theDirectory->SetGuidance("Commands for G4VUserPhysicsList.");
56
57 // /run/particle/Verbose command
58 verboseCmd = new G4UIcmdWithAnInteger("/run/particle/verbose", this);
59 verboseCmd->SetGuidance("Set the Verbose level of G4VUserPhysicsList.");
60 verboseCmd->SetGuidance(" 0 : Silent (default)");
61 verboseCmd->SetGuidance(" 1 : Display warning messages");
62 verboseCmd->SetGuidance(" 2 : Display more");
63 verboseCmd->SetParameterName("level", true);
64 verboseCmd->SetDefaultValue(0);
65 verboseCmd->SetRange("level >=0 && level <=3");
66
67 // /run/setCut command
68 setCutCmd = new G4UIcmdWithADoubleAndUnit("/run/setCut", this);
69 setCutCmd->SetGuidance("Set default cut value ");
70 setCutCmd->SetParameterName("cut", false);
71 setCutCmd->SetDefaultValue(1.0);
72 setCutCmd->SetRange("cut >=0.0");
73 setCutCmd->SetDefaultUnit("mm");
75
76 // /run/setCutForAGivenParticle command
77 setCutForAGivenParticleCmd =
78 new G4UIcommand("/run/setCutForAGivenParticle", this);
79 setCutForAGivenParticleCmd->SetGuidance(
80 "Set a cut value to a specific particle ");
81 setCutForAGivenParticleCmd->SetGuidance(
82 "Usage: /run/setCutForAGivenParticle gamma 1. mm");
83 param = new G4UIparameter("particleName", 's', false);
84 param->SetParameterCandidates("e- e+ gamma proton");
85 setCutForAGivenParticleCmd->SetParameter(param);
86 param = new G4UIparameter("cut", 'd', false);
87 param->SetDefaultValue("1.");
88 param->SetParameterRange("cut>=0.0");
89 setCutForAGivenParticleCmd->SetParameter(param);
90 param = new G4UIparameter("unit", 's', false);
91 param->SetDefaultUnit("mm");
92 setCutForAGivenParticleCmd->SetParameter(param);
93 setCutForAGivenParticleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
94
95 // /run/getCutForAGivenParticle command
96 getCutForAGivenParticleCmd =
97 new G4UIcmdWithAString("/run/getCutForAGivenParticle", this);
98 getCutForAGivenParticleCmd->SetGuidance(
99 "Get a cut value to a specific particle ");
100 getCutForAGivenParticleCmd->SetGuidance(
101 "Usage: /run/getCutForAGivenParticle gamma ");
102 getCutForAGivenParticleCmd->SetParameterName("particleName", false, false);
103 getCutForAGivenParticleCmd->SetCandidates("e- e+ gamma proton");
104 getCutForAGivenParticleCmd->AvailableForStates(
106
107 // /run/setCutForRegion command
108 setCutRCmd = new G4UIcommand("/run/setCutForRegion", this);
109 setCutRCmd->SetGuidance("Set cut value for a region");
110 param = new G4UIparameter("Region", 's', false);
111 setCutRCmd->SetParameter(param);
112 param = new G4UIparameter("cut", 'd', false);
113 param->SetParameterRange("cut >=0.0");
114 setCutRCmd->SetParameter(param);
115 param = new G4UIparameter("Unit", 's', true);
116 param->SetDefaultValue("mm");
118 setCutRCmd->UnitsList(setCutRCmd->CategoryOf("mm")));
119 setCutRCmd->SetParameter(param);
120 setCutRCmd->AvailableForStates(G4State_Idle);
121
122 // /run/particle/DumpList command
123 dumpListCmd = new G4UIcmdWithoutParameter("/run/particle/dumpList", this);
124 dumpListCmd->SetGuidance("Dump List of particles in G4VUserPhysicsList. ");
125
126 // /run/particle/addProcManager command
127 addProcManCmd = new G4UIcmdWithAString("/run/particle/addProcManager", this);
128 addProcManCmd->SetToBeBroadcasted(false);
129 addProcManCmd->SetGuidance("add process manager to specified particle type");
130 addProcManCmd->SetParameterName("particleType", true);
131 addProcManCmd->SetDefaultValue("");
134
135 // /run/particle/buildPhysicsTable command
136 buildPTCmd = new G4UIcmdWithAString("/run/particle/buildPhysicsTable", this);
137 buildPTCmd->SetGuidance("build physics table of specified particle type");
138 buildPTCmd->SetParameterName("particleType", true);
139 buildPTCmd->SetDefaultValue("");
142
143 // /run/particle/storePhysicsTable command
144 storeCmd = new G4UIcmdWithAString("/run/particle/storePhysicsTable", this);
145 storeCmd->SetGuidance("Store Physics Table");
146 storeCmd->SetGuidance(" Enter directory name");
147 storeCmd->SetParameterName("dirName", true);
148 storeCmd->SetDefaultValue("");
150
151 // /run/particle/retrievePhysicsTable command
152 retrieveCmd =
153 new G4UIcmdWithAString("/run/particle/retrievePhysicsTable", this);
154 retrieveCmd->SetGuidance("Retrieve Physics Table");
155 retrieveCmd->SetGuidance(" Enter directory name or OFF to switch off");
156 retrieveCmd->SetParameterName("dirName", true);
157 retrieveCmd->SetDefaultValue("");
159
160 // /run/particle/setStoredInAscii command
161 asciiCmd = new G4UIcmdWithAnInteger("/run/particle/setStoredInAscii", this);
162 asciiCmd->SetGuidance(
163 "Switch on/off ascii mode in store/retrieve Physics Table");
164 asciiCmd->SetGuidance(" Enter 0(binary) or 1(ascii)");
165 asciiCmd->SetParameterName("ascii", true);
166 asciiCmd->SetDefaultValue(0);
168 asciiCmd->SetRange("ascii ==0 || ascii ==1");
169
170 // Commnad /run/particle/applyCuts command
171 applyCutsCmd = new G4UIcommand("/run/particle/applyCuts", this);
172 applyCutsCmd->SetGuidance("Set applyCuts flag for a particle.");
173 applyCutsCmd->SetGuidance(
174 " Some EM processes which do not have infrared divergence");
175 applyCutsCmd->SetGuidance(
176 "may generate gamma, e- and/or e+ with kinetic energies");
177 applyCutsCmd->SetGuidance(
178 "below the production threshold. By setting this flag,");
179 applyCutsCmd->SetGuidance(
180 "such secondaries below threshold are eliminated and");
181 applyCutsCmd->SetGuidance(
182 "kinetic energies of such secondaries are accumulated");
183 applyCutsCmd->SetGuidance("to the energy deposition of their mother.");
184 applyCutsCmd->SetGuidance(
185 " Note that 'applyCuts' makes sense only for gamma,");
186 applyCutsCmd->SetGuidance(
187 "e- and e+. If this command is issued for other particle,");
188 applyCutsCmd->SetGuidance(
189 "a warning message is displayed and the command is");
190 applyCutsCmd->SetGuidance("ignored.");
191 applyCutsCmd->SetGuidance(
192 " If particle name is 'all', this command affects on");
193 applyCutsCmd->SetGuidance("gamma, e- and e+.");
194 param = new G4UIparameter("Flag", 's', true);
195 param->SetDefaultValue("true");
196 applyCutsCmd->SetParameter(param);
197 param = new G4UIparameter("Particle", 's', true);
198 param->SetDefaultValue("all");
199 applyCutsCmd->SetParameter(param);
201
202 // /run/particle/dumpCutValues command
203 dumpCutValuesCmd =
204 new G4UIcmdWithAString("/run/particle/dumpCutValues", this);
205 dumpCutValuesCmd->SetGuidance(
206 "Dump a list of production threshold values in range and energy");
207 dumpCutValuesCmd->SetGuidance("for all registered material-cuts-couples.");
208 dumpCutValuesCmd->SetGuidance(
209 "Dumping a list takes place when you issue 'beamOn' and");
210 dumpCutValuesCmd->SetGuidance(
211 "actual conversion tables from range to energy are available.");
212 dumpCutValuesCmd->SetGuidance(
213 "If you want a list 'immediately', use '/run/dumpRegion' for threshold");
214 dumpCutValuesCmd->SetGuidance(
215 "list given in range only. Also, '/run/dumpCouples' gives you the");
216 dumpCutValuesCmd->SetGuidance(
217 "current list if you have already issued 'run/beamOn' at least once.");
218 dumpCutValuesCmd->SetParameterName("particle", true);
219 dumpCutValuesCmd->SetDefaultValue("all");
220 dumpCutValuesCmd->AvailableForStates(G4State_Idle);
221
222 // /run/particle/dumpCutValues command
223 dumpOrdParamCmd =
224 new G4UIcmdWithAnInteger("/run/particle/dumpOrderingParam", this);
225 dumpOrdParamCmd->SetGuidance("Dump a list of ordering parameter ");
226 dumpOrdParamCmd->SetParameterName("subtype", true);
227 dumpOrdParamCmd->SetDefaultValue(-1);
230}
@ G4State_EventProc
@ G4State_Init
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
void SetDefaultUnit(const char *defUnit)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(const char *defVal)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:172
static G4String CategoryOf(const char *unitName)
Definition: G4UIcommand.cc:370
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:147
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:157
static G4String UnitsList(const char *unitCategory)
Definition: G4UIcommand.cc:376
void SetRange(const char *rs)
Definition: G4UIcommand.hh:121
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:287
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)
void SetDefaultUnit(const char *theDefaultUnit)

◆ ~G4UserPhysicsListMessenger()

G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger ( )
virtual

Definition at line 233 of file G4UserPhysicsListMessenger.cc.

234{
235 delete setCutCmd;
236 delete setCutRCmd;
237 delete setCutForAGivenParticleCmd;
238 delete getCutForAGivenParticleCmd;
239 delete verboseCmd;
240 delete dumpListCmd;
241 delete addProcManCmd;
242 delete buildPTCmd;
243 delete storeCmd;
244 delete retrieveCmd;
245 delete asciiCmd;
246 delete applyCutsCmd;
247 delete dumpCutValuesCmd;
248 delete dumpOrdParamCmd;
249 delete theDirectory;
250}

Member Function Documentation

◆ GetCurrentValue()

G4String G4UserPhysicsListMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 382 of file G4UserPhysicsListMessenger.cc.

383{
384 G4String cv;
385 G4String candidates("none");
387
388 if(command == setCutCmd)
389 {
390 cv = setCutCmd->ConvertToString(thePhysicsList->GetDefaultCutValue(), "mm");
391 }
392 else if(command == verboseCmd)
393 {
395 }
396 else if(command == addProcManCmd)
397 {
398 // set candidate list
399 piter->reset();
400 while((*piter)())
401 {
402 G4ParticleDefinition* particle = piter->value();
403 candidates += " " + particle->GetParticleName();
404 }
405 addProcManCmd->SetCandidates(candidates);
406 cv = "";
407 }
408 else if(command == buildPTCmd)
409 {
410 // set candidate list
411 piter->reset();
412 while((*piter)())
413 {
414 G4ParticleDefinition* particle = piter->value();
415 candidates += " " + particle->GetParticleName();
416 }
417 addProcManCmd->SetCandidates(candidates);
418 cv = "";
419 }
420 else if(command == storeCmd)
421 {
423 }
424 else if(command == retrieveCmd)
425 {
427 {
429 }
430 else
431 {
432 cv = "OFF";
433 }
434 }
435 else if(command == asciiCmd)
436 {
438 {
439 cv = "1";
440 }
441 else
442 {
443 cv = "0";
444 }
445 }
446
447 return cv;
448}
const G4String & GetParticleName() const
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:446
G4bool IsStoredInAscii() const
G4int GetVerboseLevel() const
const G4String & GetPhysicsTableDirectory() const
G4bool IsPhysicsTableRetrieved() const
G4double GetDefaultCutValue() const

◆ SetNewValue()

void G4UserPhysicsListMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 253 of file G4UserPhysicsListMessenger.cc.

255{
257 if(command == setCutCmd)
258 {
259 G4double newCut = setCutCmd->GetNewDoubleValue(newValue);
262 }
263 else if(command == setCutForAGivenParticleCmd)
264 {
265 G4String particleName, unit;
266 G4double cut;
267 std::istringstream str(newValue);
268 str >> particleName >> cut >> unit;
269 thePhysicsList->SetCutValue(cut * G4UIcommand::ValueOf(unit), particleName);
270 }
271 else if(command == getCutForAGivenParticleCmd)
272 {
273 G4cout << thePhysicsList->GetCutValue(newValue) / mm << "[mm]" << G4endl;
274 }
275 else if(command == setCutRCmd)
276 {
277 std::istringstream is(newValue);
278 G4String regName;
279 G4String uniName;
280 G4double cVal = -1.0;
281 is >> regName >> cVal >> uniName;
282 if(is.fail())
283 {
284 ed << "illegal arguments : " << newValue;
285 command->CommandFailed(ed);
286 return;
287 }
288 thePhysicsList->SetCutsForRegion(cVal * (setCutRCmd->ValueOf(uniName)),
289 regName);
290 }
291 else if(command == verboseCmd)
292 {
293 thePhysicsList->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
294 }
295 else if(command == dumpListCmd)
296 {
298 }
299 else if(command == dumpOrdParamCmd)
300 {
301 G4int stype = dumpOrdParamCmd->GetNewIntValue(newValue);
303 stype);
304 }
305 else if(command == addProcManCmd)
306 {
307 G4ParticleDefinition* particle =
308 (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
309 if(particle == nullptr)
310 {
311 ed << " Particle is not found : " << newValue;
312 command->CommandFailed(ed);
313 return;
314 }
315 else if(particle->GetProcessManager() != nullptr)
316 {
317 ed << " Particle is not initialized : " << newValue;
318 command->CommandFailed(ed);
319 return;
320 }
322 }
323 else if(command == buildPTCmd)
324 {
325 G4ParticleDefinition* particle =
326 (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
327 if(particle == nullptr)
328 {
329 ed << " Particle is not found : " << newValue;
330 command->CommandFailed(ed);
331 return;
332 }
335 }
336 else if(command == storeCmd)
337 {
339 }
340 else if(command == retrieveCmd)
341 {
342 if((newValue == "OFF") || (newValue == "off"))
343 {
345 }
346 else
347 {
349 }
350 }
351 else if(command == asciiCmd)
352 {
353 if(asciiCmd->GetNewIntValue(newValue) == 0)
354 {
356 }
357 else
358 {
360 }
361 }
362 else if(command == applyCutsCmd)
363 {
364 G4Tokenizer next(newValue);
365
366 // check 1st argument
367 G4String temp = G4String(next());
368 G4bool flag = (temp == "true" || temp == "TRUE");
369
370 // check 2nd argument
371 G4String name = G4String(next());
372
373 thePhysicsList->SetApplyCuts(flag, name);
374 }
375 else if(command == dumpCutValuesCmd)
376 {
378 }
379}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4ProcessManager * GetProcessManager() const
static G4PhysicsListHelper * GetPhysicsListHelper()
void DumpOrdingParameterTable(G4int subType=-1) const
static G4double GetNewDoubleValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:362
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
G4double GetCutValue(const G4String &pname) const
void SetDefaultCutValue(G4double newCutValue)
void SetPhysicsTableRetrieved(const G4String &directory="")
void PreparePhysicsTable(G4ParticleDefinition *)
void SetCutValue(G4double aCut, const G4String &pname)
void SetCutsForRegion(G4double aCut, const G4String &rname)
void AddProcessManager(G4ParticleDefinition *newParticle, G4ProcessManager *newManager=nullptr)
G4bool StorePhysicsTable(const G4String &directory=".")
void SetVerboseLevel(G4int value)
void SetApplyCuts(G4bool value, const G4String &name)
void DumpCutValuesTable(G4int flag=1)
const char * name(G4int ptype)

Member Data Documentation

◆ thePhysicsList

G4VUserPhysicsList* G4UserPhysicsListMessenger::thePhysicsList = nullptr
protected

Definition at line 75 of file G4UserPhysicsListMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().


The documentation for this class was generated from the following files: