Geant4 11.2.2
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)
 
 ~G4UserPhysicsListMessenger () override
 
void SetNewValue (G4UIcommand *command, G4String newValues) override
 
G4String GetCurrentValue (G4UIcommand *command) override
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
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 LtoS (G4long l)
 
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.

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

Referenced by G4UserPhysicsListMessenger().

◆ ~G4UserPhysicsListMessenger()

G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger ( )
override

Definition at line 206 of file G4UserPhysicsListMessenger.cc.

207{
208 delete setCutCmd;
209 delete setCutRCmd;
210 delete setCutForAGivenParticleCmd;
211 delete getCutForAGivenParticleCmd;
212 delete verboseCmd;
213 delete dumpListCmd;
214 delete addProcManCmd;
215 delete buildPTCmd;
216 delete storeCmd;
217 delete retrieveCmd;
218 delete asciiCmd;
219 delete applyCutsCmd;
220 delete dumpCutValuesCmd;
221 delete dumpOrdParamCmd;
222 delete theDirectory;
223}

Member Function Documentation

◆ GetCurrentValue()

G4String G4UserPhysicsListMessenger::GetCurrentValue ( G4UIcommand * command)
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 328 of file G4UserPhysicsListMessenger.cc.

329{
330 G4String cv;
331 G4String candidates("none");
333
334 if (command == setCutCmd) {
335 cv = setCutCmd->ConvertToString(thePhysicsList->GetDefaultCutValue(), "mm");
336 }
337 else if (command == verboseCmd) {
339 }
340 else if (command == addProcManCmd) {
341 // set candidate list
342 piter->reset();
343 while ((*piter)()) {
344 G4ParticleDefinition* particle = piter->value();
345 candidates += " " + particle->GetParticleName();
346 }
347 addProcManCmd->SetCandidates(candidates);
348 cv = "";
349 }
350 else if (command == buildPTCmd) {
351 // set candidate list
352 piter->reset();
353 while ((*piter)()) {
354 G4ParticleDefinition* particle = piter->value();
355 candidates += " " + particle->GetParticleName();
356 }
357 addProcManCmd->SetCandidates(candidates);
358 cv = "";
359 }
360 else if (command == storeCmd) {
362 }
363 else if (command == retrieveCmd) {
366 }
367 else {
368 cv = "OFF";
369 }
370 }
371 else if (command == asciiCmd) {
373 cv = "1";
374 }
375 else {
376 cv = "0";
377 }
378 }
379
380 return cv;
381}
const G4String & GetParticleName() const
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
static G4String ConvertToString(G4bool boolVal)
G4bool IsStoredInAscii() const
G4int GetVerboseLevel() const
const G4String & GetPhysicsTableDirectory() const
G4bool IsPhysicsTableRetrieved() const
G4double GetDefaultCutValue() const

◆ SetNewValue()

void G4UserPhysicsListMessenger::SetNewValue ( G4UIcommand * command,
G4String newValues )
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 226 of file G4UserPhysicsListMessenger.cc.

227{
229 if (command == setCutCmd) {
230 G4double newCut = setCutCmd->GetNewDoubleValue(newValue);
233 }
234 else if (command == setCutForAGivenParticleCmd) {
235 G4String particleName, unit;
236 G4double cut;
237 std::istringstream str(newValue);
238 str >> particleName >> cut >> unit;
239 thePhysicsList->SetCutValue(cut * G4UIcommand::ValueOf(unit), particleName);
240 }
241 else if (command == getCutForAGivenParticleCmd) {
242 G4cout << thePhysicsList->GetCutValue(newValue) / mm << "[mm]" << G4endl;
243 }
244 else if (command == setCutRCmd) {
245 std::istringstream is(newValue);
246 G4String regName;
247 G4String uniName;
248 G4double cVal = -1.0;
249 is >> regName >> cVal >> uniName;
250 if (is.fail()) {
251 ed << "illegal arguments : " << newValue;
252 command->CommandFailed(ed);
253 return;
254 }
255 thePhysicsList->SetCutsForRegion(cVal * (setCutRCmd->ValueOf(uniName)), regName);
256 }
257 else if (command == verboseCmd) {
258 thePhysicsList->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
259 }
260 else if (command == dumpListCmd) {
262 }
263 else if (command == dumpOrdParamCmd) {
264 G4int stype = dumpOrdParamCmd->GetNewIntValue(newValue);
266 }
267 else if (command == addProcManCmd) {
268 G4ParticleDefinition* particle = (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
269 if (particle == nullptr) {
270 ed << " Particle is not found : " << newValue;
271 command->CommandFailed(ed);
272 return;
273 }
274 if (particle->GetProcessManager() != nullptr) {
275 ed << " Particle is not initialized : " << newValue;
276 command->CommandFailed(ed);
277 return;
278 }
280 }
281 else if (command == buildPTCmd) {
282 G4ParticleDefinition* particle = (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
283 if (particle == nullptr) {
284 ed << " Particle is not found : " << newValue;
285 command->CommandFailed(ed);
286 return;
287 }
290 }
291 else if (command == storeCmd) {
293 }
294 else if (command == retrieveCmd) {
295 if ((newValue == "OFF") || (newValue == "off")) {
297 }
298 else {
300 }
301 }
302 else if (command == asciiCmd) {
303 if (asciiCmd->GetNewIntValue(newValue) == 0) {
305 }
306 else {
308 }
309 }
310 else if (command == applyCutsCmd) {
311 G4Tokenizer next(newValue);
312
313 // check 1st argument
314 G4String temp = G4String(next());
315 G4bool flag = (temp == "true" || temp == "TRUE");
316
317 // check 2nd argument
318 G4String name = G4String(next());
319
320 thePhysicsList->SetApplyCuts(flag, name);
321 }
322 else if (command == dumpCutValuesCmd) {
324 }
325}
std::ostringstream G4ExceptionDescription
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
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)
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
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 73 of file G4UserPhysicsListMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().


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