Geant4 9.6.0
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 ()
 
 G4UImessenger (const G4String &path, const G4String &dsc)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 

Protected Attributes

G4VUserPhysicsListthePhysicsList
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 

Additional Inherited Members

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

Detailed Description

Definition at line 78 of file G4UserPhysicsListMessenger.hh.

Constructor & Destructor Documentation

◆ G4UserPhysicsListMessenger()

G4UserPhysicsListMessenger::G4UserPhysicsListMessenger ( G4VUserPhysicsList pParticleList)

Definition at line 57 of file G4UserPhysicsListMessenger.cc.

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

◆ ~G4UserPhysicsListMessenger()

G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger ( )
virtual

Definition at line 208 of file G4UserPhysicsListMessenger.cc.

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

Member Function Documentation

◆ GetCurrentValue()

G4String G4UserPhysicsListMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 312 of file G4UserPhysicsListMessenger.cc.

313{
314 G4String cv;
315 G4String candidates("none");
317
318 if( command==setCutCmd ) {
319 cv = setCutCmd->ConvertToString( thePhysicsList->GetDefaultCutValue(), "mm" );
320
321 } else if( command==verboseCmd ){
323
324 } else if( command== addProcManCmd ){
325 // set candidate list
326 piter -> reset();
327 while( (*piter)() ){
328 G4ParticleDefinition *particle = piter->value();
329 candidates += " " + particle->GetParticleName();
330 }
331 addProcManCmd->SetCandidates(candidates);
332 cv = "";
333
334 } else if( command== buildPTCmd ){
335 // set candidate list
336 piter -> reset();
337 while( (*piter)() ){
338 G4ParticleDefinition *particle = piter->value();
339 candidates += " " + particle->GetParticleName();
340 }
341 addProcManCmd->SetCandidates(candidates);
342 cv = "";
343
344 } else if ( command == storeCmd ){
346
347 }else if( command == retrieveCmd ) {
350 } else {
351 cv = "OFF";
352 }
353
354 } else if( command==asciiCmd ){
356 cv = "1";
357 } else {
358 cv = "0";
359 }
360
361// } else if( command == applyCutsCmd ) {
362// if (thePhysicsList->GetApplyCuts("gamma")){
363// cv = "true";
364// } else {
365// cv = "false";
366// }
367 }
368
369 return cv;
370}
const G4String & GetParticleName() const
static G4ParticleTable * GetParticleTable()
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349
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 227 of file G4UserPhysicsListMessenger.cc.

228{
229 if( command==setCutCmd ){
230 G4double newCut = setCutCmd->GetNewDoubleValue(newValue);
233
234 } else if( command==setCutForAGivenParticleCmd ){
235 G4String particleName, unit ; G4double cut ;
236 std::istringstream str (newValue) ;
237 str >> particleName >> cut >> unit ;
238 thePhysicsList->SetCutValue(cut*G4UIcommand::ValueOf(unit), particleName) ;
239
240 } else if( command==getCutForAGivenParticleCmd ){
241 G4cout << thePhysicsList->GetCutValue(newValue)/mm <<"[mm]" << G4endl ;
242
243 } else if( command==setCutRCmd ){
244 std::istringstream is(newValue);
245 G4String regName;
246 G4String uniName;
247 G4double cVal = -1.0;
248 is >> regName >> cVal >> uniName;
249 if (is.fail()) {
250 G4cout << "illegal arguments : try again " << G4endl;
251 return;
252 }
253 thePhysicsList->SetCutsForRegion(cVal*(setCutRCmd->ValueOf(uniName)),regName);
254
255 } else if( command==verboseCmd ) {
256 thePhysicsList->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
257
258 } else if( command==dumpListCmd ){
260
261 } else if( command==dumpOrdParamCmd ){
262 G4int stype = dumpOrdParamCmd->GetNewIntValue(newValue);
264
265 } else if( command == addProcManCmd ){
266 G4ParticleDefinition* particle = (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
267 if (particle == 0) return;
268 if (particle->GetProcessManager() != 0) return;
270
271 } else if( command == buildPTCmd ){
272 G4ParticleDefinition* particle = (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
273 if (particle == 0) return;
276
277 } else if ( command == storeCmd ){
279
280 } else if( command == retrieveCmd ) {
281 if ((newValue == "OFF") || (newValue == "off") ){
283 } else {
285 }
286
287 } else if( command == asciiCmd ) {
288 if (asciiCmd->GetNewIntValue(newValue) == 0) {
290 } else {
292 }
293
294 } else if( command == applyCutsCmd ) {
295 G4Tokenizer next( newValue );
296
297 // check 1st argument
298 G4String temp = G4String(next());
299 G4bool flag = (temp =="true" || temp=="TRUE");
300
301 // check 2nd argument
302 G4String name = G4String(next());
303
304 thePhysicsList->SetApplyCuts(flag, name);
305
306 } else if( command == dumpCutValuesCmd ) {
308
309 }
310}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT 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:288
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)
G4bool StorePhysicsTable(const G4String &directory=".")
void SetVerboseLevel(G4int value)
void SetApplyCuts(G4bool value, const G4String &name)
void DumpCutValuesTable(G4int flag=1)
void AddProcessManager(G4ParticleDefinition *newParticle, G4ProcessManager *newManager=0)

Member Data Documentation

◆ thePhysicsList

G4VUserPhysicsList* G4UserPhysicsListMessenger::thePhysicsList
protected

Definition at line 93 of file G4UserPhysicsListMessenger.hh.

Referenced by GetCurrentValue(), and SetNewValue().


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